diff options
author | Ben Murdoch <benm@google.com> | 2011-05-16 16:25:10 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-23 18:54:14 +0100 |
commit | ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch) | |
tree | db769fadd053248f85db67434a5b275224defef7 /Source | |
parent | 52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff) | |
download | external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.zip external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.gz external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.bz2 |
Merge WebKit at r76408: Initial merge by git.
Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53
Diffstat (limited to 'Source')
1243 files changed, 40746 insertions, 12407 deletions
diff --git a/Source/JavaScriptCore/API/JSClassRef.h b/Source/JavaScriptCore/API/JSClassRef.h index 5062093..0971700 100644 --- a/Source/JavaScriptCore/API/JSClassRef.h +++ b/Source/JavaScriptCore/API/JSClassRef.h @@ -34,7 +34,9 @@ #include <runtime/WeakGCPtr.h> #include <wtf/HashMap.h> -struct StaticValueEntry : FastAllocBase { +struct StaticValueEntry { + WTF_MAKE_FAST_ALLOCATED; +public: StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes) : getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes) { @@ -45,7 +47,9 @@ struct StaticValueEntry : FastAllocBase { JSPropertyAttributes attributes; }; -struct StaticFunctionEntry : FastAllocBase { +struct StaticFunctionEntry { + WTF_MAKE_FAST_ALLOCATED; +public: StaticFunctionEntry(JSObjectCallAsFunctionCallback _callAsFunction, JSPropertyAttributes _attributes) : callAsFunction(_callAsFunction), attributes(_attributes) { @@ -62,7 +66,9 @@ struct OpaqueJSClass; // An OpaqueJSClass (JSClass) is created without a context, so it can be used with any context, even across context groups. // This structure holds data members that vary across context groups. -struct OpaqueJSClassContextData : Noncopyable { +struct OpaqueJSClassContextData { + WTF_MAKE_NONCOPYABLE(OpaqueJSClassContextData); WTF_MAKE_FAST_ALLOCATED; +public: OpaqueJSClassContextData(OpaqueJSClass*); ~OpaqueJSClassContextData(); diff --git a/Source/JavaScriptCore/API/JSObjectRef.cpp b/Source/JavaScriptCore/API/JSObjectRef.cpp index 4198ca8..d6de426 100644 --- a/Source/JavaScriptCore/API/JSObjectRef.cpp +++ b/Source/JavaScriptCore/API/JSObjectRef.cpp @@ -480,7 +480,9 @@ JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size return result; } -struct OpaqueJSPropertyNameArray : FastAllocBase { +struct OpaqueJSPropertyNameArray { + WTF_MAKE_FAST_ALLOCATED; +public: OpaqueJSPropertyNameArray(JSGlobalData* globalData) : refCount(0) , globalData(globalData) diff --git a/Source/JavaScriptCore/Android.mk b/Source/JavaScriptCore/Android.mk index 9f5c1ce..052af2c 100644 --- a/Source/JavaScriptCore/Android.mk +++ b/Source/JavaScriptCore/Android.mk @@ -160,6 +160,7 @@ LOCAL_SRC_FILES := \ runtime/StringConstructor.cpp \ runtime/StringObject.cpp \ runtime/StringPrototype.cpp \ + runtime/StringRecursionChecker.cpp \ runtime/Structure.cpp \ runtime/StructureChain.cpp \ runtime/TimeoutChecker.cpp \ diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt index 29de8a7..674d272 100644 --- a/Source/JavaScriptCore/CMakeLists.txt +++ b/Source/JavaScriptCore/CMakeLists.txt @@ -163,6 +163,7 @@ SET(JavaScriptCore_SOURCES runtime/StringConstructor.cpp runtime/StringObject.cpp runtime/StringPrototype.cpp + runtime/StringRecursionChecker.cpp runtime/Structure.cpp runtime/StructureChain.cpp runtime/TimeoutChecker.cpp diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 9d92e9d..a5391bf 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,484 @@ +2011-01-21 Michael Saboff <msaboff@apple.com> + + Reviewed by Oliver Hunt. + + [RegexFuzz] Hang with forward assertion + https://bugs.webkit.org/show_bug.cgi?id=52825 + <rdar://problem/8894332> + + The backtrackTo label from the first term in a list of terms is + being overwritten by processing of subsequent terms. Changed + copyBacktrackToLabel() to check for an existing bcaktrackTo label + before copying and renamed it to propagateBacktrackToLabel() since + it no longer copies. + + * yarr/YarrJIT.cpp: + (JSC::Yarr::YarrGenerator::BacktrackDestination::propagateBacktrackToLabel): + (JSC::Yarr::YarrGenerator::generateParenthesesSingle): + +2011-01-21 Geoffrey Garen <ggaren@apple.com> + + Reviewed by Sam Weinig. + + Moved the mark stack from global data to the heap, since it pertains + to the heap, and not the virtual machine as a whole. + https://bugs.webkit.org/show_bug.cgi?id=52930 + + SunSpider reports no change. + + * runtime/Heap.cpp: + (JSC::Heap::Heap): + (JSC::Heap::markRoots): + * runtime/Heap.h: + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: + +2011-01-21 Peter Gal <galpeter@inf.u-szeged.hu> + + Reviewed by Darin Adler. + + REGRESSION(r76177): All JavaScriptCore tests fail on ARM + https://bugs.webkit.org/show_bug.cgi?id=52814 + + Get the approximateByteSize value before releasing the OwnPtr. + + * parser/JSParser.cpp: + (JSC::JSParser::parseFunctionInfo): + +2011-01-21 Xan Lopez <xlopez@igalia.com> + + Reviewed by Martin Robinson. + + Remove unnecessary <stdio.h> include + https://bugs.webkit.org/show_bug.cgi?id=52884 + + * jit/JIT.cpp: remove unnecessary include. + +2011-01-20 Ryosuke Niwa <rniwa@webkit.org> + + Reviewed by Maciej Stachowiak. + + Added OwnPtrCommon.h because OwnArrayPtr::set calls deleteOwnedPtr. + + * wtf/OwnArrayPtr.h: + +2011-01-20 Patrick Gansterer <paroga@webkit.org> + + Reviewed by Oliver Hunt. + + [WINCE] Remove obsolete JSVALUE32 code + https://bugs.webkit.org/show_bug.cgi?id=52450 + + Remove the "offset hack" in create_jit_stubs, since we + only support JSVALUE32_64 in the meantime. + + * create_jit_stubs: Removed offset argument + * jit/JITStubs.cpp: + +2011-01-20 Geoffrey Garen <ggaren@apple.com> + + Reviewed by Oliver Hunt. + + When marking conservatively, guard against reviving dead objects. + https://bugs.webkit.org/show_bug.cgi?id=52840 + + SunSpider and v8 say no change. + + * interpreter/RegisterFile.h: + (JSC::RegisterFile::markCallFrames): Updated to use the ConservativeSet API. + + * runtime/Heap.cpp: + (JSC::Heap::recordExtraCost): No need to guard against conservative + marking reviving dead objects anymore, since the conservative marking + mechanism guards against this now. + + (JSC::Heap::markConservatively): + (JSC::Heap::markProtectedObjects): + (JSC::Heap::markTempSortVectors): Don't drain the mark stack inside a + marking function. We want to establish a separation of concerns between + visiting roots and draining the mark stack. + + (JSC::Heap::markRoots): Gather the set of conservative references before + clearning mark bits, because conservative marking now uses the mark bits + to determine if a reference is valid, and avoid reviving dead objects. + + (JSC::Heap::collectAllGarbage): No need to guard against conservative + marking reviving dead objects anymore, since the conservative marking + mechanism guards against this now. + + * runtime/Heap.h: Updated to use the ConservativeSet API. + + * runtime/MachineStackMarker.cpp: + (JSC::MachineStackMarker::markCurrentThreadConservativelyInternal): + (JSC::MachineStackMarker::markCurrentThreadConservatively): + (JSC::MachineStackMarker::markOtherThreadConservatively): + (JSC::MachineStackMarker::markMachineStackConservatively): + * runtime/MachineStackMarker.h: Ditto. + + * runtime/MarkStack.h: + (JSC::ConservativeSet::add): + (JSC::ConservativeSet::mark): Added ConservativeSet, for gathering the + set of conservative references. This is different from MarkStack, since + we don't mark the set until it is completely gathered. + + * runtime/MarkedSpace.cpp: + (JSC::MarkedSpace::freeBlock): + (JSC::MarkedSpace::resizeBlocks): + (JSC::MarkedSpace::markConservatively): + * runtime/MarkedSpace.h: When marking conservatively, guard against + reviving dead objects. + +2011-01-20 Siddharth Mathur <siddharth.mathur@nokia.com> + + Reviewed by Geoffrey Garen. + + [Symbian] Fix StackBounds::initialize() + https://bugs.webkit.org/show_bug.cgi?id=52842 + + * wtf/StackBounds.cpp: + (WTF::StackBounds::initialize): Use TThreadStackInfo.iLimit for stack limit + +2011-01-20 Michael Saboff <msaboff@apple.com> + + Reviewed by Oliver Hunt. + + <rdar://problem/8890203> [RegexFuzz] Crash in generated code (52773) + https://bugs.webkit.org/show_bug.cgi?id=52773 + + Fixed case where an existing DataLabelPtr is overwritten. The + replacing DataLabelPtr is now resolved immediately in + linkDataLabelToBacktrackIfExists(). Cleanup - eliminated bool + return value for the routine as it was never used. + + * yarr/YarrJIT.cpp: + (JSC::Yarr::YarrGenerator::TermGenerationState::linkDataLabelToBacktrackIfExists): + +2011-01-20 Andras Becsi <abecsi@webkit.org> + + Reviewed by Csaba Osztrogonác. + + [Qt][WK2] WebKit2 enabled build fails to link + + Work around undefined reference linking issues until the buildsystem gets redesigned. + These issues first occured in minimal builds (see BUG 50519). + + * JavaScriptCore.pri: link as whole-archive for WebKit2 builds + +2011-01-20 Zoltan Horvath <zoltan@webkit.org> + + Reviewed by Csaba Osztrogonác. + + Refactoring of the custom allocation framework + https://bugs.webkit.org/show_bug.cgi?id=49897 + + Inheriting from FastAllocBase can result in objects getting larger (bug #33896, #46589). + The modification replaces Noncopyable and FastAllocBase classes and these inherits with their + equivalent macro implementation at the necessary places. + + * wtf/FastAllocBase.h: Turn FastAllocBase's implementation into a macro. + +2011-01-20 Mark Rowe <mrowe@apple.com> + + Reviewed by Maciej Stachowiak. + + Follow-up to r75766 / <rdar://problem/5469576>. + + We were failing to initialize the key, causing all sorts of unexpected behavior. + + * wtf/FastMalloc.cpp: + (WTF::setThreadHeap): + (WTF::TCMalloc_ThreadCache::GetThreadHeap): + (WTF::TCMalloc_ThreadCache::InitTSD): Ensure that the key is initialized. + +2011-01-18 Geoffrey Garen <ggaren@apple.com> + + Reviewed by Darin Adler. + + Rolled back in r76078, with crash fixed. + https://bugs.webkit.org/show_bug.cgi?id=52668 + + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::markChildren): Account for the fact that the global + object moves its variables into and out of the register file. While out + of the register file, the symbol table's size is not an accurate count + for the size of the register array, since the BytecodeGenerator might + be compiling, adding items to the symbol table. + +2011-01-18 Darin Adler <darin@apple.com> + + Reviewed by Geoffrey Garen. + + Stack overflow when converting an Error object to string + https://bugs.webkit.org/show_bug.cgi?id=46410 + + * Android.mk: Added StringRecursionChecker.cpp and + StringRecursionChecker.h. + * CMakeLists.txt: Ditto. + * GNUmakefile.am: Ditto. + * JavaScriptCore.gypi: Ditto. + * JavaScriptCore.pro: Ditto. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto. + * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. + + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncToString): Use StringRecursionChecker instead + of the older hand-written code to do the same thing. + (JSC::arrayProtoFuncToLocaleString): Ditto. + (JSC::arrayProtoFuncJoin): Ditto. + + * runtime/ErrorPrototype.cpp: + (JSC::errorProtoFuncToString): Use StringRecursionChecker. + + * runtime/JSGlobalData.h: Renamed arrayVisitedElements to + stringRecursionCheckVisitedObjects. + + * runtime/RegExpPrototype.cpp: + (JSC::regExpProtoFuncToString): Use StringRecursionChecker. + + * runtime/StringRecursionChecker.cpp: Added. + * runtime/StringRecursionChecker.h: Added. + +2011-01-19 Oliver Hunt <oliver@apple.com> + + Reviewed by Gavin Barraclough. + + Remove non-spec support for callable RegExp + https://bugs.webkit.org/show_bug.cgi?id=28285 + + Remove support for callable regexps. If it breaks sites we can + just roll this out. + + * runtime/RegExpObject.cpp: + * runtime/RegExpObject.h: + * tests/mozilla/expected.html: update results. + +2011-01-19 Antti Koivisto <antti@apple.com> + + Reviewed by Oliver Hunt. + + Cache function offsets to speed up javascript parsing + https://bugs.webkit.org/show_bug.cgi?id=52622 + + Use cache to save function offsets and some other info. + This avoids quite a bit of work when reparsing the source. + + * parser/ASTBuilder.h: + * parser/JSParser.cpp: + (JSC::JSParser::CachedFunctionInfo::CachedFunctionInfo): + (JSC::JSParser::CachedFunctionInfo::approximateByteSize): + (JSC::JSParser::CachedFunctionInfo::closeBraceToken): + (JSC::JSParser::Scope::copyCapturedVariablesToVector): + (JSC::JSParser::Scope::saveFunctionInfo): + (JSC::JSParser::Scope::restoreFunctionInfo): + (JSC::JSParser::findCachedFunctionInfo): + (JSC::JSParser::JSParser): + (JSC::JSParser::parseProgram): + (JSC::JSParser::parseFunctionInfo): + * parser/Lexer.h: + (JSC::Lexer::setOffset): + (JSC::Lexer::setLineNumber): + (JSC::Lexer::sourceProvider): + * parser/SourceProvider.h: + (JSC::SourceProviderCache::SourceProviderCache): + (JSC::SourceProviderCache::~SourceProviderCache): + (JSC::SourceProviderCache::byteSize): + (JSC::SourceProviderCache::add): + (JSC::SourceProviderCache::get): + (JSC::SourceProvider::SourceProvider): + (JSC::SourceProvider::~SourceProvider): + (JSC::SourceProvider::cache): + (JSC::SourceProvider::notifyCacheSizeChanged): + (JSC::SourceProvider::cacheSizeChanged): + * parser/SyntaxChecker.h: + +2011-01-19 Mark Rowe <mrowe@apple.com> + + Reviewed by Darin Adler. + + Follow-up to r75766 / <rdar://problem/5469576>. + + * DerivedSources.make: Evaluate the SDKROOT variable correctly. + +2011-01-19 Oliver Hunt <oliver@apple.com> + + Reviewed by Gavin Barraclough. + + [jsfunfuzz] Defining a function called __proto__ inside an eval triggers an assertion + https://bugs.webkit.org/show_bug.cgi?id=52672 + + Rather than coming up with a somewhat convoluted mechanism to ensure that + developers can override the global objects prototype with a function named + __proto__ and expect it to work, we just disallow it at the syntax level. + + * parser/JSParser.cpp: + (JSC::JSParser::parseFunctionInfo): + +2011-01-19 Michael Saboff <msaboff@apple.com> + + Reviewed by Darin Adler. + + <rdar://problem/8882994> Regression: Simple nested backtrack hangs + https://bugs.webkit.org/show_bug.cgi?id=52675 + + The changeset (r76076) for https://bugs.webkit.org/show_bug.cgi?id=52540 + broke simple backtracking in some cases. Reworked that change to + link both jumps and labels. + + * yarr/YarrJIT.cpp: + (JSC::Yarr::YarrGenerator::BacktrackDestination::hasBacktrackToLabel): + (JSC::Yarr::YarrGenerator::TermGenerationState::propagateBacktrackingFrom): + (JSC::Yarr::YarrGenerator::generateParenthesesSingle): + +2011-01-19 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: [JSC] scripts have incorrect starting line (always 1). + https://bugs.webkit.org/show_bug.cgi?id=52721 + + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): + * debugger/Debugger.h: + * parser/Parser.h: + (JSC::Parser::parse): + * parser/SourceCode.h: + (JSC::SourceCode::SourceCode): + * parser/SourceProvider.h: + (JSC::SourceProvider::startPosition): + +2011-01-19 Csaba Osztrogonác <ossy@webkit.org> + + Reviewed by Laszlo Gombos and Tor Arne Vestbø. + + [Qt] Remove unnecessary "../Source" from paths + after moving source files into Source is finished. + + * JavaScriptCore.pri: + +2011-01-19 Benjamin Kalman <kalman@chromium.org> + + Reviewed by Darin Adler. + + Don't return void from void function String::split + https://bugs.webkit.org/show_bug.cgi?id=52684 + + * wtf/text/WTFString.cpp: + (WTF::String::split): + +2011-01-18 Kenneth Russell <kbr@google.com> + + Unreviewed, rolling out r76078. + http://trac.webkit.org/changeset/76078 + https://bugs.webkit.org/show_bug.cgi?id=52668 + + Caused crashes of fast/canvas/webgl/constants.html, + fast/canvas/webgl/gl-enum-tests.html, and possibly other layout + test crashes in Release mode. WebGL crashes were observed with + "run-webkit-tests fast/canvas/webgl". It was necessary to run + multiple tests to provoke the crash. + + * interpreter/RegisterFile.h: + (JSC::RegisterFile::markGlobals): + * runtime/JSActivation.cpp: + (JSC::JSActivation::markChildren): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::markChildren): + +2011-01-18 Oliver Hunt <oliver@apple.com> + + Reviewed by Gavin Barraclough. + + [jsfunfuzz] Assertion asking activation for arguments when arguments is overridden + https://bugs.webkit.org/show_bug.cgi?id=52690 + + Clean up code to retrieve arguments from activation and function objects. + Remove the incorrect assertion from JSActivation's argumentsGetter. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::retrieveArguments): + * runtime/JSActivation.cpp: + (JSC::JSActivation::argumentsGetter): + +2011-01-18 Geoffrey Garen <ggaren@apple.com> + + Reviewed by Darin Adler. + + Removed RegisterFile::markGlobals because it was obtuse, and it + unnecessarily relied on conservative marking. + https://bugs.webkit.org/show_bug.cgi?id=52668 + + * interpreter/RegisterFile.h: Removed markGlobals. + + * runtime/JSActivation.cpp: + (JSC::JSActivation::markChildren): Added a comment explaning why some + JSActivations don't always mark their registers arrays. + + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::markChildren): Instead of calling markGlobals, mark + the registers array directly. + +2011-01-18 Michael Saboff <msaboff@apple.com> + + Reviewed by Oliver Hunt. + + <rdar://problem/8875432> Regression: Some text-only e-mails cause hang beneath RegExp::match (52540) + https://bugs.webkit.org/show_bug.cgi?id=52540 + https://bugs.webkit.org/show_bug.cgi?id=52662 + + Directly use backtrack label with parentheses nested under a + non-capturing parentheses. Also linked current parentheses + tail code object for possible parens nested within a non-capturing + parentheses. + + * yarr/YarrJIT.cpp: + (JSC::Yarr::YarrGenerator::BacktrackDestination::linkBacktrackToLabel): + (JSC::Yarr::YarrGenerator::generateParenthesesSingle): + +2011-01-18 Daniel Bates <dbates@rim.com> + + Reviewed by Gavin Barraclough. + + Only use moving memory model assumption in ExecutableAllocator::intializePageSize() for Symbian OS + https://bugs.webkit.org/show_bug.cgi?id=52517 + + Patch by David Tapuska + + Currently, we compile code with respect to the Symbian-specific moving memory model + assumption for all ARMv5 or lower architectures. Instead, we should only compile + such code when building for Symbian OS on those architectures because this model + is Symbian-specific. + + * jit/ExecutableAllocator.cpp: + (JSC::ExecutableAllocator::intializePageSize): + +2011-01-18 Dimitry Andric <dim@freebsd.org> + + Reviewed by Andreas Kling. + + Fix linking JavaScriptCore on FreeBSD/amd64 + https://bugs.webkit.org/show_bug.cgi?id=52591 + + Linking of JavaScriptCore on FreeBSD/amd64 fails, for the same reason as + in bug 28422: cti_vm_throw needs a "@plt" suffix, otherwise the linker + complains about the relocation type. + + * jit/JITStubs.cpp: use @plt suffix on x86_64 platforms, for both Linux + and FreeBSD. + +2011-01-18 Oliver Hunt <oliver@apple.com> + + Reviewed by Antti Koivisto. + + [jsfunfuzz] Assertion in codegen for array of NaN constants + https://bugs.webkit.org/show_bug.cgi?id=52643 + + Don't cache NaN literals in the code generator, as NaN doesn't compare + as equal to itself it causes problems when rehashing the number cache. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitLoad): + 2011-01-17 Jarred Nicholls <jarred@sencha.com> Reviewed by Csaba Osztrogonác. diff --git a/Source/JavaScriptCore/DerivedSources.make b/Source/JavaScriptCore/DerivedSources.make index 4de4a88..748e254 100644 --- a/Source/JavaScriptCore/DerivedSources.make +++ b/Source/JavaScriptCore/DerivedSources.make @@ -88,4 +88,4 @@ JavaScriptCore.JSVALUE64.exp: JavaScriptCore.exp JavaScriptCore.JSVALUE64only.ex # header detection HeaderDetection.h : DerivedSources.make - if [ -f $SDKROOT/System/Library/Frameworks/System.framework/PrivateHeaders/pthread_machdep.h ]; then echo "#define HAVE_PTHREAD_MACHDEP_H 1" > $@; else echo > $@; fi + if [ -f $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders/pthread_machdep.h ]; then echo "#define HAVE_PTHREAD_MACHDEP_H 1" > $@; else echo > $@; fi diff --git a/Source/JavaScriptCore/GNUmakefile.am b/Source/JavaScriptCore/GNUmakefile.am index 4c8d204..7272471 100644 --- a/Source/JavaScriptCore/GNUmakefile.am +++ b/Source/JavaScriptCore/GNUmakefile.am @@ -404,6 +404,8 @@ javascriptcore_sources += \ Source/JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h \ Source/JavaScriptCore/runtime/StringPrototype.cpp \ Source/JavaScriptCore/runtime/StringPrototype.h \ + Source/JavaScriptCore/runtime/StringRecursionChecker.cpp \ + Source/JavaScriptCore/runtime/StringRecursionChecker.h \ Source/JavaScriptCore/runtime/StructureChain.cpp \ Source/JavaScriptCore/runtime/StructureChain.h \ Source/JavaScriptCore/runtime/Structure.cpp \ diff --git a/Source/JavaScriptCore/JavaScriptCore.gypi b/Source/JavaScriptCore/JavaScriptCore.gypi index a08b439..6ca18a0 100644 --- a/Source/JavaScriptCore/JavaScriptCore.gypi +++ b/Source/JavaScriptCore/JavaScriptCore.gypi @@ -337,6 +337,8 @@ 'runtime/StringObjectThatMasqueradesAsUndefined.h', 'runtime/StringPrototype.cpp', 'runtime/StringPrototype.h', + 'runtime/StringRecursionChecker.cpp', + 'runtime/StringRecursionChecker.h', 'runtime/Structure.cpp', 'runtime/Structure.h', 'runtime/StructureChain.cpp', diff --git a/Source/JavaScriptCore/JavaScriptCore.pri b/Source/JavaScriptCore/JavaScriptCore.pri index 222f664..a816c97 100644 --- a/Source/JavaScriptCore/JavaScriptCore.pri +++ b/Source/JavaScriptCore/JavaScriptCore.pri @@ -23,7 +23,6 @@ CONFIG(standalone_package): DEFINES *= NDEBUG JAVASCRIPTCORE_INCLUDEPATH = \ $$PWD \ $$PWD/.. \ - $$PWD/../.. \ # FIXME: Remove this include once we finish moving the source to Source $$PWD/assembler \ $$PWD/bytecode \ $$PWD/bytecompiler \ @@ -89,7 +88,12 @@ defineTest(addJavaScriptCoreLib) { # Make sure jscore will be early in the list of libraries to workaround a bug in MinGW # that can't resolve symbols from QtCore if libjscore comes after. QMAKE_LIBDIR = $$pathToJavaScriptCoreOutput $$QMAKE_LIBDIR - LIBS += -l$$JAVASCRIPTCORE_TARGET + webkit2 { + # FIXME Workaround for undefined reference linking issues until the build system gets redesigned + LIBS += -Wl,-whole-archive -l$$JAVASCRIPTCORE_TARGET -Wl,-no-whole-archive + } else { + LIBS += -l$$JAVASCRIPTCORE_TARGET + } POST_TARGETDEPS += $${pathToJavaScriptCoreOutput}$${QMAKE_DIR_SEP}lib$${JAVASCRIPTCORE_TARGET}.a } diff --git a/Source/JavaScriptCore/JavaScriptCore.pro b/Source/JavaScriptCore/JavaScriptCore.pro index ca420d2..9d254b7 100644 --- a/Source/JavaScriptCore/JavaScriptCore.pro +++ b/Source/JavaScriptCore/JavaScriptCore.pro @@ -205,6 +205,7 @@ SOURCES += \ runtime/StringConstructor.cpp \ runtime/StringObject.cpp \ runtime/StringPrototype.cpp \ + runtime/StringRecursionChecker.cpp \ runtime/StructureChain.cpp \ runtime/Structure.cpp \ runtime/TimeoutChecker.cpp \ diff --git a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj index 1ddc251..12310d8 100644 --- a/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj +++ b/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj @@ -1246,6 +1246,14 @@ > </File> <File + RelativePath="..\..\runtime\StringRecursionChecker.cpp" + > + </File> + <File + RelativePath="..\..\runtime\StringRecursionChecker.h" + > + </File> + <File RelativePath="..\..\runtime\Structure.cpp" > </File> diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj index 0f9b4ab..358e38c 100644 --- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj +++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj @@ -294,6 +294,7 @@ 932F5BEA0822A1C700736975 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; }; 933040040E6A749400786E6A /* SmallStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = 93303FEA0E6A72C000786E6A /* SmallStrings.h */; settings = {ATTRIBUTES = (Private, ); }; }; 9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93303FE80E6A72B500786E6A /* SmallStrings.cpp */; }; + 9335F24D12E6765B002B5553 /* StringRecursionChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93345A8712D838C400302BE3 /* StringRecursionChecker.cpp */; }; 933F5CDC1269229B0049191E /* NullPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 933F5CDB126922690049191E /* NullPtr.h */; settings = {ATTRIBUTES = (Private, ); }; }; 937013480CA97E0E00FA14D3 /* pcre_ucp_searchfuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 937013470CA97E0E00FA14D3 /* pcre_ucp_searchfuncs.cpp */; settings = {COMPILER_FLAGS = "-Wno-sign-compare"; }; }; 93854A9A12C93D3B00DAAF77 /* NullPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93854A9912C93D3B00DAAF77 /* NullPtr.cpp */; }; @@ -925,6 +926,8 @@ 932F5BE10822A1C700736975 /* jsc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jsc; sourceTree = BUILT_PRODUCTS_DIR; }; 93303FE80E6A72B500786E6A /* SmallStrings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmallStrings.cpp; sourceTree = "<group>"; }; 93303FEA0E6A72C000786E6A /* SmallStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmallStrings.h; sourceTree = "<group>"; }; + 93345A8712D838C400302BE3 /* StringRecursionChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringRecursionChecker.cpp; sourceTree = "<group>"; }; + 93345A8812D838C400302BE3 /* StringRecursionChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringRecursionChecker.h; sourceTree = "<group>"; }; 933A349A038AE7C6008635CE /* Identifier.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Identifier.h; sourceTree = "<group>"; tabWidth = 8; }; 933A349D038AE80F008635CE /* Identifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Identifier.cpp; sourceTree = "<group>"; tabWidth = 8; }; 933F5CDB126922690049191E /* NullPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullPtr.h; sourceTree = "<group>"; }; @@ -1867,6 +1870,8 @@ BC18C3C40E16EE3300B34460 /* StringObjectThatMasqueradesAsUndefined.h */, BC18C3C50E16EE3300B34460 /* StringPrototype.cpp */, BC18C3C60E16EE3300B34460 /* StringPrototype.h */, + 93345A8712D838C400302BE3 /* StringRecursionChecker.cpp */, + 93345A8812D838C400302BE3 /* StringRecursionChecker.h */, BCDE3AB00E6C82CF001453A7 /* Structure.cpp */, BCDE3AB10E6C82CF001453A7 /* Structure.h */, 7E4EE70E0EBB7A5B005934AA /* StructureChain.cpp */, @@ -2873,6 +2878,7 @@ 86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */, 86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */, 86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */, + 9335F24D12E6765B002B5553 /* StringRecursionChecker.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/JavaScriptCore/assembler/LinkBuffer.h b/Source/JavaScriptCore/assembler/LinkBuffer.h index e38b9d4..c5a7d5b 100644 --- a/Source/JavaScriptCore/assembler/LinkBuffer.h +++ b/Source/JavaScriptCore/assembler/LinkBuffer.h @@ -50,7 +50,8 @@ namespace JSC { // * The address of a Label pointing into the code may be resolved. // * The value referenced by a DataLabel may be set. // -class LinkBuffer : public Noncopyable { +class LinkBuffer { + WTF_MAKE_NONCOPYABLE(LinkBuffer); typedef MacroAssemblerCodeRef CodeRef; typedef MacroAssemblerCodePtr CodePtr; typedef MacroAssembler::Label Label; diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.h b/Source/JavaScriptCore/bytecode/CodeBlock.h index 7eca72a..1cd0863 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.h +++ b/Source/JavaScriptCore/bytecode/CodeBlock.h @@ -242,7 +242,8 @@ namespace JSC { } #endif - class CodeBlock : public FastAllocBase { + class CodeBlock { + WTF_MAKE_FAST_ALLOCATED; friend class JIT; protected: CodeBlock(ScriptExecutable* ownerExecutable, CodeType, JSGlobalObject*, PassRefPtr<SourceProvider>, unsigned sourceOffset, SymbolTable* symbolTable, bool isConstructor); @@ -578,7 +579,9 @@ namespace JSC { SymbolTable* m_symbolTable; - struct RareData : FastAllocBase { + struct RareData { + WTF_MAKE_FAST_ALLOCATED; + public: Vector<HandlerInfo> m_exceptionHandlers; // Rare Constants @@ -599,6 +602,9 @@ namespace JSC { Vector<CallReturnOffsetToBytecodeOffset> m_callReturnIndexVector; #endif }; +#if PLATFORM(WIN) + friend void WTF::deleteOwnedPtr<RareData>(RareData*); +#endif OwnPtr<RareData> m_rareData; }; diff --git a/Source/JavaScriptCore/bytecode/Instruction.h b/Source/JavaScriptCore/bytecode/Instruction.h index c6468a5..f077cbf 100644 --- a/Source/JavaScriptCore/bytecode/Instruction.h +++ b/Source/JavaScriptCore/bytecode/Instruction.h @@ -54,7 +54,9 @@ namespace JSC { class StructureChain; // Structure used by op_get_by_id_self_list and op_get_by_id_proto_list instruction to hold data off the main opcode stream. - struct PolymorphicAccessStructureList : FastAllocBase { + struct PolymorphicAccessStructureList { + WTF_MAKE_FAST_ALLOCATED; + public: struct PolymorphicStubInfo { bool isChain; PolymorphicAccessStructureListStubRoutineType stubRoutine; diff --git a/Source/JavaScriptCore/bytecode/SamplingTool.h b/Source/JavaScriptCore/bytecode/SamplingTool.h index 8e3ed9e..9ca54da 100644 --- a/Source/JavaScriptCore/bytecode/SamplingTool.h +++ b/Source/JavaScriptCore/bytecode/SamplingTool.h @@ -142,7 +142,8 @@ namespace JSC { friend class HostCallRecord; #if ENABLE(OPCODE_SAMPLING) - class CallRecord : public Noncopyable { + class CallRecord { + WTF_MAKE_NONCOPYABLE(CallRecord); public: CallRecord(SamplingTool* samplingTool) : m_samplingTool(samplingTool) @@ -172,7 +173,8 @@ namespace JSC { } }; #else - class CallRecord : public Noncopyable { + class CallRecord { + WTF_MAKE_NONCOPYABLE(CallRecord); public: CallRecord(SamplingTool*) { diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp index 34afb52..78c373a 100644 --- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp +++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp @@ -1082,8 +1082,9 @@ RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, bool b) RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, double number) { // FIXME: Our hash tables won't hold infinity, so we make a new JSNumberCell each time. - // Later we can do the extra work to handle that like the other cases. - if (number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number)) + // Later we can do the extra work to handle that like the other cases. They also don't + // work correctly with NaN as a key. + if (isnan(number) || number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number)) return emitLoad(dst, jsNumber(number)); JSValue& valueInMap = m_numberMap.add(number, JSValue()).first->second; if (!valueInMap) diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h index 8b0cc40..de16f8e 100644 --- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h +++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h @@ -40,7 +40,6 @@ #include "SymbolTable.h" #include "Debugger.h" #include "Nodes.h" -#include <wtf/FastAllocBase.h> #include <wtf/PassRefPtr.h> #include <wtf/SegmentedVector.h> #include <wtf/Vector.h> @@ -85,7 +84,8 @@ namespace JSC { RefPtr<RegisterID> propertyRegister; }; - class BytecodeGenerator : public FastAllocBase { + class BytecodeGenerator { + WTF_MAKE_FAST_ALLOCATED; public: typedef DeclarationStacks::VarStack VarStack; typedef DeclarationStacks::FunctionStack FunctionStack; diff --git a/Source/JavaScriptCore/bytecompiler/RegisterID.h b/Source/JavaScriptCore/bytecompiler/RegisterID.h index 3532ad8..78d49d2 100644 --- a/Source/JavaScriptCore/bytecompiler/RegisterID.h +++ b/Source/JavaScriptCore/bytecompiler/RegisterID.h @@ -30,12 +30,12 @@ #define RegisterID_h #include <wtf/Assertions.h> -#include <wtf/Noncopyable.h> #include <wtf/VectorTraits.h> namespace JSC { - class RegisterID : public Noncopyable { + class RegisterID { + WTF_MAKE_NONCOPYABLE(RegisterID); public: RegisterID() : m_refCount(0) diff --git a/Source/JavaScriptCore/create_jit_stubs b/Source/JavaScriptCore/create_jit_stubs index 4950bfc..f0fcb53 100644 --- a/Source/JavaScriptCore/create_jit_stubs +++ b/Source/JavaScriptCore/create_jit_stubs @@ -22,20 +22,16 @@ use strict; use File::Basename; use Getopt::Long; -my $usage = basename($0) . " --prefix prefix [--offset offset] file"; +my $usage = basename($0) . " --prefix prefix file"; my $rtype_template = quotemeta("#rtype#"); -my $offset_template = quotemeta(" THUNK_RETURN_ADDRESS_OFFSET"); my $op_template = quotemeta("#op#"); my $prefix; -my $offset_is_set = 0; -my $offset = 32; my $file; my $getOptionsResult = GetOptions( - 'prefix=s' => \$prefix, - 'offset=i' => sub { $offset_is_set = 1; $offset = $_[1]; } + 'prefix=s' => \$prefix ); $file = $ARGV[0]; @@ -55,9 +51,6 @@ open(IN, $file) or die "No such file $file"; while ( $_ = <IN> ) { if ( /^$prefix\_BEGIN\((.*)\)/ ) { $stub = $1; - if ($offset_is_set) { - $stub =~ s/$offset_template/$offset/g; - } print $stub . "\n"; } if ( /^$prefix\((.*)\)/ ) { @@ -70,9 +63,6 @@ while ( $_ = <IN> ) { $stub = $stub_template; $rtype = quotemeta($1); $op = quotemeta($2); - if ($offset_is_set) { - $stub =~ s/$offset_template/$offset/g; - } $stub =~ s/$rtype_template/$rtype/g; $stub =~ s/$op_template/$op/g; $stub =~ s/\\\*/\*/g; diff --git a/Source/JavaScriptCore/debugger/Debugger.cpp b/Source/JavaScriptCore/debugger/Debugger.cpp index 6b24c5a..23b9361 100644 --- a/Source/JavaScriptCore/debugger/Debugger.cpp +++ b/Source/JavaScriptCore/debugger/Debugger.cpp @@ -94,7 +94,7 @@ void Debugger::recompileAllJSFunctions(JSGlobalData* globalData) // JavaScript in the inspector. SourceProviderMap::const_iterator end = sourceProviders.end(); for (SourceProviderMap::const_iterator iter = sourceProviders.begin(); iter != end; ++iter) - sourceParsed(iter->second, SourceCode(iter->first), -1, UString()); + sourceParsed(iter->second, iter->first, -1, UString()); } JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject) diff --git a/Source/JavaScriptCore/debugger/Debugger.h b/Source/JavaScriptCore/debugger/Debugger.h index 3b9bec4..ec5cf37 100644 --- a/Source/JavaScriptCore/debugger/Debugger.h +++ b/Source/JavaScriptCore/debugger/Debugger.h @@ -31,7 +31,7 @@ namespace JSC { class JSGlobalData; class JSGlobalObject; class JSValue; - class SourceCode; + class SourceProvider; class UString; class Debugger { @@ -41,7 +41,7 @@ namespace JSC { void attach(JSGlobalObject*); virtual void detach(JSGlobalObject*); - virtual void sourceParsed(ExecState*, const SourceCode&, int errorLineNumber, const UString& errorMessage) = 0; + virtual void sourceParsed(ExecState*, SourceProvider*, int errorLineNumber, const UString& errorMessage) = 0; virtual void exception(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber, bool hasHandler) = 0; virtual void atStatement(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; virtual void callEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0; diff --git a/Source/JavaScriptCore/interpreter/CachedCall.h b/Source/JavaScriptCore/interpreter/CachedCall.h index dfbe658..740001d 100644 --- a/Source/JavaScriptCore/interpreter/CachedCall.h +++ b/Source/JavaScriptCore/interpreter/CachedCall.h @@ -32,7 +32,8 @@ #include "Interpreter.h" namespace JSC { - class CachedCall : public Noncopyable { + class CachedCall { + WTF_MAKE_NONCOPYABLE(CachedCall); WTF_MAKE_FAST_ALLOCATED; public: CachedCall(CallFrame* callFrame, JSFunction* function, int argCount) : m_valid(false) diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp index cf9f8a1..392e8b8 100644 --- a/Source/JavaScriptCore/interpreter/Interpreter.cpp +++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp @@ -4802,12 +4802,13 @@ JSValue Interpreter::retrieveArguments(CallFrame* callFrame, JSFunction* functio if (codeBlock->usesArguments()) { ASSERT(codeBlock->codeType() == FunctionCode); int argumentsRegister = codeBlock->argumentsRegister(); - if (!functionCallFrame->r(argumentsRegister).jsValue()) { - JSValue arguments = JSValue(new (callFrame) Arguments(functionCallFrame)); - functionCallFrame->r(argumentsRegister) = arguments; - functionCallFrame->r(unmodifiedArgumentsRegister(argumentsRegister)) = arguments; - } - return functionCallFrame->r(argumentsRegister).jsValue(); + int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister); + if (JSValue arguments = functionCallFrame->uncheckedR(argumentsRegister).jsValue()) + return arguments; + JSValue arguments = JSValue(new (callFrame) Arguments(functionCallFrame)); + functionCallFrame->r(argumentsRegister) = arguments; + functionCallFrame->r(realArgumentsRegister) = arguments; + return arguments; } Arguments* arguments = new (functionCallFrame) Arguments(functionCallFrame); diff --git a/Source/JavaScriptCore/interpreter/Interpreter.h b/Source/JavaScriptCore/interpreter/Interpreter.h index 47790cf..753d90e 100644 --- a/Source/JavaScriptCore/interpreter/Interpreter.h +++ b/Source/JavaScriptCore/interpreter/Interpreter.h @@ -30,7 +30,6 @@ #define Interpreter_h #include "ArgList.h" -#include "FastAllocBase.h" #include "JSCell.h" #include "JSValue.h" #include "JSObject.h" @@ -65,7 +64,8 @@ namespace JSC { enum { MaxLargeThreadReentryDepth = 256, MaxSmallThreadReentryDepth = 32 }; - class Interpreter : public FastAllocBase { + class Interpreter { + WTF_MAKE_FAST_ALLOCATED; friend class JIT; friend class CachedCall; public: diff --git a/Source/JavaScriptCore/interpreter/Register.h b/Source/JavaScriptCore/interpreter/Register.h index 38d1647..3944642 100644 --- a/Source/JavaScriptCore/interpreter/Register.h +++ b/Source/JavaScriptCore/interpreter/Register.h @@ -31,7 +31,6 @@ #include "JSValue.h" #include <wtf/Assertions.h> -#include <wtf/FastAllocBase.h> #include <wtf/VectorTraits.h> namespace JSC { @@ -47,7 +46,8 @@ namespace JSC { typedef ExecState CallFrame; - class Register : public WTF::FastAllocBase { + class Register { + WTF_MAKE_FAST_ALLOCATED; public: Register(); diff --git a/Source/JavaScriptCore/interpreter/RegisterFile.h b/Source/JavaScriptCore/interpreter/RegisterFile.h index f2e6553..9dfc432 100644 --- a/Source/JavaScriptCore/interpreter/RegisterFile.h +++ b/Source/JavaScriptCore/interpreter/RegisterFile.h @@ -89,7 +89,8 @@ namespace JSC { class JSGlobalObject; - class RegisterFile : public Noncopyable { + class RegisterFile { + WTF_MAKE_NONCOPYABLE(RegisterFile); friend class JIT; public: enum CallFrameHeaderEntry { @@ -131,8 +132,7 @@ namespace JSC { Register* lastGlobal() const { return m_start - m_numGlobals; } - void markGlobals(MarkStack& markStack, Heap* heap) { heap->markConservatively(markStack, lastGlobal(), m_start); } - void markCallFrames(MarkStack& markStack, Heap* heap) { heap->markConservatively(markStack, m_start, m_end); } + void markCallFrames(ConservativeSet& conservativeSet, Heap* heap) { heap->markConservatively(conservativeSet, m_start, m_end); } static size_t committedByteCount(); static void initializeThreading(); diff --git a/Source/JavaScriptCore/jit/ExecutableAllocator.cpp b/Source/JavaScriptCore/jit/ExecutableAllocator.cpp index 4530b38..fa6db83 100644 --- a/Source/JavaScriptCore/jit/ExecutableAllocator.cpp +++ b/Source/JavaScriptCore/jit/ExecutableAllocator.cpp @@ -37,7 +37,7 @@ size_t ExecutableAllocator::pageSize = 0; void ExecutableAllocator::intializePageSize() { -#if CPU(ARMV5_OR_LOWER) +#if OS(SYMBIAN) && CPU(ARMV5_OR_LOWER) // The moving memory model (as used in ARMv5 and earlier platforms) // on Symbian OS limits the number of chunks for each process to 16. // To mitigate this limitation increase the pagesize to allocate diff --git a/Source/JavaScriptCore/jit/JIT.cpp b/Source/JavaScriptCore/jit/JIT.cpp index 89b1e30..b8bd718 100644 --- a/Source/JavaScriptCore/jit/JIT.cpp +++ b/Source/JavaScriptCore/jit/JIT.cpp @@ -45,10 +45,6 @@ JSC::MacroAssemblerX86Common::SSE2CheckState JSC::MacroAssemblerX86Common::s_sse #include "ResultType.h" #include "SamplingTool.h" -#ifndef NDEBUG -#include <stdio.h> -#endif - using namespace std; namespace JSC { diff --git a/Source/JavaScriptCore/jit/JITStubs.cpp b/Source/JavaScriptCore/jit/JITStubs.cpp index ded3428..9126ea7 100644 --- a/Source/JavaScriptCore/jit/JITStubs.cpp +++ b/Source/JavaScriptCore/jit/JITStubs.cpp @@ -79,7 +79,7 @@ namespace JSC { #define THUMB_FUNC_PARAM(name) #endif -#if OS(LINUX) && CPU(X86_64) +#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64) #define SYMBOL_STRING_RELOCATION(name) #name "@plt" #elif OS(DARWIN) #define SYMBOL_STRING_RELOCATION(name) "_" #name @@ -233,8 +233,10 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" #define EXCEPTION_OFFSET 0x54 #define ENABLE_PROFILER_REFERENCE_OFFSET 0x58 -#elif (COMPILER(GCC) || COMPILER(RVCT)) && CPU(ARM_TRADITIONAL) +#elif (COMPILER(GCC) || COMPILER(MSVC) || COMPILER(RVCT)) && CPU(ARM_TRADITIONAL) +// Also update the MSVC section (defined at DEFINE_STUB_FUNCTION) +// when changing one of the following values. #define THUNK_RETURN_ADDRESS_OFFSET 64 #define PRESERVEDR4_OFFSET 68 @@ -298,12 +300,6 @@ extern "C" { } } -#elif COMPILER(MSVC) && CPU(ARM_TRADITIONAL) - -#define THUNK_RETURN_ADDRESS_OFFSET 64 -#define PRESERVEDR4_OFFSET 68 -// See DEFINE_STUB_FUNCTION for more information. - #elif CPU(MIPS) #define PRESERVED_GP_OFFSET 60 @@ -533,12 +529,6 @@ extern "C" { } } -#elif COMPILER(MSVC) && CPU(ARM_TRADITIONAL) - -#define THUNK_RETURN_ADDRESS_OFFSET 32 -#define PRESERVEDR4_OFFSET 36 -// See DEFINE_STUB_FUNCTION for more information. - #else #error "JIT not supported on this platform." #endif @@ -1270,13 +1260,13 @@ MSVC_BEGIN() MSVC_BEGIN(ctiTrampoline PROC) MSVC_BEGIN( stmdb sp!, {r1-r3}) MSVC_BEGIN( stmdb sp!, {r4-r8, lr}) -MSVC_BEGIN( sub sp, sp, # THUNK_RETURN_ADDRESS_OFFSET + 4) +MSVC_BEGIN( sub sp, sp, #68 ; sync with PRESERVEDR4_OFFSET) MSVC_BEGIN( mov r4, r2) MSVC_BEGIN( mov r5, #512) MSVC_BEGIN( ; r0 contains the code) MSVC_BEGIN( mov lr, pc) MSVC_BEGIN( bx r0) -MSVC_BEGIN( add sp, sp, # THUNK_RETURN_ADDRESS_OFFSET + 4) +MSVC_BEGIN( add sp, sp, #68 ; sync with PRESERVEDR4_OFFSET) MSVC_BEGIN( ldmia sp!, {r4-r8, lr}) MSVC_BEGIN( add sp, sp, #12) MSVC_BEGIN( bx lr) @@ -1287,7 +1277,7 @@ MSVC_BEGIN( mov r0, sp) MSVC_BEGIN( mov lr, pc) MSVC_BEGIN( bl cti_vm_throw) MSVC_BEGIN(ctiOpThrowNotCaught) -MSVC_BEGIN( add sp, sp, # THUNK_RETURN_ADDRESS_OFFSET + 4) +MSVC_BEGIN( add sp, sp, #68 ; sync with PRESERVEDR4_OFFSET) MSVC_BEGIN( ldmia sp!, {r4-r8, lr}) MSVC_BEGIN( add sp, sp, #12) MSVC_BEGIN( bx lr) @@ -1297,9 +1287,9 @@ MSVC_BEGIN() MSVC( EXPORT cti_#op#) MSVC( IMPORT JITStubThunked_#op#) MSVC(cti_#op# PROC) -MSVC( str lr, [sp, # THUNK_RETURN_ADDRESS_OFFSET]) +MSVC( str lr, [sp, #64] ; sync with THUNK_RETURN_ADDRESS_OFFSET) MSVC( bl JITStubThunked_#op#) -MSVC( ldr lr, [sp, # THUNK_RETURN_ADDRESS_OFFSET]) +MSVC( ldr lr, [sp, #64] ; sync with THUNK_RETURN_ADDRESS_OFFSET) MSVC( bx lr) MSVC(cti_#op# ENDP) MSVC() diff --git a/Source/JavaScriptCore/parser/ASTBuilder.h b/Source/JavaScriptCore/parser/ASTBuilder.h index 337c87e..0e18d1d 100644 --- a/Source/JavaScriptCore/parser/ASTBuilder.h +++ b/Source/JavaScriptCore/parser/ASTBuilder.h @@ -108,6 +108,7 @@ public: static const bool CreatesAST = true; static const bool NeedsFreeVariableInfo = true; + static const bool CanUseFunctionCache = true; ExpressionNode* makeBinaryNode(int token, std::pair<ExpressionNode*, BinaryOpInfo>, std::pair<ExpressionNode*, BinaryOpInfo>); ExpressionNode* makeFunctionCallNode(ExpressionNode* func, ArgumentsNode* args, int start, int divot, int end); diff --git a/Source/JavaScriptCore/parser/JSParser.cpp b/Source/JavaScriptCore/parser/JSParser.cpp index 37b7f90..cb59f93 100644 --- a/Source/JavaScriptCore/parser/JSParser.cpp +++ b/Source/JavaScriptCore/parser/JSParser.cpp @@ -33,6 +33,7 @@ using namespace JSC; #include "JSGlobalData.h" #include "NodeInfo.h" #include "ASTBuilder.h" +#include "SourceProvider.h" #include <wtf/HashFunctions.h> #include <wtf/WTFThreadData.h> #include <utility> @@ -94,6 +95,39 @@ private: StringImpl* m_ident; bool m_isLoop; }; + + struct CachedFunctionInfo : public SourceProviderCache::Item { + CachedFunctionInfo(int closeBraceLine, int closeBracePos) + : closeBraceLine(closeBraceLine) + , closeBracePos(closeBracePos) + { + } + unsigned approximateByteSize() const + { + // The identifiers are uniqued strings so most likely there are few names that actually use any additional memory. + static const unsigned assummedAverageIdentifierSize = sizeof(RefPtr<StringImpl>) + 2; + unsigned size = sizeof(*this); + size += usedVariables.size() * assummedAverageIdentifierSize; + size += writtenVariables.size() * assummedAverageIdentifierSize; + return size; + } + JSToken closeBraceToken() const + { + JSToken token; + token.m_type = CLOSEBRACE; + token.m_data.intValue = closeBracePos; + token.m_info.startOffset = closeBracePos; + token.m_info.endOffset = closeBracePos + 1; + token.m_info.line = closeBraceLine; + return token; + } + + int closeBraceLine; + int closeBracePos; + bool usesEval; + Vector<RefPtr<StringImpl> > usedVariables; + Vector<RefPtr<StringImpl> > writtenVariables; + }; void next(Lexer::LexType lexType = Lexer::IdentifyReservedWords) { @@ -417,6 +451,37 @@ private: bool strictMode() const { return m_strictMode; } bool isValidStrictMode() const { return m_isValidStrictMode; } bool shadowsArguments() const { return m_shadowsArguments; } + + void copyCapturedVariablesToVector(const IdentifierSet& capturedVariables, Vector<RefPtr<StringImpl> >& vector) + { + IdentifierSet::iterator end = capturedVariables.end(); + for (IdentifierSet::iterator it = capturedVariables.begin(); it != end; ++it) { + if (m_declaredVariables.contains(*it)) + continue; + vector.append(*it); + } + vector.shrinkToFit(); + } + + void saveFunctionInfo(CachedFunctionInfo* info) + { + ASSERT(m_isFunction); + info->usesEval = m_usesEval; + copyCapturedVariablesToVector(m_writtenVariables, info->writtenVariables); + copyCapturedVariablesToVector(m_usedVariables, info->usedVariables); + } + + void restoreFunctionInfo(const CachedFunctionInfo* info) + { + ASSERT(m_isFunction); + m_usesEval = info->usesEval; + unsigned size = info->usedVariables.size(); + for (unsigned i = 0; i < size; ++i) + m_usedVariables.add(info->usedVariables[i]); + size = info->writtenVariables.size(); + for (unsigned i = 0; i < size; ++i) + m_writtenVariables.add(info->writtenVariables[i]); + } private: JSGlobalData* m_globalData; @@ -543,6 +608,13 @@ private: } ScopeStack m_scopeStack; + + const CachedFunctionInfo* findCachedFunctionInfo(int openBracePos) + { + return m_functionCache ? static_cast<const CachedFunctionInfo*>(m_functionCache->get(openBracePos)) : 0; + } + + SourceProviderCache* m_functionCache; }; const char* jsParse(JSGlobalData* globalData, FunctionParameters* parameters, JSParserStrictness strictness, JSParserMode parserMode, const SourceCode* source) @@ -566,6 +638,7 @@ JSParser::JSParser(Lexer* lexer, JSGlobalData* globalData, FunctionParameters* p , m_statementDepth(0) , m_nonTrivialExpressionCount(0) , m_lastIdentifier(0) + , m_functionCache(m_lexer->sourceProvider()->cache()) { ScopeRef scope = pushScope(); if (isFunction) @@ -582,6 +655,7 @@ JSParser::JSParser(Lexer* lexer, JSGlobalData* globalData, FunctionParameters* p const char* JSParser::parseProgram() { + unsigned oldFunctionCacheSize = m_functionCache ? m_functionCache->byteSize() : 0; ASTBuilder context(m_globalData, m_lexer); if (m_lexer->isReparsing()) m_statementDepth--; @@ -596,6 +670,10 @@ const char* JSParser::parseProgram() features |= StrictModeFeature; if (scope->shadowsArguments()) features |= ShadowsArgumentsFeature; + + unsigned functionCacheSize = m_functionCache ? m_functionCache->byteSize() : 0; + if (functionCacheSize != oldFunctionCacheSize) + m_lexer->sourceProvider()->notifyCacheSizeChanged(functionCacheSize - oldFunctionCacheSize); m_globalData->parser->didFinishParsing(sourceElements, context.varDeclarations(), context.funcDeclarations(), features, m_lastLine, context.numConstants(), capturedVariables); @@ -1223,6 +1301,7 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc functionScope->setIsFunction(); if (match(IDENT)) { name = m_token.m_data.ident; + failIfTrue(*name == m_globalData->propertyNames->underscoreProto); next(); if (!nameIsInContainingScope) failIfFalseIfStrict(functionScope->declareVariable(name)); @@ -1238,6 +1317,23 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc openBracePos = m_token.m_data.intValue; bodyStartLine = tokenLine(); + + if (const CachedFunctionInfo* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) { + // If we know about this function already, we can use the cached info and skip the parser to the end of the function. + body = context.createFunctionBody(strictMode()); + + functionScope->restoreFunctionInfo(cachedInfo); + failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo)); + + closeBracePos = cachedInfo->closeBracePos; + m_token = cachedInfo->closeBraceToken(); + m_lexer->setOffset(m_token.m_info.endOffset); + m_lexer->setLineNumber(m_token.m_info.line); + + next(); + return true; + } + next(); body = parseFunctionBody(context); @@ -1246,9 +1342,26 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc failIfTrue(m_globalData->propertyNames->arguments == *name); failIfTrue(m_globalData->propertyNames->eval == *name); } + closeBracePos = m_token.m_data.intValue; + + // Cache the tokenizer state and the function scope the first time the function is parsed. + // Any future reparsing can then skip the function. + static const int minimumFunctionLengthToCache = 64; + OwnPtr<CachedFunctionInfo> newInfo; + int functionLength = closeBracePos - openBracePos; + if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) { + newInfo = adoptPtr(new CachedFunctionInfo(m_token.m_info.line, closeBracePos)); + functionScope->saveFunctionInfo(newInfo.get()); + } + failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo)); matchOrFail(CLOSEBRACE); - closeBracePos = m_token.m_data.intValue; + + if (newInfo) { + unsigned approximateByteSize = newInfo->approximateByteSize(); + m_functionCache->add(openBracePos, newInfo.release(), approximateByteSize); + } + next(); return true; } diff --git a/Source/JavaScriptCore/parser/Lexer.h b/Source/JavaScriptCore/parser/Lexer.h index 79987af..d4145c1 100644 --- a/Source/JavaScriptCore/parser/Lexer.h +++ b/Source/JavaScriptCore/parser/Lexer.h @@ -37,7 +37,8 @@ namespace JSC { class RegExp; - class Lexer : public Noncopyable { + class Lexer { + WTF_MAKE_NONCOPYABLE(Lexer); WTF_MAKE_FAST_ALLOCATED; public: // Character manipulation functions. static bool isWhiteSpace(int character); @@ -73,7 +74,15 @@ namespace JSC { m_current = *m_code; m_buffer8.resize(0); m_buffer16.resize(0); + if (UNLIKELY(m_code == m_codeEnd)) + m_current = -1; } + void setLineNumber(int line) + { + m_lineNumber = line; + } + + SourceProvider* sourceProvider() const { return m_source->provider(); } private: friend class JSGlobalData; diff --git a/Source/JavaScriptCore/parser/Nodes.h b/Source/JavaScriptCore/parser/Nodes.h index 54b7231..6e73c00 100644 --- a/Source/JavaScriptCore/parser/Nodes.h +++ b/Source/JavaScriptCore/parser/Nodes.h @@ -1376,7 +1376,9 @@ namespace JSC { ParameterNode* m_next; }; - struct ScopeNodeData : FastAllocBase { + struct ScopeNodeData { + WTF_MAKE_FAST_ALLOCATED; + public: typedef DeclarationStacks::VarStack VarStack; typedef DeclarationStacks::FunctionStack FunctionStack; @@ -1472,6 +1474,7 @@ namespace JSC { }; class FunctionParameters : public Vector<Identifier>, public RefCounted<FunctionParameters> { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<FunctionParameters> create(ParameterNode* firstParameter) { return adoptRef(new FunctionParameters(firstParameter)); } diff --git a/Source/JavaScriptCore/parser/Parser.h b/Source/JavaScriptCore/parser/Parser.h index 213827b..58398d1 100644 --- a/Source/JavaScriptCore/parser/Parser.h +++ b/Source/JavaScriptCore/parser/Parser.h @@ -45,8 +45,10 @@ namespace JSC { template <typename T> struct ParserArenaData : ParserArenaDeletable { T data; }; - class Parser : public Noncopyable { + class Parser { + WTF_MAKE_NONCOPYABLE(Parser); WTF_MAKE_FAST_ALLOCATED; public: + Parser() { } template <class ParsedNode> PassRefPtr<ParsedNode> parse(JSGlobalObject* lexicalGlobalObject, Debugger*, ExecState*, const SourceCode& source, FunctionParameters*, JSParserStrictness strictness, JSObject** exception); @@ -119,7 +121,7 @@ namespace JSC { m_funcDeclarations = 0; if (debugger && !ParsedNode::scopeIsFunction) - debugger->sourceParsed(debuggerExecState, source, errLine, errMsg); + debugger->sourceParsed(debuggerExecState, source.provider(), errLine, errMsg); return result.release(); } diff --git a/Source/JavaScriptCore/parser/ParserArena.h b/Source/JavaScriptCore/parser/ParserArena.h index 7c1809e..82fb808 100644 --- a/Source/JavaScriptCore/parser/ParserArena.h +++ b/Source/JavaScriptCore/parser/ParserArena.h @@ -34,7 +34,8 @@ namespace JSC { class ParserArenaDeletable; class ParserArenaRefCounted; - class IdentifierArena : public FastAllocBase { + class IdentifierArena { + WTF_MAKE_FAST_ALLOCATED; public: ALWAYS_INLINE const Identifier& makeIdentifier(JSGlobalData*, const UChar* characters, size_t length); const Identifier& makeNumericIdentifier(JSGlobalData*, double number); @@ -59,7 +60,8 @@ namespace JSC { return m_identifiers.last(); } - class ParserArena : Noncopyable { + class ParserArena { + WTF_MAKE_NONCOPYABLE(ParserArena); public: ParserArena(); ~ParserArena(); diff --git a/Source/JavaScriptCore/parser/SourceCode.h b/Source/JavaScriptCore/parser/SourceCode.h index a3ce759..9ba4da3 100644 --- a/Source/JavaScriptCore/parser/SourceCode.h +++ b/Source/JavaScriptCore/parser/SourceCode.h @@ -31,7 +31,6 @@ #include "SourceProvider.h" #include <wtf/RefPtr.h> -#include <wtf/text/TextPosition.h> namespace JSC { @@ -42,34 +41,22 @@ namespace JSC { , m_startChar(0) , m_endChar(0) , m_firstLine(0) - , m_firstColumn(0) { } - SourceCode(PassRefPtr<SourceProvider> provider, int firstLine = 1, int firstColumn = 1) + SourceCode(PassRefPtr<SourceProvider> provider, int firstLine = 1) : m_provider(provider) , m_startChar(0) , m_endChar(m_provider->length()) , m_firstLine(std::max(firstLine, 1)) - , m_firstColumn(std::max(firstColumn, 1)) { } - SourceCode(PassRefPtr<SourceProvider> provider, int start, int end, int firstLine, int firstColumn = 1) + SourceCode(PassRefPtr<SourceProvider> provider, int start, int end, int firstLine) : m_provider(provider) , m_startChar(start) , m_endChar(end) , m_firstLine(std::max(firstLine, 1)) - , m_firstColumn(std::max(firstColumn, 1)) - { - } - - SourceCode(PassRefPtr<SourceProvider> provider, const TextPosition1& startPosition) - : m_provider(provider) - , m_startChar(0) - , m_endChar(m_provider->length()) - , m_firstLine(startPosition.m_line.oneBasedInt()) - , m_firstColumn(startPosition.m_column.oneBasedInt()) { } @@ -83,7 +70,6 @@ namespace JSC { bool isNull() const { return !m_provider; } SourceProvider* provider() const { return m_provider.get(); } int firstLine() const { return m_firstLine; } - int firstColumn() const { return m_firstColumn; } int startOffset() const { return m_startChar; } int endOffset() const { return m_endChar; } const UChar* data() const { return m_provider->data() + m_startChar; } @@ -94,7 +80,6 @@ namespace JSC { int m_startChar; int m_endChar; int m_firstLine; - int m_firstColumn; }; inline SourceCode makeSource(const UString& source, const UString& url = UString(), int firstLine = 1) diff --git a/Source/JavaScriptCore/parser/SourceProvider.h b/Source/JavaScriptCore/parser/SourceProvider.h index 5ff1d14..bcc445b 100644 --- a/Source/JavaScriptCore/parser/SourceProvider.h +++ b/Source/JavaScriptCore/parser/SourceProvider.h @@ -30,32 +30,67 @@ #define SourceProvider_h #include "UString.h" +#include <wtf/HashMap.h> +#include <wtf/PassOwnPtr.h> #include <wtf/RefCounted.h> +#include <wtf/UnusedParam.h> +#include <wtf/text/TextPosition.h> + namespace JSC { + class SourceProviderCache { + public: + struct Item {}; + + SourceProviderCache() : m_contentByteSize(0) {} + ~SourceProviderCache() { deleteAllValues(m_map); } + + unsigned byteSize() const { return m_contentByteSize + sizeof(*this) + m_map.capacity() * sizeof(Item*); } + void add(int sourcePosition, PassOwnPtr<Item> item, unsigned size) { m_map.add(sourcePosition, item.leakPtr()); m_contentByteSize += size; } + const Item* get(int sourcePosition) const { return m_map.get(sourcePosition); } + + private: + HashMap<int, Item*> m_map; + unsigned m_contentByteSize; + }; + class SourceProvider : public RefCounted<SourceProvider> { public: - SourceProvider(const UString& url) + SourceProvider(const UString& url, SourceProviderCache* cache = 0) : m_url(url) , m_validated(false) + , m_cache(cache ? cache : new SourceProviderCache) + , m_cacheOwned(!cache) + { + } + virtual ~SourceProvider() { + if (m_cacheOwned) + delete m_cache; } - virtual ~SourceProvider() { } virtual UString getRange(int start, int end) const = 0; virtual const UChar* data() const = 0; virtual int length() const = 0; const UString& url() { return m_url; } + virtual TextPosition1 startPosition() const { return TextPosition1::minimumPosition(); } intptr_t asID() { return reinterpret_cast<intptr_t>(this); } bool isValid() const { return m_validated; } void setValid() { m_validated = true; } + SourceProviderCache* cache() const { return m_cache; } + void notifyCacheSizeChanged(int delta) { if (!m_cacheOwned) cacheSizeChanged(delta); } + private: + virtual void cacheSizeChanged(int delta) { UNUSED_PARAM(delta); } + UString m_url; bool m_validated; + SourceProviderCache* m_cache; + bool m_cacheOwned; }; class UStringSourceProvider : public SourceProvider { diff --git a/Source/JavaScriptCore/parser/SyntaxChecker.h b/Source/JavaScriptCore/parser/SyntaxChecker.h index 1b5497a..8823566 100644 --- a/Source/JavaScriptCore/parser/SyntaxChecker.h +++ b/Source/JavaScriptCore/parser/SyntaxChecker.h @@ -112,6 +112,7 @@ public: static const bool CreatesAST = false; static const bool NeedsFreeVariableInfo = false; + static const bool CanUseFunctionCache = true; int createSourceElements() { return 1; } ExpressionType makeFunctionCallNode(int, int, int, int, int) { return CallExpr; } diff --git a/Source/JavaScriptCore/pcre/pcre_exec.cpp b/Source/JavaScriptCore/pcre/pcre_exec.cpp index 789f80a..b7018aa 100644 --- a/Source/JavaScriptCore/pcre/pcre_exec.cpp +++ b/Source/JavaScriptCore/pcre/pcre_exec.cpp @@ -112,7 +112,9 @@ struct BracketChainNode { const UChar* bracketStart; }; -struct MatchFrame : FastAllocBase { +struct MatchFrame { + WTF_MAKE_FAST_ALLOCATED; +public: ReturnLocation returnLocation; struct MatchFrame* previousFrame; diff --git a/Source/JavaScriptCore/profiler/CallIdentifier.h b/Source/JavaScriptCore/profiler/CallIdentifier.h index 76c1470..a9827c0 100644 --- a/Source/JavaScriptCore/profiler/CallIdentifier.h +++ b/Source/JavaScriptCore/profiler/CallIdentifier.h @@ -28,13 +28,14 @@ #define CallIdentifier_h #include <runtime/UString.h> -#include "FastAllocBase.h" #include <wtf/text/CString.h> #include <wtf/text/StringHash.h> namespace JSC { - struct CallIdentifier : public FastAllocBase { + struct CallIdentifier { + WTF_MAKE_FAST_ALLOCATED; + public: UString m_name; UString m_url; unsigned m_lineNumber; diff --git a/Source/JavaScriptCore/profiler/Profiler.h b/Source/JavaScriptCore/profiler/Profiler.h index f9c2ccb..f88746d 100644 --- a/Source/JavaScriptCore/profiler/Profiler.h +++ b/Source/JavaScriptCore/profiler/Profiler.h @@ -44,7 +44,8 @@ namespace JSC { class UString; struct CallIdentifier; - class Profiler : public FastAllocBase { + class Profiler { + WTF_MAKE_FAST_ALLOCATED; public: static Profiler** enabledProfilerReference() { diff --git a/Source/JavaScriptCore/runtime/ArgList.h b/Source/JavaScriptCore/runtime/ArgList.h index cd563a2..57e3c20 100644 --- a/Source/JavaScriptCore/runtime/ArgList.h +++ b/Source/JavaScriptCore/runtime/ArgList.h @@ -25,14 +25,14 @@ #include "CallFrame.h" #include "Register.h" #include <wtf/HashSet.h> -#include <wtf/Noncopyable.h> #include <wtf/Vector.h> namespace JSC { class MarkStack; - class MarkedArgumentBuffer : public Noncopyable { + class MarkedArgumentBuffer { + WTF_MAKE_NONCOPYABLE(MarkedArgumentBuffer); private: static const unsigned inlineCapacity = 8; typedef Vector<Register, inlineCapacity> VectorType; diff --git a/Source/JavaScriptCore/runtime/Arguments.h b/Source/JavaScriptCore/runtime/Arguments.h index 715a2ac..fe900a2 100644 --- a/Source/JavaScriptCore/runtime/Arguments.h +++ b/Source/JavaScriptCore/runtime/Arguments.h @@ -33,7 +33,10 @@ namespace JSC { - struct ArgumentsData : Noncopyable { + struct ArgumentsData { + WTF_MAKE_NONCOPYABLE(ArgumentsData); WTF_MAKE_FAST_ALLOCATED; + public: + ArgumentsData() { } JSActivation* activation; unsigned numParameters; diff --git a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp index ab0c3d4..7615ffc 100644 --- a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp +++ b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved. * Copyright (C) 2003 Peter Kelly (pmk@post.com) * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) * @@ -32,6 +32,7 @@ #include "Lookup.h" #include "ObjectPrototype.h" #include "Operations.h" +#include "StringRecursionChecker.h" #include <algorithm> #include <wtf/Assertions.h> #include <wtf/HashSet.h> @@ -168,15 +169,9 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec) return throwVMTypeError(exec); JSArray* thisObj = asArray(thisValue); - HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; - if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { - if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) - return throwVMError(exec, createStackOverflowError(exec)); - } - - bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; - if (alreadyVisited) - return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoiding infinite recursion. + StringRecursionChecker checker(exec, thisObj); + if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) + return earlyReturnValue; unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); unsigned totalSize = length ? length - 1 : 0; @@ -209,7 +204,6 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec) if (exec->hadException()) break; } - arrayVisitedElements.remove(thisObj); if (!totalSize) return JSValue::encode(jsEmptyString(exec)); Vector<UChar> buffer; @@ -234,15 +228,9 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec) return throwVMTypeError(exec); JSObject* thisObj = asArray(thisValue); - HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; - if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { - if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) - return throwVMError(exec, createStackOverflowError(exec)); - } - - bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; - if (alreadyVisited) - return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion. + StringRecursionChecker checker(exec, thisObj); + if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) + return earlyReturnValue; JSStringBuilder strBuffer; unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); @@ -264,7 +252,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec) strBuffer.append(str); } } - arrayVisitedElements.remove(thisObj); + return JSValue::encode(strBuffer.build(exec)); } @@ -272,15 +260,9 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec) { JSObject* thisObj = exec->hostThisValue().toThisObject(exec); - HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; - if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { - if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) - return throwVMError(exec, createStackOverflowError(exec)); - } - - bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; - if (alreadyVisited) - return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion. + StringRecursionChecker checker(exec, thisObj); + if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) + return earlyReturnValue; JSStringBuilder strBuffer; @@ -335,7 +317,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec) if (!element.isUndefinedOrNull()) strBuffer.append(element.toString(exec)); } - arrayVisitedElements.remove(thisObj); + return JSValue::encode(strBuffer.build(exec)); } diff --git a/Source/JavaScriptCore/runtime/BatchedTransitionOptimizer.h b/Source/JavaScriptCore/runtime/BatchedTransitionOptimizer.h index 74089a5..db2d1d7 100644 --- a/Source/JavaScriptCore/runtime/BatchedTransitionOptimizer.h +++ b/Source/JavaScriptCore/runtime/BatchedTransitionOptimizer.h @@ -27,12 +27,12 @@ #ifndef BatchedTransitionOptimizer_h #define BatchedTransitionOptimizer_h -#include <wtf/Noncopyable.h> #include "JSObject.h" namespace JSC { - class BatchedTransitionOptimizer : public Noncopyable { + class BatchedTransitionOptimizer { + WTF_MAKE_NONCOPYABLE(BatchedTransitionOptimizer); public: BatchedTransitionOptimizer(JSObject* object) : m_object(object) diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.h b/Source/JavaScriptCore/runtime/CommonIdentifiers.h index 1e22b6a..6587a8f 100644 --- a/Source/JavaScriptCore/runtime/CommonIdentifiers.h +++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.h @@ -84,7 +84,8 @@ namespace JSC { - class CommonIdentifiers : public Noncopyable { + class CommonIdentifiers { + WTF_MAKE_NONCOPYABLE(CommonIdentifiers); WTF_MAKE_FAST_ALLOCATED; private: CommonIdentifiers(JSGlobalData*); friend class JSGlobalData; diff --git a/Source/JavaScriptCore/runtime/ErrorPrototype.cpp b/Source/JavaScriptCore/runtime/ErrorPrototype.cpp index d18e7d8..d8fc829 100644 --- a/Source/JavaScriptCore/runtime/ErrorPrototype.cpp +++ b/Source/JavaScriptCore/runtime/ErrorPrototype.cpp @@ -26,6 +26,7 @@ #include "JSStringBuilder.h" #include "ObjectPrototype.h" #include "PrototypeFunction.h" +#include "StringRecursionChecker.h" #include "UString.h" namespace JSC { @@ -47,6 +48,11 @@ ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, No EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec) { JSObject* thisObj = exec->hostThisValue().toThisObject(exec); + + StringRecursionChecker checker(exec, thisObj); + if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) + return earlyReturnValue; + JSValue name = thisObj->get(exec, exec->propertyNames().name); JSValue message = thisObj->get(exec, exec->propertyNames().message); diff --git a/Source/JavaScriptCore/runtime/Heap.cpp b/Source/JavaScriptCore/runtime/Heap.cpp index a224ee0..3966324 100644 --- a/Source/JavaScriptCore/runtime/Heap.cpp +++ b/Source/JavaScriptCore/runtime/Heap.cpp @@ -41,7 +41,8 @@ Heap::Heap(JSGlobalData* globalData) , m_markListSet(0) , m_activityCallback(DefaultGCActivityCallback::create(this)) , m_globalData(globalData) - , m_machineStackMarker(&globalData->heap) + , m_machineStackMarker(this) + , m_markStack(globalData->jsArrayVPtr) , m_extraCost(0) { (*m_activityCallback)(); @@ -93,12 +94,6 @@ void Heap::recordExtraCost(size_t cost) if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.size() / 2) { JAVASCRIPTCORE_GC_BEGIN(); - // If the last iteration through the heap deallocated blocks, we need - // to clean up remaining garbage before marking. Otherwise, the conservative - // marking mechanism might follow a pointer to unmapped memory. - if (m_markedSpace.didShrink()) - m_markedSpace.sweep(); - markRoots(); JAVASCRIPTCORE_GC_MARKED(); @@ -152,9 +147,9 @@ void* Heap::allocate(size_t s) return result; } -void Heap::markConservatively(MarkStack& markStack, void* start, void* end) +void Heap::markConservatively(ConservativeSet& conservativeSet, void* start, void* end) { - m_markedSpace.markConservatively(markStack, start, end); + m_markedSpace.markConservatively(conservativeSet, start, end); } void Heap::updateWeakGCHandles() @@ -212,10 +207,8 @@ bool Heap::unprotect(JSValue k) void Heap::markProtectedObjects(MarkStack& markStack) { ProtectCountSet::iterator end = m_protectedValues.end(); - for (ProtectCountSet::iterator it = m_protectedValues.begin(); it != end; ++it) { + for (ProtectCountSet::iterator it = m_protectedValues.begin(); it != end; ++it) markStack.append(it->first); - markStack.drain(); - } } void Heap::pushTempSortVector(Vector<ValueStringPair>* tempVector) @@ -238,10 +231,10 @@ void Heap::markTempSortVectors(MarkStack& markStack) Vector<ValueStringPair>* tempSortingVector = *it; Vector<ValueStringPair>::iterator vectorEnd = tempSortingVector->end(); - for (Vector<ValueStringPair>::iterator vectorIt = tempSortingVector->begin(); vectorIt != vectorEnd; ++vectorIt) + for (Vector<ValueStringPair>::iterator vectorIt = tempSortingVector->begin(); vectorIt != vectorEnd; ++vectorIt) { if (vectorIt->first) markStack.append(vectorIt->first); - markStack.drain(); + } } } @@ -260,20 +253,27 @@ void Heap::markRoots() m_operationInProgress = Collection; - MarkStack& markStack = m_globalData->markStack; + // We gather the conservative set before clearing mark bits, because + // conservative gathering uses the mark bits from our last mark pass to + // determine whether a reference is valid. + ConservativeSet conservativeSet; + m_machineStackMarker.markMachineStackConservatively(conservativeSet); + m_globalData->interpreter->registerFile().markCallFrames(conservativeSet, this); // Reset mark bits. m_markedSpace.clearMarkBits(); - // Mark stack roots. - m_machineStackMarker.markMachineStackConservatively(markStack); - m_globalData->interpreter->registerFile().markCallFrames(markStack, this); + MarkStack& markStack = m_markStack; + conservativeSet.mark(markStack); + markStack.drain(); // Mark explicitly registered roots. markProtectedObjects(markStack); + markStack.drain(); // Mark temporary vector for Array sorting markTempSortVectors(markStack); + markStack.drain(); // Mark misc. other roots. if (m_markListSet && m_markListSet->size()) @@ -282,6 +282,7 @@ void Heap::markRoots() markStack.append(m_globalData->exception); if (m_globalData->firstStringifierToMark) JSONObject::markStringifiers(markStack, m_globalData->firstStringifierToMark); + markStack.drain(); // Mark the small strings cache last, since it will clear itself if nothing // else has marked it. @@ -392,12 +393,6 @@ void Heap::collectAllGarbage() ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable()); JAVASCRIPTCORE_GC_BEGIN(); - // If the last iteration through the heap deallocated blocks, we need - // to clean up remaining garbage before marking. Otherwise, the conservative - // marking mechanism might follow a pointer to unmapped memory. - if (m_markedSpace.didShrink()) - m_markedSpace.sweep(); - markRoots(); JAVASCRIPTCORE_GC_MARKED(); diff --git a/Source/JavaScriptCore/runtime/Heap.h b/Source/JavaScriptCore/runtime/Heap.h index 243bba3..f7f4deb 100644 --- a/Source/JavaScriptCore/runtime/Heap.h +++ b/Source/JavaScriptCore/runtime/Heap.h @@ -22,6 +22,7 @@ #ifndef Heap_h #define Heap_h +#include "MarkStack.h" #include "MarkedSpace.h" #include <wtf/Forward.h> #include <wtf/HashSet.h> @@ -45,7 +46,8 @@ namespace JSC { enum OperationInProgress { NoOperation, Allocation, Collection }; - class Heap : public Noncopyable { + class Heap { + WTF_MAKE_NONCOPYABLE(Heap); public: void destroy(); @@ -86,7 +88,7 @@ namespace JSC { WeakGCHandle* addWeakGCHandle(JSCell*); - void markConservatively(MarkStack&, void* start, void* end); + void markConservatively(ConservativeSet&, void* start, void* end); void pushTempSortVector(WTF::Vector<ValueStringPair>*); void popTempSortVector(WTF::Vector<ValueStringPair>*); @@ -130,6 +132,7 @@ namespace JSC { JSGlobalData* m_globalData; MachineStackMarker m_machineStackMarker; + MarkStack m_markStack; size_t m_extraCost; }; diff --git a/Source/JavaScriptCore/runtime/JSActivation.cpp b/Source/JavaScriptCore/runtime/JSActivation.cpp index 1147858..428403d 100644 --- a/Source/JavaScriptCore/runtime/JSActivation.cpp +++ b/Source/JavaScriptCore/runtime/JSActivation.cpp @@ -53,6 +53,7 @@ void JSActivation::markChildren(MarkStack& markStack) { Base::markChildren(markStack); + // No need to mark our registers if they're still in the RegisterFile. Register* registerArray = d()->registerArray.get(); if (!registerArray) return; @@ -202,14 +203,16 @@ JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, const Identi JSActivation* activation = asActivation(slotBase); CallFrame* callFrame = CallFrame::create(activation->d()->registers); int argumentsRegister = activation->d()->functionExecutable->generatedBytecode().argumentsRegister(); - if (!callFrame->uncheckedR(argumentsRegister).jsValue()) { - JSValue arguments = JSValue(new (callFrame) Arguments(callFrame)); - callFrame->uncheckedR(argumentsRegister) = arguments; - callFrame->uncheckedR(unmodifiedArgumentsRegister(argumentsRegister)) = arguments; - } + if (JSValue arguments = callFrame->uncheckedR(argumentsRegister).jsValue()) + return arguments; + int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister); - ASSERT(callFrame->uncheckedR(argumentsRegister).jsValue().inherits(&Arguments::info)); - return callFrame->uncheckedR(argumentsRegister).jsValue(); + JSValue arguments = JSValue(new (callFrame) Arguments(callFrame)); + callFrame->uncheckedR(argumentsRegister) = arguments; + callFrame->uncheckedR(realArgumentsRegister) = arguments; + + ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(&Arguments::info)); + return callFrame->uncheckedR(realArgumentsRegister).jsValue(); } // These two functions serve the purpose of isolating the common case from a diff --git a/Source/JavaScriptCore/runtime/JSGlobalData.cpp b/Source/JavaScriptCore/runtime/JSGlobalData.cpp index f20a9a4..3928c82 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalData.cpp +++ b/Source/JavaScriptCore/runtime/JSGlobalData.cpp @@ -143,7 +143,6 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread , head(0) , dynamicGlobalObject(0) , firstStringifierToMark(0) - , markStack(jsArrayVPtr) , cachedUTCOffset(NaN) , maxReentryDepth(threadStackType == ThreadStackTypeSmall ? MaxSmallThreadReentryDepth : MaxLargeThreadReentryDepth) , m_regExpCache(new RegExpCache(this)) diff --git a/Source/JavaScriptCore/runtime/JSGlobalData.h b/Source/JavaScriptCore/runtime/JSGlobalData.h index a24732a..31f41e9 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalData.h +++ b/Source/JavaScriptCore/runtime/JSGlobalData.h @@ -35,7 +35,6 @@ #include "ExecutableAllocator.h" #include "JITStubs.h" #include "JSValue.h" -#include "MarkStack.h" #include "NumericStrings.h" #include "SmallStrings.h" #include "Terminator.h" @@ -214,12 +213,10 @@ namespace JSC { JSGlobalObject* head; JSGlobalObject* dynamicGlobalObject; - HashSet<JSObject*> arrayVisitedElements; + HashSet<JSObject*> stringRecursionCheckVisitedObjects; Stringifier* firstStringifierToMark; - MarkStack markStack; - double cachedUTCOffset; DSTOffsetCache dstOffsetCache; diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp index 408aea7..9b67dbb 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -349,10 +349,6 @@ void JSGlobalObject::markChildren(MarkStack& markStack) for (HashSet<GlobalCodeBlock*>::const_iterator it = codeBlocks().begin(); it != end; ++it) (*it)->markAggregate(markStack); - RegisterFile& registerFile = globalData().interpreter->registerFile(); - if (registerFile.globalObject() == this) - registerFile.markGlobals(markStack, &globalData().heap); - markIfNeeded(markStack, d()->regExpConstructor); markIfNeeded(markStack, d()->errorConstructor); markIfNeeded(markStack, d()->evalErrorConstructor); @@ -397,12 +393,16 @@ void JSGlobalObject::markChildren(MarkStack& markStack) // No need to mark the other structures, because their prototypes are all // guaranteed to be referenced elsewhere. - Register* registerArray = d()->registerArray.get(); - if (!registerArray) - return; - - size_t size = d()->registerArraySize; - markStack.appendValues(reinterpret_cast<JSValue*>(registerArray), size); + if (d()->registerArray) { + // Outside the execution of global code, when our variables are torn off, + // we can mark the torn-off array. + markStack.appendValues(d()->registerArray.get(), d()->registerArraySize); + } else if (d()->registers) { + // During execution of global code, when our variables are in the register file, + // the symbol table tells us how many variables there are, and registers + // points to where they end, and the registers used for execution begin. + markStack.appendValues(d()->registers - symbolTable().size(), symbolTable().size()); + } } ExecState* JSGlobalObject::globalExec() diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h index a22b0aa..24bc2f8 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalObject.h +++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h @@ -465,7 +465,8 @@ namespace JSC { return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values); } - class DynamicGlobalObjectScope : public Noncopyable { + class DynamicGlobalObjectScope { + WTF_MAKE_NONCOPYABLE(DynamicGlobalObjectScope); public: DynamicGlobalObjectScope(CallFrame* callFrame, JSGlobalObject* dynamicGlobalObject); diff --git a/Source/JavaScriptCore/runtime/JSLock.h b/Source/JavaScriptCore/runtime/JSLock.h index 05b388c..7b07b4f 100644 --- a/Source/JavaScriptCore/runtime/JSLock.h +++ b/Source/JavaScriptCore/runtime/JSLock.h @@ -53,7 +53,8 @@ namespace JSC { enum JSLockBehavior { SilenceAssertionsOnly, LockForReal }; - class JSLock : public Noncopyable { + class JSLock { + WTF_MAKE_NONCOPYABLE(JSLock); public: JSLock(ExecState*); JSLock(JSGlobalData*); @@ -89,7 +90,8 @@ namespace JSC { JSLockBehavior m_lockBehavior; - class DropAllLocks : public Noncopyable { + class DropAllLocks { + WTF_MAKE_NONCOPYABLE(DropAllLocks); public: DropAllLocks(ExecState* exec); DropAllLocks(JSLockBehavior); diff --git a/Source/JavaScriptCore/runtime/JSONObject.cpp b/Source/JavaScriptCore/runtime/JSONObject.cpp index 9e63027..df4be52 100644 --- a/Source/JavaScriptCore/runtime/JSONObject.cpp +++ b/Source/JavaScriptCore/runtime/JSONObject.cpp @@ -70,7 +70,8 @@ private: mutable JSValue m_value; }; -class Stringifier : public Noncopyable { +class Stringifier { + WTF_MAKE_NONCOPYABLE(Stringifier); public: Stringifier(ExecState*, JSValue replacer, JSValue space); ~Stringifier(); diff --git a/Source/JavaScriptCore/runtime/Lookup.h b/Source/JavaScriptCore/runtime/Lookup.h index 9bc81d4..0d6d98f 100644 --- a/Source/JavaScriptCore/runtime/Lookup.h +++ b/Source/JavaScriptCore/runtime/Lookup.h @@ -53,7 +53,8 @@ namespace JSC { typedef PropertySlot::GetValueFunc GetFunction; typedef void (*PutFunction)(ExecState*, JSObject* baseObject, JSValue value); - class HashEntry : public FastAllocBase { + class HashEntry { + WTF_MAKE_FAST_ALLOCATED; public: void initialize(StringImpl* key, unsigned char attributes, intptr_t v1, intptr_t v2 #if ENABLE(JIT) diff --git a/Source/JavaScriptCore/runtime/MachineStackMarker.cpp b/Source/JavaScriptCore/runtime/MachineStackMarker.cpp index b4a1936..e52f402 100644 --- a/Source/JavaScriptCore/runtime/MachineStackMarker.cpp +++ b/Source/JavaScriptCore/runtime/MachineStackMarker.cpp @@ -194,10 +194,9 @@ void MachineStackMarker::unregisterThread() #endif -void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(MarkStack& markStack) +void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(ConservativeSet& conservativeSet) { - m_heap->markConservatively(markStack, m_heap->globalData()->stack().current(), m_heap->globalData()->stack().origin()); - markStack.drain(); + m_heap->markConservatively(conservativeSet, m_heap->globalData()->stack().current(), m_heap->globalData()->stack().origin()); } #if COMPILER(GCC) @@ -206,7 +205,7 @@ void NEVER_INLINE MachineStackMarker::markCurrentThreadConservativelyInternal(Ma #define REGISTER_BUFFER_ALIGNMENT #endif -void MachineStackMarker::markCurrentThreadConservatively(MarkStack& markStack) +void MachineStackMarker::markCurrentThreadConservatively(ConservativeSet& conservativeSet) { // setjmp forces volatile registers onto the stack jmp_buf registers REGISTER_BUFFER_ALIGNMENT; @@ -219,7 +218,7 @@ void MachineStackMarker::markCurrentThreadConservatively(MarkStack& markStack) #pragma warning(pop) #endif - markCurrentThreadConservativelyInternal(markStack); + markCurrentThreadConservativelyInternal(conservativeSet); } #if ENABLE(JSC_MULTIPLE_THREADS) @@ -351,7 +350,7 @@ static inline void* otherThreadStackPointer(const PlatformThreadRegisters& regs) #endif } -void MachineStackMarker::markOtherThreadConservatively(MarkStack& markStack, Thread* thread) +void MachineStackMarker::markOtherThreadConservatively(ConservativeSet& conservativeSet, Thread* thread) { suspendThread(thread->platformThread); @@ -359,21 +358,19 @@ void MachineStackMarker::markOtherThreadConservatively(MarkStack& markStack, Thr size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs); // mark the thread's registers - m_heap->markConservatively(markStack, static_cast<void*>(®s), static_cast<void*>(reinterpret_cast<char*>(®s) + regSize)); - markStack.drain(); + m_heap->markConservatively(conservativeSet, static_cast<void*>(®s), static_cast<void*>(reinterpret_cast<char*>(®s) + regSize)); void* stackPointer = otherThreadStackPointer(regs); - m_heap->markConservatively(markStack, stackPointer, thread->stackBase); - markStack.drain(); + m_heap->markConservatively(conservativeSet, stackPointer, thread->stackBase); resumeThread(thread->platformThread); } #endif -void MachineStackMarker::markMachineStackConservatively(MarkStack& markStack) +void MachineStackMarker::markMachineStackConservatively(ConservativeSet& conservativeSet) { - markCurrentThreadConservatively(markStack); + markCurrentThreadConservatively(conservativeSet); #if ENABLE(JSC_MULTIPLE_THREADS) @@ -391,7 +388,7 @@ void MachineStackMarker::markMachineStackConservatively(MarkStack& markStack) // and since this is a shared heap, they are real locks. for (Thread* thread = m_registeredThreads; thread; thread = thread->next) { if (!pthread_equal(thread->posixThread, pthread_self())) - markOtherThreadConservatively(markStack, thread); + markOtherThreadConservatively(conservativeSet, thread); } #ifndef NDEBUG fastMallocAllow(); diff --git a/Source/JavaScriptCore/runtime/MachineStackMarker.h b/Source/JavaScriptCore/runtime/MachineStackMarker.h index e80fe05..8afdb46 100644 --- a/Source/JavaScriptCore/runtime/MachineStackMarker.h +++ b/Source/JavaScriptCore/runtime/MachineStackMarker.h @@ -32,14 +32,15 @@ namespace JSC { class Heap; - class MarkStack; + class ConservativeSet; - class MachineStackMarker : public Noncopyable { + class MachineStackMarker { + WTF_MAKE_NONCOPYABLE(MachineStackMarker); public: MachineStackMarker(Heap*); ~MachineStackMarker(); - void markMachineStackConservatively(MarkStack&); + void markMachineStackConservatively(ConservativeSet&); #if ENABLE(JSC_MULTIPLE_THREADS) void makeUsableFromMultipleThreads(); @@ -47,8 +48,8 @@ namespace JSC { #endif private: - void markCurrentThreadConservatively(MarkStack&); - void markCurrentThreadConservativelyInternal(MarkStack&); + void markCurrentThreadConservatively(ConservativeSet&); + void markCurrentThreadConservativelyInternal(ConservativeSet&); #if ENABLE(JSC_MULTIPLE_THREADS) class Thread; @@ -56,7 +57,7 @@ namespace JSC { static void unregisterThread(void*); void unregisterThread(); - void markOtherThreadConservatively(MarkStack&, Thread*); + void markOtherThreadConservatively(ConservativeSet&, Thread*); #endif Heap* m_heap; diff --git a/Source/JavaScriptCore/runtime/MarkStack.h b/Source/JavaScriptCore/runtime/MarkStack.h index 7bccadf..7946e65 100644 --- a/Source/JavaScriptCore/runtime/MarkStack.h +++ b/Source/JavaScriptCore/runtime/MarkStack.h @@ -27,6 +27,7 @@ #define MarkStack_h #include "JSValue.h" +#include <wtf/HashSet.h> #include <wtf/Noncopyable.h> #include <wtf/OSAllocator.h> @@ -37,7 +38,8 @@ namespace JSC { enum MarkSetProperties { MayContainNullValues, NoNullValues }; - class MarkStack : Noncopyable { + class MarkStack { + WTF_MAKE_NONCOPYABLE(MarkStack); public: MarkStack(void* jsArrayVPtr) : m_jsArrayVPtr(jsArrayVPtr) @@ -185,6 +187,20 @@ namespace JSC { bool m_isDraining; #endif }; + + class ConservativeSet { + public: + void add(JSCell* cell) { m_set.add(cell); } + void mark(MarkStack& markStack) + { + HashSet<JSCell*>::iterator end = m_set.end(); + for (HashSet<JSCell*>::iterator it = m_set.begin(); it != end; ++it) + markStack.append(*it); + } + + private: + HashSet<JSCell*> m_set; + }; } #endif diff --git a/Source/JavaScriptCore/runtime/MarkedSpace.cpp b/Source/JavaScriptCore/runtime/MarkedSpace.cpp index 4bc3c18..036c8f0 100644 --- a/Source/JavaScriptCore/runtime/MarkedSpace.cpp +++ b/Source/JavaScriptCore/runtime/MarkedSpace.cpp @@ -108,8 +108,6 @@ NEVER_INLINE CollectorBlock* MarkedSpace::allocateBlock() NEVER_INLINE void MarkedSpace::freeBlock(size_t block) { - m_heap.didShrink = true; - ObjectIterator it(m_heap, block); ObjectIterator end(m_heap, block + 1); for ( ; it != end; ++it) @@ -162,8 +160,6 @@ void* MarkedSpace::allocate(size_t s) void MarkedSpace::resizeBlocks() { - m_heap.didShrink = false; - size_t usedCellCount = markedCells(); size_t minCellCount = usedCellCount + max(ALLOCATIONS_PER_COLLECTION, usedCellCount); size_t minBlockCount = (minCellCount + HeapConstants::cellsPerBlock - 1) / HeapConstants::cellsPerBlock; @@ -222,7 +218,7 @@ static inline bool isPossibleCell(void* p) return isCellAligned(p) && p; } -void MarkedSpace::markConservatively(MarkStack& markStack, void* start, void* end) +void MarkedSpace::markConservatively(ConservativeSet& conservativeSet, void* start, void* end) { #if OS(WINCE) if (start > end) { @@ -244,7 +240,6 @@ void MarkedSpace::markConservatively(MarkStack& markStack, void* start, void* en while (p != e) { char* x = *p++; if (isPossibleCell(x)) { - size_t usedBlocks; uintptr_t xAsBits = reinterpret_cast<uintptr_t>(x); xAsBits &= CELL_ALIGN_MASK; @@ -254,11 +249,30 @@ void MarkedSpace::markConservatively(MarkStack& markStack, void* start, void* en continue; CollectorBlock* blockAddr = reinterpret_cast<CollectorBlock*>(xAsBits - offset); - usedBlocks = m_heap.usedBlocks; + size_t usedBlocks = m_heap.usedBlocks; for (size_t block = 0; block < usedBlocks; block++) { if (m_heap.collectorBlock(block) != blockAddr) continue; - markStack.append(reinterpret_cast<JSCell*>(xAsBits)); + + // x is a pointer into the heap. Now, verify that the cell it + // points to is live. (If the cell is dead, we must not mark it, + // since that would revive it in a zombie state.) + if (block < m_heap.nextBlock) { + conservativeSet.add(reinterpret_cast<JSCell*>(xAsBits)); + break; + } + + size_t cellOffset = offset / CELL_SIZE; + + if (block == m_heap.nextBlock && cellOffset < m_heap.nextCell) { + conservativeSet.add(reinterpret_cast<JSCell*>(xAsBits)); + break; + } + + if (blockAddr->marked.get(cellOffset)) { + conservativeSet.add(reinterpret_cast<JSCell*>(xAsBits)); + break; + } } } } diff --git a/Source/JavaScriptCore/runtime/MarkedSpace.h b/Source/JavaScriptCore/runtime/MarkedSpace.h index 78f918c..af312b5 100644 --- a/Source/JavaScriptCore/runtime/MarkedSpace.h +++ b/Source/JavaScriptCore/runtime/MarkedSpace.h @@ -55,15 +55,14 @@ namespace JSC { size_t numBlocks; size_t usedBlocks; - bool didShrink; - CollectorBlock* collectorBlock(size_t index) const { return static_cast<CollectorBlock*>(blocks[index].base()); } }; - class MarkedSpace : public Noncopyable { + class MarkedSpace { + WTF_MAKE_NONCOPYABLE(MarkedSpace); public: MarkedSpace(JSGlobalData*); void destroy(ProtectCountSet&); @@ -86,7 +85,7 @@ namespace JSC { WeakGCHandle* addWeakGCHandle(JSCell*); - void markConservatively(MarkStack&, void* start, void* end); + void markConservatively(ConservativeSet&, void* start, void* end); static bool isNumber(JSCell*); @@ -114,8 +113,6 @@ namespace JSC { void markRoots(); - bool didShrink() { return m_heap.didShrink; } - private: CollectorHeap m_heap; JSGlobalData* m_globalData; diff --git a/Source/JavaScriptCore/runtime/RegExpConstructor.h b/Source/JavaScriptCore/runtime/RegExpConstructor.h index 58abde5..1714bd3 100644 --- a/Source/JavaScriptCore/runtime/RegExpConstructor.h +++ b/Source/JavaScriptCore/runtime/RegExpConstructor.h @@ -31,7 +31,9 @@ namespace JSC { class RegExpPrototype; struct RegExpConstructorPrivate; - struct RegExpConstructorPrivate : FastAllocBase { + struct RegExpConstructorPrivate { + WTF_MAKE_FAST_ALLOCATED; + public: // Global search cache / settings RegExpConstructorPrivate() : lastNumSubPatterns(0) diff --git a/Source/JavaScriptCore/runtime/RegExpObject.cpp b/Source/JavaScriptCore/runtime/RegExpObject.cpp index 7fda5b1..b969e38 100644 --- a/Source/JavaScriptCore/runtime/RegExpObject.cpp +++ b/Source/JavaScriptCore/runtime/RegExpObject.cpp @@ -128,17 +128,6 @@ JSValue RegExpObject::exec(ExecState* exec) return jsNull(); } -static EncodedJSValue JSC_HOST_CALL callRegExpObject(ExecState* exec) -{ - return JSValue::encode(asRegExpObject(exec->callee())->exec(exec)); -} - -CallType RegExpObject::getCallData(CallData& callData) -{ - callData.native.function = callRegExpObject; - return CallTypeHost; -} - // Shared implementation used by test and exec. bool RegExpObject::match(ExecState* exec) { diff --git a/Source/JavaScriptCore/runtime/RegExpObject.h b/Source/JavaScriptCore/runtime/RegExpObject.h index 19de929..99c84da 100644 --- a/Source/JavaScriptCore/runtime/RegExpObject.h +++ b/Source/JavaScriptCore/runtime/RegExpObject.h @@ -58,9 +58,9 @@ namespace JSC { private: bool match(ExecState*); - virtual CallType getCallData(CallData&); - - struct RegExpObjectData : FastAllocBase { + struct RegExpObjectData { + WTF_MAKE_FAST_ALLOCATED; + public: RegExpObjectData(NonNullPassRefPtr<RegExp> regExp, double lastIndex) : regExp(regExp) , lastIndex(lastIndex) @@ -70,7 +70,9 @@ namespace JSC { RefPtr<RegExp> regExp; double lastIndex; }; - +#if PLATFORM(WIN) + friend void WTF::deleteOwnedPtr<RegExpObjectData>(RegExpObjectData*); +#endif OwnPtr<RegExpObjectData> d; }; diff --git a/Source/JavaScriptCore/runtime/RegExpPrototype.cpp b/Source/JavaScriptCore/runtime/RegExpPrototype.cpp index 04bcc3b..a7c447d 100644 --- a/Source/JavaScriptCore/runtime/RegExpPrototype.cpp +++ b/Source/JavaScriptCore/runtime/RegExpPrototype.cpp @@ -34,6 +34,7 @@ #include "RegExpObject.h" #include "RegExp.h" #include "RegExpCache.h" +#include "StringRecursionChecker.h" #include "UStringConcatenate.h" namespace JSC { @@ -111,15 +112,21 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec) return throwVMTypeError(exec); } + RegExpObject* thisObject = asRegExpObject(thisValue); + + StringRecursionChecker checker(exec, thisObject); + if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) + return earlyReturnValue; + char postfix[5] = { '/', 0, 0, 0, 0 }; int index = 1; - if (asRegExpObject(thisValue)->get(exec, exec->propertyNames().global).toBoolean(exec)) + if (thisObject->get(exec, exec->propertyNames().global).toBoolean(exec)) postfix[index++] = 'g'; - if (asRegExpObject(thisValue)->get(exec, exec->propertyNames().ignoreCase).toBoolean(exec)) + if (thisObject->get(exec, exec->propertyNames().ignoreCase).toBoolean(exec)) postfix[index++] = 'i'; - if (asRegExpObject(thisValue)->get(exec, exec->propertyNames().multiline).toBoolean(exec)) + if (thisObject->get(exec, exec->propertyNames().multiline).toBoolean(exec)) postfix[index] = 'm'; - UString source = asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec); + UString source = thisObject->get(exec, exec->propertyNames().source).toString(exec); // If source is empty, use "/(?:)/" to avoid colliding with comment syntax return JSValue::encode(jsMakeNontrivialString(exec, "/", source.length() ? source : UString("(?:)"), postfix)); } diff --git a/Source/JavaScriptCore/runtime/ScopeChain.h b/Source/JavaScriptCore/runtime/ScopeChain.h index 0b15b67..b104e75 100644 --- a/Source/JavaScriptCore/runtime/ScopeChain.h +++ b/Source/JavaScriptCore/runtime/ScopeChain.h @@ -21,7 +21,7 @@ #ifndef ScopeChain_h #define ScopeChain_h -#include "FastAllocBase.h" +#include <wtf/FastAllocBase.h> namespace JSC { @@ -31,7 +31,8 @@ namespace JSC { class MarkStack; class ScopeChainIterator; - class ScopeChainNode : public FastAllocBase { + class ScopeChainNode { + WTF_MAKE_FAST_ALLOCATED; public: ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis) : next(next) diff --git a/Source/JavaScriptCore/runtime/SmallStrings.cpp b/Source/JavaScriptCore/runtime/SmallStrings.cpp index f358727..5614932 100644 --- a/Source/JavaScriptCore/runtime/SmallStrings.cpp +++ b/Source/JavaScriptCore/runtime/SmallStrings.cpp @@ -40,7 +40,8 @@ static inline bool isMarked(JSString* string) return string && Heap::isCellMarked(string); } -class SmallStringsStorage : public Noncopyable { +class SmallStringsStorage { + WTF_MAKE_NONCOPYABLE(SmallStringsStorage); WTF_MAKE_FAST_ALLOCATED; public: SmallStringsStorage(); diff --git a/Source/JavaScriptCore/runtime/SmallStrings.h b/Source/JavaScriptCore/runtime/SmallStrings.h index d1ebfb1..ac84fe8 100644 --- a/Source/JavaScriptCore/runtime/SmallStrings.h +++ b/Source/JavaScriptCore/runtime/SmallStrings.h @@ -37,7 +37,8 @@ namespace JSC { class MarkStack; class SmallStringsStorage; - class SmallStrings : public Noncopyable { + class SmallStrings { + WTF_MAKE_NONCOPYABLE(SmallStrings); WTF_MAKE_FAST_ALLOCATED; public: SmallStrings(); ~SmallStrings(); diff --git a/Source/JavaScriptCore/runtime/StringRecursionChecker.cpp b/Source/JavaScriptCore/runtime/StringRecursionChecker.cpp new file mode 100644 index 0000000..4e74735 --- /dev/null +++ b/Source/JavaScriptCore/runtime/StringRecursionChecker.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * 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 "StringRecursionChecker.h" + +#include "Error.h" +#include "ExceptionHelpers.h" + +namespace JSC { + +EncodedJSValue StringRecursionChecker::throwStackOverflowError() +{ + return throwVMError(m_exec, createStackOverflowError(m_exec)); +} + +EncodedJSValue StringRecursionChecker::emptyString() +{ + return JSValue::encode(jsEmptyString(m_exec)); +} + +} diff --git a/Source/JavaScriptCore/runtime/StringRecursionChecker.h b/Source/JavaScriptCore/runtime/StringRecursionChecker.h new file mode 100644 index 0000000..314f14e --- /dev/null +++ b/Source/JavaScriptCore/runtime/StringRecursionChecker.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * 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 + * + */ + +#ifndef StringRecursionChecker_h +#define StringRecursionChecker_h + +#include "Interpreter.h" + +namespace JSC { + +class StringRecursionChecker { + WTF_MAKE_NONCOPYABLE(StringRecursionChecker); + +public: + StringRecursionChecker(ExecState*, JSObject* thisObject); + ~StringRecursionChecker(); + + EncodedJSValue earlyReturnValue() const; // 0 if everything is OK, value to return for failure cases + +private: + EncodedJSValue throwStackOverflowError(); + EncodedJSValue emptyString(); + EncodedJSValue performCheck(); + + ExecState* m_exec; + JSObject* m_thisObject; + EncodedJSValue m_earlyReturnValue; +}; + +inline EncodedJSValue StringRecursionChecker::performCheck() +{ + int size = m_exec->globalData().stringRecursionCheckVisitedObjects.size(); + if (size >= MaxSmallThreadReentryDepth && size >= m_exec->globalData().maxReentryDepth) + return throwStackOverflowError(); + bool alreadyVisited = !m_exec->globalData().stringRecursionCheckVisitedObjects.add(m_thisObject).second; + if (alreadyVisited) + return emptyString(); // Return empty string to avoid infinite recursion. + return 0; // Indicate success. +} + +inline StringRecursionChecker::StringRecursionChecker(ExecState* exec, JSObject* thisObject) + : m_exec(exec) + , m_thisObject(thisObject) + , m_earlyReturnValue(performCheck()) +{ +} + +inline EncodedJSValue StringRecursionChecker::earlyReturnValue() const +{ + return m_earlyReturnValue; +} + +inline StringRecursionChecker::~StringRecursionChecker() +{ + if (m_earlyReturnValue) + return; + ASSERT(m_exec->globalData().stringRecursionCheckVisitedObjects.contains(m_thisObject)); + m_exec->globalData().stringRecursionCheckVisitedObjects.remove(m_thisObject); +} + +} + +#endif diff --git a/Source/JavaScriptCore/runtime/SymbolTable.h b/Source/JavaScriptCore/runtime/SymbolTable.h index 1b1636d..2635501 100644 --- a/Source/JavaScriptCore/runtime/SymbolTable.h +++ b/Source/JavaScriptCore/runtime/SymbolTable.h @@ -122,6 +122,7 @@ namespace JSC { typedef HashMap<RefPtr<StringImpl>, SymbolTableEntry, IdentifierRepHash, HashTraits<RefPtr<StringImpl> >, SymbolTableIndexHashTraits> SymbolTable; class SharedSymbolTable : public SymbolTable, public RefCounted<SharedSymbolTable> { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<SharedSymbolTable> create() { return adoptRef(new SharedSymbolTable); } private: diff --git a/Source/JavaScriptCore/runtime/WeakGCMap.h b/Source/JavaScriptCore/runtime/WeakGCMap.h index 2d4e59d..316794f 100644 --- a/Source/JavaScriptCore/runtime/WeakGCMap.h +++ b/Source/JavaScriptCore/runtime/WeakGCMap.h @@ -35,7 +35,8 @@ class JSCell; // A HashMap whose get() function returns emptyValue() for cells awaiting destruction. template<typename KeyType, typename MappedType> -class WeakGCMap : public FastAllocBase { +class WeakGCMap { + WTF_MAKE_FAST_ALLOCATED; /* Invariants: * A value enters the WeakGCMap marked. (Guaranteed by set().) diff --git a/Source/JavaScriptCore/runtime/WeakGCPtr.h b/Source/JavaScriptCore/runtime/WeakGCPtr.h index 6cc75a5..4946ee7 100644 --- a/Source/JavaScriptCore/runtime/WeakGCPtr.h +++ b/Source/JavaScriptCore/runtime/WeakGCPtr.h @@ -28,12 +28,12 @@ #include "Heap.h" #include "GCHandle.h" -#include <wtf/Noncopyable.h> namespace JSC { // A smart pointer whose get() function returns 0 for cells awaiting destruction. -template <typename T> class WeakGCPtr : Noncopyable { +template <typename T> class WeakGCPtr { + WTF_MAKE_NONCOPYABLE(WeakGCPtr); public: WeakGCPtr() : m_ptr(0) diff --git a/Source/JavaScriptCore/tests/mozilla/expected.html b/Source/JavaScriptCore/tests/mozilla/expected.html index 785378d..7dd958b 100644 --- a/Source/JavaScriptCore/tests/mozilla/expected.html +++ b/Source/JavaScriptCore/tests/mozilla/expected.html @@ -7,11 +7,11 @@ <p class='results_summary'> Test List: All tests<br> Skip List: ecma/Date/15.9.2.1.js, ecma/Date/15.9.2.2-1.js, ecma/Date/15.9.2.2-2.js, ecma/Date/15.9.2.2-3.js, ecma/Date/15.9.2.2-4.js, ecma/Date/15.9.2.2-5.js, ecma/Date/15.9.2.2-6.js, ecma_3/Date/15.9.5.7.js<br> -1127 test(s) selected, 1119 test(s) completed, 46 failures reported (4.11% failed)<br> -Engine command line: "/home/stampho/webkit/WebKitBuild/Release/JavaScriptCore/jsc" <br> -OS type: Linux euclides 2.6.35-gentoo-r5 #1 SMP Tue Aug 31 13:19:25 CEST 2010 i686 Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz GenuineIntel GNU/Linux<br> -Testcase execution time: 16 seconds.<br> -Tests completed on Fri Oct 15 00:29:31 2010.<br><br> +1127 test(s) selected, 1119 test(s) completed, 51 failures reported (4.55% failed)<br> +Engine command line: "/Volumes/BigData/git/WebKit/WebKitBuild/Debug/jsc" <br> +OS type: Darwin 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386<br> +Testcase execution time: 1 minutes, 3 seconds.<br> +Tests completed on Wed Jan 19 13:26:57 2011.<br><br> [ <a href='#fail_detail'>Failure Details</a> | <a href='#retest_list'>Retest List</a> | <a href='menu.html'>Test Selection Page</a> ]<br> <hr> <a name='fail_detail'></a> @@ -29,53 +29,67 @@ Failure messages were:<br> Failure messages were:<br> eval("function f(){}function g(){}") (threw no exception thrown = fail FAILED! expected: pass<br> </tt><br> -<a name='failure3'></a><dd><b>Testcase <a target='other_window' href='./ecma_3/FunExpr/fe-001.js'>ecma_3/FunExpr/fe-001.js</a> failed</b> <br> +<a name='failure3'></a><dd><b>Testcase <a target='other_window' href='./ecma_2/RegExp/regress-001.js'>ecma_2/RegExp/regress-001.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=http://bugzilla.mozilla.org/show_bug.cgi?id=2157' target='other_window'>Bug Number http://bugzilla.mozilla.org/show_bug.cgi?id=2157</a><br> [ <a href='#failure2'>Previous Failure</a> | <a href='#failure4'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<tt>Expected exit code 0, got 3<br> +Testcase terminated with signal 0<br> +Complete testcase output was:<br> +RegExp/hex-001.js JS regexp anchoring on empty match bug<br> +BUGNUMBER: http://bugzilla.mozilla.org/show_bug.cgi?id=2157<br> +</tt><br> +<a name='failure4'></a><dd><b>Testcase <a target='other_window' href='./ecma_3/FunExpr/fe-001.js'>ecma_3/FunExpr/fe-001.js</a> failed</b> <br> + [ <a href='#failure3'>Previous Failure</a> | <a href='#failure5'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>STATUS: Function Expression Statements basic test.<br> Failure messages were:<br> FAILED!: [reported from test()] Both functions were defined.<br> FAILED!: [reported from test()] Expected value '1', Actual value '0'<br> FAILED!: [reported from test()] <br> </tt><br> -<a name='failure4'></a><dd><b>Testcase <a target='other_window' href='./ecma_3/Statements/regress-194364.js'>ecma_3/Statements/regress-194364.js</a> failed</b> <br> - [ <a href='#failure3'>Previous Failure</a> | <a href='#failure5'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure5'></a><dd><b>Testcase <a target='other_window' href='./ecma_3/Statements/regress-194364.js'>ecma_3/Statements/regress-194364.js</a> failed</b> <br> + [ <a href='#failure4'>Previous Failure</a> | <a href='#failure6'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure5'></a><dd><b>Testcase <a target='other_window' href='./ecma_3/Unicode/uc-001.js'>ecma_3/Unicode/uc-001.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=23610' target='other_window'>Bug Number 23610</a><br> - [ <a href='#failure4'>Previous Failure</a> | <a href='#failure6'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure6'></a><dd><b>Testcase <a target='other_window' href='./ecma_3/Unicode/uc-001.js'>ecma_3/Unicode/uc-001.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=23610' target='other_window'>Bug Number 23610</a><br> + [ <a href='#failure5'>Previous Failure</a> | <a href='#failure7'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>STATUS: Unicode format-control character (Category Cf) test.<br> Failure messages were:<br> FAILED!: [reported from test()] Unicode format-control character test (Category Cf.)<br> FAILED!: [reported from test()] Expected value 'no error', Actual value 'no error'<br> FAILED!: [reported from test()] <br> </tt><br> -<a name='failure6'></a><dd><b>Testcase <a target='other_window' href='./js1_2/Objects/toString-001.js'>js1_2/Objects/toString-001.js</a> failed</b> <br> - [ <a href='#failure5'>Previous Failure</a> | <a href='#failure7'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> -<tt><br> -Failure messages were:<br> -var o = new Object(); o.toString() = [object Object] FAILED! expected: {}<br> -o = {}; o.toString() = [object Object] FAILED! expected: {}<br> -o = { name:"object", length:0, value:"hello" }; o.toString() = false FAILED! expected: true<br> -</tt><br> -<a name='failure7'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/Function_object.js'>js1_2/function/Function_object.js</a> failed</b> <br> +<a name='failure7'></a><dd><b>Testcase <a target='other_window' href='./js1_2/Objects/toString-001.js'>js1_2/Objects/toString-001.js</a> failed</b> <br> [ <a href='#failure6'>Previous Failure</a> | <a href='#failure8'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<tt>Expected exit code 0, got 3<br> +Testcase terminated with signal 0<br> +Complete testcase output was:<br> +JS1_2 Object.toString()<br> +</tt><br> +<a name='failure8'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/Function_object.js'>js1_2/function/Function_object.js</a> failed</b> <br> + [ <a href='#failure7'>Previous Failure</a> | <a href='#failure9'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> f.arity = undefined FAILED! expected: 3<br> } FAILED! expected: <br> </tt><br> -<a name='failure8'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/function-001-n.js'>js1_2/function/function-001-n.js</a> failed</b> <br> - [ <a href='#failure7'>Previous Failure</a> | <a href='#failure9'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure9'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/function-001-n.js'>js1_2/function/function-001-n.js</a> failed</b> <br> + [ <a href='#failure8'>Previous Failure</a> | <a href='#failure10'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 3, got 0<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> function-001.js functions not separated by semicolons are errors in version 120 and higher<br> eval("function f(){}function g(){}") = undefined FAILED! expected: error<br> </tt><br> -<a name='failure9'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/tostring-1.js'>js1_2/function/tostring-1.js</a> failed</b> <br> - [ <a href='#failure8'>Previous Failure</a> | <a href='#failure10'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure10'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/regexparg-1.js'>js1_2/function/regexparg-1.js</a> failed</b> <br> + [ <a href='#failure9'>Previous Failure</a> | <a href='#failure11'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<tt>Expected exit code 0, got 3<br> +Testcase terminated with signal 0<br> +Complete testcase output was:<br> +JS_1.2 The variable statment<br> +</tt><br> +<a name='failure11'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/tostring-1.js'>js1_2/function/tostring-1.js</a> failed</b> <br> + [ <a href='#failure10'>Previous Failure</a> | <a href='#failure12'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> } FAILED! expected: <br> @@ -84,8 +98,8 @@ Failure messages were:<br> } FAILED! expected: <br> } FAILED! expected: <br> </tt><br> -<a name='failure10'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/tostring-2.js'>js1_2/function/tostring-2.js</a> failed</b> <br> - [ <a href='#failure9'>Previous Failure</a> | <a href='#failure11'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure12'></a><dd><b>Testcase <a target='other_window' href='./js1_2/function/tostring-2.js'>js1_2/function/tostring-2.js</a> failed</b> <br> + [ <a href='#failure11'>Previous Failure</a> | <a href='#failure13'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> } FAILED! expected: <br> @@ -98,22 +112,22 @@ Failure messages were:<br> } FAILED! expected: <br> } FAILED! expected: <br> </tt><br> -<a name='failure11'></a><dd><b>Testcase <a target='other_window' href='./js1_2/operator/equality.js'>js1_2/operator/equality.js</a> failed</b> <br> - [ <a href='#failure10'>Previous Failure</a> | <a href='#failure12'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure13'></a><dd><b>Testcase <a target='other_window' href='./js1_2/operator/equality.js'>js1_2/operator/equality.js</a> failed</b> <br> + [ <a href='#failure12'>Previous Failure</a> | <a href='#failure14'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> (new String('x') == 'x') = true FAILED! expected: false<br> ('x' == new String('x')) = true FAILED! expected: false<br> </tt><br> -<a name='failure12'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/RegExp_lastIndex.js'>js1_2/regexp/RegExp_lastIndex.js</a> failed</b> <br> - [ <a href='#failure11'>Previous Failure</a> | <a href='#failure13'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure14'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/RegExp_lastIndex.js'>js1_2/regexp/RegExp_lastIndex.js</a> failed</b> <br> + [ <a href='#failure13'>Previous Failure</a> | <a href='#failure15'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> re=/x./g; re.lastIndex=4; re.exec('xyabcdxa') = xa FAILED! expected: ["xa"]<br> re.exec('xyabcdef') = xy FAILED! expected: ["xy"]<br> </tt><br> -<a name='failure13'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/RegExp_multiline.js'>js1_2/regexp/RegExp_multiline.js</a> failed</b> <br> - [ <a href='#failure12'>Previous Failure</a> | <a href='#failure14'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure15'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/RegExp_multiline.js'>js1_2/regexp/RegExp_multiline.js</a> failed</b> <br> + [ <a href='#failure14'>Previous Failure</a> | <a href='#failure16'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> (multiline == true) '123\n456'.match(/^4../) = null FAILED! expected: 456<br> @@ -122,8 +136,8 @@ Failure messages were:<br> (multiline == true) 'a11\na22\na23\na24'.match(/a..$/g) = a24 FAILED! expected: a11,a22,a23,a24<br> (multiline == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) = a24 FAILED! expected: a11,a22,a23,a24<br> </tt><br> -<a name='failure14'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/RegExp_multiline_as_array.js'>js1_2/regexp/RegExp_multiline_as_array.js</a> failed</b> <br> - [ <a href='#failure13'>Previous Failure</a> | <a href='#failure15'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure16'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/RegExp_multiline_as_array.js'>js1_2/regexp/RegExp_multiline_as_array.js</a> failed</b> <br> + [ <a href='#failure15'>Previous Failure</a> | <a href='#failure17'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> (['$*'] == true) '123\n456'.match(/^4../) = null FAILED! expected: 456<br> @@ -132,20 +146,42 @@ Failure messages were:<br> (['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g) = a24 FAILED! expected: a11,a22,a23,a24<br> (['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) = a24 FAILED! expected: a11,a22,a23,a24<br> </tt><br> -<a name='failure15'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/beginLine.js'>js1_2/regexp/beginLine.js</a> failed</b> <br> - [ <a href='#failure14'>Previous Failure</a> | <a href='#failure16'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure17'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/beginLine.js'>js1_2/regexp/beginLine.js</a> failed</b> <br> + [ <a href='#failure16'>Previous Failure</a> | <a href='#failure18'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> 123xyz'.match(new RegExp('^\d+')) = null FAILED! expected: 123<br> </tt><br> -<a name='failure16'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/endLine.js'>js1_2/regexp/endLine.js</a> failed</b> <br> - [ <a href='#failure15'>Previous Failure</a> | <a href='#failure17'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure18'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/endLine.js'>js1_2/regexp/endLine.js</a> failed</b> <br> + [ <a href='#failure17'>Previous Failure</a> | <a href='#failure19'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> xyz'.match(new RegExp('\d+$')) = null FAILED! expected: 890<br> </tt><br> -<a name='failure17'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/string_split.js'>js1_2/regexp/string_split.js</a> failed</b> <br> - [ <a href='#failure16'>Previous Failure</a> | <a href='#failure18'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure19'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/regress-6359.js'>js1_2/regexp/regress-6359.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=http://bugzilla.mozilla.org/show_bug.cgi?id=6359' target='other_window'>Bug Number http://bugzilla.mozilla.org/show_bug.cgi?id=6359</a><br> + [ <a href='#failure18'>Previous Failure</a> | <a href='#failure20'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<tt>Expected exit code 0, got 3<br> +Testcase terminated with signal 0<br> +Complete testcase output was:<br> +BUGNUMBER: http://bugzilla.mozilla.org/show_bug.cgi?id=6359<br> +</tt><br> +<a name='failure20'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/regress-9141.js'>js1_2/regexp/regress-9141.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=http://bugzilla.mozilla.org/show_bug.cgi?id=9141' target='other_window'>Bug Number http://bugzilla.mozilla.org/show_bug.cgi?id=9141</a><br> + [ <a href='#failure19'>Previous Failure</a> | <a href='#failure21'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<tt>Expected exit code 0, got 3<br> +Testcase terminated with signal 0<br> +Complete testcase output was:<br> +BUGNUMBER: http://bugzilla.mozilla.org/show_bug.cgi?id=9141<br> +</tt><br> +<a name='failure21'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/simple_form.js'>js1_2/regexp/simple_form.js</a> failed</b> <br> + [ <a href='#failure20'>Previous Failure</a> | <a href='#failure22'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<tt>Expected exit code 0, got 3<br> +Testcase terminated with signal 0<br> +Complete testcase output was:<br> +Executing script: simple_form.js<br> +As described in Netscape doc "Whats new in JavaScript 1.2" RegExp: simple form<br> +</tt><br> +<a name='failure22'></a><dd><b>Testcase <a target='other_window' href='./js1_2/regexp/string_split.js'>js1_2/regexp/string_split.js</a> failed</b> <br> + [ <a href='#failure21'>Previous Failure</a> | <a href='#failure23'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> 'abc'.split(/[a-z]/) = ,,, FAILED! expected: ,,<br> @@ -153,22 +189,22 @@ Failure messages were:<br> 'abc'.split(new RegExp('[a-z]')) = ,,, FAILED! expected: ,,<br> 'abc'.split(new RegExp('[a-z]')) = ,,, FAILED! expected: ,,<br> </tt><br> -<a name='failure18'></a><dd><b>Testcase <a target='other_window' href='./js1_2/version120/boolean-001.js'>js1_2/version120/boolean-001.js</a> failed</b> <br> - [ <a href='#failure17'>Previous Failure</a> | <a href='#failure19'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure23'></a><dd><b>Testcase <a target='other_window' href='./js1_2/version120/boolean-001.js'>js1_2/version120/boolean-001.js</a> failed</b> <br> + [ <a href='#failure22'>Previous Failure</a> | <a href='#failure24'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt><br> Failure messages were:<br> new Boolean(false) = true FAILED! expected: false<br> </tt><br> -<a name='failure19'></a><dd><b>Testcase <a target='other_window' href='./js1_2/version120/regress-99663.js'>js1_2/version120/regress-99663.js</a> failed</b> <br> - [ <a href='#failure18'>Previous Failure</a> | <a href='#failure20'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure24'></a><dd><b>Testcase <a target='other_window' href='./js1_2/version120/regress-99663.js'>js1_2/version120/regress-99663.js</a> failed</b> <br> + [ <a href='#failure23'>Previous Failure</a> | <a href='#failure25'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>STATUS: Regression test for Bugzilla bug 99663<br> Failure messages were:<br> Section 1 of test - got Error: Can't find variable: it FAILED! expected: a "read-only" error<br> Section 2 of test - got Error: Can't find variable: it FAILED! expected: a "read-only" error<br> Section 3 of test - got Error: Can't find variable: it FAILED! expected: a "read-only" error<br> </tt><br> -<a name='failure20'></a><dd><b>Testcase <a target='other_window' href='./js1_3/Script/function-001-n.js'>js1_3/Script/function-001-n.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=10278' target='other_window'>Bug Number 10278</a><br> - [ <a href='#failure19'>Previous Failure</a> | <a href='#failure21'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure25'></a><dd><b>Testcase <a target='other_window' href='./js1_3/Script/function-001-n.js'>js1_3/Script/function-001-n.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=10278' target='other_window'>Bug Number 10278</a><br> + [ <a href='#failure24'>Previous Failure</a> | <a href='#failure26'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 3, got 0<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> @@ -176,15 +212,15 @@ BUGNUMBER: 10278<br> function-001.js functions not separated by semicolons are errors in version 120 and higher<br> eval("function f(){}function g(){}") = undefined FAILED! expected: error<br> </tt><br> -<a name='failure21'></a><dd><b>Testcase <a target='other_window' href='./js1_3/Script/script-001.js'>js1_3/Script/script-001.js</a> failed</b> <br> - [ <a href='#failure20'>Previous Failure</a> | <a href='#failure22'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure26'></a><dd><b>Testcase <a target='other_window' href='./js1_3/Script/script-001.js'>js1_3/Script/script-001.js</a> failed</b> <br> + [ <a href='#failure25'>Previous Failure</a> | <a href='#failure27'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> script-001 NativeScript<br> </tt><br> -<a name='failure22'></a><dd><b>Testcase <a target='other_window' href='./js1_3/regress/function-001-n.js'>js1_3/regress/function-001-n.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=10278' target='other_window'>Bug Number 10278</a><br> - [ <a href='#failure21'>Previous Failure</a> | <a href='#failure23'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure27'></a><dd><b>Testcase <a target='other_window' href='./js1_3/regress/function-001-n.js'>js1_3/regress/function-001-n.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=10278' target='other_window'>Bug Number 10278</a><br> + [ <a href='#failure26'>Previous Failure</a> | <a href='#failure28'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 3, got 0<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> @@ -192,90 +228,90 @@ BUGNUMBER: 10278<br> function-001.js functions not separated by semicolons are errors in version 120 and higher<br> eval("function f(){}function g(){}") = undefined FAILED! expected: error<br> </tt><br> -<a name='failure23'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/catchguard-001.js'>js1_5/Exceptions/catchguard-001.js</a> failed</b> <br> - [ <a href='#failure22'>Previous Failure</a> | <a href='#failure24'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure28'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/catchguard-001.js'>js1_5/Exceptions/catchguard-001.js</a> failed</b> <br> + [ <a href='#failure27'>Previous Failure</a> | <a href='#failure29'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure24'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/catchguard-002.js'>js1_5/Exceptions/catchguard-002.js</a> failed</b> <br> - [ <a href='#failure23'>Previous Failure</a> | <a href='#failure25'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure29'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/catchguard-002.js'>js1_5/Exceptions/catchguard-002.js</a> failed</b> <br> + [ <a href='#failure28'>Previous Failure</a> | <a href='#failure30'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure25'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/catchguard-003.js'>js1_5/Exceptions/catchguard-003.js</a> failed</b> <br> - [ <a href='#failure24'>Previous Failure</a> | <a href='#failure26'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure30'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/catchguard-003.js'>js1_5/Exceptions/catchguard-003.js</a> failed</b> <br> + [ <a href='#failure29'>Previous Failure</a> | <a href='#failure31'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure26'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/errstack-001.js'>js1_5/Exceptions/errstack-001.js</a> failed</b> <br> - [ <a href='#failure25'>Previous Failure</a> | <a href='#failure27'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure31'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/errstack-001.js'>js1_5/Exceptions/errstack-001.js</a> failed</b> <br> + [ <a href='#failure30'>Previous Failure</a> | <a href='#failure32'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure27'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/regress-50447.js'>js1_5/Exceptions/regress-50447.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=50447' target='other_window'>Bug Number 50447</a><br> - [ <a href='#failure26'>Previous Failure</a> | <a href='#failure28'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure32'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Exceptions/regress-50447.js'>js1_5/Exceptions/regress-50447.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=50447' target='other_window'>Bug Number 50447</a><br> + [ <a href='#failure31'>Previous Failure</a> | <a href='#failure33'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> BUGNUMBER: 50447<br> STATUS: Test (non-ECMA) Error object properties fileName, lineNumber<br> </tt><br> -<a name='failure28'></a><dd><b>Testcase <a target='other_window' href='./js1_5/GetSet/getset-001.js'>js1_5/GetSet/getset-001.js</a> failed</b> <br> - [ <a href='#failure27'>Previous Failure</a> | <a href='#failure29'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure33'></a><dd><b>Testcase <a target='other_window' href='./js1_5/GetSet/getset-001.js'>js1_5/GetSet/getset-001.js</a> failed</b> <br> + [ <a href='#failure32'>Previous Failure</a> | <a href='#failure34'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure29'></a><dd><b>Testcase <a target='other_window' href='./js1_5/GetSet/getset-002.js'>js1_5/GetSet/getset-002.js</a> failed</b> <br> - [ <a href='#failure28'>Previous Failure</a> | <a href='#failure30'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure34'></a><dd><b>Testcase <a target='other_window' href='./js1_5/GetSet/getset-002.js'>js1_5/GetSet/getset-002.js</a> failed</b> <br> + [ <a href='#failure33'>Previous Failure</a> | <a href='#failure35'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure30'></a><dd><b>Testcase <a target='other_window' href='./js1_5/GetSet/getset-003.js'>js1_5/GetSet/getset-003.js</a> failed</b> <br> - [ <a href='#failure29'>Previous Failure</a> | <a href='#failure31'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure35'></a><dd><b>Testcase <a target='other_window' href='./js1_5/GetSet/getset-003.js'>js1_5/GetSet/getset-003.js</a> failed</b> <br> + [ <a href='#failure34'>Previous Failure</a> | <a href='#failure36'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure31'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-90596-001.js'>js1_5/Object/regress-90596-001.js</a> failed</b> <br> - [ <a href='#failure30'>Previous Failure</a> | <a href='#failure32'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure36'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-90596-001.js'>js1_5/Object/regress-90596-001.js</a> failed</b> <br> + [ <a href='#failure35'>Previous Failure</a> | <a href='#failure37'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure32'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-90596-002.js'>js1_5/Object/regress-90596-002.js</a> failed</b> <br> - [ <a href='#failure31'>Previous Failure</a> | <a href='#failure33'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure37'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-90596-002.js'>js1_5/Object/regress-90596-002.js</a> failed</b> <br> + [ <a href='#failure36'>Previous Failure</a> | <a href='#failure38'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure33'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-96284-001.js'>js1_5/Object/regress-96284-001.js</a> failed</b> <br> - [ <a href='#failure32'>Previous Failure</a> | <a href='#failure34'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure38'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-96284-001.js'>js1_5/Object/regress-96284-001.js</a> failed</b> <br> + [ <a href='#failure37'>Previous Failure</a> | <a href='#failure39'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure34'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-96284-002.js'>js1_5/Object/regress-96284-002.js</a> failed</b> <br> - [ <a href='#failure33'>Previous Failure</a> | <a href='#failure35'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure39'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Object/regress-96284-002.js'>js1_5/Object/regress-96284-002.js</a> failed</b> <br> + [ <a href='#failure38'>Previous Failure</a> | <a href='#failure40'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure35'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-44009.js'>js1_5/Regress/regress-44009.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=44009' target='other_window'>Bug Number 44009</a><br> - [ <a href='#failure34'>Previous Failure</a> | <a href='#failure36'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure40'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-44009.js'>js1_5/Regress/regress-44009.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=44009' target='other_window'>Bug Number 44009</a><br> + [ <a href='#failure39'>Previous Failure</a> | <a href='#failure41'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> BUGNUMBER: 44009<br> STATUS: Testing that we don't crash on obj.toSource()<br> </tt><br> -<a name='failure36'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-103602.js'>js1_5/Regress/regress-103602.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=103602' target='other_window'>Bug Number 103602</a><br> - [ <a href='#failure35'>Previous Failure</a> | <a href='#failure37'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure41'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-103602.js'>js1_5/Regress/regress-103602.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=103602' target='other_window'>Bug Number 103602</a><br> + [ <a href='#failure40'>Previous Failure</a> | <a href='#failure42'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>STATUS: Reassignment to a const is NOT an error per ECMA<br> Failure messages were:<br> FAILED!: [reported from test()] Section 1 of test -<br> @@ -285,26 +321,26 @@ FAILED!: [reported from test()] Section 3 of test -<br> FAILED!: [reported from test()] Expected value '1', Actual value '2'<br> FAILED!: [reported from test()] <br> </tt><br> -<a name='failure37'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-104077.js'>js1_5/Regress/regress-104077.js</a> failed</b> <br> - [ <a href='#failure36'>Previous Failure</a> | <a href='#failure38'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure42'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-104077.js'>js1_5/Regress/regress-104077.js</a> failed</b> <br> + [ <a href='#failure41'>Previous Failure</a> | <a href='#failure43'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure38'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-127557.js'>js1_5/Regress/regress-127557.js</a> failed</b> <br> - [ <a href='#failure37'>Previous Failure</a> | <a href='#failure39'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure43'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-127557.js'>js1_5/Regress/regress-127557.js</a> failed</b> <br> + [ <a href='#failure42'>Previous Failure</a> | <a href='#failure44'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure39'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-172699.js'>js1_5/Regress/regress-172699.js</a> failed</b> <br> - [ <a href='#failure38'>Previous Failure</a> | <a href='#failure40'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure44'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-172699.js'>js1_5/Regress/regress-172699.js</a> failed</b> <br> + [ <a href='#failure43'>Previous Failure</a> | <a href='#failure45'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure40'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-179524.js'>js1_5/Regress/regress-179524.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=179524' target='other_window'>Bug Number 179524</a><br> - [ <a href='#failure39'>Previous Failure</a> | <a href='#failure41'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure45'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-179524.js'>js1_5/Regress/regress-179524.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=179524' target='other_window'>Bug Number 179524</a><br> + [ <a href='#failure44'>Previous Failure</a> | <a href='#failure46'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>STATUS: Don't crash on extraneous arguments to str.match(), etc.<br> Failure messages were:<br> FAILED!: [reported from test()] Section 14 of test -<br> @@ -354,14 +390,14 @@ FAILED!: [reported from test()] Section 36 of test -<br> FAILED!: [reported from test()] Expected value 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!', Actual value 'ABC Zbc'<br> FAILED!: [reported from test()] <br> </tt><br> -<a name='failure41'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/regress-220584.js'>js1_5/Scope/regress-220584.js</a> failed</b> <br> - [ <a href='#failure40'>Previous Failure</a> | <a href='#failure42'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure46'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/regress-220584.js'>js1_5/Scope/regress-220584.js</a> failed</b> <br> + [ <a href='#failure45'>Previous Failure</a> | <a href='#failure47'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure42'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/scope-001.js'>js1_5/Scope/scope-001.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=53268' target='other_window'>Bug Number 53268</a><br> - [ <a href='#failure41'>Previous Failure</a> | <a href='#failure43'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure47'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/scope-001.js'>js1_5/Scope/scope-001.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=53268' target='other_window'>Bug Number 53268</a><br> + [ <a href='#failure46'>Previous Failure</a> | <a href='#failure48'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>STATUS: Testing scope after changing obj.__proto__<br> Failure messages were:<br> FAILED!: [reported from test()] Step 1: setting obj.__proto__ = global object<br> @@ -372,8 +408,8 @@ FAILED!: [reported from test()] Type mismatch, expected type undefined, actual t FAILED!: [reported from test()] Expected value 'undefined', Actual value '1'<br> FAILED!: [reported from test()] <br> </tt><br> -<a name='failure43'></a><dd><b>Testcase <a target='other_window' href='./js1_6/Regress/regress-301574.js'>js1_6/Regress/regress-301574.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=301574' target='other_window'>Bug Number 301574</a><br> - [ <a href='#failure42'>Previous Failure</a> | <a href='#failure44'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure48'></a><dd><b>Testcase <a target='other_window' href='./js1_6/Regress/regress-301574.js'>js1_6/Regress/regress-301574.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=301574' target='other_window'>Bug Number 301574</a><br> + [ <a href='#failure47'>Previous Failure</a> | <a href='#failure49'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>STATUS: E4X should be enabled even when e4x=1 not specified<br> Failure messages were:<br> FAILED!: E4X should be enabled even when e4x=1 not specified: XML()<br> @@ -383,20 +419,20 @@ FAILED!: E4X should be enabled even when e4x=1 not specified: XMLList()<br> FAILED!: Expected value 'No error', Actual value 'error: ReferenceError: Can't find variable: XML'<br> FAILED!: <br> </tt><br> -<a name='failure44'></a><dd><b>Testcase <a target='other_window' href='./js1_6/Regress/regress-309242.js'>js1_6/Regress/regress-309242.js</a> failed</b> <br> - [ <a href='#failure43'>Previous Failure</a> | <a href='#failure45'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure49'></a><dd><b>Testcase <a target='other_window' href='./js1_6/Regress/regress-309242.js'>js1_6/Regress/regress-309242.js</a> failed</b> <br> + [ <a href='#failure48'>Previous Failure</a> | <a href='#failure50'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure45'></a><dd><b>Testcase <a target='other_window' href='./js1_6/Regress/regress-314887.js'>js1_6/Regress/regress-314887.js</a> failed</b> <br> - [ <a href='#failure44'>Previous Failure</a> | <a href='#failure46'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure50'></a><dd><b>Testcase <a target='other_window' href='./js1_6/Regress/regress-314887.js'>js1_6/Regress/regress-314887.js</a> failed</b> <br> + [ <a href='#failure49'>Previous Failure</a> | <a href='#failure51'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> Testcase produced no output!</tt><br> -<a name='failure46'></a><dd><b>Testcase <a target='other_window' href='./js1_6/String/regress-306591.js'>js1_6/String/regress-306591.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=306591' target='other_window'>Bug Number 306591</a><br> - [ <a href='#failure45'>Previous Failure</a> | <a href='#failure47'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> +<a name='failure51'></a><dd><b>Testcase <a target='other_window' href='./js1_6/String/regress-306591.js'>js1_6/String/regress-306591.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=306591' target='other_window'>Bug Number 306591</a><br> + [ <a href='#failure50'>Previous Failure</a> | <a href='#failure52'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br> <tt>Expected exit code 0, got 3<br> Testcase terminated with signal 0<br> Complete testcase output was:<br> @@ -410,17 +446,19 @@ STATUS: See https://bugzilla.mozilla.org/show_bug.cgi?id=304828<br> <pre> <a name='retest_list'></a> <h2>Retest List</h2><br> -# Retest List, squirrelfish, generated Fri Oct 15 00:29:31 2010. +# Retest List, squirrelfish, generated Wed Jan 19 13:26:57 2011. # Original test base was: All tests. -# 1119 of 1127 test(s) were completed, 46 failures reported. +# 1119 of 1127 test(s) were completed, 51 failures reported. ecma/TypeConversion/9.3.1-3.js ecma_2/Exceptions/function-001.js +ecma_2/RegExp/regress-001.js ecma_3/FunExpr/fe-001.js ecma_3/Statements/regress-194364.js ecma_3/Unicode/uc-001.js js1_2/Objects/toString-001.js js1_2/function/Function_object.js js1_2/function/function-001-n.js +js1_2/function/regexparg-1.js js1_2/function/tostring-1.js js1_2/function/tostring-2.js js1_2/operator/equality.js @@ -429,6 +467,9 @@ js1_2/regexp/RegExp_multiline.js js1_2/regexp/RegExp_multiline_as_array.js js1_2/regexp/beginLine.js js1_2/regexp/endLine.js +js1_2/regexp/regress-6359.js +js1_2/regexp/regress-9141.js +js1_2/regexp/simple_form.js js1_2/regexp/string_split.js js1_2/version120/boolean-001.js js1_2/version120/regress-99663.js diff --git a/Source/JavaScriptCore/wtf/CrossThreadRefCounted.h b/Source/JavaScriptCore/wtf/CrossThreadRefCounted.h index 0c0e997..8b65977 100644 --- a/Source/JavaScriptCore/wtf/CrossThreadRefCounted.h +++ b/Source/JavaScriptCore/wtf/CrossThreadRefCounted.h @@ -51,7 +51,8 @@ namespace WTF { // with respect to the original and any other copies. The underlying m_data is jointly // owned by the original instance and all copies. template<class T> - class CrossThreadRefCounted : public Noncopyable { + class CrossThreadRefCounted { + WTF_MAKE_NONCOPYABLE(CrossThreadRefCounted); public: static PassRefPtr<CrossThreadRefCounted<T> > create(T* data) { diff --git a/Source/JavaScriptCore/wtf/DateMath.h b/Source/JavaScriptCore/wtf/DateMath.h index 8d0d932..41bd4fa 100644 --- a/Source/JavaScriptCore/wtf/DateMath.h +++ b/Source/JavaScriptCore/wtf/DateMath.h @@ -44,6 +44,7 @@ #define DateMath_h #include <math.h> +#include <stdint.h> #include <string.h> #include <time.h> #include <wtf/CurrentTime.h> @@ -120,7 +121,9 @@ double parseDateFromNullTerminatedCharacters(ExecState*, const char* dateString) // Intentionally overridding the default tm of the system. // The members of tm differ on various operating systems. -struct GregorianDateTime : Noncopyable { +struct GregorianDateTime { + WTF_MAKE_NONCOPYABLE(GregorianDateTime); +public: GregorianDateTime() : second(0) , minute(0) diff --git a/Source/JavaScriptCore/wtf/Deque.h b/Source/JavaScriptCore/wtf/Deque.h index 745e0b6..1b16afc 100644 --- a/Source/JavaScriptCore/wtf/Deque.h +++ b/Source/JavaScriptCore/wtf/Deque.h @@ -44,7 +44,8 @@ namespace WTF { template<typename T> class DequeConstReverseIterator; template<typename T> - class Deque : public FastAllocBase { + class Deque { + WTF_MAKE_FAST_ALLOCATED; public: typedef DequeIterator<T> iterator; typedef DequeConstIterator<T> const_iterator; diff --git a/Source/JavaScriptCore/wtf/FastAllocBase.h b/Source/JavaScriptCore/wtf/FastAllocBase.h index bb1825e..e4899ab 100644 --- a/Source/JavaScriptCore/wtf/FastAllocBase.h +++ b/Source/JavaScriptCore/wtf/FastAllocBase.h @@ -32,8 +32,8 @@ // Provides customizable overrides of fastMalloc/fastFree and operator new/delete // // Provided functionality: +// Macro: WTF_MAKE_FAST_ALLOCATED // namespace WTF { -// class FastAllocBase; // // T* fastNew<T>(); // T* fastNew<T>(arg); @@ -48,7 +48,16 @@ // FastDelete assumes that the underlying // // Example usage: -// class Widget : public FastAllocBase { ... }; +// class Widget { +// WTF_MAKE_FAST_ALLOCATED +// ... +// }; +// +// struct Data { +// WTF_MAKE_FAST_ALLOCATED +// public: +// ... +// }; // // char* charPtr = fastNew<char>(); // fastDelete(charPtr); @@ -83,8 +92,6 @@ #include "FastMalloc.h" #include "TypeTraits.h" -namespace WTF { - #define WTF_MAKE_FAST_ALLOCATED \ public: \ void* operator new(size_t, void* p) { return p; } \ @@ -115,11 +122,10 @@ public: \ ::WTF::fastMallocMatchValidateFree(p, ::WTF::Internal::AllocTypeClassNewArray); \ ::WTF::fastFree(p); \ } \ -private: +private: \ +typedef int ThisIsHereToForceASemicolonAfterThisMacro -class FastAllocBase { - WTF_MAKE_FAST_ALLOCATED -}; +namespace WTF { // fastNew / fastDelete @@ -410,7 +416,6 @@ class FastAllocBase { } // namespace WTF -using WTF::FastAllocBase; using WTF::fastDeleteSkippingDestructor; #endif // FastAllocBase_h diff --git a/Source/JavaScriptCore/wtf/FastMalloc.cpp b/Source/JavaScriptCore/wtf/FastMalloc.cpp index 882f10d..ae93c02 100644 --- a/Source/JavaScriptCore/wtf/FastMalloc.cpp +++ b/Source/JavaScriptCore/wtf/FastMalloc.cpp @@ -453,6 +453,10 @@ extern "C" const int jscore_fastmalloc_introspection = 0; #if HAVE(PTHREAD_MACHDEP_H) #include <System/pthread_machdep.h> + +#if defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0) +#define WTF_USE_PTHREAD_GETSPECIFIC_DIRECT 1 +#endif #endif #ifndef PRIuS @@ -463,9 +467,14 @@ extern "C" const int jscore_fastmalloc_introspection = 0; // call to the function on Mac OS X, and it's used in performance-critical code. So we // use a function pointer. But that's not necessarily faster on other platforms, and we had // problems with this technique on Windows, so we'll do this only on Mac OS X. -#if OS(DARWIN) && !defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0) +#if OS(DARWIN) +#if !USE(PTHREAD_GETSPECIFIC_DIRECT) static void* (*pthread_getspecific_function_pointer)(pthread_key_t) = pthread_getspecific; #define pthread_getspecific(key) pthread_getspecific_function_pointer(key) +#else +#define pthread_getspecific(key) _pthread_getspecific_direct(key) +#define pthread_setspecific(key, val) _pthread_setspecific_direct(key, (val)) +#endif #endif #define DEFINE_VARIABLE(type, name, value, meaning) \ @@ -2519,25 +2528,30 @@ static __thread TCMalloc_ThreadCache *threadlocal_heap; // Therefore, we use TSD keys only after tsd_inited is set to true. // Until then, we use a slow path to get the heap object. static bool tsd_inited = false; +#if USE(PTHREAD_GETSPECIFIC_DIRECT) +static const pthread_key_t heap_key = __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0; +#else static pthread_key_t heap_key; +#endif #if OS(WINDOWS) DWORD tlsIndex = TLS_OUT_OF_INDEXES; #endif static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap) { +#if USE(PTHREAD_GETSPECIFIC_DIRECT) + // Can't have two libraries both doing this in the same process, + // so check and make this crash right away. + if (pthread_getspecific(heap_key)) + CRASH(); +#endif + // Still do pthread_setspecific even if there's an alternate form // of thread-local storage in use, to benefit from the delete callback. pthread_setspecific(heap_key, heap); #if OS(WINDOWS) TlsSetValue(tlsIndex, heap); -#elif defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0) - // Can't have two libraries both doing this in the same process, - // so check and make this crash right away. - if (_pthread_getspecific_direct(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0)) - CRASH(); - _pthread_setspecific_direct(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0, heap); #endif } @@ -3049,8 +3063,6 @@ inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetThreadHeap() { return threadlocal_heap; #elif OS(WINDOWS) return static_cast<TCMalloc_ThreadCache*>(TlsGetValue(tlsIndex)); -#elif defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0) - return static_cast<TCMalloc_ThreadCache*>(_pthread_getspecific_direct(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0)); #else return static_cast<TCMalloc_ThreadCache*>(pthread_getspecific(heap_key)); #endif @@ -3078,7 +3090,11 @@ inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetCacheIfPresent() { void TCMalloc_ThreadCache::InitTSD() { ASSERT(!tsd_inited); +#if USE(PTHREAD_GETSPECIFIC_DIRECT) + pthread_key_init_np(heap_key, DestroyThreadCache); +#else pthread_key_create(&heap_key, DestroyThreadCache); +#endif #if OS(WINDOWS) tlsIndex = TlsAlloc(); #endif diff --git a/Source/JavaScriptCore/wtf/HashCountedSet.h b/Source/JavaScriptCore/wtf/HashCountedSet.h index 4ed75c5..b97d8c8 100644 --- a/Source/JavaScriptCore/wtf/HashCountedSet.h +++ b/Source/JavaScriptCore/wtf/HashCountedSet.h @@ -22,14 +22,14 @@ #define WTF_HashCountedSet_h #include "Assertions.h" -#include "FastAllocBase.h" #include "HashMap.h" #include "Vector.h" namespace WTF { template<typename Value, typename HashFunctions = typename DefaultHash<Value>::Hash, - typename Traits = HashTraits<Value> > class HashCountedSet : public FastAllocBase { + typename Traits = HashTraits<Value> > class HashCountedSet { + WTF_MAKE_FAST_ALLOCATED; private: typedef HashMap<Value, unsigned, HashFunctions, Traits> ImplType; public: diff --git a/Source/JavaScriptCore/wtf/HashMap.h b/Source/JavaScriptCore/wtf/HashMap.h index 09094d1..7731546 100644 --- a/Source/JavaScriptCore/wtf/HashMap.h +++ b/Source/JavaScriptCore/wtf/HashMap.h @@ -29,7 +29,8 @@ namespace WTF { template<typename KeyArg, typename MappedArg, typename HashArg = typename DefaultHash<KeyArg>::Hash, typename KeyTraitsArg = HashTraits<KeyArg>, typename MappedTraitsArg = HashTraits<MappedArg> > - class HashMap : public FastAllocBase { + class HashMap { + WTF_MAKE_FAST_ALLOCATED; private: typedef KeyTraitsArg KeyTraits; typedef MappedTraitsArg MappedTraits; diff --git a/Source/JavaScriptCore/wtf/HashSet.h b/Source/JavaScriptCore/wtf/HashSet.h index 66639e4..be6b93d 100644 --- a/Source/JavaScriptCore/wtf/HashSet.h +++ b/Source/JavaScriptCore/wtf/HashSet.h @@ -35,7 +35,8 @@ namespace WTF { template<typename T> struct IdentityExtractor; template<typename ValueArg, typename HashArg = typename DefaultHash<ValueArg>::Hash, - typename TraitsArg = HashTraits<ValueArg> > class HashSet : public FastAllocBase { + typename TraitsArg = HashTraits<ValueArg> > class HashSet { + WTF_MAKE_FAST_ALLOCATED; private: typedef HashArg HashFunctions; typedef TraitsArg ValueTraits; diff --git a/Source/JavaScriptCore/wtf/ListHashSet.h b/Source/JavaScriptCore/wtf/ListHashSet.h index e14ac45..e916ef2 100644 --- a/Source/JavaScriptCore/wtf/ListHashSet.h +++ b/Source/JavaScriptCore/wtf/ListHashSet.h @@ -52,7 +52,8 @@ namespace WTF { template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNodeAllocator; template<typename ValueArg, size_t inlineCapacity, typename HashArg> struct ListHashSetNodeHashFunctions; - template<typename ValueArg, size_t inlineCapacity = 256, typename HashArg = typename DefaultHash<ValueArg>::Hash> class ListHashSet : public FastAllocBase { + template<typename ValueArg, size_t inlineCapacity = 256, typename HashArg = typename DefaultHash<ValueArg>::Hash> class ListHashSet { + WTF_MAKE_FAST_ALLOCATED; private: typedef ListHashSetNode<ValueArg, inlineCapacity> Node; typedef ListHashSetNodeAllocator<ValueArg, inlineCapacity> NodeAllocator; diff --git a/Source/JavaScriptCore/wtf/Locker.h b/Source/JavaScriptCore/wtf/Locker.h index 41813d3..c465b99 100644 --- a/Source/JavaScriptCore/wtf/Locker.h +++ b/Source/JavaScriptCore/wtf/Locker.h @@ -32,7 +32,8 @@ namespace WTF { -template <typename T> class Locker : public Noncopyable { +template <typename T> class Locker { + WTF_MAKE_NONCOPYABLE(Locker); public: Locker(T& lockable) : m_lockable(lockable) { m_lockable.lock(); } ~Locker() { m_lockable.unlock(); } diff --git a/Source/JavaScriptCore/wtf/MessageQueue.h b/Source/JavaScriptCore/wtf/MessageQueue.h index 14100c9..7c18a0c 100644 --- a/Source/JavaScriptCore/wtf/MessageQueue.h +++ b/Source/JavaScriptCore/wtf/MessageQueue.h @@ -48,7 +48,8 @@ namespace WTF { // when messages are fetched from the queue. // Essentially, MessageQueue acts as a queue of OwnPtr<DataType>. template<typename DataType> - class MessageQueue : public Noncopyable { + class MessageQueue { + WTF_MAKE_NONCOPYABLE(MessageQueue); public: MessageQueue() : m_killed(false) { } ~MessageQueue(); diff --git a/Source/JavaScriptCore/wtf/Noncopyable.h b/Source/JavaScriptCore/wtf/Noncopyable.h index 285ed2e..cc6bc55 100644 --- a/Source/JavaScriptCore/wtf/Noncopyable.h +++ b/Source/JavaScriptCore/wtf/Noncopyable.h @@ -41,23 +41,4 @@ ClassName& operator=(const ClassName&) #endif -// We don't want argument-dependent lookup to pull in everything from the WTF -// namespace when you use Noncopyable, so put it in its own namespace. - -#include "FastAllocBase.h" - -namespace WTFNoncopyable { - - class Noncopyable : public FastAllocBase { - Noncopyable(const Noncopyable&); - Noncopyable& operator=(const Noncopyable&); - protected: - Noncopyable() { } - ~Noncopyable() { } - }; - -} // namespace WTFNoncopyable - -using WTFNoncopyable::Noncopyable; - #endif // WTF_Noncopyable_h diff --git a/Source/JavaScriptCore/wtf/OwnArrayPtr.h b/Source/JavaScriptCore/wtf/OwnArrayPtr.h index 643b90b..f838a7e 100644 --- a/Source/JavaScriptCore/wtf/OwnArrayPtr.h +++ b/Source/JavaScriptCore/wtf/OwnArrayPtr.h @@ -24,6 +24,7 @@ #include "Assertions.h" #include "Noncopyable.h" #include "NullPtr.h" +#include "OwnPtrCommon.h" #include "OwnArrayPtrCommon.h" #include <algorithm> @@ -35,7 +36,7 @@ namespace WTF { template<typename T> class PassOwnArrayPtr; template<typename T> PassOwnArrayPtr<T> adoptArrayPtr(T*); -template <typename T> class OwnArrayPtr : public Noncopyable { +template <typename T> class OwnArrayPtr { public: typedef T* PtrType; diff --git a/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h b/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h index 8b6cbf4..9d4841a 100644 --- a/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h +++ b/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h @@ -23,11 +23,11 @@ #define OwnFastMallocPtr_h #include "FastMalloc.h" -#include "Noncopyable.h" namespace WTF { - template<class T> class OwnFastMallocPtr : public Noncopyable { + template<class T> class OwnFastMallocPtr { + WTF_MAKE_NONCOPYABLE(OwnFastMallocPtr); public: explicit OwnFastMallocPtr(T* ptr) : m_ptr(ptr) { diff --git a/Source/JavaScriptCore/wtf/OwnPtr.h b/Source/JavaScriptCore/wtf/OwnPtr.h index cdc277c..fb59432 100644 --- a/Source/JavaScriptCore/wtf/OwnPtr.h +++ b/Source/JavaScriptCore/wtf/OwnPtr.h @@ -22,7 +22,6 @@ #define WTF_OwnPtr_h #include "Assertions.h" -#include "Noncopyable.h" #include "NullPtr.h" #include "OwnPtrCommon.h" #include "TypeTraits.h" @@ -39,7 +38,7 @@ namespace WTF { template<typename T> class PassOwnPtr; template<typename T> PassOwnPtr<T> adoptPtr(T*); - template<typename T> class OwnPtr : public Noncopyable { + template<typename T> class OwnPtr { public: typedef typename RemovePointer<T>::Type ValueType; typedef ValueType* PtrType; diff --git a/Source/JavaScriptCore/wtf/RefCounted.h b/Source/JavaScriptCore/wtf/RefCounted.h index 8d8b302..da178b2 100644 --- a/Source/JavaScriptCore/wtf/RefCounted.h +++ b/Source/JavaScriptCore/wtf/RefCounted.h @@ -22,6 +22,7 @@ #define RefCounted_h #include "Assertions.h" +#include "FastAllocBase.h" #include "Noncopyable.h" namespace WTF { @@ -131,7 +132,8 @@ inline void adopted(RefCountedBase* object) #endif -template<typename T> class RefCounted : public RefCountedBase, public Noncopyable { +template<typename T> class RefCounted : public RefCountedBase { + WTF_MAKE_NONCOPYABLE(RefCounted); WTF_MAKE_FAST_ALLOCATED; public: void deref() { @@ -140,6 +142,7 @@ public: } protected: + RefCounted() { } ~RefCounted() { } diff --git a/Source/JavaScriptCore/wtf/RefPtr.h b/Source/JavaScriptCore/wtf/RefPtr.h index d57f88a..353bd35 100644 --- a/Source/JavaScriptCore/wtf/RefPtr.h +++ b/Source/JavaScriptCore/wtf/RefPtr.h @@ -36,7 +36,8 @@ namespace WTF { enum HashTableDeletedValueType { HashTableDeletedValue }; - template<typename T> class RefPtr : public FastAllocBase { + template<typename T> class RefPtr { + WTF_MAKE_FAST_ALLOCATED; public: ALWAYS_INLINE RefPtr() : m_ptr(0) { } ALWAYS_INLINE RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } diff --git a/Source/JavaScriptCore/wtf/RefPtrHashMap.h b/Source/JavaScriptCore/wtf/RefPtrHashMap.h index b9e7eea..dbeabfa 100644 --- a/Source/JavaScriptCore/wtf/RefPtrHashMap.h +++ b/Source/JavaScriptCore/wtf/RefPtrHashMap.h @@ -45,7 +45,8 @@ namespace WTF { }; template<typename T, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg> - class HashMap<RefPtr<T>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> : public FastAllocBase { + class HashMap<RefPtr<T>, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> { + WTF_MAKE_FAST_ALLOCATED; private: typedef KeyTraitsArg KeyTraits; typedef MappedTraitsArg MappedTraits; diff --git a/Source/JavaScriptCore/wtf/StackBounds.cpp b/Source/JavaScriptCore/wtf/StackBounds.cpp index be8ce84..41e0d60 100644 --- a/Source/JavaScriptCore/wtf/StackBounds.cpp +++ b/Source/JavaScriptCore/wtf/StackBounds.cpp @@ -60,12 +60,12 @@ namespace WTF { // Bug 26276 - Need a mechanism to determine stack extent // // These platforms should now be working correctly: -// DARWIN, QNX, UNIX +// DARWIN, QNX, UNIX, SYMBIAN // These platforms are not: -// WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE +// WINDOWS, SOLARIS, OPENBSD, HAIKU, WINCE // // FIXME: remove this! - this code unsafely guesses at stack sizes! -#if OS(WINDOWS) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU) +#if OS(WINDOWS) || OS(SOLARIS) || OS(OPENBSD) || OS(HAIKU) // Based on the current limit used by the JSC parser, guess the stack size. static const ptrdiff_t estimatedStackSize = 128 * sizeof(void*) * 1024; // This method assumes the stack is growing downwards. @@ -139,7 +139,7 @@ void StackBounds::initialize() RThread thread; thread.StackInfo(info); m_origin = (void*)info.iBase; - m_bound = estimateStackBound(m_origin); + m_bound = (void*)info.iLimit; } #elif OS(HAIKU) diff --git a/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h b/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h index 3af87a8..ed1ba2c 100644 --- a/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h +++ b/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h @@ -31,14 +31,14 @@ #ifndef ThreadIdentifierDataPthreads_h #define ThreadIdentifierDataPthreads_h -#include <wtf/Noncopyable.h> #include <wtf/Threading.h> namespace WTF { // Holds ThreadIdentifier in the thread-specific storage and employs pthreads-specific 2-pass destruction to reliably remove // ThreadIdentifier from threadMap. It assumes regular ThreadSpecific types don't use multiple-pass destruction. -class ThreadIdentifierData : public Noncopyable { +class ThreadIdentifierData { + WTF_MAKE_NONCOPYABLE(ThreadIdentifierData); public: ~ThreadIdentifierData(); diff --git a/Source/JavaScriptCore/wtf/ThreadSafeShared.h b/Source/JavaScriptCore/wtf/ThreadSafeShared.h index 33c6612..a6a1cf2 100644 --- a/Source/JavaScriptCore/wtf/ThreadSafeShared.h +++ b/Source/JavaScriptCore/wtf/ThreadSafeShared.h @@ -62,12 +62,12 @@ #include "Platform.h" #include <wtf/Atomics.h> -#include <wtf/Noncopyable.h> #include <wtf/ThreadingPrimitives.h> namespace WTF { -class ThreadSafeSharedBase : public Noncopyable { +class ThreadSafeSharedBase { + WTF_MAKE_NONCOPYABLE(ThreadSafeSharedBase); WTF_MAKE_FAST_ALLOCATED; public: ThreadSafeSharedBase(int initialRefCount = 1) : m_refCount(initialRefCount) diff --git a/Source/JavaScriptCore/wtf/ThreadSpecific.h b/Source/JavaScriptCore/wtf/ThreadSpecific.h index 93ed466..fa9a393 100644 --- a/Source/JavaScriptCore/wtf/ThreadSpecific.h +++ b/Source/JavaScriptCore/wtf/ThreadSpecific.h @@ -61,7 +61,8 @@ namespace WTF { void ThreadSpecificThreadExit(); #endif -template<typename T> class ThreadSpecific : public Noncopyable { +template<typename T> class ThreadSpecific { + WTF_MAKE_NONCOPYABLE(ThreadSpecific); public: ThreadSpecific(); T* operator->(); @@ -84,7 +85,9 @@ private: void static destroy(void* ptr); #if USE(PTHREADS) || PLATFORM(QT) || PLATFORM(GTK) || OS(WINDOWS) - struct Data : Noncopyable { + struct Data { + WTF_MAKE_NONCOPYABLE(Data); + public: Data(T* value, ThreadSpecific<T>* owner) : value(value), owner(owner) {} #if PLATFORM(QT) ~Data() { owner->destroy(this); } diff --git a/Source/JavaScriptCore/wtf/ThreadSpecificWin.cpp b/Source/JavaScriptCore/wtf/ThreadSpecificWin.cpp index f2c0cad..d72996a 100644 --- a/Source/JavaScriptCore/wtf/ThreadSpecificWin.cpp +++ b/Source/JavaScriptCore/wtf/ThreadSpecificWin.cpp @@ -21,7 +21,6 @@ #include "config.h" #include "ThreadSpecific.h" -#include <wtf/Noncopyable.h> #if USE(PTHREADS) #error This file should not be compiled by ports that do not use Windows native ThreadSpecific implementation. diff --git a/Source/JavaScriptCore/wtf/Threading.cpp b/Source/JavaScriptCore/wtf/Threading.cpp index 49de59e..f2e0565 100644 --- a/Source/JavaScriptCore/wtf/Threading.cpp +++ b/Source/JavaScriptCore/wtf/Threading.cpp @@ -30,7 +30,9 @@ namespace WTF { -struct NewThreadContext : FastAllocBase { +struct NewThreadContext { + WTF_MAKE_FAST_ALLOCATED; +public: NewThreadContext(ThreadFunction entryPoint, void* data, const char* name) : entryPoint(entryPoint) , data(data) diff --git a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h index c11a6cb..809c3e2 100644 --- a/Source/JavaScriptCore/wtf/ThreadingPrimitives.h +++ b/Source/JavaScriptCore/wtf/ThreadingPrimitives.h @@ -34,6 +34,7 @@ #include "Platform.h" #include <wtf/Assertions.h> +#include <wtf/FastAllocBase.h> #include <wtf/Locker.h> #include <wtf/Noncopyable.h> @@ -96,7 +97,8 @@ typedef void* PlatformReadWriteLock; typedef void* PlatformCondition; #endif -class Mutex : public Noncopyable { +class Mutex { + WTF_MAKE_NONCOPYABLE(Mutex); WTF_MAKE_FAST_ALLOCATED; public: Mutex(); ~Mutex(); @@ -113,7 +115,8 @@ private: typedef Locker<Mutex> MutexLocker; -class ReadWriteLock : public Noncopyable { +class ReadWriteLock { + WTF_MAKE_NONCOPYABLE(ReadWriteLock); public: ReadWriteLock(); ~ReadWriteLock(); @@ -130,7 +133,8 @@ private: PlatformReadWriteLock m_readWriteLock; }; -class ThreadCondition : public Noncopyable { +class ThreadCondition { + WTF_MAKE_NONCOPYABLE(ThreadCondition); public: ThreadCondition(); ~ThreadCondition(); diff --git a/Source/JavaScriptCore/wtf/Vector.h b/Source/JavaScriptCore/wtf/Vector.h index f73793f..6d8dd4c 100644 --- a/Source/JavaScriptCore/wtf/Vector.h +++ b/Source/JavaScriptCore/wtf/Vector.h @@ -277,7 +277,8 @@ namespace WTF { }; template<typename T> - class VectorBufferBase : public Noncopyable { + class VectorBufferBase { + WTF_MAKE_NONCOPYABLE(VectorBufferBase); public: void allocateBuffer(size_t newCapacity) { @@ -488,7 +489,8 @@ namespace WTF { }; template<typename T, size_t inlineCapacity = 0> - class Vector : public FastAllocBase { + class Vector { + WTF_MAKE_FAST_ALLOCATED; private: typedef VectorBuffer<T, inlineCapacity> Buffer; typedef VectorTypeOperations<T> TypeOperations; diff --git a/Source/JavaScriptCore/wtf/WTFThreadData.h b/Source/JavaScriptCore/wtf/WTFThreadData.h index 52c267a..243aa91 100644 --- a/Source/JavaScriptCore/wtf/WTFThreadData.h +++ b/Source/JavaScriptCore/wtf/WTFThreadData.h @@ -52,7 +52,8 @@ namespace JSC { typedef HashMap<const char*, RefPtr<StringImpl>, PtrHash<const char*> > LiteralIdentifierTable; -class IdentifierTable : public FastAllocBase { +class IdentifierTable { + WTF_MAKE_FAST_ALLOCATED; public: ~IdentifierTable(); @@ -85,7 +86,8 @@ class AtomicStringTable; typedef void (*AtomicStringTableDestructor)(AtomicStringTable*); -class WTFThreadData : public Noncopyable { +class WTFThreadData { + WTF_MAKE_NONCOPYABLE(WTFThreadData); public: WTFThreadData(); ~WTFThreadData(); diff --git a/Source/JavaScriptCore/wtf/dtoa.cpp b/Source/JavaScriptCore/wtf/dtoa.cpp index c89c036..b5b1261 100644 --- a/Source/JavaScriptCore/wtf/dtoa.cpp +++ b/Source/JavaScriptCore/wtf/dtoa.cpp @@ -414,7 +414,10 @@ static void mult(BigInt& aRef, const BigInt& bRef) aRef = c; } -struct P5Node : Noncopyable { +struct P5Node { + WTF_MAKE_NONCOPYABLE(P5Node); WTF_MAKE_FAST_ALLOCATED; +public: + P5Node() { } BigInt val; P5Node* next; }; diff --git a/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h b/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h index cec3e43..4136f28 100644 --- a/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h +++ b/Source/JavaScriptCore/wtf/gobject/GOwnPtr.h @@ -41,7 +41,8 @@ template<> void freeOwnedGPtr<GPatternSpec>(GPatternSpec*); template<> void freeOwnedGPtr<GDir>(GDir*); template<> void freeOwnedGPtr<GFile>(GFile*); -template <typename T> class GOwnPtr : public Noncopyable { +template <typename T> class GOwnPtr { + WTF_MAKE_NONCOPYABLE(GOwnPtr); public: explicit GOwnPtr(T* ptr = 0) : m_ptr(ptr) { } ~GOwnPtr() { freeOwnedGPtr(m_ptr); } diff --git a/Source/JavaScriptCore/wtf/text/StringBuffer.h b/Source/JavaScriptCore/wtf/text/StringBuffer.h index a546bf3..e73d38e 100644 --- a/Source/JavaScriptCore/wtf/text/StringBuffer.h +++ b/Source/JavaScriptCore/wtf/text/StringBuffer.h @@ -30,13 +30,13 @@ #define StringBuffer_h #include <wtf/Assertions.h> -#include <wtf/Noncopyable.h> #include <wtf/unicode/Unicode.h> #include <limits> namespace WTF { -class StringBuffer : public Noncopyable { +class StringBuffer { + WTF_MAKE_NONCOPYABLE(StringBuffer); public: explicit StringBuffer(unsigned length) : m_length(length) diff --git a/Source/JavaScriptCore/wtf/text/StringImplBase.h b/Source/JavaScriptCore/wtf/text/StringImplBase.h index 6567672..26bc1d9 100644 --- a/Source/JavaScriptCore/wtf/text/StringImplBase.h +++ b/Source/JavaScriptCore/wtf/text/StringImplBase.h @@ -26,12 +26,12 @@ #ifndef StringImplBase_h #define StringImplBase_h -#include <wtf/Noncopyable.h> #include <wtf/unicode/Unicode.h> namespace WTF { -class StringImplBase : public Noncopyable { +class StringImplBase { + WTF_MAKE_NONCOPYABLE(StringImplBase); WTF_MAKE_FAST_ALLOCATED; public: bool isStringImpl() { return (m_refCountAndFlags & s_refCountInvalidForStringImpl) != s_refCountInvalidForStringImpl; } unsigned length() const { return m_length; } @@ -45,9 +45,6 @@ protected: BufferShared, }; - using Noncopyable::operator new; - void* operator new(size_t, void* inPlace) { ASSERT(inPlace); return inPlace; } - // For SmallStringStorage, which allocates an array and uses an in-place new. StringImplBase() { } diff --git a/Source/JavaScriptCore/wtf/text/WTFString.cpp b/Source/JavaScriptCore/wtf/text/WTFString.cpp index 6bb74f6..4b6ff75 100644 --- a/Source/JavaScriptCore/wtf/text/WTFString.cpp +++ b/Source/JavaScriptCore/wtf/text/WTFString.cpp @@ -612,7 +612,7 @@ void String::split(const String& separator, bool allowEmptyEntries, Vector<Strin void String::split(const String& separator, Vector<String>& result) const { - return split(separator, false, result); + split(separator, false, result); } void String::split(UChar separator, bool allowEmptyEntries, Vector<String>& result) const @@ -632,7 +632,7 @@ void String::split(UChar separator, bool allowEmptyEntries, Vector<String>& resu void String::split(UChar separator, Vector<String>& result) const { - return split(String(&separator, 1), false, result); + split(String(&separator, 1), false, result); } CString String::ascii() const diff --git a/Source/JavaScriptCore/wtf/unicode/Collator.h b/Source/JavaScriptCore/wtf/unicode/Collator.h index fe6a809..00ab16e 100644 --- a/Source/JavaScriptCore/wtf/unicode/Collator.h +++ b/Source/JavaScriptCore/wtf/unicode/Collator.h @@ -29,6 +29,7 @@ #ifndef WTF_Collator_h #define WTF_Collator_h +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> #include <wtf/unicode/Unicode.h> @@ -39,7 +40,8 @@ struct UCollator; namespace WTF { - class Collator : public Noncopyable { + class Collator { + WTF_MAKE_NONCOPYABLE(Collator); WTF_MAKE_FAST_ALLOCATED; public: enum Result { Equal = 0, Greater = 1, Less = -1 }; diff --git a/Source/JavaScriptCore/yarr/YarrInterpreter.h b/Source/JavaScriptCore/yarr/YarrInterpreter.h index be703a9..eea5266 100644 --- a/Source/JavaScriptCore/yarr/YarrInterpreter.h +++ b/Source/JavaScriptCore/yarr/YarrInterpreter.h @@ -299,7 +299,8 @@ struct ByteTerm { } }; -class ByteDisjunction : public FastAllocBase { +class ByteDisjunction { + WTF_MAKE_FAST_ALLOCATED; public: ByteDisjunction(unsigned numSubpatterns, unsigned frameSize) : m_numSubpatterns(numSubpatterns) @@ -312,7 +313,9 @@ public: unsigned m_frameSize; }; -struct BytecodePattern : FastAllocBase { +struct BytecodePattern { + WTF_MAKE_FAST_ALLOCATED; +public: BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<ByteDisjunction*> allParenthesesInfo, YarrPattern& pattern, BumpPointerAllocator* allocator) : m_body(body) , m_ignoreCase(pattern.m_ignoreCase) diff --git a/Source/JavaScriptCore/yarr/YarrJIT.cpp b/Source/JavaScriptCore/yarr/YarrJIT.cpp index ae59cba..9d13d45 100644 --- a/Source/JavaScriptCore/yarr/YarrJIT.cpp +++ b/Source/JavaScriptCore/yarr/YarrJIT.cpp @@ -606,9 +606,9 @@ class YarrGenerator : private MacroAssembler { m_nextBacktrack->setLabel(label); } - void copyBacktrackToLabel(BacktrackDestination& rhs) + void propagateBacktrackToLabel(const BacktrackDestination& rhs) { - if (rhs.m_backtrackToLabel) + if (!m_backtrackToLabel && rhs.m_backtrackToLabel) m_backtrackToLabel = rhs.m_backtrackToLabel; } @@ -618,6 +618,11 @@ class YarrGenerator : private MacroAssembler { m_backtrackToLabel = backtrackToLabel; } + bool hasBacktrackToLabel() + { + return m_backtrackToLabel; + } + void setBacktrackJumpList(JumpList* jumpList) { m_backtrackType = BacktrackJumpList; @@ -634,8 +639,10 @@ class YarrGenerator : private MacroAssembler { if (m_subDataLabelPtr) { *m_subDataLabelPtr = dp; m_subDataLabelPtr = 0; - } else + } else { + ASSERT(!hasDataLabel()); m_dataLabelPtr = dp; + } } void clearSubDataLabelPtr() @@ -748,6 +755,12 @@ class YarrGenerator : private MacroAssembler { return false; } + void linkBacktrackToLabel(Label backtrackLabel) + { + if (m_backtrackToLabel) + *m_backtrackToLabel = backtrackLabel; + } + void linkAlternativeBacktracks(YarrGenerator* generator, bool nextIteration = false) { Label hereLabel = generator->label(); @@ -919,24 +932,19 @@ class YarrGenerator : private MacroAssembler { return m_backtrack.plantJumpToBacktrackIfExists(generator); } - bool linkDataLabelToBacktrackIfExists(YarrGenerator* generator, DataLabelPtr dataLabel) + void linkDataLabelToBacktrackIfExists(YarrGenerator* generator, DataLabelPtr dataLabel) { // If we have a stack offset backtrack destination, use it directly if (m_backtrack.isStackOffset()) { generator->m_expressionState.addIndirectJumpEntry(m_backtrack.getStackOffset(), dataLabel); m_backtrack.clearSubDataLabelPtr(); } else { - // Otherwise set the data label (which may be linked) - setBacktrackDataLabel(dataLabel); - - if ((m_backtrack.isLabel()) && (m_backtrack.hasDataLabel())) { - generator->m_expressionState.m_backtrackRecords.append(AlternativeBacktrackRecord(m_backtrack.getDataLabel(), m_backtrack.getLabel())); - m_backtrack.clearDataLabel(); - return true; - } + // If we have a backtrack label, connect the datalabel to it directly. + if (m_backtrack.isLabel()) + generator->m_expressionState.m_backtrackRecords.append(AlternativeBacktrackRecord(dataLabel, m_backtrack.getLabel())); + else + setBacktrackDataLabel(dataLabel); } - - return false; } void addBacktrackJump(Jump jump) @@ -990,6 +998,10 @@ class YarrGenerator : private MacroAssembler { { if (doJump) m_backtrack.jumpToBacktrack(generator, backtrack.getBacktrackJumps()); + + if (m_backtrack.isLabel() && backtrack.hasBacktrackToLabel()) + backtrack.linkBacktrackToLabel(m_backtrack.getLabel()); + if (backtrack.hasDestination()) { if (m_backtrack.hasDataLabel()) generator->m_expressionState.addDataLabelToNextIteration(m_backtrack.getDataLabel()); @@ -1007,7 +1019,6 @@ class YarrGenerator : private MacroAssembler { BacktrackDestination m_backtrack; BacktrackDestination* m_linkedBacktrack; ParenthesesTail* m_parenthesesTail; - }; struct ParenthesesTail { @@ -1638,13 +1649,19 @@ class YarrGenerator : private MacroAssembler { m_expressionState.incrementParenNestingLevel(); TermGenerationState parenthesesState(disjunction, state.checkedTotal); + + // Use the current paren Tail to connect the nested parentheses. + parenthesesState.setParenthesesTail(state.getParenthesesTail()); + generateParenthesesDisjunction(state.term(), parenthesesState, alternativeFrameLocation); // this expects that any backtracks back out of the parentheses will be in the // parenthesesState's m_backTrackJumps vector, and that if they need backtracking // they will have set an entry point on the parenthesesState's m_backtrackLabel. BacktrackDestination& parenthesesBacktrack = parenthesesState.getBacktrackDestination(); + BacktrackDestination& stateBacktrack = state.getBacktrackDestination(); + state.propagateBacktrackingFrom(this, parenthesesBacktrack); - state.getBacktrackDestination().copyBacktrackToLabel(parenthesesBacktrack); + stateBacktrack.propagateBacktrackToLabel(parenthesesBacktrack); m_expressionState.decrementParenNestingLevel(); } else { diff --git a/Source/JavaScriptCore/yarr/YarrPattern.h b/Source/JavaScriptCore/yarr/YarrPattern.h index 2172dda..d80f692 100644 --- a/Source/JavaScriptCore/yarr/YarrPattern.h +++ b/Source/JavaScriptCore/yarr/YarrPattern.h @@ -63,7 +63,9 @@ private: } }; -struct CharacterClass : FastAllocBase { +struct CharacterClass { + WTF_MAKE_FAST_ALLOCATED; +public: // All CharacterClass instances have to have the full set of matches and ranges, // they may have an optional table for faster lookups (which must match the // specified matches and ranges) @@ -204,7 +206,9 @@ struct PatternTerm { } }; -struct PatternAlternative : FastAllocBase { +struct PatternAlternative { + WTF_MAKE_FAST_ALLOCATED; +public: PatternAlternative(PatternDisjunction* disjunction) : m_parent(disjunction) , m_onceThrough(false) @@ -245,7 +249,9 @@ struct PatternAlternative : FastAllocBase { bool m_containsBOL : 1; }; -struct PatternDisjunction : FastAllocBase { +struct PatternDisjunction { + WTF_MAKE_FAST_ALLOCATED; +public: PatternDisjunction(PatternAlternative* parent = 0) : m_parent(parent) , m_hasFixedSize(false) diff --git a/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj b/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj index 066a930..aa91bdb 100644 --- a/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj +++ b/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj @@ -7,6 +7,22 @@ objects = { /* Begin PBXBuildFile section */ + 90D9B10212E11DCB002D4255 /* Compiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B0F912E11DCB002D4255 /* Compiler.cpp */; }; + 90D9B10312E11DCB002D4255 /* ExtensionBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B0FA12E11DCB002D4255 /* ExtensionBehavior.h */; }; + 90D9B10412E11DCB002D4255 /* glslang_lex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B0FB12E11DCB002D4255 /* glslang_lex.cpp */; }; + 90D9B10512E11DCB002D4255 /* glslang_tab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B0FC12E11DCB002D4255 /* glslang_tab.cpp */; }; + 90D9B10612E11DCB002D4255 /* glslang_tab.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B0FD12E11DCB002D4255 /* glslang_tab.h */; }; + 90D9B10712E11DCB002D4255 /* glslang.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B0FE12E11DCB002D4255 /* glslang.h */; }; + 90D9B10912E11DCB002D4255 /* SearchSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10012E11DCB002D4255 /* SearchSymbol.cpp */; }; + 90D9B10A12E11DCB002D4255 /* SearchSymbol.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B10112E11DCB002D4255 /* SearchSymbol.h */; }; + 90D9B11312E11DD6002D4255 /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10B12E11DD6002D4255 /* util.cpp */; }; + 90D9B11412E11DD6002D4255 /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B10C12E11DD6002D4255 /* util.h */; }; + 90D9B11512E11DD6002D4255 /* ValidateLimitations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10D12E11DD6002D4255 /* ValidateLimitations.cpp */; }; + 90D9B11612E11DD6002D4255 /* ValidateLimitations.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B10E12E11DD6002D4255 /* ValidateLimitations.h */; }; + 90D9B11712E11DD6002D4255 /* VariableInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B10F12E11DD6002D4255 /* VariableInfo.cpp */; }; + 90D9B11812E11DD6002D4255 /* VariableInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B11012E11DD6002D4255 /* VariableInfo.h */; }; + 90D9B11912E11DD6002D4255 /* VersionGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90D9B11112E11DD6002D4255 /* VersionGLSL.cpp */; }; + 90D9B11A12E11DD6002D4255 /* VersionGLSL.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D9B11212E11DD6002D4255 /* VersionGLSL.h */; }; FB39D2711200F35A00088E69 /* CodeGenGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D2221200F35A00088E69 /* CodeGenGLSL.cpp */; }; FB39D2751200F35A00088E69 /* debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D2261200F35A00088E69 /* debug.cpp */; }; FB39D2791200F35A00088E69 /* InfoSink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D22A1200F35A00088E69 /* InfoSink.cpp */; }; @@ -33,8 +49,6 @@ FB39D2AA1200F35A00088E69 /* SymbolTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D25C1200F35A00088E69 /* SymbolTable.cpp */; }; FB39D2AC1200F35A00088E69 /* TranslatorGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D2681200F35A00088E69 /* TranslatorGLSL.cpp */; }; FB39D2B11200F35A00088E69 /* UnfoldSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D26D1200F35A00088E69 /* UnfoldSelect.cpp */; }; - FB39D7231201032000088E69 /* glslang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D7201201032000088E69 /* glslang.cpp */; }; - FB39D7241201032000088E69 /* glslang_tab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB39D7221201032000088E69 /* glslang_tab.cpp */; }; FB39D76E120110FC00088E69 /* ShaderLang.h in Headers */ = {isa = PBXBuildFile; fileRef = FB39D2BF1200F3E600088E69 /* ShaderLang.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ @@ -42,6 +56,23 @@ 5D7C59C51208C68B001C873E /* ANGLE.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ANGLE.xcconfig; sourceTree = "<group>"; }; 5D7C59C61208C68B001C873E /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; 5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; }; + 90D9B0F912E11DCB002D4255 /* Compiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Compiler.cpp; sourceTree = "<group>"; }; + 90D9B0FA12E11DCB002D4255 /* ExtensionBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionBehavior.h; sourceTree = "<group>"; }; + 90D9B0FB12E11DCB002D4255 /* glslang_lex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glslang_lex.cpp; sourceTree = "<group>"; }; + 90D9B0FC12E11DCB002D4255 /* glslang_tab.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glslang_tab.cpp; sourceTree = "<group>"; }; + 90D9B0FD12E11DCB002D4255 /* glslang_tab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glslang_tab.h; sourceTree = "<group>"; }; + 90D9B0FE12E11DCB002D4255 /* glslang.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glslang.h; sourceTree = "<group>"; }; + 90D9B0FF12E11DCB002D4255 /* ossource_nspr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ossource_nspr.cpp; sourceTree = "<group>"; }; + 90D9B10012E11DCB002D4255 /* SearchSymbol.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SearchSymbol.cpp; sourceTree = "<group>"; }; + 90D9B10112E11DCB002D4255 /* SearchSymbol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchSymbol.h; sourceTree = "<group>"; }; + 90D9B10B12E11DD6002D4255 /* util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = util.cpp; sourceTree = "<group>"; }; + 90D9B10C12E11DD6002D4255 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = "<group>"; }; + 90D9B10D12E11DD6002D4255 /* ValidateLimitations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValidateLimitations.cpp; sourceTree = "<group>"; }; + 90D9B10E12E11DD6002D4255 /* ValidateLimitations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValidateLimitations.h; sourceTree = "<group>"; }; + 90D9B10F12E11DD6002D4255 /* VariableInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VariableInfo.cpp; sourceTree = "<group>"; }; + 90D9B11012E11DD6002D4255 /* VariableInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VariableInfo.h; sourceTree = "<group>"; }; + 90D9B11112E11DD6002D4255 /* VersionGLSL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VersionGLSL.cpp; sourceTree = "<group>"; }; + 90D9B11212E11DD6002D4255 /* VersionGLSL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionGLSL.h; sourceTree = "<group>"; }; FB39D0D11200F0E300088E69 /* libANGLE.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libANGLE.a; sourceTree = BUILT_PRODUCTS_DIR; }; FB39D1861200F26200088E69 /* BaseTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseTypes.h; sourceTree = "<group>"; }; FB39D1871200F26200088E69 /* CodeGenGLSL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGenGLSL.cpp; sourceTree = "<group>"; }; @@ -50,8 +81,6 @@ FB39D18A1200F26200088E69 /* ConstantUnion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstantUnion.h; sourceTree = "<group>"; }; FB39D18B1200F26200088E69 /* debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.cpp.cpp; path = debug.cpp; sourceTree = "<group>"; }; FB39D18C1200F26200088E69 /* debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = "<group>"; }; - FB39D18D1200F26200088E69 /* glslang.l */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lex; path = glslang.l; sourceTree = "<group>"; }; - FB39D18E1200F26200088E69 /* glslang.y */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; path = glslang.y; sourceTree = "<group>"; }; FB39D18F1200F26200088E69 /* InfoSink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.cpp.cpp; path = InfoSink.cpp; sourceTree = "<group>"; }; FB39D1901200F26200088E69 /* InfoSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfoSink.h; sourceTree = "<group>"; }; FB39D1911200F26200088E69 /* Initialize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.cpp.cpp; path = Initialize.cpp; sourceTree = "<group>"; }; @@ -112,15 +141,12 @@ FB39D1D11200F26200088E69 /* Types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Types.h; sourceTree = "<group>"; }; FB39D1D21200F26200088E69 /* UnfoldSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.cpp.cpp; path = UnfoldSelect.cpp; sourceTree = "<group>"; }; FB39D1D31200F26200088E69 /* UnfoldSelect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnfoldSelect.h; sourceTree = "<group>"; }; - FB39D1D41200F26200088E69 /* unistd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unistd.h; sourceTree = "<group>"; }; FB39D2211200F35A00088E69 /* BaseTypes.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = BaseTypes.h; sourceTree = "<group>"; }; FB39D2221200F35A00088E69 /* CodeGenGLSL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGenGLSL.cpp; sourceTree = "<group>"; }; FB39D2241200F35A00088E69 /* Common.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = Common.h; sourceTree = "<group>"; }; FB39D2251200F35A00088E69 /* ConstantUnion.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = ConstantUnion.h; sourceTree = "<group>"; }; FB39D2261200F35A00088E69 /* debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = debug.cpp; sourceTree = "<group>"; }; FB39D2271200F35A00088E69 /* debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = "<group>"; }; - FB39D2281200F35A00088E69 /* glslang.l */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lex; path = glslang.l; sourceTree = "<group>"; }; - FB39D2291200F35A00088E69 /* glslang.y */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; path = glslang.y; sourceTree = "<group>"; }; FB39D22A1200F35A00088E69 /* InfoSink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InfoSink.cpp; sourceTree = "<group>"; }; FB39D22B1200F35A00088E69 /* InfoSink.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = InfoSink.h; sourceTree = "<group>"; }; FB39D22C1200F35A00088E69 /* Initialize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Initialize.cpp; sourceTree = "<group>"; }; @@ -175,11 +201,7 @@ FB39D26C1200F35A00088E69 /* Types.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = Types.h; sourceTree = "<group>"; }; FB39D26D1200F35A00088E69 /* UnfoldSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnfoldSelect.cpp; sourceTree = "<group>"; }; FB39D26E1200F35A00088E69 /* UnfoldSelect.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = UnfoldSelect.h; sourceTree = "<group>"; }; - FB39D26F1200F35A00088E69 /* unistd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unistd.h; sourceTree = "<group>"; }; FB39D2BF1200F3E600088E69 /* ShaderLang.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = ShaderLang.h; sourceTree = "<group>"; }; - FB39D7201201032000088E69 /* glslang.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glslang.cpp; path = DerivedSources/ANGLE/glslang.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; - FB39D7211201032000088E69 /* glslang_tab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glslang_tab.h; path = DerivedSources/ANGLE/glslang_tab.h; sourceTree = BUILT_PRODUCTS_DIR; }; - FB39D7221201032000088E69 /* glslang_tab.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glslang_tab.cpp; path = DerivedSources/ANGLE/glslang_tab.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -208,7 +230,6 @@ children = ( FB39D2201200F35A00088E69 /* compiler */, FB39D0841200EDEB00088E69 /* Source */, - FB39D0CB1200EF9400088E69 /* Intermediates */, 5D7C59C41208C68B001C873E /* Configurations */, FB39D0CC1200EF9B00088E69 /* Products */, ); @@ -223,16 +244,6 @@ name = Source; sourceTree = "<group>"; }; - FB39D0CB1200EF9400088E69 /* Intermediates */ = { - isa = PBXGroup; - children = ( - FB39D7201201032000088E69 /* glslang.cpp */, - FB39D7211201032000088E69 /* glslang_tab.h */, - FB39D7221201032000088E69 /* glslang_tab.cpp */, - ); - name = Intermediates; - sourceTree = "<group>"; - }; FB39D0CC1200EF9B00088E69 /* Products */ = { isa = PBXGroup; children = ( @@ -251,8 +262,6 @@ FB39D18A1200F26200088E69 /* ConstantUnion.h */, FB39D18B1200F26200088E69 /* debug.cpp */, FB39D18C1200F26200088E69 /* debug.h */, - FB39D18D1200F26200088E69 /* glslang.l */, - FB39D18E1200F26200088E69 /* glslang.y */, FB39D18F1200F26200088E69 /* InfoSink.cpp */, FB39D1901200F26200088E69 /* InfoSink.h */, FB39D1911200F26200088E69 /* Initialize.cpp */, @@ -297,7 +306,6 @@ FB39D1D11200F26200088E69 /* Types.h */, FB39D1D21200F26200088E69 /* UnfoldSelect.cpp */, FB39D1D31200F26200088E69 /* UnfoldSelect.h */, - FB39D1D41200F26200088E69 /* unistd.h */, ); includeInIndex = 0; name = compiler; @@ -332,14 +340,19 @@ FB39D2201200F35A00088E69 /* compiler */ = { isa = PBXGroup; children = ( + FB39D2441200F35A00088E69 /* preprocessor */, FB39D2211200F35A00088E69 /* BaseTypes.h */, FB39D2221200F35A00088E69 /* CodeGenGLSL.cpp */, FB39D2241200F35A00088E69 /* Common.h */, + 90D9B0F912E11DCB002D4255 /* Compiler.cpp */, FB39D2251200F35A00088E69 /* ConstantUnion.h */, FB39D2261200F35A00088E69 /* debug.cpp */, FB39D2271200F35A00088E69 /* debug.h */, - FB39D2281200F35A00088E69 /* glslang.l */, - FB39D2291200F35A00088E69 /* glslang.y */, + 90D9B0FA12E11DCB002D4255 /* ExtensionBehavior.h */, + 90D9B0FB12E11DCB002D4255 /* glslang_lex.cpp */, + 90D9B0FC12E11DCB002D4255 /* glslang_tab.cpp */, + 90D9B0FD12E11DCB002D4255 /* glslang_tab.h */, + 90D9B0FE12E11DCB002D4255 /* glslang.h */, FB39D22A1200F35A00088E69 /* InfoSink.cpp */, FB39D22B1200F35A00088E69 /* InfoSink.h */, FB39D22C1200F35A00088E69 /* Initialize.cpp */, @@ -355,6 +368,7 @@ FB39D2361200F35A00088E69 /* localintermediate.h */, FB39D2371200F35A00088E69 /* MMap.h */, FB39D2381200F35A00088E69 /* osinclude.h */, + 90D9B0FF12E11DCB002D4255 /* ossource_nspr.cpp */, FB39D2391200F35A00088E69 /* ossource_posix.cpp */, FB39D23A1200F35A00088E69 /* ossource_win.cpp */, FB39D23B1200F35A00088E69 /* OutputGLSL.cpp */, @@ -364,11 +378,12 @@ FB39D2411200F35A00088E69 /* ParseHelper.h */, FB39D2421200F35A00088E69 /* PoolAlloc.cpp */, FB39D2431200F35A00088E69 /* PoolAlloc.h */, - FB39D2441200F35A00088E69 /* preprocessor */, FB39D2561200F35A00088E69 /* QualifierAlive.cpp */, FB39D2571200F35A00088E69 /* QualifierAlive.h */, FB39D2581200F35A00088E69 /* RemoveTree.cpp */, FB39D2591200F35A00088E69 /* RemoveTree.h */, + 90D9B10012E11DCB002D4255 /* SearchSymbol.cpp */, + 90D9B10112E11DCB002D4255 /* SearchSymbol.h */, FB39D25A1200F35A00088E69 /* ShaderLang.cpp */, FB39D25B1200F35A00088E69 /* ShHandle.h */, FB39D25C1200F35A00088E69 /* SymbolTable.cpp */, @@ -378,7 +393,14 @@ FB39D26C1200F35A00088E69 /* Types.h */, FB39D26D1200F35A00088E69 /* UnfoldSelect.cpp */, FB39D26E1200F35A00088E69 /* UnfoldSelect.h */, - FB39D26F1200F35A00088E69 /* unistd.h */, + 90D9B10B12E11DD6002D4255 /* util.cpp */, + 90D9B10C12E11DD6002D4255 /* util.h */, + 90D9B10D12E11DD6002D4255 /* ValidateLimitations.cpp */, + 90D9B10E12E11DD6002D4255 /* ValidateLimitations.h */, + 90D9B10F12E11DD6002D4255 /* VariableInfo.cpp */, + 90D9B11012E11DD6002D4255 /* VariableInfo.h */, + 90D9B11112E11DD6002D4255 /* VersionGLSL.cpp */, + 90D9B11212E11DD6002D4255 /* VersionGLSL.h */, ); name = compiler; path = src/compiler; @@ -425,6 +447,14 @@ buildActionMask = 2147483647; files = ( FB39D76E120110FC00088E69 /* ShaderLang.h in Headers */, + 90D9B10312E11DCB002D4255 /* ExtensionBehavior.h in Headers */, + 90D9B10612E11DCB002D4255 /* glslang_tab.h in Headers */, + 90D9B10712E11DCB002D4255 /* glslang.h in Headers */, + 90D9B10A12E11DCB002D4255 /* SearchSymbol.h in Headers */, + 90D9B11412E11DD6002D4255 /* util.h in Headers */, + 90D9B11612E11DD6002D4255 /* ValidateLimitations.h in Headers */, + 90D9B11812E11DD6002D4255 /* VariableInfo.h in Headers */, + 90D9B11A12E11DD6002D4255 /* VersionGLSL.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -436,8 +466,6 @@ buildConfigurationList = FB39D0D61200F11E00088E69 /* Build configuration list for PBXNativeTarget "ANGLE" */; buildPhases = ( FB39D77B1201110C00088E69 /* Headers */, - FB39D0DE1200F19100088E69 /* Generate glslang lexer */, - FB39D31C1200F69200088E69 /* Generate glslang parser */, FB39D0CE1200F0E300088E69 /* Sources */, FB39D0CF1200F0E300088E69 /* Frameworks */, ); @@ -457,7 +485,6 @@ isa = PBXProject; buildConfigurationList = FB39D0731200ED9200088E69 /* Build configuration list for PBXProject "ANGLE" */; compatibilityVersion = "Xcode 2.4"; - developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( English, @@ -474,49 +501,11 @@ }; /* End PBXProject section */ -/* Begin PBXShellScriptBuildPhase section */ - FB39D0DE1200F19100088E69 /* Generate glslang lexer */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 12; - files = ( - ); - inputPaths = ( - "$(SRCROOT)/src/compiler/glslang.l", - ); - name = "Generate glslang lexer"; - outputPaths = ( - "$(BUILT_PRODUCTS_DIR)/DerivedSources/$(PROJECT_NAME)/glslang.cpp", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "mkdir -p \"${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}\"\nflex --noline --nounistd \"--outfile=${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}/glslang.cpp\" \"${SRCROOT}/src/compiler/glslang.l\"\n"; - }; - FB39D31C1200F69200088E69 /* Generate glslang parser */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "$(SRCROOT)/src/compiler/glslang.y", - ); - name = "Generate glslang parser"; - outputPaths = ( - "$(BUILT_PRODUCTS_DIR)/DerivedSources/$(PROJECT_NAME)/glslang_tab.cpp", - "$(BUILT_PRODUCTS_DIR)/DerivedSources/$(PROJECT_NAME)/glslang_tab.h", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "mkdir -p \"${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}\"\nbison --no-lines \"--defines=${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}/glslang_tab.h\" \"--skeleton=yacc.c\" \"--output=${BUILT_PRODUCTS_DIR}/DerivedSources/${PROJECT_NAME}/glslang_tab.cpp\" \"${SRCROOT}/src/compiler/glslang.y\"\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ FB39D0CE1200F0E300088E69 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - FB39D7231201032000088E69 /* glslang.cpp in Sources */, - FB39D7241201032000088E69 /* glslang_tab.cpp in Sources */, FB39D2711200F35A00088E69 /* CodeGenGLSL.cpp in Sources */, FB39D2751200F35A00088E69 /* debug.cpp in Sources */, FB39D2791200F35A00088E69 /* InfoSink.cpp in Sources */, @@ -543,6 +532,14 @@ FB39D2AA1200F35A00088E69 /* SymbolTable.cpp in Sources */, FB39D2AC1200F35A00088E69 /* TranslatorGLSL.cpp in Sources */, FB39D2B11200F35A00088E69 /* UnfoldSelect.cpp in Sources */, + 90D9B10212E11DCB002D4255 /* Compiler.cpp in Sources */, + 90D9B10412E11DCB002D4255 /* glslang_lex.cpp in Sources */, + 90D9B10512E11DCB002D4255 /* glslang_tab.cpp in Sources */, + 90D9B10912E11DCB002D4255 /* SearchSymbol.cpp in Sources */, + 90D9B11312E11DD6002D4255 /* util.cpp in Sources */, + 90D9B11512E11DD6002D4255 /* ValidateLimitations.cpp in Sources */, + 90D9B11712E11DD6002D4255 /* VariableInfo.cpp in Sources */, + 90D9B11912E11DD6002D4255 /* VersionGLSL.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/ThirdParty/ANGLE/ChangeLog b/Source/ThirdParty/ANGLE/ChangeLog index bd993b7..604df51 100644 --- a/Source/ThirdParty/ANGLE/ChangeLog +++ b/Source/ThirdParty/ANGLE/ChangeLog @@ -1,3 +1,613 @@ +2011-01-18 Kenneth Russell <kbr@google.com> + + Unreviewed, Leopard build fix. Remove flex/bison targets for GLSL + grammar because the generated sources are already checked in. + + * ANGLE.xcodeproj/project.pbxproj: + * src/build_angle.xcodeproj/project.pbxproj: + +2011-01-18 Kenneth Russell <kbr@google.com> + + Unreviewed, release build fix. Explicitly cast away const. + + * src/compiler/preprocessor/scanner.c: + (ScanFromString): + +2011-01-18 Ben Vanik <ben.vanik@gmail.com> + + Reviewed by Kenneth Russell. + + Updating ANGLE in WebKit to r533. + https://bugs.webkit.org/show_bug.cgi?id=47194 + + * ANGLE.xcodeproj/project.pbxproj: + * include/GLSLANG/ShaderLang.h: + * src/common/debug.cpp: + (gl::trace): + * src/common/debug.h: + * src/compiler/CodeGenGLSL.cpp: + (ConstructCompiler): + * src/compiler/CodeGenHLSL.cpp: + (ConstructCompiler): + * src/compiler/Common.h: + (EncodeSourceLoc): + (DecodeSourceLoc): + * src/compiler/Compiler.cpp: Added. + (TShHandleBase::TShHandleBase): + (TShHandleBase::~TShHandleBase): + (TCompiler::TCompiler): + (TCompiler::~TCompiler): + (TCompiler::Init): + (TCompiler::compile): + (TCompiler::InitBuiltInSymbolTable): + (TCompiler::clearResults): + (TCompiler::validateLimitations): + (TCompiler::collectAttribsUniforms): + * src/compiler/ExtensionBehavior.h: Added. + * src/compiler/InfoSink.cpp: + (TInfoSinkBase::location): + * src/compiler/InfoSink.h: + (TInfoSinkBase::size): + * src/compiler/Initialize.cpp: + (BuiltInFunctionsCommon): + (BuiltInFunctionsVertex): + (BuiltInFunctionsFragment): + (StandardUniforms): + (DefaultPrecisionVertex): + (DefaultPrecisionFragment): + (BuiltInConstants): + (TBuiltIns::initialize): + (IdentifyBuiltIns): + (InitExtensionBehavior): + * src/compiler/Initialize.h: + * src/compiler/IntermTraverse.cpp: + (TIntermLoop::traverse): + * src/compiler/Intermediate.cpp: + (getOperatorString): + (TIntermediate::addBinaryMath): + (TIntermediate::addLoop): + (TIntermediate::postProcess): + (TIntermBinary::promote): + * src/compiler/OutputGLSL.cpp: + (TOutputGLSL::visitUnary): + (TOutputGLSL::visitLoop): + * src/compiler/OutputHLSL.cpp: + (sh::OutputHLSL::OutputHLSL): + (sh::OutputHLSL::header): + (sh::OutputHLSL::visitBinary): + (sh::OutputHLSL::visitUnary): + (sh::OutputHLSL::visitAggregate): + (sh::OutputHLSL::visitLoop): + (sh::OutputHLSL::handleExcessiveLoop): + (sh::OutputHLSL::argumentString): + * src/compiler/OutputHLSL.h: + * src/compiler/ParseHelper.cpp: + (ReportInfo): + (DefineExtensionMacros): + (TParseContext::error): + (TParseContext::warning): + (TParseContext::reservedErrorCheck): + (TParseContext::constructorErrorCheck): + (TParseContext::arrayQualifierErrorCheck): + (TParseContext::extensionErrorCheck): + (TParseContext::areAllChildConst): + (PaParseStrings): + * src/compiler/ParseHelper.h: + (TParseContext::TParseContext): + * src/compiler/PoolAlloc.cpp: + (InitializeGlobalPools): + (FreeGlobalPools): + (SetGlobalPoolAllocator): + (TPoolAllocator::TPoolAllocator): + (TPoolAllocator::~TPoolAllocator): + (TAllocation::checkAllocList): + * src/compiler/PoolAlloc.h: + * src/compiler/SearchSymbol.cpp: Added. + (sh::SearchSymbol::SearchSymbol): + (sh::SearchSymbol::traverse): + (sh::SearchSymbol::visitSymbol): + (sh::SearchSymbol::foundMatch): + * src/compiler/SearchSymbol.h: Added. + * src/compiler/ShHandle.h: + (TCompiler::getAsCompiler): + (TCompiler::getInfoSink): + (TCompiler::getAttribs): + (TCompiler::getUniforms): + (TCompiler::getShaderType): + (TCompiler::getShaderSpec): + * src/compiler/ShaderLang.cpp: + (getVariableMaxLength): + (getVariableInfo): + (ShInitBuiltInResources): + (ShConstructCompiler): + (ShCompile): + (ShGetInfo): + (ShGetInfoLog): + (ShGetObjectCode): + (ShGetActiveAttrib): + (ShGetActiveUniform): + * src/compiler/SymbolTable.cpp: + (TSymbolTableLevel::relateToExtension): + * src/compiler/SymbolTable.h: + (TVariable::shareConstPointer): + (TFunction::relateToExtension): + (TFunction::getExtension): + (TFunction::getParamCount): + (TFunction::getParam): + (TSymbolTable::getGlobalLevel): + (TSymbolTable::relateToOperator): + (TSymbolTable::relateToExtension): + * src/compiler/TranslatorGLSL.cpp: + (writeVersion): + (TranslatorGLSL::TranslatorGLSL): + (TranslatorGLSL::translate): + * src/compiler/TranslatorGLSL.h: + * src/compiler/TranslatorHLSL.cpp: + (TranslatorHLSL::TranslatorHLSL): + (TranslatorHLSL::translate): + * src/compiler/TranslatorHLSL.h: + * src/compiler/Types.h: + (TType::TType): + * src/compiler/UnfoldSelect.cpp: + (sh::UnfoldSelect::visitSelection): + * src/compiler/UnfoldSelect.h: + * src/compiler/ValidateLimitations.cpp: Added. + (ValidateLimitations::ValidateLimitations): + (ValidateLimitations::visitSymbol): + (ValidateLimitations::visitConstantUnion): + (ValidateLimitations::visitBinary): + (ValidateLimitations::visitUnary): + (ValidateLimitations::visitSelection): + (ValidateLimitations::visitAggregate): + (ValidateLimitations::visitLoop): + (ValidateLimitations::visitBranch): + (ValidateLimitations::error): + (ValidateLimitations::withinLoopBody): + (ValidateLimitations::isLoopIndex): + (ValidateLimitations::validateLoopType): + (ValidateLimitations::validateForLoopHeader): + (ValidateLimitations::validateForLoopInit): + (ValidateLimitations::validateForLoopCond): + (ValidateLimitations::validateForLoopExpr): + (ValidateLimitations::validateFunctionCall): + (ValidateLimitations::validateOperation): + (ValidateLimitations::isConstExpr): + (ValidateLimitations::isConstIndexExpr): + (ValidateLimitations::validateIndexing): + * src/compiler/ValidateLimitations.h: Added. + (ValidateLimitations::numErrors): + * src/compiler/VariableInfo.cpp: Added. + (arrayBrackets): + (getVariableDataType): + (getVariableInfo): + (getBuiltInVariableInfo): + (getUserDefinedVariableInfo): + (CollectAttribsUniforms::CollectAttribsUniforms): + (CollectAttribsUniforms::visitSymbol): + (CollectAttribsUniforms::visitConstantUnion): + (CollectAttribsUniforms::visitBinary): + (CollectAttribsUniforms::visitUnary): + (CollectAttribsUniforms::visitSelection): + (CollectAttribsUniforms::visitAggregate): + (CollectAttribsUniforms::visitLoop): + (CollectAttribsUniforms::visitBranch): + * src/compiler/VariableInfo.h: Added. + * src/compiler/VersionGLSL.cpp: Added. + (TVersionGLSL::TVersionGLSL): + (TVersionGLSL::visitSymbol): + (TVersionGLSL::visitConstantUnion): + (TVersionGLSL::visitBinary): + (TVersionGLSL::visitUnary): + (TVersionGLSL::visitSelection): + (TVersionGLSL::visitAggregate): + (TVersionGLSL::visitLoop): + (TVersionGLSL::visitBranch): + (TVersionGLSL::updateVersion): + * src/compiler/VersionGLSL.h: Added. + (TVersionGLSL::getVersion): + * src/compiler/generate_glslang_lexer.sh: Added. + * src/compiler/generate_glslang_parser.sh: Added. + * src/compiler/glslang.h: Added. + * src/compiler/glslang.l: + * src/compiler/glslang.y: + * src/compiler/glslang_lex.cpp: Added. + (yy_get_next_buffer): + (yy_get_previous_state): + (yy_try_NUL_trans): + (input): + (yyrestart): + (yy_switch_to_buffer): + (yy_load_buffer_state): + (yy_create_buffer): + (yy_delete_buffer): + (yy_init_buffer): + (yy_flush_buffer): + (yypush_buffer_state): + (yypop_buffer_state): + (yyensure_buffer_stack): + (yy_scan_buffer): + (yy_scan_string): + (yy_scan_bytes): + (yy_push_state): + (yy_pop_state): + (yy_top_state): + (yy_fatal_error): + (yyget_extra): + (yyget_lineno): + (yyget_column): + (yyget_in): + (yyget_out): + (yyget_leng): + (yyget_text): + (yyset_extra): + (yyset_lineno): + (yyset_column): + (yyset_in): + (yyset_out): + (yyget_debug): + (yyset_debug): + (yyget_lval): + (yyset_lval): + (yylex_init): + (yylex_init_extra): + (yy_init_globals): + (yylex_destroy): + (yy_flex_strncpy): + (yy_flex_strlen): + (yyalloc): + (yyrealloc): + (yyfree): + (string_input): + (check_type): + (reserved_word): + (yyerror): + (glslang_initialize): + (glslang_finalize): + (glslang_scan): + * src/compiler/glslang_tab.cpp: Added. + (yytnamerr): + (yysyntax_error): + (glslang_parse): + * src/compiler/glslang_tab.h: Added. + * src/compiler/intermOut.cpp: + (TOutputTraverser::TOutputTraverser): + (OutputTreeText): + (TOutputTraverser::visitSymbol): + (TOutputTraverser::visitBinary): + (TOutputTraverser::visitUnary): + (TOutputTraverser::visitAggregate): + (TOutputTraverser::visitSelection): + (TOutputTraverser::visitConstantUnion): + (TOutputTraverser::visitLoop): + (TOutputTraverser::visitBranch): + (TIntermediate::outputTree): + * src/compiler/intermediate.h: + (TIntermLoop::TIntermLoop): + (TIntermLoop::getType): + (TIntermLoop::getInit): + (TIntermLoop::getCondition): + (TIntermLoop::getExpression): + (TIntermLoop::getBody): + * src/compiler/localintermediate.h: + * src/compiler/osinclude.h: + (OS_GetTLSValue): + * src/compiler/ossource_nspr.cpp: Added. + (OS_AllocTLSIndex): + (OS_SetTLSValue): + (OS_FreeTLSIndex): + * src/compiler/preprocessor/compile.h: + * src/compiler/preprocessor/cpp.c: + (CPPdefine): + (CPPelse): + (CPPif): + (CPPifdef): + (CPPerror): + (CPPextension): + (readCPPline): + * src/compiler/preprocessor/preprocess.h: + * src/compiler/preprocessor/scanner.c: + (str_getch): + (str_ungetch): + (ScanFromString): + (lFloatConst): + (byte_scan): + (yylex_CPP): + (check_EOF): + * src/compiler/preprocessor/scanner.h: + * src/compiler/preprocessor/tokens.c: + (RecordToken): + (ReadToken): + * src/compiler/tools: Removed. + * src/compiler/unistd.h: Removed. + * src/compiler/util.cpp: Added. + (atof_dot): + * src/compiler/util.h: Added. + * src/libEGL/Config.cpp: + (egl::Config::set): + * src/libEGL/Display.cpp: + (egl::Display::Display): + (egl::Display::initialize): + (egl::Display::terminate): + (egl::Display::createDevice): + (egl::Display::resetDevice): + (egl::Display::createContext): + (egl::Display::destroyContext): + (egl::Display::getMinSwapInterval): + (egl::Display::getMaxSwapInterval): + (egl::Display::getDevice): + (egl::Display::getFloatTextureSupport): + (egl::Display::getHalfFloatTextureSupport): + (egl::Display::getLuminanceTextureSupport): + (egl::Display::getLuminanceAlphaTextureSupport): + (egl::Display::getBufferPool): + (egl::Display::getEventQuerySupport): + (egl::Display::getDefaultPresentParameters): + * src/libEGL/Display.h: + * src/libEGL/Surface.cpp: + (egl::Surface::Surface): + (egl::Surface::~Surface): + (egl::Surface::release): + (egl::Surface::resetSwapChain): + (egl::Surface::writeRecordableFlipState): + (egl::Surface::restoreState): + (egl::SurfaceWindowProc): + (egl::Surface::subclassWindow): + (egl::Surface::unsubclassWindow): + (egl::Surface::checkForOutOfDateSwapChain): + (egl::Surface::convertInterval): + (egl::Surface::swap): + (egl::Surface::getRenderTarget): + (egl::Surface::setSwapInterval): + * src/libEGL/Surface.h: + * src/libEGL/libEGL.cpp: + * src/libGLESv2/Blit.cpp: + (gl::Blit::copySurfaceToTexture): + (gl::Blit::setCommonBlitState): + * src/libGLESv2/Buffer.cpp: + (gl::Buffer::Buffer): + (gl::Buffer::~Buffer): + (gl::Buffer::bufferData): + (gl::Buffer::bufferSubData): + (gl::Buffer::getVertexBuffer): + (gl::Buffer::getIndexBuffer): + (gl::Buffer::invalidateStaticData): + * src/libGLESv2/Buffer.h: + * src/libGLESv2/Context.cpp: + (gl::Context::Context): + (gl::Context::~Context): + (gl::Context::makeCurrent): + (gl::Context::markAllStateDirty): + (gl::Context::setFragmentShaderDerivativeHint): + (gl::Context::setEnableVertexAttribArray): + (gl::Context::getVertexAttribState): + (gl::Context::getVertexAttributes): + (gl::Context::createFence): + (gl::Context::deleteFence): + (gl::Context::bindTexture2D): + (gl::Context::bindTextureCubeMap): + (gl::Context::getFence): + (gl::Context::getTexture2D): + (gl::Context::getTextureCubeMap): + (gl::Context::getSamplerTexture): + (gl::Context::getBooleanv): + (gl::Context::getIntegerv): + (gl::Context::getQueryParameterInfo): + (gl::Context::applyRenderTarget): + (gl::Context::applyState): + (gl::Context::lookupAttributeMapping): + (gl::Context::applyVertexBuffer): + (gl::Context::applyIndexBuffer): + (gl::Context::readPixels): + (gl::Context::clear): + (gl::Context::drawArrays): + (gl::Context::drawElements): + (gl::Context::finish): + (gl::Context::drawClosingLine): + (gl::Context::getMaximumVaryingVectors): + (gl::Context::getMaximumFragmentUniformVectors): + (gl::Context::supportsEventQueries): + (gl::Context::supportsFloatTextures): + (gl::Context::supportsFloatLinearFilter): + (gl::Context::supportsFloatRenderableTextures): + (gl::Context::supportsHalfFloatTextures): + (gl::Context::supportsHalfFloatLinearFilter): + (gl::Context::supportsHalfFloatRenderableTextures): + (gl::Context::getMaximumRenderbufferDimension): + (gl::Context::getMaximumTextureDimension): + (gl::Context::getMaximumCubeTextureDimension): + (gl::Context::getMaximumTextureLevel): + (gl::Context::supportsLuminanceTextures): + (gl::Context::supportsLuminanceAlphaTextures): + (gl::Context::supports32bitIndices): + (gl::Context::getIncompleteTexture): + (gl::Context::setVertexAttrib): + (gl::Context::initExtensionString): + (gl::Context::blitFramebuffer): + * src/libGLESv2/Context.h: + (gl::VertexAttribute::VertexAttribute): + (gl::VertexAttribute::typeSize): + (gl::VertexAttribute::stride): + * src/libGLESv2/Fence.cpp: Added. + (gl::Fence::Fence): + (gl::Fence::~Fence): + (gl::Fence::isFence): + (gl::Fence::setFence): + (gl::Fence::testFence): + (gl::Fence::finishFence): + (gl::Fence::getFenceiv): + * src/libGLESv2/Fence.h: Added. + * src/libGLESv2/Framebuffer.cpp: + (gl::Framebuffer::completeness): + (gl::DefaultFramebuffer::DefaultFramebuffer): + (gl::DefaultFramebuffer::completeness): + * src/libGLESv2/Program.cpp: + (gl::Program::Program): + (gl::Program::getSamplerMapping): + (gl::Program::getUniformLocation): + (gl::Program::setUniform1iv): + (gl::Program::applyUniforms): + (gl::Program::packVaryings): + (gl::Program::linkVaryings): + (gl::Program::link): + (gl::Program::defineUniform): + (gl::Program::createUniform): + (gl::Program::applyUniform1iv): + (gl::Program::resetInfoLog): + (gl::Program::unlink): + (gl::Program::getActiveAttribute): + (gl::Program::getActiveUniform): + (gl::Program::getDxDepthRangeLocation): + * src/libGLESv2/Program.h: + * src/libGLESv2/RefCountObject.cpp: + (gl::RefCountObject::~RefCountObject): + * src/libGLESv2/Renderbuffer.cpp: + (gl::RenderbufferStorage::RenderbufferStorage): + (gl::RenderbufferStorage::isFloatingPoint): + (gl::Colorbuffer::Colorbuffer): + (gl::DepthStencilbuffer::DepthStencilbuffer): + * src/libGLESv2/Renderbuffer.h: + * src/libGLESv2/Shader.cpp: + (gl::Shader::Shader): + (gl::Shader::parseVaryings): + (gl::Shader::compileToHLSL): + (gl::VertexShader::parseAttributes): + * src/libGLESv2/Texture.cpp: + (gl::Texture::Texture): + (gl::Texture::isFloatingPoint): + (gl::Texture::isRenderableFormat): + (gl::Texture::selectFormat): + (gl::Texture::loadImageData): + (gl::Texture::loadAlphaFloatImageData): + (gl::Texture::loadAlphaHalfFloatImageData): + (gl::Texture::loadLuminanceImageData): + (gl::Texture::loadLuminanceFloatImageData): + (gl::Texture::loadLuminanceHalfFloatImageData): + (gl::Texture::loadLuminanceAlphaImageData): + (gl::Texture::loadLuminanceAlphaFloatImageData): + (gl::Texture::loadLuminanceAlphaHalfFloatImageData): + (gl::Texture::loadRGBFloatImageData): + (gl::Texture::loadRGBHalfFloatImageData): + (gl::Texture::loadRGBAFloatImageData): + (gl::Texture::loadRGBAHalfFloatImageData): + (gl::Texture::createSurface): + (gl::Texture::setImage): + (gl::Texture::setCompressedImage): + (gl::Texture::subImage): + (gl::Texture::subImageCompressed): + (gl::Texture::copyNonRenderable): + (gl::Texture::getD3DFormat): + (gl::Texture::isRenderable): + (gl::Texture2D::Texture2D): + (gl::Texture2D::~Texture2D): + (gl::Texture2D::redefineTexture): + (gl::Texture2D::setImage): + (gl::Texture2D::setCompressedImage): + (gl::Texture2D::copyImage): + (gl::Texture2D::copySubImage): + (gl::Texture2D::isComplete): + (gl::Texture2D::createTexture): + (gl::Texture2D::convertToRenderTarget): + (gl::Texture2D::generateMipmaps): + (gl::Texture2D::getColorbuffer): + (gl::Texture2D::getRenderTarget): + (gl::TextureCubeMap::TextureCubeMap): + (gl::TextureCubeMap::~TextureCubeMap): + (gl::TextureCubeMap::subImage): + (gl::TextureCubeMap::subImageCompressed): + (gl::TextureCubeMap::isComplete): + (gl::TextureCubeMap::createTexture): + (gl::TextureCubeMap::convertToRenderTarget): + (gl::TextureCubeMap::redefineTexture): + (gl::TextureCubeMap::copyImage): + (gl::TextureCubeMap::copySubImage): + (gl::TextureCubeMap::generateMipmaps): + (gl::TextureCubeMap::getColorbuffer): + (gl::TextureCubeMap::getRenderTarget): + (gl::Texture::TextureColorbufferProxy::TextureColorbufferProxy): + (gl::Texture::TextureColorbufferProxy::isFloatingPoint): + * src/libGLESv2/Texture.h: + * src/libGLESv2/geometry/IndexDataManager.cpp: + (gl::IndexDataManager::IndexDataManager): + (gl::IndexDataManager::~IndexDataManager): + (gl::convertIndices): + (gl::computeRange): + (gl::IndexDataManager::prepareIndexData): + (gl::IndexDataManager::indexSize): + (gl::IndexDataManager::typeSize): + (gl::IndexBuffer::IndexBuffer): + (gl::IndexBuffer::~IndexBuffer): + (gl::IndexBuffer::getBuffer): + (gl::IndexBuffer::unmap): + (gl::StreamingIndexBuffer::StreamingIndexBuffer): + (gl::StreamingIndexBuffer::~StreamingIndexBuffer): + (gl::StreamingIndexBuffer::map): + (gl::StreamingIndexBuffer::reserveSpace): + (gl::StaticIndexBuffer::StaticIndexBuffer): + (gl::StaticIndexBuffer::~StaticIndexBuffer): + (gl::StaticIndexBuffer::map): + (gl::StaticIndexBuffer::reserveSpace): + (gl::StaticIndexBuffer::lookupType): + (gl::StaticIndexBuffer::lookupRange): + (gl::StaticIndexBuffer::addRange): + * src/libGLESv2/geometry/IndexDataManager.h: + (gl::IndexBuffer::size): + * src/libGLESv2/geometry/VertexDataManager.cpp: + (gl::VertexDataManager::VertexDataManager): + (gl::VertexDataManager::~VertexDataManager): + (gl::VertexDataManager::writeAttributeData): + (gl::VertexDataManager::prepareVertexData): + (gl::VertexDataManager::spaceRequired): + (gl::VertexDataManager::checkVertexCaps): + (gl::VertexDataManager::typeIndex): + (gl::VertexDataManager::setupAttributes): + (gl::VertexBuffer::VertexBuffer): + (gl::VertexBuffer::~VertexBuffer): + (gl::VertexBuffer::unmap): + (gl::VertexBuffer::getBuffer): + (gl::ConstantVertexBuffer::ConstantVertexBuffer): + (gl::ConstantVertexBuffer::~ConstantVertexBuffer): + (gl::ArrayVertexBuffer::ArrayVertexBuffer): + (gl::ArrayVertexBuffer::~ArrayVertexBuffer): + (gl::ArrayVertexBuffer::addRequiredSpace): + (gl::ArrayVertexBuffer::addRequiredSpaceFor): + (gl::StreamingVertexBuffer::StreamingVertexBuffer): + (gl::StreamingVertexBuffer::~StreamingVertexBuffer): + (gl::StreamingVertexBuffer::map): + (gl::StreamingVertexBuffer::reserveRequiredSpace): + (gl::StaticVertexBuffer::StaticVertexBuffer): + (gl::StaticVertexBuffer::~StaticVertexBuffer): + (gl::StaticVertexBuffer::map): + (gl::StaticVertexBuffer::reserveRequiredSpace): + (gl::StaticVertexBuffer::lookupAttribute): + (gl::VertexDataManager::formatConverter): + * src/libGLESv2/geometry/VertexDataManager.h: + (gl::ArrayVertexBuffer::size): + (gl::VertexDataManager::dirtyCurrentValue): + * src/libGLESv2/geometry/backend.cpp: Removed. + * src/libGLESv2/geometry/backend.h: Removed. + * src/libGLESv2/geometry/dx9.cpp: Removed. + * src/libGLESv2/geometry/dx9.h: Removed. + * src/libGLESv2/libGLESv2.cpp: + * src/libGLESv2/libGLESv2.def: + * src/libGLESv2/libGLESv2.vcproj: + * src/libGLESv2/utilities.cpp: + (gl::UniformComponentCount): + (gl::UniformComponentType): + (gl::ComputePixelSize): + (gl::CheckTextureFormatType): + (gl::IsColorRenderable): + (gl::IsDepthRenderable): + (gl::IsStencilRenderable): + (es2dx::GetAlphaSize): + (es2dx::GetRedSize): + (es2dx::GetGreenSize): + (es2dx::GetBlueSize): + (es2dx::GetDepthSize): + (es2dx::ConvertPrimitiveType): + (dx2es::ConvertBackBufferFormat): + (dx2es::ConvertDepthStencilFormat): + * src/libGLESv2/utilities.h: + 2011-01-17 Dan Bernstein <mitz@apple.com> Rubber-stamped by Mark Rowe. diff --git a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h index e0a5cc8..d0664e4 100644 --- a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h +++ b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h @@ -14,6 +14,66 @@ #ifdef __cplusplus extern "C" { #endif + +// Version number for shader translation API. +// It is incremented everytime the API changes. +#define SH_VERSION 103 + +// +// The names of the following enums have been derived by replacing GL prefix +// with SH. For example, SH_INFO_LOG_LENGTH is equivalent to GL_INFO_LOG_LENGTH. +// The enum values are also equal to the values of their GL counterpart. This +// is done to make it easier for applications to use the shader library. +// +typedef enum { + SH_FRAGMENT_SHADER = 0x8B30, + SH_VERTEX_SHADER = 0x8B31 +} ShShaderType; + +typedef enum { + SH_GLES2_SPEC = 0x8B40, + SH_WEBGL_SPEC = 0x8B41 +} ShShaderSpec; + +typedef enum { + SH_NONE = 0, + SH_INT = 0x1404, + SH_FLOAT = 0x1406, + SH_FLOAT_VEC2 = 0x8B50, + SH_FLOAT_VEC3 = 0x8B51, + SH_FLOAT_VEC4 = 0x8B52, + SH_INT_VEC2 = 0x8B53, + SH_INT_VEC3 = 0x8B54, + SH_INT_VEC4 = 0x8B55, + SH_BOOL = 0x8B56, + SH_BOOL_VEC2 = 0x8B57, + SH_BOOL_VEC3 = 0x8B58, + SH_BOOL_VEC4 = 0x8B59, + SH_FLOAT_MAT2 = 0x8B5A, + SH_FLOAT_MAT3 = 0x8B5B, + SH_FLOAT_MAT4 = 0x8B5C, + SH_SAMPLER_2D = 0x8B5E, + SH_SAMPLER_CUBE = 0x8B60 +} ShDataType; + +typedef enum { + SH_INFO_LOG_LENGTH = 0x8B84, + SH_OBJECT_CODE_LENGTH = 0x8B88, // GL_SHADER_SOURCE_LENGTH + SH_ACTIVE_UNIFORMS = 0x8B86, + SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, + SH_ACTIVE_ATTRIBUTES = 0x8B89, + SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A +} ShShaderInfo; + +// Compile options. +typedef enum { + SH_VALIDATE = 0, + SH_VALIDATE_LOOP_INDEXING = 0x0001, + SH_INTERMEDIATE_TREE = 0x0002, + SH_OBJECT_CODE = 0x0004, + SH_ATTRIBUTES_UNIFORMS = 0x0008 +} ShCompileOptions; + // // Driver must call this first, once, before doing any other // compiler operations. @@ -25,23 +85,6 @@ int ShInitialize(); // If the function succeeds, the return value is nonzero, else zero. // int ShFinalize(); -// -// Types of languages the compiler can consume. -// -typedef enum { - EShLangVertex, - EShLangFragment, - EShLangCount, -} EShLanguage; - -// -// The language specification compiler conforms to. -// It currently supports OpenGL ES and WebGL specifications. -// -typedef enum { - EShSpecGLES2, - EShSpecWebGL, -} EShSpec; // // Implementation dependent built-in resources (constants and extensions). @@ -62,27 +105,12 @@ typedef struct // Extensions. // Set to 1 to enable the extension, else 0. int OES_standard_derivatives; -} TBuiltInResource; +} ShBuiltInResources; // // Initialize built-in resources with minimum expected values. // -void ShInitBuiltInResource(TBuiltInResource* resources); - -// -// Optimization level for the compiler. -// -typedef enum { - EShOptNoGeneration, - EShOptNone, - EShOptSimple, // Optimizations that can be done quickly - EShOptFull, // Optimizations that will take more time -} EShOptimizationLevel; - -enum TDebugOptions { - EDebugOpNone = 0x000, - EDebugOpIntermediate = 0x001, // Writes intermediate tree into info-log. -}; +void ShInitBuiltInResources(ShBuiltInResources* resources); // // ShHandle held by but opaque to the driver. It is allocated, @@ -96,30 +124,130 @@ typedef void* ShHandle; // // Driver calls these to create and destroy compiler objects. // -ShHandle ShConstructCompiler(EShLanguage, EShSpec, const TBuiltInResource*); -void ShDestruct(ShHandle); +// Returns the handle of constructed compiler. +// Parameters: +// type: Specifies the type of shader - SH_FRAGMENT_SHADER or SH_VERTEX_SHADER. +// spec: Specifies the language spec the compiler must conform to - +// SH_GLES2_SPEC or SH_WEBGL_SPEC. +// resources: Specifies the built-in resources. +ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec, + const ShBuiltInResources* resources); +void ShDestruct(ShHandle handle); // -// The return value of ShCompile is boolean, indicating -// success or failure. -// -// The info-log should be written by ShCompile into -// ShHandle, so it can answer future queries. +// Compiles the given shader source. +// If the function succeeds, the return value is nonzero, else zero. +// Parameters: +// handle: Specifies the handle of compiler to be used. +// shaderStrings: Specifies an array of pointers to null-terminated strings +// containing the shader source code. +// numStrings: Specifies the number of elements in shaderStrings array. +// compileOptions: A mask containing the following parameters: +// SH_VALIDATE: Validates shader to ensure that it conforms to the spec +// specified during compiler construction. +// SH_VALIDATE_LOOP_INDEXING: Validates loop and indexing in the shader to +// ensure that they do not exceed the minimum +// functionality mandated in GLSL 1.0 spec, +// Appendix A, Section 4 and 5. +// There is no need to specify this parameter when +// compiling for WebGL - it is implied. +// SH_INTERMEDIATE_TREE: Writes intermediate tree to info log. +// Can be queried by calling ShGetInfoLog(). +// SH_OBJECT_CODE: Translates intermediate tree to glsl or hlsl shader. +// Can be queried by calling ShGetObjectCode(). +// SH_ATTRIBUTES_UNIFORMS: Extracts attributes and uniforms. +// Can be queried by calling ShGetActiveAttrib() and +// ShGetActiveUniform(). // int ShCompile( - const ShHandle, + const ShHandle handle, const char* const shaderStrings[], const int numStrings, - const EShOptimizationLevel, - int debugOptions + int compileOptions ); -// -// All the following return 0 if the information is not -// available in the object passed down, or the object is bad. -// -const char* ShGetInfoLog(const ShHandle); -const char* ShGetObjectCode(const ShHandle); +// Returns a parameter from a compiled shader. +// Parameters: +// handle: Specifies the compiler +// pname: Specifies the parameter to query. +// The following parameters are defined: +// SH_INFO_LOG_LENGTH: the number of characters in the information log +// including the null termination character. +// SH_OBJECT_CODE_LENGTH: the number of characters in the object code +// including the null termination character. +// SH_ACTIVE_ATTRIBUTES: the number of active attribute variables. +// SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: the length of the longest active attribute +// variable name including the null +// termination character. +// SH_ACTIVE_UNIFORMS: the number of active uniform variables. +// SH_ACTIVE_UNIFORM_MAX_LENGTH: the length of the longest active uniform +// variable name including the null +// termination character. +// +// params: Requested parameter +void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params); + +// Returns nul-terminated information log for a compiled shader. +// Parameters: +// handle: Specifies the compiler +// infoLog: Specifies an array of characters that is used to return +// the information log. It is assumed that infoLog has enough memory +// to accomodate the information log. The size of the buffer required +// to store the returned information log can be obtained by calling +// ShGetInfo with SH_INFO_LOG_LENGTH. +void ShGetInfoLog(const ShHandle handle, char* infoLog); + +// Returns null-terminated object code for a compiled shader. +// Parameters: +// handle: Specifies the compiler +// infoLog: Specifies an array of characters that is used to return +// the object code. It is assumed that infoLog has enough memory to +// accomodate the object code. The size of the buffer required to +// store the returned object code can be obtained by calling +// ShGetInfo with SH_OBJECT_CODE_LENGTH. +void ShGetObjectCode(const ShHandle handle, char* objCode); + +// Returns information about an active attribute variable. +// Parameters: +// handle: Specifies the compiler +// index: Specifies the index of the attribute variable to be queried. +// length: Returns the number of characters actually written in the string +// indicated by name (excluding the null terminator) if a value other +// than NULL is passed. +// size: Returns the size of the attribute variable. +// type: Returns the data type of the attribute variable. +// name: Returns a null terminated string containing the name of the +// attribute variable. It is assumed that name has enough memory to +// accomodate the attribute variable name. The size of the buffer +// required to store the attribute variable name can be obtained by +// calling ShGetInfo with SH_ACTIVE_ATTRIBUTE_MAX_LENGTH. +void ShGetActiveAttrib(const ShHandle handle, + int index, + int* length, + int* size, + ShDataType* type, + char* name); + +// Returns information about an active uniform variable. +// Parameters: +// handle: Specifies the compiler +// index: Specifies the index of the uniform variable to be queried. +// length: Returns the number of characters actually written in the string +// indicated by name (excluding the null terminator) if a value +// other than NULL is passed. +// size: Returns the size of the uniform variable. +// type: Returns the data type of the uniform variable. +// name: Returns a null terminated string containing the name of the +// uniform variable. It is assumed that name has enough memory to +// accomodate the uniform variable name. The size of the buffer required +// to store the uniform variable name can be obtained by calling +// ShGetInfo with SH_ACTIVE_UNIFORMS_MAX_LENGTH. +void ShGetActiveUniform(const ShHandle handle, + int index, + int* length, + int* size, + ShDataType* type, + char* name); #ifdef __cplusplus } diff --git a/Source/ThirdParty/ANGLE/src/build_angle.xcodeproj/project.pbxproj b/Source/ThirdParty/ANGLE/src/build_angle.xcodeproj/project.pbxproj index f118435..67f7e29 100644 --- a/Source/ThirdParty/ANGLE/src/build_angle.xcodeproj/project.pbxproj +++ b/Source/ThirdParty/ANGLE/src/build_angle.xcodeproj/project.pbxproj @@ -35,7 +35,6 @@ /* Begin PBXBuildFile section */ 05563ADFEA15116D7233332F /* QualifierAlive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4857E18799D332C30EF460C7 /* QualifierAlive.cpp */; }; 0A216949103E1E228F9C12F0 /* InitializeDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 60C3998C9CE66DE0C5B0FD99 /* InitializeDll.cpp */; }; - 0D4064167398A6892809A09E /* glslang_tab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A53D169CB849B861E15DF99A /* glslang_tab.cpp */; }; 3065D29E97FAC6E127388D15 /* Initialize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A54F2ED0D82D7BBCA4E9EEEA /* Initialize.cpp */; }; 32B1DBCD6B83F2146D787A62 /* atom.c in Sources */ = {isa = PBXBuildFile; fileRef = 0C9B4616A65A5ABEF91FD6DC /* atom.c */; }; 35BE1BBEE6135A1CB0608EA8 /* cppstruct.c in Sources */ = {isa = PBXBuildFile; fileRef = 8058A0A2A0A02386867517EA /* cppstruct.c */; }; @@ -45,7 +44,6 @@ 6F9F875017A68ABE5D39FF19 /* ParseHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976C831A75EBE009A9861796 /* ParseHelper.cpp */; }; 888F1382498E2D74AF2801C8 /* debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4ABA230FEA3654B030E4C4FB /* debug.cpp */; }; 9E8DFE1CCEF038BF2B65428C /* parseConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D2C9C8EB4A7EFF5B67FF9DBF /* parseConst.cpp */; }; - ABA5C61B1B78B9A8D69F6AEC /* glslang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB1F91D3D8CC446F35B00D1B /* glslang.cpp */; }; AC23F58FDD3C55F5CA18EED7 /* RemoveTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B436EFF06913FCB19C3522A7 /* RemoveTree.cpp */; }; AD85517F086FDCEF3947C403 /* symbols.c in Sources */ = {isa = PBXBuildFile; fileRef = F013A7240BDAE8A61413D8C0 /* symbols.c */; }; B4858417E54365BE8CDE3919 /* ossource_posix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE258486005F6696CC031622 /* ossource_posix.cpp */; }; @@ -60,8 +58,6 @@ FB3C505711F7924A0081F5BA /* CodeGenGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B7B1127C75B576FC00D74AED /* CodeGenGLSL.cpp */; }; FB3C505811F7924A0081F5BA /* OutputGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 48B7402CC07A059FEF5EC351 /* OutputGLSL.cpp */; }; FB3C505911F7924A0081F5BA /* TranslatorGLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6FB70DC74A21FBCD665ABDF9 /* TranslatorGLSL.cpp */; }; - FB3C508E11F7949E0081F5BA /* glslang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB1F91D3D8CC446F35B00D1B /* glslang.cpp */; }; - FB3C508F11F7949E0081F5BA /* glslang_tab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A53D169CB849B861E15DF99A /* glslang_tab.cpp */; }; FB3C509211F794CE0081F5BA /* debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4ABA230FEA3654B030E4C4FB /* debug.cpp */; }; FB3C509311F794CE0081F5BA /* InfoSink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E6927BE5D3C2C82F86111DF /* InfoSink.cpp */; }; FB3C509411F794CE0081F5BA /* Initialize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A54F2ED0D82D7BBCA4E9EEEA /* Initialize.cpp */; }; @@ -133,6 +129,10 @@ 5A21599C59BC1A75A7FABA34 /* OutputHLSL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OutputHLSL.h; sourceTree = "<group>"; }; 60C3998C9CE66DE0C5B0FD99 /* InitializeDll.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InitializeDll.cpp; sourceTree = "<group>"; }; 6BBC8224B9D8E234D117FA0C /* preprocess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = preprocess.h; sourceTree = "<group>"; }; + 6E02565112E6934D00B3431F /* glslang_lex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glslang_lex.cpp; sourceTree = "<group>"; }; + 6E02565212E6934D00B3431F /* glslang_tab.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glslang_tab.cpp; sourceTree = "<group>"; }; + 6E02565312E6934D00B3431F /* glslang_tab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glslang_tab.h; sourceTree = "<group>"; }; + 6E02565412E6934D00B3431F /* glslang.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glslang.h; sourceTree = "<group>"; }; 6E6927BE5D3C2C82F86111DF /* InfoSink.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InfoSink.cpp; sourceTree = "<group>"; }; 6FB70DC74A21FBCD665ABDF9 /* TranslatorGLSL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TranslatorGLSL.cpp; sourceTree = "<group>"; }; 799DC9611EE2EA3BA7CF5477 /* intermediate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = intermediate.h; sourceTree = "<group>"; }; @@ -143,7 +143,6 @@ 8513FAC699DB1558D1D49A48 /* Initialize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Initialize.h; sourceTree = "<group>"; }; 85845FFF5A8E63364308236D /* InitializeParseContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InitializeParseContext.h; sourceTree = "<group>"; }; 89A6F7B1AD3918E64DF76EB1 /* slglobals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = slglobals.h; sourceTree = "<group>"; }; - 8C3225C2F8C3573CD9725E66 /* glslang.y */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.yacc; path = glslang.y; sourceTree = "<group>"; }; 93D61CB0BCE54E069D71F920 /* OutputGLSL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OutputGLSL.h; sourceTree = "<group>"; }; 95276AA6B36FC1B1D913FCE4 /* debug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = "<group>"; }; 976C831A75EBE009A9861796 /* ParseHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ParseHelper.cpp; sourceTree = "<group>"; }; @@ -151,8 +150,6 @@ 9CED3AFF1E61B45EE1005656 /* atom.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = atom.h; sourceTree = "<group>"; }; 9D47B1AC82E4EE859AC54243 /* QualifierAlive.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QualifierAlive.h; sourceTree = "<group>"; }; A0CE43631849276A31187C7B /* InitializeDll.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InitializeDll.h; sourceTree = "<group>"; }; - A3153D58F4BBBD98A84E4210 /* glslang.l */ = {isa = PBXFileReference; lastKnownFileType = text; path = glslang.l; sourceTree = "<group>"; }; - A53D169CB849B861E15DF99A /* glslang_tab.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = glslang_tab.cpp; sourceTree = "<group>"; }; A54F2ED0D82D7BBCA4E9EEEA /* Initialize.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Initialize.cpp; sourceTree = "<group>"; }; AA53B6632C76F905DF08E564 /* Types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Types.h; sourceTree = "<group>"; }; AE65E139AE10DE9EFAD8D5B1 /* ShHandle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShHandle.h; sourceTree = "<group>"; }; @@ -163,13 +160,11 @@ B75707B393B7EAB7DD9999CB /* cpp.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpp.c; sourceTree = "<group>"; }; B7B1127C75B576FC00D74AED /* CodeGenGLSL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGenGLSL.cpp; sourceTree = "<group>"; }; B7E5B0F04635E6090F0DE8EF /* SymbolTable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolTable.cpp; sourceTree = "<group>"; }; - BC66D6B47D9AF3286644BBE1 /* glslang_tab.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = glslang_tab.h; sourceTree = "<group>"; }; BE258486005F6696CC031622 /* ossource_posix.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ossource_posix.cpp; sourceTree = "<group>"; }; C3DAFF6BF12BB7F4784D6C7E /* TranslatorHLSL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TranslatorHLSL.cpp; sourceTree = "<group>"; }; C49549DCCAF450EB761520E1 /* CodeGenHLSL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGenHLSL.cpp; sourceTree = "<group>"; }; C4FE988EF9A293867E5C771B /* IntermTraverse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IntermTraverse.cpp; sourceTree = "<group>"; }; C8BD59BD7056FFC21373C50A /* osinclude.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = osinclude.h; sourceTree = "<group>"; }; - CB1F91D3D8CC446F35B00D1B /* glslang.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = glslang.cpp; sourceTree = "<group>"; }; CEE0C90DF6D504D1F3629711 /* ParseHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ParseHelper.h; sourceTree = "<group>"; }; CF2B62E0820C831AF812D000 /* build_angle.gyp */ = {isa = PBXFileReference; lastKnownFileType = text; path = build_angle.gyp; sourceTree = "<group>"; }; CFD12C6E46EBE0839BBE52B5 /* parser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = parser.h; sourceTree = "<group>"; }; @@ -233,6 +228,10 @@ 196DB6AB006BB83503C7D786 /* Source */ = { isa = PBXGroup; children = ( + 6E02565112E6934D00B3431F /* glslang_lex.cpp */, + 6E02565212E6934D00B3431F /* glslang_tab.cpp */, + 6E02565312E6934D00B3431F /* glslang_tab.h */, + 6E02565412E6934D00B3431F /* glslang.h */, 0E8D65F584FDB84DAABD3969 /* preprocessor */, 27E4C7ED0B82E18DCBEDF1C9 /* BaseTypes.h */, B7B1127C75B576FC00D74AED /* CodeGenGLSL.cpp */, @@ -275,8 +274,6 @@ 2A765B86CBAF0D4A3E69DCA7 /* UnfoldSelect.h */, 4ABA230FEA3654B030E4C4FB /* debug.cpp */, 95276AA6B36FC1B1D913FCE4 /* debug.h */, - A3153D58F4BBBD98A84E4210 /* glslang.l */, - 8C3225C2F8C3573CD9725E66 /* glslang.y */, DEAF6F3126C2EC4397785C3F /* intermOut.cpp */, 799DC9611EE2EA3BA7CF5477 /* intermediate.h */, 153BF06BF12C6F50496C6156 /* localintermediate.h */, @@ -289,21 +286,10 @@ path = compiler; sourceTree = "<group>"; }; - 466E1D0531A79B5813E8A7F8 /* Intermediates */ = { - isa = PBXGroup; - children = ( - CB1F91D3D8CC446F35B00D1B /* glslang.cpp */, - A53D169CB849B861E15DF99A /* glslang_tab.cpp */, - BC66D6B47D9AF3286644BBE1 /* glslang_tab.h */, - ); - name = Intermediates; - sourceTree = INTERMEDIATE_DIR; - }; 5BBEFF9B91738297B95C568D = { isa = PBXGroup; children = ( 196DB6AB006BB83503C7D786 /* Source */, - 466E1D0531A79B5813E8A7F8 /* Intermediates */, E0EDC4130E7D374318CE72BE /* Products */, B2C184C3543198BA51592EA4 /* Build */, ); @@ -373,7 +359,6 @@ }; buildConfigurationList = 0E59F8FE4A8099E8DDCA4CE7 /* Build configuration list for PBXProject "build_angle" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, @@ -457,8 +442,6 @@ F098F463EDABCF0769007678 /* scanner.c in Sources */, AD85517F086FDCEF3947C403 /* symbols.c in Sources */, E8C727AA8E9DC5E7B58857DF /* tokens.c in Sources */, - ABA5C61B1B78B9A8D69F6AEC /* glslang.cpp in Sources */, - 0D4064167398A6892809A09E /* glslang_tab.cpp in Sources */, B4858417E54365BE8CDE3919 /* ossource_posix.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -476,7 +459,6 @@ FB3C50A811F794FF0081F5BA /* scanner.c in Sources */, FB3C50A911F794FF0081F5BA /* symbols.c in Sources */, FB3C50AA11F794FF0081F5BA /* tokens.c in Sources */, - FB3C508E11F7949E0081F5BA /* glslang.cpp in Sources */, FB3C505711F7924A0081F5BA /* CodeGenGLSL.cpp in Sources */, FB3C509211F794CE0081F5BA /* debug.cpp in Sources */, FB3C509311F794CE0081F5BA /* InfoSink.cpp in Sources */, @@ -495,7 +477,6 @@ FB3C50A011F794CE0081F5BA /* ShaderLang.cpp in Sources */, FB3C50A111F794CE0081F5BA /* SymbolTable.cpp in Sources */, FB3C505911F7924A0081F5BA /* TranslatorGLSL.cpp in Sources */, - FB3C508F11F7949E0081F5BA /* glslang_tab.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/ThirdParty/ANGLE/src/common/debug.cpp b/Source/ThirdParty/ANGLE/src/common/debug.cpp index d8d6ab8..3de5d4e 100644 --- a/Source/ThirdParty/ANGLE/src/common/debug.cpp +++ b/Source/ThirdParty/ANGLE/src/common/debug.cpp @@ -11,17 +11,22 @@ #include <stdio.h> #include <stdarg.h> +#ifndef TRACE_OUTPUT_FILE +#define TRACE_OUTPUT_FILE "debug.txt" +#endif + static bool trace_on = true; namespace gl { void trace(const char *format, ...) { +#if !defined(ANGLE_DISABLE_TRACE) if (trace_on) { if (format) { - FILE *file = fopen("debug.txt", "a"); + FILE *file = fopen(TRACE_OUTPUT_FILE, "a"); if (file) { @@ -34,5 +39,6 @@ void trace(const char *format, ...) } } } +#endif // !defined(ANGLE_DISABLE_TRACE) } } diff --git a/Source/ThirdParty/ANGLE/src/common/debug.h b/Source/ThirdParty/ANGLE/src/common/debug.h index 9a5135b..2c4ec70 100644 --- a/Source/ThirdParty/ANGLE/src/common/debug.h +++ b/Source/ThirdParty/ANGLE/src/common/debug.h @@ -19,7 +19,7 @@ namespace gl } // A macro to output a trace of a function call and its arguments to the debugging log -#ifndef NDEBUG +#if !defined(NDEBUG) && !defined(ANGLE_DISABLE_TRACE) #define TRACE(message, ...) gl::trace("trace: %s"message"\n", __FUNCTION__, __VA_ARGS__) #else #define TRACE(...) ((void)0) diff --git a/Source/ThirdParty/ANGLE/src/compiler/CodeGenGLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/CodeGenGLSL.cpp index 855b092..d140b37 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/CodeGenGLSL.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/CodeGenGLSL.cpp @@ -11,9 +11,9 @@ // compile object used by higher level code. It returns // a subclass of TCompiler. // -TCompiler* ConstructCompiler(EShLanguage language, EShSpec spec) +TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec) { - return new TranslatorGLSL(language, spec); + return new TranslatorGLSL(type, spec); } // diff --git a/Source/ThirdParty/ANGLE/src/compiler/CodeGenHLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/CodeGenHLSL.cpp index 4db771d..e04e789 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/CodeGenHLSL.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/CodeGenHLSL.cpp @@ -11,9 +11,9 @@ // compile object used by higher level code. It returns // a subclass of TCompiler. // -TCompiler* ConstructCompiler(EShLanguage language, EShSpec spec) +TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec) { - return new TranslatorHLSL(language, spec); + return new TranslatorHLSL(type, spec); } // diff --git a/Source/ThirdParty/ANGLE/src/compiler/Common.h b/Source/ThirdParty/ANGLE/src/compiler/Common.h index 65d0a51..27a5598 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/Common.h +++ b/Source/ThirdParty/ANGLE/src/compiler/Common.h @@ -14,9 +14,24 @@ #include "compiler/PoolAlloc.h" +// We need two pieces of information to report errors/warnings - string and +// line number. We encode these into a single int so that it can be easily +// incremented/decremented by lexer. The right SOURCE_LOC_LINE_SIZE bits store +// line number while the rest store the string number. Since the shaders are +// usually small, we should not run out of memory. SOURCE_LOC_LINE_SIZE +// can be increased to alleviate this issue. typedef int TSourceLoc; -const unsigned int SourceLocLineMask = 0xffff; -const unsigned int SourceLocStringShift = 16; +const unsigned int SOURCE_LOC_LINE_SIZE = 16; // in bits. +const unsigned int SOURCE_LOC_LINE_MASK = (1 << SOURCE_LOC_LINE_SIZE) - 1; + +inline TSourceLoc EncodeSourceLoc(int string, int line) { + return (string << SOURCE_LOC_LINE_SIZE) | (line & SOURCE_LOC_LINE_MASK); +} + +inline void DecodeSourceLoc(TSourceLoc loc, int* string, int* line) { + if (string) *string = loc >> SOURCE_LOC_LINE_SIZE; + if (line) *line = loc & SOURCE_LOC_LINE_MASK; +} // // Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme. @@ -71,6 +86,4 @@ public: TMap(const tAllocator& a) : std::map<K, D, CMP, tAllocator>(std::map<K, D, CMP, tAllocator>::key_compare(), a) {} }; -typedef TMap<TString, TString> TPragmaTable; - #endif // _COMMON_INCLUDED_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp b/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp new file mode 100644 index 0000000..649b457 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp @@ -0,0 +1,189 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/Initialize.h" +#include "compiler/ParseHelper.h" +#include "compiler/ShHandle.h" +#include "compiler/ValidateLimitations.h" + +namespace { +bool InitializeSymbolTable( + const TBuiltInStrings& builtInStrings, + ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources, + TInfoSink& infoSink, TSymbolTable& symbolTable) +{ + TIntermediate intermediate(infoSink); + TExtensionBehavior extBehavior; + TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, infoSink); + + GlobalParseContext = &parseContext; + + assert(symbolTable.isEmpty()); + // + // Parse the built-ins. This should only happen once per + // language symbol table. + // + // Push the symbol table to give it an initial scope. This + // push should not have a corresponding pop, so that built-ins + // are preserved, and the test for an empty table fails. + // + symbolTable.push(); + + for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i) + { + const char* builtInShaders = i->c_str(); + int builtInLengths = static_cast<int>(i->size()); + if (builtInLengths <= 0) + continue; + + if (PaParseStrings(1, &builtInShaders, &builtInLengths, &parseContext) != 0) + { + infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins"); + return false; + } + } + + IdentifyBuiltIns(type, spec, resources, symbolTable); + + return true; +} + +class TScopedPoolAllocator { +public: + TScopedPoolAllocator(TPoolAllocator* allocator, bool pushPop) + : mAllocator(allocator), mPushPopAllocator(pushPop) { + if (mPushPopAllocator) mAllocator->push(); + SetGlobalPoolAllocator(mAllocator); + } + ~TScopedPoolAllocator() { + SetGlobalPoolAllocator(NULL); + if (mPushPopAllocator) mAllocator->pop(); + } + +private: + TPoolAllocator* mAllocator; + bool mPushPopAllocator; +}; +} // namespace + +TShHandleBase::TShHandleBase() { + allocator.push(); + SetGlobalPoolAllocator(&allocator); +} + +TShHandleBase::~TShHandleBase() { + SetGlobalPoolAllocator(NULL); + allocator.popAll(); +} + +TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec) + : shaderType(type), + shaderSpec(spec) +{ +} + +TCompiler::~TCompiler() +{ +} + +bool TCompiler::Init(const ShBuiltInResources& resources) +{ + TScopedPoolAllocator scopedAlloc(&allocator, false); + + // Generate built-in symbol table. + if (!InitBuiltInSymbolTable(resources)) + return false; + InitExtensionBehavior(resources, extensionBehavior); + + return true; +} + +bool TCompiler::compile(const char* const shaderStrings[], + const int numStrings, + int compileOptions) +{ + TScopedPoolAllocator scopedAlloc(&allocator, true); + clearResults(); + + if (numStrings == 0) + return true; + + // If compiling for WebGL, validate loop and indexing as well. + if (shaderSpec == SH_WEBGL_SPEC) + compileOptions |= SH_VALIDATE_LOOP_INDEXING; + + TIntermediate intermediate(infoSink); + TParseContext parseContext(symbolTable, extensionBehavior, intermediate, + shaderType, shaderSpec, infoSink); + GlobalParseContext = &parseContext; + + // We preserve symbols at the built-in level from compile-to-compile. + // Start pushing the user-defined symbols at global level. + symbolTable.push(); + if (!symbolTable.atGlobalLevel()) + infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); + + // Parse shader. + bool success = + (PaParseStrings(numStrings, shaderStrings, NULL, &parseContext) == 0) && + (parseContext.treeRoot != NULL); + if (success) { + TIntermNode* root = parseContext.treeRoot; + success = intermediate.postProcess(root); + + if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING)) + success = validateLimitations(root); + + if (success && (compileOptions & SH_INTERMEDIATE_TREE)) + intermediate.outputTree(root); + + if (success && (compileOptions & SH_OBJECT_CODE)) + translate(root); + + if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) + collectAttribsUniforms(root); + } + + // Cleanup memory. + intermediate.remove(parseContext.treeRoot); + // Ensure symbol table is returned to the built-in level, + // throwing away all but the built-ins. + while (!symbolTable.atBuiltInLevel()) + symbolTable.pop(); + + return success; +} + +bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources& resources) +{ + TBuiltIns builtIns; + + builtIns.initialize(shaderType, shaderSpec, resources); + return InitializeSymbolTable(builtIns.getBuiltInStrings(), + shaderType, shaderSpec, resources, infoSink, symbolTable); +} + +void TCompiler::clearResults() +{ + infoSink.info.erase(); + infoSink.obj.erase(); + infoSink.debug.erase(); + + attribs.clear(); + uniforms.clear(); +} + +bool TCompiler::validateLimitations(TIntermNode* root) { + ValidateLimitations validate(shaderType, infoSink.info); + root->traverse(&validate); + return validate.numErrors() == 0; +} + +void TCompiler::collectAttribsUniforms(TIntermNode* root) +{ + CollectAttribsUniforms collect(attribs, uniforms); + root->traverse(&collect); +} diff --git a/Source/ThirdParty/ANGLE/src/compiler/ExtensionBehavior.h b/Source/ThirdParty/ANGLE/src/compiler/ExtensionBehavior.h new file mode 100644 index 0000000..da96c24 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/ExtensionBehavior.h @@ -0,0 +1,21 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef _EXTENSION_BEHAVIOR_INCLUDED_ +#define _EXTENSION_BEHAVIOR_INCLUDED_ + +#include "compiler/Common.h" + +typedef enum { + EBhRequire, + EBhEnable, + EBhWarn, + EBhDisable +} TBehavior; + +typedef TMap<TString, TBehavior> TExtensionBehavior; + +#endif // _EXTENSION_TABLE_INCLUDED_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/InfoSink.cpp b/Source/ThirdParty/ANGLE/src/compiler/InfoSink.cpp index 317a88f..ba32f78 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/InfoSink.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/InfoSink.cpp @@ -32,8 +32,8 @@ void TInfoSinkBase::prefix(TPrefixType message) { } void TInfoSinkBase::location(TSourceLoc loc) { - int string = loc >> SourceLocStringShift; - int line = loc & SourceLocLineMask; + int string = 0, line = 0; + DecodeSourceLoc(loc, &string, &line); TPersistStringStream stream; if (line) diff --git a/Source/ThirdParty/ANGLE/src/compiler/InfoSink.h b/Source/ThirdParty/ANGLE/src/compiler/InfoSink.h index 4762778..e2224e9 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/InfoSink.h +++ b/Source/ThirdParty/ANGLE/src/compiler/InfoSink.h @@ -91,6 +91,7 @@ public: } void erase() { sink.clear(); } + int size() { return static_cast<int>(sink.size()); } const TPersistString& str() const { return sink; } const char* c_str() const { return sink.c_str(); } diff --git a/Source/ThirdParty/ANGLE/src/compiler/Initialize.cpp b/Source/ThirdParty/ANGLE/src/compiler/Initialize.cpp index 6bfcf4f..12b53fe 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/Initialize.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/Initialize.cpp @@ -311,15 +311,6 @@ static TString BuiltInFunctionsCommon() s.append(TString("bvec4 not(bvec4 x);")); // - // Texture Functions. - // - s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);")); - s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);")); - s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);")); - - s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);")); - - // // Noise functions. // //s.append(TString("float noise1(float x);")); @@ -342,7 +333,6 @@ static TString BuiltInFunctionsCommon() //s.append(TString("vec4 noise4(vec3 x);")); //s.append(TString("vec4 noise4(vec4 x);")); - s.append(TString("\n")); return s; } @@ -351,7 +341,7 @@ static TString BuiltInFunctionsCommon() // Prototypes for built-in functions seen by vertex shaders only. // //============================================================================ -static TString BuiltInFunctionsVertex() +static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources) { TString s; @@ -363,12 +353,18 @@ static TString BuiltInFunctionsVertex() // // Texture Functions. // - s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);")); - s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);")); - s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);")); - s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);")); + if (resources.MaxVertexTextureImageUnits > 0) { + s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);")); + s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);")); + s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);")); + s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);")); + + s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);")); + s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);")); + s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);")); + s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);")); + } - s.append(TString("\n")); return s; } @@ -377,34 +373,40 @@ static TString BuiltInFunctionsVertex() // Prototypes for built-in functions seen by fragment shaders only. // //============================================================================ -static TString BuiltInFunctionsFragment() +static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources) { TString s; // // Texture Functions. // + s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);")); + s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);")); + s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);")); + s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);")); + s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);")); s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);")); s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);")); - //s.append(TString("float dFdx(float p);")); - //s.append(TString("vec2 dFdx(vec2 p);")); - //s.append(TString("vec3 dFdx(vec3 p);")); - //s.append(TString("vec4 dFdx(vec4 p);")); - - //s.append(TString("float dFdy(float p);")); - //s.append(TString("vec2 dFdy(vec2 p);")); - //s.append(TString("vec3 dFdy(vec3 p);")); - //s.append(TString("vec4 dFdy(vec4 p);")); - - s.append(TString("float fwidth(float p);")); - s.append(TString("vec2 fwidth(vec2 p);")); - s.append(TString("vec3 fwidth(vec3 p);")); - s.append(TString("vec4 fwidth(vec4 p);")); + if (resources.OES_standard_derivatives) { + s.append(TString("float dFdx(float p);")); + s.append(TString("vec2 dFdx(vec2 p);")); + s.append(TString("vec3 dFdx(vec3 p);")); + s.append(TString("vec4 dFdx(vec4 p);")); + + s.append(TString("float dFdy(float p);")); + s.append(TString("vec2 dFdy(vec2 p);")); + s.append(TString("vec3 dFdy(vec3 p);")); + s.append(TString("vec4 dFdy(vec4 p);")); + + s.append(TString("float fwidth(float p);")); + s.append(TString("vec2 fwidth(vec2 p);")); + s.append(TString("vec3 fwidth(vec3 p);")); + s.append(TString("vec4 fwidth(vec4 p);")); + } - s.append(TString("\n")); return s; } @@ -427,7 +429,6 @@ static TString StandardUniforms() s.append(TString("};")); s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;")); - s.append(TString("\n")); return s; } @@ -443,7 +444,6 @@ static TString DefaultPrecisionVertex() s.append(TString("precision highp int;")); s.append(TString("precision highp float;")); - s.append(TString("\n")); return s; } @@ -459,7 +459,6 @@ static TString DefaultPrecisionFragment() s.append(TString("precision mediump int;")); // No default precision for float in fragment shaders - s.append(TString("\n")); return s; } @@ -468,7 +467,7 @@ static TString DefaultPrecisionFragment() // Implementation dependent built-in constants. // //============================================================================ -static TString BuiltInConstants(const TBuiltInResource &resources) +static TString BuiltInConstants(const ShBuiltInResources &resources) { TStringStream s; @@ -485,20 +484,21 @@ static TString BuiltInConstants(const TBuiltInResource &resources) return s.str(); } -void TBuiltIns::initialize(EShLanguage language, EShSpec spec, const TBuiltInResource& resources) +void TBuiltIns::initialize(ShShaderType type, ShShaderSpec spec, + const ShBuiltInResources& resources) { - switch (language) { - case EShLangFragment: + switch (type) { + case SH_FRAGMENT_SHADER: builtInStrings.push_back(DefaultPrecisionFragment()); builtInStrings.push_back(BuiltInFunctionsCommon()); - builtInStrings.push_back(BuiltInFunctionsFragment()); + builtInStrings.push_back(BuiltInFunctionsFragment(resources)); builtInStrings.push_back(StandardUniforms()); break; - case EShLangVertex: + case SH_VERTEX_SHADER: builtInStrings.push_back(DefaultPrecisionVertex()); builtInStrings.push_back(BuiltInFunctionsCommon()); - builtInStrings.push_back(BuiltInFunctionsVertex()); + builtInStrings.push_back(BuiltInFunctionsVertex(resources)); builtInStrings.push_back(StandardUniforms()); break; @@ -508,14 +508,16 @@ void TBuiltIns::initialize(EShLanguage language, EShSpec spec, const TBuiltInRes builtInStrings.push_back(BuiltInConstants(resources)); } -void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource& resources, TSymbolTable& symbolTable) +void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, + const ShBuiltInResources& resources, + TSymbolTable& symbolTable) { // // First, insert some special built-in variables that are not in // the built-in header files. // - switch(language) { - case EShLangFragment: + switch(type) { + case SH_FRAGMENT_SHADER: symbolTable.insert(*new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); symbolTable.insert(*new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); @@ -523,7 +525,7 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource symbolTable.insert(*new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); break; - case EShLangVertex: + case SH_VERTEX_SHADER: symbolTable.insert(*new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); symbolTable.insert(*new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); break; @@ -591,20 +593,26 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource symbolTable.relateToOperator("all", EOpAll); // Map language-specific operators. - switch(language) { - case EShLangVertex: + switch(type) { + case SH_VERTEX_SHADER: break; - case EShLangFragment: - //symbolTable.relateToOperator("dFdx", EOpDPdx); // OES_standard_derivatives extension - //symbolTable.relateToOperator("dFdy", EOpDPdy); // OES_standard_derivatives extension - //symbolTable.relateToOperator("fwidth", EOpFwidth); // OES_standard_derivatives extension + case SH_FRAGMENT_SHADER: + if (resources.OES_standard_derivatives) { + symbolTable.relateToOperator("dFdx", EOpDFdx); + symbolTable.relateToOperator("dFdy", EOpDFdy); + symbolTable.relateToOperator("fwidth", EOpFwidth); + + symbolTable.relateToExtension("dFdx", "GL_OES_standard_derivatives"); + symbolTable.relateToExtension("dFdy", "GL_OES_standard_derivatives"); + symbolTable.relateToExtension("fwidth", "GL_OES_standard_derivatives"); + } break; default: break; } // Finally add resource-specific variables. - switch(language) { - case EShLangFragment: { + switch(type) { + case SH_FRAGMENT_SHADER: { // Set up gl_FragData. The array size. TType fragData(EbtFloat, EbpMedium, EvqFragColor, 4, false, true); fragData.setArraySize(resources.MaxDrawBuffers); @@ -615,3 +623,9 @@ void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource } } +void InitExtensionBehavior(const ShBuiltInResources& resources, + TExtensionBehavior& extBehavior) +{ + if (resources.OES_standard_derivatives) + extBehavior["GL_OES_standard_derivatives"] = EBhDisable; +} diff --git a/Source/ThirdParty/ANGLE/src/compiler/Initialize.h b/Source/ThirdParty/ANGLE/src/compiler/Initialize.h index c078659..8b0adc6 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/Initialize.h +++ b/Source/ThirdParty/ANGLE/src/compiler/Initialize.h @@ -17,17 +17,19 @@ class TBuiltIns { public: POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) - void initialize(EShLanguage language, EShSpec spec, const TBuiltInResource& resources); + void initialize(ShShaderType type, ShShaderSpec spec, + const ShBuiltInResources& resources); const TBuiltInStrings& getBuiltInStrings() { return builtInStrings; } protected: TBuiltInStrings builtInStrings; }; -void IdentifyBuiltIns(EShLanguage language, EShSpec spec, const TBuiltInResource& resources, +void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, + const ShBuiltInResources& resources, TSymbolTable& symbolTable); -extern "C" int InitPreprocessor(void); -extern "C" int FinalizePreprocessor(void); +void InitExtensionBehavior(const ShBuiltInResources& resources, + TExtensionBehavior& extensionBehavior); #endif // _INITIALIZE_INCLUDED_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/IntermTraverse.cpp b/Source/ThirdParty/ANGLE/src/compiler/IntermTraverse.cpp index 34a6f3c..a13877f 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/IntermTraverse.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/IntermTraverse.cpp @@ -229,9 +229,9 @@ void TIntermLoop::traverse(TIntermTraverser* it) if(it->rightToLeft) { - if(terminal) + if(expr) { - terminal->traverse(it); + expr->traverse(it); } if(body) @@ -239,16 +239,16 @@ void TIntermLoop::traverse(TIntermTraverser* it) body->traverse(it); } - if(test) + if(cond) { - test->traverse(it); + cond->traverse(it); } } else { - if(test) + if(cond) { - test->traverse(it); + cond->traverse(it); } if(body) @@ -256,9 +256,9 @@ void TIntermLoop::traverse(TIntermTraverser* it) body->traverse(it); } - if(terminal) + if(expr) { - terminal->traverse(it); + expr->traverse(it); } } diff --git a/Source/ThirdParty/ANGLE/src/compiler/Intermediate.cpp b/Source/ThirdParty/ANGLE/src/compiler/Intermediate.cpp index 5ebd919..ea71234 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/Intermediate.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/Intermediate.cpp @@ -22,6 +22,101 @@ static TPrecision GetHigherPrecision( TPrecision left, TPrecision right ){ return left > right ? left : right; } +const char* getOperatorString(TOperator op) { + switch (op) { + case EOpInitialize: return "="; + case EOpAssign: return "="; + case EOpAddAssign: return "+="; + case EOpSubAssign: return "-="; + case EOpDivAssign: return "/="; + + // Fall-through. + case EOpMulAssign: + case EOpVectorTimesMatrixAssign: + case EOpVectorTimesScalarAssign: + case EOpMatrixTimesScalarAssign: + case EOpMatrixTimesMatrixAssign: return "*="; + + // Fall-through. + case EOpIndexDirect: + case EOpIndexIndirect: return "[]"; + + case EOpIndexDirectStruct: return "."; + case EOpVectorSwizzle: return "."; + case EOpAdd: return "+"; + case EOpSub: return "-"; + case EOpMul: return "*"; + case EOpDiv: return "/"; + case EOpMod: UNIMPLEMENTED(); break; + case EOpEqual: return "=="; + case EOpNotEqual: return "!="; + case EOpLessThan: return "<"; + case EOpGreaterThan: return ">"; + case EOpLessThanEqual: return "<="; + case EOpGreaterThanEqual: return ">="; + + // Fall-through. + case EOpVectorTimesScalar: + case EOpVectorTimesMatrix: + case EOpMatrixTimesVector: + case EOpMatrixTimesScalar: + case EOpMatrixTimesMatrix: return "*"; + + case EOpLogicalOr: return "||"; + case EOpLogicalXor: return "^^"; + case EOpLogicalAnd: return "&&"; + case EOpNegative: return "-"; + case EOpVectorLogicalNot: return "not"; + case EOpLogicalNot: return "!"; + case EOpPostIncrement: return "++"; + case EOpPostDecrement: return "--"; + case EOpPreIncrement: return "++"; + case EOpPreDecrement: return "--"; + + // Fall-through. + case EOpConvIntToBool: + case EOpConvFloatToBool: return "bool"; + + // Fall-through. + case EOpConvBoolToFloat: + case EOpConvIntToFloat: return "float"; + + // Fall-through. + case EOpConvFloatToInt: + case EOpConvBoolToInt: return "int"; + + case EOpRadians: return "radians"; + case EOpDegrees: return "degrees"; + case EOpSin: return "sin"; + case EOpCos: return "cos"; + case EOpTan: return "tan"; + case EOpAsin: return "asin"; + case EOpAcos: return "acos"; + case EOpAtan: return "atan"; + case EOpExp: return "exp"; + case EOpLog: return "log"; + case EOpExp2: return "exp2"; + case EOpLog2: return "log2"; + case EOpSqrt: return "sqrt"; + case EOpInverseSqrt: return "inversesqrt"; + case EOpAbs: return "abs"; + case EOpSign: return "sign"; + case EOpFloor: return "floor"; + case EOpCeil: return "ceil"; + case EOpFract: return "fract"; + case EOpLength: return "length"; + case EOpNormalize: return "normalize"; + case EOpDFdx: return "dFdx"; + case EOpDFdy: return "dFdy"; + case EOpFwidth: return "fwidth"; + case EOpAny: return "any"; + case EOpAll: return "all"; + + default: break; + } + return ""; +} + //////////////////////////////////////////////////////////////////////////// // // First set of functions are to help build the intermediate representation. @@ -51,18 +146,23 @@ TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TSymbolTable& symbolTable) { switch (op) { + case EOpEqual: + case EOpNotEqual: + if (left->isArray()) + return 0; + break; case EOpLessThan: case EOpGreaterThan: case EOpLessThanEqual: case EOpGreaterThanEqual: - if (left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector() || left->getType().getBasicType() == EbtStruct) { + if (left->isMatrix() || left->isArray() || left->isVector() || left->getBasicType() == EbtStruct) { return 0; } break; case EOpLogicalOr: case EOpLogicalXor: case EOpLogicalAnd: - if (left->getType().getBasicType() != EbtBool || left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector()) { + if (left->getBasicType() != EbtBool || left->isMatrix() || left->isArray() || left->isVector()) { return 0; } break; @@ -70,7 +170,7 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn case EOpSub: case EOpDiv: case EOpMul: - if (left->getType().getBasicType() == EbtStruct || left->getType().getBasicType() == EbtBool) + if (left->getBasicType() == EbtStruct || left->getBasicType() == EbtBool) return 0; default: break; } @@ -78,8 +178,10 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn // // First try converting the children to compatible types. // - - if (!(left->getType().getStruct() && right->getType().getStruct())) { + if (left->getType().getStruct() && right->getType().getStruct()) { + if (left->getType() != right->getType()) + return 0; + } else { TIntermTyped* child = addConversion(op, left->getType(), right); if (child) right = child; @@ -90,12 +192,8 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn else return 0; } - } else { - if (left->getType() != right->getType()) - return 0; } - // // Need a new node holding things together then. Make // one and promote it to the right type. @@ -107,18 +205,16 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn node->setLeft(left); node->setRight(right); - if (! node->promote(infoSink)) + if (!node->promote(infoSink)) return 0; - TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion(); - TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion(); - // // See if we can fold constants. // - TIntermTyped* typedReturnNode = 0; - if ( leftTempConstant && rightTempConstant) { + TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion(); + TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion(); + if (leftTempConstant && rightTempConstant) { typedReturnNode = leftTempConstant->fold(node->getOp(), rightTempConstant, infoSink); if (typedReturnNode) @@ -602,9 +698,9 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc line) // // Create loop nodes. // -TIntermNode* TIntermediate::addLoop(TIntermNode *init, TIntermNode* body, TIntermTyped* test, TIntermTyped* terminal, bool testFirst, TSourceLoc line) +TIntermNode* TIntermediate::addLoop(TLoopType type, TIntermNode* init, TIntermTyped* cond, TIntermTyped* expr, TIntermNode* body, TSourceLoc line) { - TIntermNode* node = new TIntermLoop(init, body, test, terminal, testFirst); + TIntermNode* node = new TIntermLoop(type, init, cond, expr, body); node->setLine(line); return node; @@ -630,7 +726,7 @@ TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expres // This is to be executed once the final root is put on top by the parsing // process. // -bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language) +bool TIntermediate::postProcess(TIntermNode* root) { if (root == 0) return true; @@ -760,6 +856,12 @@ bool TIntermUnary::promote(TInfoSink&) // bool TIntermBinary::promote(TInfoSink& infoSink) { + // This function only handles scalars, vectors, and matrices. + if (left->isArray() || right->isArray()) { + infoSink.info.message(EPrefixInternalError, "Invalid operation for arrays", getLine()); + return false; + } + // GLSL ES 2.0 does not support implicit type casting. // So the basic type should always match. if (left->getBasicType() != right->getBasicType()) @@ -781,40 +883,6 @@ bool TIntermBinary::promote(TInfoSink& infoSink) getTypePointer()->setQualifier(EvqTemporary); } - // - // Array operations. - // - if (left->isArray() || right->isArray()) { - // - // Arrays types have to be exact matches. - // - if (left->getType() != right->getType()) - return false; - - switch (op) { - // - // Promote to conditional - // - case EOpEqual: - case EOpNotEqual: - setType(TType(EbtBool, EbpUndefined)); - break; - - // - // Set array information. - // - case EOpAssign: - case EOpInitialize: - getTypePointer()->setArraySize(left->getType().getArraySize()); - getTypePointer()->setArrayInformationType(left->getType().getArrayInformationType()); - break; - - default: - return false; - } - return true; - } - int size = std::max(left->getNominalSize(), right->getNominalSize()); // diff --git a/Source/ThirdParty/ANGLE/src/compiler/OutputGLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/OutputGLSL.cpp index fd263b6..23476f2 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/OutputGLSL.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/OutputGLSL.cpp @@ -374,6 +374,10 @@ bool TOutputGLSL::visitUnary(Visit visit, TIntermUnary* node) case EOpLength: writeTriplet(visit, "length(", NULL, ")"); break; case EOpNormalize: writeTriplet(visit, "normalize(", NULL, ")"); break; + case EOpDFdx: writeTriplet(visit, "dFdx(", NULL, ")"); break; + case EOpDFdy: writeTriplet(visit, "dFdy(", NULL, ")"); break; + case EOpFwidth: writeTriplet(visit, "fwidth(", NULL, ")"); break; + case EOpAny: writeTriplet(visit, "any(", NULL, ")"); break; case EOpAll: writeTriplet(visit, "all(", NULL, ")"); break; @@ -608,23 +612,32 @@ bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node) incrementDepth(); // Loop header. - if (node->testFirst()) // for loop + TLoopType loopType = node->getType(); + if (loopType == ELoopFor) // for loop { out << "for ("; if (node->getInit()) node->getInit()->traverse(this); out << "; "; - ASSERT(node->getTest() != NULL); - node->getTest()->traverse(this); + if (node->getCondition()) + node->getCondition()->traverse(this); out << "; "; - if (node->getTerminal()) - node->getTerminal()->traverse(this); + if (node->getExpression()) + node->getExpression()->traverse(this); + out << ")\n"; + } + else if (loopType == ELoopWhile) // while loop + { + out << "while ("; + ASSERT(node->getCondition() != NULL); + node->getCondition()->traverse(this); out << ")\n"; } else // do-while loop { + ASSERT(loopType == ELoopDoWhile); out << "do\n"; } @@ -632,11 +645,11 @@ bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node) visitCodeBlock(node->getBody()); // Loop footer. - if (!node->testFirst()) // while loop + if (loopType == ELoopDoWhile) // do-while loop { out << "while ("; - ASSERT(node->getTest() != NULL); - node->getTest()->traverse(this); + ASSERT(node->getCondition() != NULL); + node->getCondition()->traverse(this); out << ");\n"; } decrementDepth(); diff --git a/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.cpp index 8b8a4e6..57e99d2 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.cpp @@ -9,6 +9,7 @@ #include "compiler/debug.h" #include "compiler/InfoSink.h" #include "compiler/UnfoldSelect.h" +#include "compiler/SearchSymbol.h" #include <stdio.h> #include <algorithm> @@ -64,7 +65,7 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr mScopeDepth = 0; - mArgumentIndex = 0; + mUniqueIndex = 0; } OutputHLSL::~OutputHLSL() @@ -96,7 +97,7 @@ int OutputHLSL::vectorSize(const TType &type) const void OutputHLSL::header() { - EShLanguage language = mContext.language; + ShShaderType shaderType = mContext.shaderType; TInfoSinkBase &out = mHeader; for (StructDeclarations::iterator structDeclaration = mStructDeclarations.begin(); structDeclaration != mStructDeclarations.end(); structDeclaration++) @@ -109,7 +110,7 @@ void OutputHLSL::header() out << *constructor; } - if (language == EShLangFragment) + if (shaderType == SH_FRAGMENT_SHADER) { TString uniforms; TString varyings; @@ -361,7 +362,8 @@ void OutputHLSL::header() " float diff;\n" "};\n" "\n" - "uniform gl_DepthRangeParameters gl_DepthRange;\n" + "uniform float3 dx_DepthRange;" + "static gl_DepthRangeParameters gl_DepthRange = {dx_DepthRange.x, dx_DepthRange.y, dx_DepthRange.z};\n" "\n"; } @@ -653,7 +655,39 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) switch (node->getOp()) { case EOpAssign: outputTriplet(visit, "(", " = ", ")"); break; - case EOpInitialize: outputTriplet(visit, "", " = ", ""); break; + case EOpInitialize: + if (visit == PreVisit) + { + // GLSL allows to write things like "float x = x;" where a new variable x is defined + // and the value of an existing variable x is assigned. HLSL uses C semantics (the + // new variable is created before the assignment is evaluated), so we need to convert + // this to "float t = x, x = t;". + + TIntermSymbol *symbolNode = node->getLeft()->getAsSymbolNode(); + TIntermTyped *expression = node->getRight(); + + sh::SearchSymbol searchSymbol(symbolNode->getSymbol()); + expression->traverse(&searchSymbol); + bool sameSymbol = searchSymbol.foundMatch(); + + if (sameSymbol) + { + // Type already printed + out << "t" + str(mUniqueIndex) + " = "; + expression->traverse(this); + out << ", "; + symbolNode->traverse(this); + out << " = t" + str(mUniqueIndex); + + mUniqueIndex++; + return false; + } + } + else if (visit == InVisit) + { + out << " = "; + } + break; case EOpAddAssign: outputTriplet(visit, "(", " += ", ")"); break; case EOpSubAssign: outputTriplet(visit, "(", " -= ", ")"); break; case EOpMulAssign: outputTriplet(visit, "(", " *= ", ")"); break; @@ -933,9 +967,9 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node) case EOpFract: outputTriplet(visit, "frac(", "", ")"); break; case EOpLength: outputTriplet(visit, "length(", "", ")"); break; case EOpNormalize: outputTriplet(visit, "normalize(", "", ")"); break; -// case EOpDPdx: outputTriplet(visit, "ddx(", "", ")"); break; -// case EOpDPdy: outputTriplet(visit, "ddy(", "", ")"); break; -// case EOpFwidth: outputTriplet(visit, "fwidth(", "", ")"); break; + case EOpDFdx: outputTriplet(visit, "ddx(", "", ")"); break; + case EOpDFdy: outputTriplet(visit, "ddy(", "", ")"); break; + case EOpFwidth: outputTriplet(visit, "fwidth(", "", ")"); break; case EOpAny: outputTriplet(visit, "any(", "", ")"); break; case EOpAll: outputTriplet(visit, "all(", "", ")"); break; default: UNREACHABLE(); @@ -946,7 +980,7 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node) bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) { - EShLanguage language = mContext.language; + ShShaderType shaderType = mContext.shaderType; TInfoSinkBase &out = mBody; switch (node->getOp()) @@ -1392,7 +1426,7 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) TInfoSinkBase &out = mBody; - if (!node->testFirst()) + if (node->getType() == ELoopDoWhile) { out << "do\n" "{\n"; @@ -1404,14 +1438,14 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) mUnfoldSelect->traverse(node->getInit()); } - if (node->getTest()) + if (node->getCondition()) { - mUnfoldSelect->traverse(node->getTest()); + mUnfoldSelect->traverse(node->getCondition()); } - if (node->getTerminal()) + if (node->getExpression()) { - mUnfoldSelect->traverse(node->getTerminal()); + mUnfoldSelect->traverse(node->getExpression()); } out << "for("; @@ -1423,16 +1457,16 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) out << "; "; - if (node->getTest()) + if (node->getCondition()) { - node->getTest()->traverse(this); + node->getCondition()->traverse(this); } out << "; "; - if (node->getTerminal()) + if (node->getExpression()) { - node->getTerminal()->traverse(this); + node->getExpression()->traverse(this); } out << ")\n" @@ -1446,11 +1480,11 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) out << "}\n"; - if (!node->testFirst()) + if (node->getType() == ELoopDoWhile) { out << "while(\n"; - node->getTest()->traverse(this); + node->getCondition()->traverse(this); out << ")"; } @@ -1565,9 +1599,9 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) } // Parse comparator and limit value - if (index != NULL && node->getTest()) + if (index != NULL && node->getCondition()) { - TIntermBinary *test = node->getTest()->getAsBinaryNode(); + TIntermBinary *test = node->getCondition()->getAsBinaryNode(); if (test && test->getLeft()->getAsSymbolNode()->getId() == index->getId()) { @@ -1585,10 +1619,10 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) } // Parse increment - if (index != NULL && comparator != EOpNull && node->getTerminal()) + if (index != NULL && comparator != EOpNull && node->getExpression()) { - TIntermBinary *binaryTerminal = node->getTerminal()->getAsBinaryNode(); - TIntermUnary *unaryTerminal = node->getTerminal()->getAsUnaryNode(); + TIntermBinary *binaryTerminal = node->getExpression()->getAsBinaryNode(); + TIntermUnary *unaryTerminal = node->getExpression()->getAsUnaryNode(); if (binaryTerminal) { @@ -1711,7 +1745,7 @@ TString OutputHLSL::argumentString(const TIntermSymbol *symbol) if (name.empty()) // HLSL demands named arguments, also for prototypes { - name = "x" + str(mArgumentIndex++); + name = "x" + str(mUniqueIndex++); } else { diff --git a/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.h b/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.h index dc3c482..ddbd077 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.h +++ b/Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.h @@ -120,7 +120,7 @@ class OutputHLSL : public TIntermTraverser ScopeBracket mScopeBracket; unsigned int mScopeDepth; - int mArgumentIndex; // For creating unique argument names + int mUniqueIndex; // For creating unique names }; } diff --git a/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.cpp b/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.cpp index 407226b..53f3fa8 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.cpp @@ -9,9 +9,35 @@ #include <stdarg.h> #include <stdio.h> +#include "compiler/glslang.h" #include "compiler/osinclude.h" #include "compiler/InitializeParseContext.h" +extern "C" { +extern int InitPreprocessor(); +extern int FinalizePreprocessor(); +extern void PredefineIntMacro(const char *name, int value); +} + +static void ReportInfo(TInfoSinkBase& sink, + TPrefixType type, TSourceLoc loc, + const char* reason, const char* token, + const char* extraInfo) +{ + /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ + sink.prefix(type); + sink.location(loc); + sink << "'" << token << "' : " << reason << " " << extraInfo << "\n"; +} + +static void DefineExtensionMacros(const TExtensionBehavior& extBehavior) +{ + for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); + iter != extBehavior.end(); ++iter) { + PredefineIntMacro(iter->first.c_str(), 1); + } +} + /////////////////////////////////////////////////////////////////////// // // Sub- vector and matrix fields @@ -176,24 +202,32 @@ void TParseContext::recover() // // Used by flex/bison to output all syntax and parsing errors. // -void TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken, - const char *szExtraInfoFormat, ...) +void TParseContext::error(TSourceLoc loc, + const char* reason, const char* token, + const char* extraInfoFormat, ...) { - char szExtraInfo[400]; + char extraInfo[512]; va_list marker; + va_start(marker, extraInfoFormat); + vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker); - va_start(marker, szExtraInfoFormat); + ReportInfo(infoSink.info, EPrefixError, loc, reason, token, extraInfo); - vsnprintf(szExtraInfo, sizeof(szExtraInfo), szExtraInfoFormat, marker); + va_end(marker); + ++numErrors; +} - /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ - infoSink.info.prefix(EPrefixError); - infoSink.info.location(nLine); - infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n"; +void TParseContext::warning(TSourceLoc loc, + const char* reason, const char* token, + const char* extraInfoFormat, ...) { + char extraInfo[512]; + va_list marker; + va_start(marker, extraInfoFormat); + vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker); - va_end(marker); + ReportInfo(infoSink.info, EPrefixWarning, loc, reason, token, extraInfo); - ++numErrors; + va_end(marker); } // @@ -415,7 +449,7 @@ bool TParseContext::reservedErrorCheck(int line, const TString& identifier) error(line, reservedErrMsg, "gl_", ""); return true; } - if (spec == EShSpecWebGL) { + if (shaderSpec == SH_WEBGL_SPEC) { if (identifier.substr(0, 6) == TString("webgl_")) { error(line, reservedErrMsg, "webgl_", ""); return true; @@ -471,17 +505,18 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction bool matrixInMatrix = false; bool arrayArg = false; for (int i = 0; i < function.getParamCount(); ++i) { - size += function[i].type->getObjectSize(); + const TParameter& param = function.getParam(i); + size += param.type->getObjectSize(); - if (constructingMatrix && function[i].type->isMatrix()) + if (constructingMatrix && param.type->isMatrix()) matrixInMatrix = true; if (full) overFull = true; if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize()) full = true; - if (function[i].type->getQualifier() != EvqConst) + if (param.type->getQualifier() != EvqConst) constType = false; - if (function[i].type->isArray()) + if (param.type->isArray()) arrayArg = true; } @@ -510,7 +545,7 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction return true; } - if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->size() != function.getParamCount()) { + if (op == EOpConstructStruct && !type->isArray() && int(type->getStruct()->size()) != function.getParamCount()) { error(line, "Number of constructor parameters does not match the number of structure fields", "constructor", ""); return true; } @@ -674,14 +709,11 @@ bool TParseContext::arraySizeErrorCheck(int line, TIntermTyped* expr, int& size) // bool TParseContext::arrayQualifierErrorCheck(int line, TPublicType type) { - if (type.qualifier == EvqAttribute) { + if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqConst)) { error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str(), ""); return true; } - if (type.qualifier == EvqConst && extensionErrorCheck(line, "GL_3DL_array_objects")) - return true; - return false; } @@ -886,16 +918,22 @@ bool TParseContext::paramErrorCheck(int line, TQualifier qualifier, TQualifier p return false; } -bool TParseContext::extensionErrorCheck(int line, const char* extension) -{ - if (extensionBehavior[extension] == EBhWarn) { - infoSink.info.message(EPrefixWarning, ("extension " + TString(extension) + " is being used").c_str(), line); - return false; +bool TParseContext::extensionErrorCheck(int line, const TString& extension) +{ + TExtensionBehavior::const_iterator iter = extensionBehavior.find(extension); + if (iter == extensionBehavior.end()) { + error(line, "extension", extension.c_str(), "is not supported"); + return true; } - if (extensionBehavior[extension] == EBhDisable) { - error(line, "extension", extension, "is disabled"); + if (iter->second == EBhDisable) { + error(line, "extension", extension.c_str(), "is disabled"); return true; } + if (iter->second == EBhWarn) { + TString msg = "extension " + extension + " is being used"; + infoSink.info.message(EPrefixWarning, msg.c_str(), line); + return false; + } return false; } @@ -1021,6 +1059,7 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPu bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode) { + ASSERT(aggrNode != NULL); if (!aggrNode->isConstructor()) return false; @@ -1028,13 +1067,10 @@ bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode) // check if all the child nodes are constants so that they can be inserted into // the parent node - if (aggrNode) { - TIntermSequence &childSequenceVector = aggrNode->getSequence() ; - for (TIntermSequence::iterator p = childSequenceVector.begin(); - p != childSequenceVector.end(); p++) { - if (!(*p)->getAsTyped()->getAsConstantUnion()) - return false; - } + TIntermSequence &sequence = aggrNode->getSequence() ; + for (TIntermSequence::iterator p = sequence.begin(); p != sequence.end(); ++p) { + if (!(*p)->getAsTyped()->getAsConstantUnion()) + return false; } return allConstant; @@ -1379,16 +1415,29 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n } // -// Initialize all supported extensions to disable +// Parse an array of strings using yyparse. // -void TParseContext::initializeExtensionBehavior() -{ - // - // example code: extensionBehavior["test"] = EBhDisable; // where "test" is the name of - // supported extension - // - extensionBehavior["GL_ARB_texture_rectangle"] = EBhRequire; - extensionBehavior["GL_3DL_array_objects"] = EBhDisable; +// Returns 0 for success. +// +int PaParseStrings(int count, const char* const string[], const int length[], + TParseContext* context) { + if ((count == 0) || (string == NULL)) + return 1; + + // setup preprocessor. + if (InitPreprocessor()) + return 1; + DefineExtensionMacros(context->extensionBehavior); + + if (glslang_initialize(context)) + return 1; + + glslang_scan(count, string, length, context); + int error = glslang_parse(context); + + glslang_finalize(context); + FinalizePreprocessor(); + return (error == 0) && (context->numErrors == 0) ? 0 : 1; } OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX; diff --git a/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.h b/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.h index 792333f..cb6e0d0 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.h +++ b/Source/ThirdParty/ANGLE/src/compiler/ParseHelper.h @@ -6,9 +6,10 @@ #ifndef _PARSER_HELPER_INCLUDED_ #define _PARSER_HELPER_INCLUDED_ +#include "compiler/ExtensionBehavior.h" +#include "compiler/localintermediate.h" #include "compiler/ShHandle.h" #include "compiler/SymbolTable.h" -#include "compiler/localintermediate.h" struct TMatrixFields { bool wholeRow; @@ -17,13 +18,6 @@ struct TMatrixFields { int col; }; -typedef enum { - EBhRequire, - EBhEnable, - EBhWarn, - EBhDisable -} TBehavior; - struct TPragma { TPragma(bool o, bool d) : optimize(o), debug(d) { } bool optimize; @@ -36,15 +30,16 @@ struct TPragma { // they can be passed to the parser without needing a global. // struct TParseContext { - TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage l, EShSpec s, TInfoSink& is) : - intermediate(interm), symbolTable(symt), infoSink(is), language(l), spec(s), treeRoot(0), + TParseContext(TSymbolTable& symt, const TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, TInfoSink& is) : + intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), treeRoot(0), recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), - inTypeParen(false), contextPragma(true, false) { } + inTypeParen(false), scanner(NULL), contextPragma(true, false) { } TIntermediate& intermediate; // to hold and build a parse tree TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed + TExtensionBehavior extensionBehavior; // mapping between supported extensions and current behavior. TInfoSink& infoSink; - EShLanguage language; // vertex or fragment language (future: pack or unpack) - EShSpec spec; // The language specification compiler conforms to - GLES2 or WebGL. + ShShaderType shaderType; // vertex or fragment language (future: pack or unpack) + ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL. TIntermNode* treeRoot; // root of parse tree being created bool recoveredFromError; // true if a parse error has occurred, but we continue to parse int numErrors; @@ -53,11 +48,11 @@ struct TParseContext { bool inTypeParen; // true if in parentheses, looking only for an identifier const TType* currentFunctionType; // the return type of the function that's currently being parsed bool functionReturnsValue; // true if a non-void function has a return - TMap<TString, TBehavior> extensionBehavior; - void initializeExtensionBehavior(); - void error(TSourceLoc, const char *szReason, const char *szToken, - const char *szExtraInfoFormat, ...); + void error(TSourceLoc loc, const char *reason, const char* token, + const char* extraInfoFormat, ...); + void warning(TSourceLoc loc, const char* reason, const char* token, + const char* extraInfoFormat, ...); bool reservedErrorCheck(int line, const TString& identifier); void recover(); @@ -86,7 +81,7 @@ struct TParseContext { bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type); bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type); bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type); - bool extensionErrorCheck(int line, const char*); + bool extensionErrorCheck(int line, const TString&); const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0); bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType, TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); @@ -100,16 +95,14 @@ struct TParseContext { TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line); TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc); bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); + void* scanner; struct TPragma contextPragma; TString HashErrMsg; bool AfterEOF; }; -int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&); -void PaReservedWord(); -int PaIdentOrType(TString& id, TParseContext&, TSymbol*&); -int PaParseComment(int &lineno, TParseContext&); -void setInitialState(); +int PaParseStrings(int count, const char* const string[], const int length[], + TParseContext* context); typedef TParseContext* TParseContextPointer; extern TParseContextPointer& GetGlobalParseContext(); diff --git a/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.cpp b/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.cpp index 7e348ca..93e21e4 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.cpp @@ -22,14 +22,10 @@ void InitializeGlobalPools() if (globalPools) return; - TPoolAllocator *globalPoolAllocator = new TPoolAllocator(true); - TThreadGlobalPools* threadData = new TThreadGlobalPools(); - - threadData->globalPoolAllocator = globalPoolAllocator; - - OS_SetTLSValue(PoolIndex, threadData); - globalPoolAllocator->push(); + threadData->globalPoolAllocator = 0; + + OS_SetTLSValue(PoolIndex, threadData); } void FreeGlobalPools() @@ -38,9 +34,7 @@ void FreeGlobalPools() TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); if (!globalPools) return; - - GlobalPoolAllocator.popAll(); - delete &GlobalPoolAllocator; + delete globalPools; } @@ -66,7 +60,7 @@ TPoolAllocator& GetGlobalPoolAllocator() return *threadData->globalPoolAllocator; } -void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator) +void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator) { TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); @@ -77,13 +71,13 @@ void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator) // Implement the functionality of the TPoolAllocator class, which // is documented in PoolAlloc.h. // -TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignment) : - global(g), +TPoolAllocator::TPoolAllocator(int growthIncrement, int allocationAlignment) : pageSize(growthIncrement), alignment(allocationAlignment), freeList(0), inUseList(0), - numCalls(0) + numCalls(0), + totalBytes(0) { // // Don't allow page sizes we know are smaller than all common @@ -123,24 +117,14 @@ TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignm TPoolAllocator::~TPoolAllocator() { - if (!global) { - // - // Then we know that this object is not being - // allocated after other, globally scoped objects - // that depend on it. So we can delete the "in use" memory. - // - while (inUseList) { - tHeader* next = inUseList->nextPage; - inUseList->~tHeader(); - delete [] reinterpret_cast<char*>(inUseList); - inUseList = next; - } + while (inUseList) { + tHeader* next = inUseList->nextPage; + inUseList->~tHeader(); + delete [] reinterpret_cast<char*>(inUseList); + inUseList = next; } - // - // Always delete the free list memory - it can't be being - // (correctly) referenced, whether the pool allocator was - // global or not. We should not check the guard blocks + // We should not check the guard blocks // here, because we did it already when the block was // placed into the free list. // @@ -315,4 +299,4 @@ void TAllocation::checkAllocList() const { for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc) alloc->check(); -} +}
\ No newline at end of file diff --git a/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.h b/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.h index 645db78..051dc00 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.h +++ b/Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.h @@ -115,7 +115,7 @@ private: // class TPoolAllocator { public: - TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16); + TPoolAllocator(int growthIncrement = 8*1024, int allocationAlignment = 16); // // Don't call the destructor just to free up the memory, call pop() @@ -194,7 +194,6 @@ protected: return TAllocation::offsetAllocation(memory); } - bool global; // should be true if this object is globally scoped size_t pageSize; // granularity of allocation from the OS size_t alignment; // all returned allocations will be aligned at // this granularity, which will be a power of 2 @@ -220,18 +219,15 @@ private: // different times. But a simple use is to have a global pop // with everyone using the same global allocator. // -typedef TPoolAllocator* PoolAllocatorPointer; extern TPoolAllocator& GetGlobalPoolAllocator(); +extern void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator); #define GlobalPoolAllocator GetGlobalPoolAllocator() - struct TThreadGlobalPools { TPoolAllocator* globalPoolAllocator; }; -void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator); - // // This STL compatible allocator is intended to be used as the allocator // parameter to templatized STL containers, like vector and map. @@ -301,4 +297,4 @@ protected: TPoolAllocator& allocator; }; -#endif // _POOLALLOC_INCLUDED_ +#endif // _POOLALLOC_INCLUDED_
\ No newline at end of file diff --git a/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.cpp b/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.cpp new file mode 100644 index 0000000..9368f1a --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.cpp @@ -0,0 +1,38 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// SearchSymbol is an AST traverser to detect the use of a given symbol name +// + +#include "compiler/SearchSymbol.h" + +#include "compiler/InfoSink.h" +#include "compiler/OutputHLSL.h" + +namespace sh +{ +SearchSymbol::SearchSymbol(const TString &symbol) : mSymbol(symbol) +{ + match = false; +} + +void SearchSymbol::traverse(TIntermNode *node) +{ + node->traverse(this); +} + +void SearchSymbol::visitSymbol(TIntermSymbol *symbolNode) +{ + if (symbolNode->getSymbol() == mSymbol) + { + match = true; + } +} + +bool SearchSymbol::foundMatch() const +{ + return match; +} +} diff --git a/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.h b/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.h new file mode 100644 index 0000000..6bc0b90 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.h @@ -0,0 +1,33 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// SearchSymbol is an AST traverser to detect the use of a given symbol name +// + +#ifndef COMPILER_SEARCHSYMBOL_H_ +#define COMPILER_SEARCHSYMBOL_H_ + +#include "compiler/intermediate.h" +#include "compiler/ParseHelper.h" + +namespace sh +{ +class SearchSymbol : public TIntermTraverser +{ + public: + SearchSymbol(const TString &symbol); + + void traverse(TIntermNode *node); + void visitSymbol(TIntermSymbol *symbolNode); + + bool foundMatch() const; + + protected: + const TString &mSymbol; + bool match; +}; +} + +#endif // COMPILER_SEARCHSYMBOL_H_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h b/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h index 5ef5d30..e65c1ee 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h +++ b/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h @@ -16,20 +16,26 @@ #include "GLSLANG/ShaderLang.h" +#include "compiler/ExtensionBehavior.h" #include "compiler/InfoSink.h" #include "compiler/SymbolTable.h" +#include "compiler/VariableInfo.h" class TCompiler; -class TIntermNode; // // The base class used to back handles returned to the driver. // class TShHandleBase { public: - TShHandleBase() { } - virtual ~TShHandleBase() { } + TShHandleBase(); + virtual ~TShHandleBase(); virtual TCompiler* getAsCompiler() { return 0; } + +protected: + // Memory allocator. Allocates and tracks memory required by the compiler. + // Deallocates all memory when compiler is destructed. + TPoolAllocator allocator; }; // @@ -38,27 +44,49 @@ public: // class TCompiler : public TShHandleBase { public: - TCompiler(EShLanguage l, EShSpec s) : language(l), spec(s) { } - virtual ~TCompiler() { } - - EShLanguage getLanguage() const { return language; } - EShSpec getSpec() const { return spec; } - TSymbolTable& getSymbolTable() { return symbolTable; } - TInfoSink& getInfoSink() { return infoSink; } + TCompiler(ShShaderType type, ShShaderSpec spec); + virtual ~TCompiler(); + virtual TCompiler* getAsCompiler() { return this; } - virtual bool compile(TIntermNode* root) = 0; + bool Init(const ShBuiltInResources& resources); + bool compile(const char* const shaderStrings[], + const int numStrings, + int compileOptions); - virtual TCompiler* getAsCompiler() { return this; } + // Get results of the last compilation. + TInfoSink& getInfoSink() { return infoSink; } + const TVariableInfoList& getAttribs() const { return attribs; } + const TVariableInfoList& getUniforms() const { return uniforms; } protected: - EShLanguage language; - EShSpec spec; + ShShaderType getShaderType() const { return shaderType; } + ShShaderSpec getShaderSpec() const { return shaderSpec; } + // Initialize symbol-table with built-in symbols. + bool InitBuiltInSymbolTable(const ShBuiltInResources& resources); + // Clears the results from the previous compilation. + void clearResults(); + // Returns true if the given shader does not exceed the minimum + // functionality mandated in GLSL 1.0 spec Appendix A. + bool validateLimitations(TIntermNode* root); + // Collect info for all attribs and uniforms. + void collectAttribsUniforms(TIntermNode* root); + // Translate to object code. + virtual void translate(TIntermNode* root) = 0; + +private: + ShShaderType shaderType; + ShShaderSpec shaderSpec; // Built-in symbol table for the given language, spec, and resources. // It is preserved from compile-to-compile. TSymbolTable symbolTable; - // Output sink. - TInfoSink infoSink; + // Built-in extensions with default behavior. + TExtensionBehavior extensionBehavior; + + // Results of compilation. + TInfoSink infoSink; // Output sink. + TVariableInfoList attribs; // Active attributes in the compiled shader. + TVariableInfoList uniforms; // Active uniforms in the compiled shader. }; // @@ -70,7 +98,7 @@ protected: // destroy the machine dependent objects, which contain the // above machine independent information. // -TCompiler* ConstructCompiler(EShLanguage, EShSpec); +TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec); void DeleteCompiler(TCompiler*); -#endif // _SHHANDLE_INCLUDED_ +#endif // _SHHANDLE_INCLUDED_
\ No newline at end of file diff --git a/Source/ThirdParty/ANGLE/src/compiler/ShaderLang.cpp b/Source/ThirdParty/ANGLE/src/compiler/ShaderLang.cpp index e0c646a..6cac61d 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/ShaderLang.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/ShaderLang.cpp @@ -11,78 +11,55 @@ #include "GLSLANG/ShaderLang.h" -#include "compiler/Initialize.h" #include "compiler/InitializeDll.h" -#include "compiler/ParseHelper.h" #include "compiler/ShHandle.h" -#include "compiler/SymbolTable.h" -static bool InitializeSymbolTable( - const TBuiltInStrings& builtInStrings, - EShLanguage language, EShSpec spec, const TBuiltInResource& resources, - TInfoSink& infoSink, TSymbolTable& symbolTable) -{ - TIntermediate intermediate(infoSink); - TParseContext parseContext(symbolTable, intermediate, language, spec, infoSink); - - GlobalParseContext = &parseContext; - - setInitialState(); - - assert(symbolTable.isEmpty()); - // - // Parse the built-ins. This should only happen once per - // language symbol table. - // - // Push the symbol table to give it an initial scope. This - // push should not have a corresponding pop, so that built-ins - // are preserved, and the test for an empty table fails. - // - symbolTable.push(); - - //Initialize the Preprocessor - if (InitPreprocessor()) - { - infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor"); - return false; - } +// +// This is the platform independent interface between an OGL driver +// and the shading language compiler. +// - for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i) +static int getVariableMaxLength(const TVariableInfoList& varList) +{ + TString::size_type maxLen = 0; + for (TVariableInfoList::const_iterator i = varList.begin(); + i != varList.end(); ++i) { - const char* builtInShaders[1]; - int builtInLengths[1]; - - builtInShaders[0] = (*i).c_str(); - builtInLengths[0] = (int) (*i).size(); - - if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) - { - infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins"); - return false; - } + maxLen = std::max(maxLen, i->name.size()); } - - IdentifyBuiltIns(language, spec, resources, symbolTable); - - FinalizePreprocessor(); - - return true; + // Add 1 to include null-termination character. + return static_cast<int>(maxLen) + 1; } -static bool GenerateBuiltInSymbolTable( - EShLanguage language, EShSpec spec, const TBuiltInResource& resources, - TInfoSink& infoSink, TSymbolTable& symbolTable) +static void getVariableInfo(ShShaderInfo varType, + const ShHandle handle, + int index, + int* length, + int* size, + ShDataType* type, + char* name) { - TBuiltIns builtIns; + if (!handle || !size || !type || !name) + return; + ASSERT((varType == SH_ACTIVE_ATTRIBUTES) || + (varType == SH_ACTIVE_UNIFORMS)); - builtIns.initialize(language, spec, resources); - return InitializeSymbolTable(builtIns.getBuiltInStrings(), language, spec, resources, infoSink, symbolTable); -} + TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); + TCompiler* compiler = base->getAsCompiler(); + if (compiler == 0) + return; -// -// This is the platform independent interface between an OGL driver -// and the shading language compiler. -// + const TVariableInfoList& varList = varType == SH_ACTIVE_ATTRIBUTES ? + compiler->getAttribs() : compiler->getUniforms(); + if (index < 0 || index >= static_cast<int>(varList.size())) + return; + + const TVariableInfo& varInfo = varList[index]; + if (length) *length = varInfo.name.size(); + *size = varInfo.size; + *type = varInfo.type; + strcpy(name, varInfo.name.c_str()); +} // // Driver must call this first, once, before doing any other @@ -110,7 +87,7 @@ int ShFinalize() // // Initialize built-in resources with minimum expected values. // -void ShInitBuiltInResource(TBuiltInResource* resources) +void ShInitBuiltInResources(ShBuiltInResources* resources) { // Constants. resources->MaxVertexAttribs = 8; @@ -129,18 +106,19 @@ void ShInitBuiltInResource(TBuiltInResource* resources) // // Driver calls these to create and destroy compiler objects. // -ShHandle ShConstructCompiler(EShLanguage language, EShSpec spec, const TBuiltInResource* resources) +ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec, + const ShBuiltInResources* resources) { if (!InitThread()) return 0; - TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, spec)); + TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec)); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; // Generate built-in symbol table. - if (!GenerateBuiltInSymbolTable(language, spec, *resources, compiler->getInfoSink(), compiler->getSymbolTable())) { + if (!compiler->Init(*resources)) { ShDestruct(base); return 0; } @@ -170,9 +148,7 @@ int ShCompile( const ShHandle handle, const char* const shaderStrings[], const int numStrings, - const EShOptimizationLevel optLevel, - int debugOptions - ) + int compileOptions) { if (!InitThread()) return 0; @@ -184,128 +160,95 @@ int ShCompile( TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; - - GlobalPoolAllocator.push(); - TInfoSink& infoSink = compiler->getInfoSink(); - infoSink.info.erase(); - infoSink.debug.erase(); - infoSink.obj.erase(); - - if (numStrings == 0) - return 1; - - TIntermediate intermediate(infoSink); - TSymbolTable& symbolTable = compiler->getSymbolTable(); - - TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->getSpec(), infoSink); - parseContext.initializeExtensionBehavior(); - GlobalParseContext = &parseContext; - - setInitialState(); - - InitPreprocessor(); - // - // Parse the application's shaders. All the following symbol table - // work will be throw-away, so push a new allocation scope that can - // be thrown away, then push a scope for the current shader's globals. - // - bool success = true; - - symbolTable.push(); - if (!symbolTable.atGlobalLevel()) - parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); - - int ret = PaParseStrings(const_cast<char**>(shaderStrings), 0, numStrings, parseContext); - if (ret) - success = false; - - if (success && parseContext.treeRoot) { - if (optLevel == EShOptNoGeneration) - parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation was requested."); - else { - success = intermediate.postProcess(parseContext.treeRoot, parseContext.language); - - if (success) { - - if (debugOptions & EDebugOpIntermediate) - intermediate.outputTree(parseContext.treeRoot); - - // - // Call the machine dependent compiler - // - if (!compiler->compile(parseContext.treeRoot)) - success = false; - } - } - } else if (!success) { - parseContext.infoSink.info.prefix(EPrefixError); - parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n"; - success = false; - if (debugOptions & EDebugOpIntermediate) - intermediate.outputTree(parseContext.treeRoot); - } else if (!parseContext.treeRoot) { - parseContext.error(1, "Unexpected end of file.", "", ""); - parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n"; - success = false; - if (debugOptions & EDebugOpIntermediate) - intermediate.outputTree(parseContext.treeRoot); - } - intermediate.remove(parseContext.treeRoot); + bool success = compiler->compile(shaderStrings, numStrings, compileOptions); + return success ? 1 : 0; +} - // - // Ensure symbol table is returned to the built-in level, - // throwing away all but the built-ins. - // - while (!symbolTable.atBuiltInLevel()) - symbolTable.pop(); +void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params) +{ + if (!handle || !params) + return; - FinalizePreprocessor(); - // - // Throw away all the temporary memory used by the compilation process. - // - GlobalPoolAllocator.pop(); + TShHandleBase* base = static_cast<TShHandleBase*>(handle); + TCompiler* compiler = base->getAsCompiler(); + if (!compiler) return; - return success ? 1 : 0; + switch(pname) + { + case SH_INFO_LOG_LENGTH: + *params = compiler->getInfoSink().info.size() + 1; + break; + case SH_OBJECT_CODE_LENGTH: + *params = compiler->getInfoSink().obj.size() + 1; + break; + case SH_ACTIVE_UNIFORMS: + *params = compiler->getUniforms().size(); + break; + case SH_ACTIVE_UNIFORM_MAX_LENGTH: + *params = getVariableMaxLength(compiler->getUniforms()); + break; + case SH_ACTIVE_ATTRIBUTES: + *params = compiler->getAttribs().size(); + break; + case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: + *params = getVariableMaxLength(compiler->getAttribs()); + break; + + default: UNREACHABLE(); + } } // // Return any compiler log of messages for the application. // -const char* ShGetInfoLog(const ShHandle handle) +void ShGetInfoLog(const ShHandle handle, char* infoLog) { - if (!InitThread()) - return 0; - - if (handle == 0) - return 0; + if (!handle || !infoLog) + return; TShHandleBase* base = static_cast<TShHandleBase*>(handle); - TInfoSink* infoSink = 0; - - if (base->getAsCompiler()) - infoSink = &(base->getAsCompiler()->getInfoSink()); + TCompiler* compiler = base->getAsCompiler(); + if (!compiler) return; - infoSink->info << infoSink->debug.c_str(); - return infoSink->info.c_str(); + TInfoSink& infoSink = compiler->getInfoSink(); + strcpy(infoLog, infoSink.info.c_str()); } // // Return any object code. // -const char* ShGetObjectCode(const ShHandle handle) +void ShGetObjectCode(const ShHandle handle, char* objCode) { - if (!InitThread()) - return 0; - - if (handle == 0) - return 0; + if (!handle || !objCode) + return; TShHandleBase* base = static_cast<TShHandleBase*>(handle); - TInfoSink* infoSink; + TCompiler* compiler = base->getAsCompiler(); + if (!compiler) return; - if (base->getAsCompiler()) - infoSink = &(base->getAsCompiler()->getInfoSink()); + TInfoSink& infoSink = compiler->getInfoSink(); + strcpy(objCode, infoSink.obj.c_str()); +} - return infoSink->obj.c_str(); +void ShGetActiveAttrib(const ShHandle handle, + int index, + int* length, + int* size, + ShDataType* type, + char* name) +{ + getVariableInfo(SH_ACTIVE_ATTRIBUTES, + handle, index, length, size, type, name); +} + +void ShGetActiveUniform(const ShHandle handle, + int index, + int* length, + int* size, + ShDataType* type, + char* name) +{ + getVariableInfo(SH_ACTIVE_UNIFORMS, + handle, index, length, size, type, name); } diff --git a/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.cpp b/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.cpp index 1b08667..02817d4 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.cpp @@ -140,6 +140,22 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op) } } +// +// Change all function entries in the table with the non-mangled name +// to be related to the provided built-in extension. This is a low +// performance operation, and only intended for symbol tables that +// live across a large number of compiles. +// +void TSymbolTableLevel::relateToExtension(const char* name, const TString& ext) +{ + for (tLevel::iterator it = level.begin(); it != level.end(); ++it) { + if (it->second->isFunction()) { + TFunction* function = static_cast<TFunction*>(it->second); + if (function->getName() == name) + function->relateToExtension(ext); + } + } +} TSymbol::TSymbol(const TSymbol& copyOf) { diff --git a/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.h b/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.h index b1a80b5..38bc657 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.h +++ b/Source/ThirdParty/ANGLE/src/compiler/SymbolTable.h @@ -94,7 +94,10 @@ public: void shareConstPointer( ConstantUnion *constArray) { - delete unionArray; + if (unionArray == constArray) + return; + + delete[] unionArray; unionArray = constArray; } TVariable(const TVariable&, TStructureMap& remapper); // copy constructor @@ -156,14 +159,18 @@ public: const TString& getMangledName() const { return mangledName; } const TType& getReturnType() const { return returnType; } + void relateToOperator(TOperator o) { op = o; } TOperator getBuiltInOp() const { return op; } + + void relateToExtension(const TString& ext) { extension = ext; } + const TString& getExtension() const { return extension; } + void setDefined() { defined = true; } bool isDefined() { return defined; } - int getParamCount() const { return static_cast<int>(parameters.size()); } - TParameter& operator [](int i) { return parameters[i]; } - const TParameter& operator [](int i) const { return parameters[i]; } + int getParamCount() const { return static_cast<int>(parameters.size()); } + const TParameter& getParam(int i) const { return parameters[i]; } virtual void dump(TInfoSink &infoSink) const; TFunction(const TFunction&, TStructureMap& remapper); @@ -175,6 +182,7 @@ protected: TType returnType; TString mangledName; TOperator op; + TString extension; bool defined; }; @@ -221,6 +229,7 @@ public: } void relateToOperator(const char* name, TOperator op); + void relateToExtension(const char* name, const TString& ext); void dump(TInfoSink &infoSink) const; TSymbolTableLevel* clone(TStructureMap& remapper); @@ -289,8 +298,16 @@ public: return symbol; } - TSymbolTableLevel* getGlobalLevel() { assert(table.size() >= 2); return table[1]; } - void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); } + TSymbolTableLevel* getGlobalLevel() { + assert(table.size() >= 2); + return table[1]; + } + void relateToOperator(const char* name, TOperator op) { + table[0]->relateToOperator(name, op); + } + void relateToExtension(const char* name, const TString& ext) { + table[0]->relateToExtension(name, ext); + } int getMaxSymbolId() { return uniqueId; } void dump(TInfoSink &infoSink) const; void copyTable(const TSymbolTable& copyOf); diff --git a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp index 7b8d903..7a63ae1 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp @@ -7,14 +7,31 @@ #include "compiler/TranslatorGLSL.h" #include "compiler/OutputGLSL.h" +#include "compiler/VersionGLSL.h" -TranslatorGLSL::TranslatorGLSL(EShLanguage lang, EShSpec spec) - : TCompiler(lang, spec) { +static void writeVersion(ShShaderType type, TIntermNode* root, + TInfoSinkBase& sink) { + TVersionGLSL versionGLSL(type); + root->traverse(&versionGLSL); + int version = versionGLSL.getVersion(); + // We need to write version directive only if it is greater than 110. + // If there is no version directive in the shader, 110 is implied. + if (version > 110) { + sink << "#version " << version << "\n"; + } } -bool TranslatorGLSL::compile(TIntermNode* root) { - TOutputGLSL outputGLSL(infoSink.obj); - root->traverse(&outputGLSL); +TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec) + : TCompiler(type, spec) { +} + +void TranslatorGLSL::translate(TIntermNode* root) { + TInfoSinkBase& sink = getInfoSink().obj; - return true; + // Write GLSL version. + writeVersion(getShaderType(), root, sink); + + // Write translated shader. + TOutputGLSL outputGLSL(sink); + root->traverse(&outputGLSL); } diff --git a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.h b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.h index 973e39a..c2ce06d 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.h +++ b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.h @@ -11,8 +11,10 @@ class TranslatorGLSL : public TCompiler { public: - TranslatorGLSL(EShLanguage lang, EShSpec spec); - virtual bool compile(TIntermNode* root); + TranslatorGLSL(ShShaderType type, ShShaderSpec spec); + +protected: + virtual void translate(TIntermNode* root); }; #endif // COMPILER_TRANSLATORGLSL_H_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.cpp index 3a1e52d..96d7f10 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.cpp @@ -8,17 +8,15 @@ #include "compiler/OutputHLSL.h" -TranslatorHLSL::TranslatorHLSL(EShLanguage lang, EShSpec spec) - : TCompiler(lang, spec) +TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec) + : TCompiler(type, spec) { } -bool TranslatorHLSL::compile(TIntermNode *root) +void TranslatorHLSL::translate(TIntermNode *root) { TParseContext& parseContext = *GetGlobalParseContext(); sh::OutputHLSL outputHLSL(parseContext); outputHLSL.output(); - - return true; } diff --git a/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.h b/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.h index 38a5f0c..c3f672b 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.h +++ b/Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.h @@ -11,8 +11,10 @@ class TranslatorHLSL : public TCompiler { public: - TranslatorHLSL(EShLanguage lang, EShSpec spec); - virtual bool compile(TIntermNode* root); + TranslatorHLSL(ShShaderType type, ShShaderSpec spec); + +protected: + virtual void translate(TIntermNode* root); }; #endif // COMPILER_TRANSLATORHLSL_H_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/Types.h b/Source/ThirdParty/ANGLE/src/compiler/Types.h index 897b28f..d0fcc08 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/Types.h +++ b/Source/ThirdParty/ANGLE/src/compiler/Types.h @@ -85,12 +85,12 @@ public: TType() {} TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) : type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0), - structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0) + maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0) { } explicit TType(const TPublicType &p) : type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize), - structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0) + maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0) { if (p.userDef) { structure = p.userDef->getStruct(); @@ -99,7 +99,7 @@ public: } TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) : type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0), - structure(userDef), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) + maxArraySize(0), arrayInformationType(0), structure(userDef), structureSize(0), fieldName(0), mangled(0) { typeName = NewPoolTString(n.c_str()); } diff --git a/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.cpp b/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.cpp index 20035fe..a36c393 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.cpp @@ -3,6 +3,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // +// UnfoldSelect is an AST traverser to output the select operator ?: as if-else statements +// #include "compiler/UnfoldSelect.h" @@ -44,7 +46,7 @@ bool UnfoldSelect::visitSelection(Visit visit, TIntermSelection *node) "}\n" "else\n" "{\n"; - node->getCondition()->traverse(this); + node->getFalseBlock()->traverse(this); out << " t" << i << " = "; node->getFalseBlock()->traverse(mOutputHLSL); out << ";\n" diff --git a/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.h b/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.h index 68b2e8a..de296e4 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.h +++ b/Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.h @@ -3,6 +3,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // +// UnfoldSelect is an AST traverser to output the select operator ?: as if-else statements +// #ifndef COMPILER_UNFOLDSELECT_H_ #define COMPILER_UNFOLDSELECT_H_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.cpp b/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.cpp new file mode 100644 index 0000000..886f693 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.cpp @@ -0,0 +1,468 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/ValidateLimitations.h" +#include "compiler/InfoSink.h" +#include "compiler/ParseHelper.h" + +namespace { +bool IsLoopIndex(const TIntermSymbol* symbol, const TLoopStack& stack) { + for (TLoopStack::const_iterator i = stack.begin(); i != stack.end(); ++i) { + if (i->index.id == symbol->getId()) + return true; + } + return false; +} + +// Traverses a node to check if it represents a constant index expression. +// Definition: +// constant-index-expressions are a superset of constant-expressions. +// Constant-index-expressions can include loop indices as defined in +// GLSL ES 1.0 spec, Appendix A, section 4. +// The following are constant-index-expressions: +// - Constant expressions +// - Loop indices as defined in section 4 +// - Expressions composed of both of the above +class ValidateConstIndexExpr : public TIntermTraverser { +public: + ValidateConstIndexExpr(const TLoopStack& stack) + : mValid(true), mLoopStack(stack) {} + + // Returns true if the parsed node represents a constant index expression. + bool isValid() const { return mValid; } + + virtual void visitSymbol(TIntermSymbol* symbol) { + // Only constants and loop indices are allowed in a + // constant index expression. + if (mValid) { + mValid = (symbol->getQualifier() == EvqConst) || + IsLoopIndex(symbol, mLoopStack); + } + } + virtual void visitConstantUnion(TIntermConstantUnion*) {} + virtual bool visitBinary(Visit, TIntermBinary*) { return true; } + virtual bool visitUnary(Visit, TIntermUnary*) { return true; } + virtual bool visitSelection(Visit, TIntermSelection*) { return true; } + virtual bool visitAggregate(Visit, TIntermAggregate*) { return true; } + virtual bool visitLoop(Visit, TIntermLoop*) { return true; } + virtual bool visitBranch(Visit, TIntermBranch*) { return true; } + +private: + bool mValid; + const TLoopStack& mLoopStack; +}; +} // namespace + +ValidateLimitations::ValidateLimitations(ShShaderType shaderType, + TInfoSinkBase& sink) + : mShaderType(shaderType), + mSink(sink), + mNumErrors(0) +{ +} + +void ValidateLimitations::visitSymbol(TIntermSymbol*) +{ +} + +void ValidateLimitations::visitConstantUnion(TIntermConstantUnion*) +{ +} + +bool ValidateLimitations::visitBinary(Visit, TIntermBinary* node) +{ + // Check if loop index is modified in the loop body. + validateOperation(node, node->getLeft()); + + // Check indexing. + switch (node->getOp()) { + case EOpIndexDirect: + case EOpIndexIndirect: + validateIndexing(node); + break; + default: break; + } + return true; +} + +bool ValidateLimitations::visitUnary(Visit, TIntermUnary* node) +{ + // Check if loop index is modified in the loop body. + validateOperation(node, node->getOperand()); + + return true; +} + +bool ValidateLimitations::visitSelection(Visit, TIntermSelection*) +{ + return true; +} + +bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate* node) +{ + switch (node->getOp()) { + case EOpFunctionCall: + validateFunctionCall(node); + break; + default: + break; + } + return true; +} + +bool ValidateLimitations::visitLoop(Visit, TIntermLoop* node) +{ + if (!validateLoopType(node)) + return false; + + TLoopInfo info; + memset(&info, 0, sizeof(TLoopInfo)); + if (!validateForLoopHeader(node, &info)) + return false; + + TIntermNode* body = node->getBody(); + if (body != NULL) { + mLoopStack.push_back(info); + body->traverse(this); + mLoopStack.pop_back(); + } + + // The loop is fully processed - no need to visit children. + return false; +} + +bool ValidateLimitations::visitBranch(Visit, TIntermBranch*) +{ + return true; +} + +void ValidateLimitations::error(TSourceLoc loc, + const char *reason, const char* token) +{ + mSink.prefix(EPrefixError); + mSink.location(loc); + mSink << "'" << token << "' : " << reason << "\n"; + ++mNumErrors; +} + +bool ValidateLimitations::withinLoopBody() const +{ + return !mLoopStack.empty(); +} + +bool ValidateLimitations::isLoopIndex(const TIntermSymbol* symbol) const +{ + return IsLoopIndex(symbol, mLoopStack); +} + +bool ValidateLimitations::validateLoopType(TIntermLoop* node) { + TLoopType type = node->getType(); + if (type == ELoopFor) + return true; + + // Reject while and do-while loops. + error(node->getLine(), + "This type of loop is not allowed", + type == ELoopWhile ? "while" : "do"); + return false; +} + +bool ValidateLimitations::validateForLoopHeader(TIntermLoop* node, + TLoopInfo* info) +{ + ASSERT(node->getType() == ELoopFor); + + // + // The for statement has the form: + // for ( init-declaration ; condition ; expression ) statement + // + if (!validateForLoopInit(node, info)) + return false; + if (!validateForLoopCond(node, info)) + return false; + if (!validateForLoopExpr(node, info)) + return false; + + return true; +} + +bool ValidateLimitations::validateForLoopInit(TIntermLoop* node, + TLoopInfo* info) +{ + TIntermNode* init = node->getInit(); + if (init == NULL) { + error(node->getLine(), "Missing init declaration", "for"); + return false; + } + + // + // init-declaration has the form: + // type-specifier identifier = constant-expression + // + TIntermAggregate* decl = init->getAsAggregate(); + if ((decl == NULL) || (decl->getOp() != EOpDeclaration)) { + error(init->getLine(), "Invalid init declaration", "for"); + return false; + } + // To keep things simple do not allow declaration list. + TIntermSequence& declSeq = decl->getSequence(); + if (declSeq.size() != 1) { + error(decl->getLine(), "Invalid init declaration", "for"); + return false; + } + TIntermBinary* declInit = declSeq[0]->getAsBinaryNode(); + if ((declInit == NULL) || (declInit->getOp() != EOpInitialize)) { + error(decl->getLine(), "Invalid init declaration", "for"); + return false; + } + TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode(); + if (symbol == NULL) { + error(declInit->getLine(), "Invalid init declaration", "for"); + return false; + } + // The loop index has type int or float. + TBasicType type = symbol->getBasicType(); + if ((type != EbtInt) && (type != EbtFloat)) { + error(symbol->getLine(), + "Invalid type for loop index", getBasicString(type)); + return false; + } + // The loop index is initialized with constant expression. + if (!isConstExpr(declInit->getRight())) { + error(declInit->getLine(), + "Loop index cannot be initialized with non-constant expression", + symbol->getSymbol().c_str()); + return false; + } + + info->index.id = symbol->getId(); + return true; +} + +bool ValidateLimitations::validateForLoopCond(TIntermLoop* node, + TLoopInfo* info) +{ + TIntermNode* cond = node->getCondition(); + if (cond == NULL) { + error(node->getLine(), "Missing condition", "for"); + return false; + } + // + // condition has the form: + // loop_index relational_operator constant_expression + // + TIntermBinary* binOp = cond->getAsBinaryNode(); + if (binOp == NULL) { + error(node->getLine(), "Invalid condition", "for"); + return false; + } + // Loop index should be to the left of relational operator. + TIntermSymbol* symbol = binOp->getLeft()->getAsSymbolNode(); + if (symbol == NULL) { + error(binOp->getLine(), "Invalid condition", "for"); + return false; + } + if (symbol->getId() != info->index.id) { + error(symbol->getLine(), + "Expected loop index", symbol->getSymbol().c_str()); + return false; + } + // Relational operator is one of: > >= < <= == or !=. + switch (binOp->getOp()) { + case EOpEqual: + case EOpNotEqual: + case EOpLessThan: + case EOpGreaterThan: + case EOpLessThanEqual: + case EOpGreaterThanEqual: + break; + default: + error(binOp->getLine(), + "Invalid relational operator", + getOperatorString(binOp->getOp())); + break; + } + // Loop index must be compared with a constant. + if (!isConstExpr(binOp->getRight())) { + error(binOp->getLine(), + "Loop index cannot be compared with non-constant expression", + symbol->getSymbol().c_str()); + return false; + } + + return true; +} + +bool ValidateLimitations::validateForLoopExpr(TIntermLoop* node, + TLoopInfo* info) +{ + TIntermNode* expr = node->getExpression(); + if (expr == NULL) { + error(node->getLine(), "Missing expression", "for"); + return false; + } + + // for expression has one of the following forms: + // loop_index++ + // loop_index-- + // loop_index += constant_expression + // loop_index -= constant_expression + // ++loop_index + // --loop_index + // The last two forms are not specified in the spec, but I am assuming + // its an oversight. + TIntermUnary* unOp = expr->getAsUnaryNode(); + TIntermBinary* binOp = unOp ? NULL : expr->getAsBinaryNode(); + + TOperator op = EOpNull; + TIntermSymbol* symbol = NULL; + if (unOp != NULL) { + op = unOp->getOp(); + symbol = unOp->getOperand()->getAsSymbolNode(); + } else if (binOp != NULL) { + op = binOp->getOp(); + symbol = binOp->getLeft()->getAsSymbolNode(); + } + + // The operand must be loop index. + if (symbol == NULL) { + error(expr->getLine(), "Invalid expression", "for"); + return false; + } + if (symbol->getId() != info->index.id) { + error(symbol->getLine(), + "Expected loop index", symbol->getSymbol().c_str()); + return false; + } + + // The operator is one of: ++ -- += -=. + switch (op) { + case EOpPostIncrement: + case EOpPostDecrement: + case EOpPreIncrement: + case EOpPreDecrement: + ASSERT((unOp != NULL) && (binOp == NULL)); + break; + case EOpAddAssign: + case EOpSubAssign: + ASSERT((unOp == NULL) && (binOp != NULL)); + break; + default: + error(expr->getLine(), "Invalid operator", getOperatorString(op)); + return false; + } + + // Loop index must be incremented/decremented with a constant. + if (binOp != NULL) { + if (!isConstExpr(binOp->getRight())) { + error(binOp->getLine(), + "Loop index cannot be modified by non-constant expression", + symbol->getSymbol().c_str()); + return false; + } + } + + return true; +} + +bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node) +{ + ASSERT(node->getOp() == EOpFunctionCall); + + // If not within loop body, there is nothing to check. + if (!withinLoopBody()) + return true; + + // List of param indices for which loop indices are used as argument. + typedef std::vector<int> ParamIndex; + ParamIndex pIndex; + TIntermSequence& params = node->getSequence(); + for (TIntermSequence::size_type i = 0; i < params.size(); ++i) { + TIntermSymbol* symbol = params[i]->getAsSymbolNode(); + if (symbol && isLoopIndex(symbol)) + pIndex.push_back(i); + } + // If none of the loop indices are used as arguments, + // there is nothing to check. + if (pIndex.empty()) + return true; + + bool valid = true; + TSymbolTable& symbolTable = GlobalParseContext->symbolTable; + TSymbol* symbol = symbolTable.find(node->getName()); + ASSERT(symbol && symbol->isFunction()); + TFunction* function = static_cast<TFunction*>(symbol); + for (ParamIndex::const_iterator i = pIndex.begin(); + i != pIndex.end(); ++i) { + const TParameter& param = function->getParam(*i); + TQualifier qual = param.type->getQualifier(); + if ((qual == EvqOut) || (qual == EvqInOut)) { + error(params[*i]->getLine(), + "Loop index cannot be used as argument to a function out or inout parameter", + params[*i]->getAsSymbolNode()->getSymbol().c_str()); + valid = false; + } + } + + return valid; +} + +bool ValidateLimitations::validateOperation(TIntermOperator* node, + TIntermNode* operand) { + // Check if loop index is modified in the loop body. + if (!withinLoopBody() || !node->modifiesState()) + return true; + + const TIntermSymbol* symbol = operand->getAsSymbolNode(); + if (symbol && isLoopIndex(symbol)) { + error(node->getLine(), + "Loop index cannot be statically assigned to within the body of the loop", + symbol->getSymbol().c_str()); + } + return true; +} + +bool ValidateLimitations::isConstExpr(TIntermNode* node) +{ + ASSERT(node != NULL); + return node->getAsConstantUnion() != NULL; +} + +bool ValidateLimitations::isConstIndexExpr(TIntermNode* node) +{ + ASSERT(node != NULL); + + ValidateConstIndexExpr validate(mLoopStack); + node->traverse(&validate); + return validate.isValid(); +} + +bool ValidateLimitations::validateIndexing(TIntermBinary* node) +{ + ASSERT((node->getOp() == EOpIndexDirect) || + (node->getOp() == EOpIndexIndirect)); + + bool valid = true; + TIntermTyped* index = node->getRight(); + // The index expression must have integral type. + if (!index->isScalar() || (index->getBasicType() != EbtInt)) { + error(index->getLine(), + "Index expression must have integral type", + index->getCompleteString().c_str()); + valid = false; + } + // The index expession must be a constant-index-expression unless + // the operand is a uniform in a vertex shader. + TIntermTyped* operand = node->getLeft(); + bool skip = (mShaderType == SH_VERTEX_SHADER) && + (operand->getQualifier() == EvqUniform); + if (!skip && !isConstIndexExpr(index)) { + error(index->getLine(), "Index expression must be constant", "[]"); + valid = false; + } + return valid; +} + diff --git a/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.h b/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.h new file mode 100644 index 0000000..a4f5a28 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.h @@ -0,0 +1,62 @@ +// +// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "GLSLANG/ShaderLang.h" +#include "compiler/intermediate.h" + +class TInfoSinkBase; + +struct TLoopInfo { + struct TIndex { + int id; // symbol id. + } index; +}; +typedef TVector<TLoopInfo> TLoopStack; + +// Traverses intermediate tree to ensure that the shader does not exceed the +// minimum functionality mandated in GLSL 1.0 spec, Appendix A. +class ValidateLimitations : public TIntermTraverser { +public: + ValidateLimitations(ShShaderType shaderType, TInfoSinkBase& sink); + + int numErrors() const { return mNumErrors; } + + virtual void visitSymbol(TIntermSymbol*); + virtual void visitConstantUnion(TIntermConstantUnion*); + virtual bool visitBinary(Visit, TIntermBinary*); + virtual bool visitUnary(Visit, TIntermUnary*); + virtual bool visitSelection(Visit, TIntermSelection*); + virtual bool visitAggregate(Visit, TIntermAggregate*); + virtual bool visitLoop(Visit, TIntermLoop*); + virtual bool visitBranch(Visit, TIntermBranch*); + +private: + void error(TSourceLoc loc, const char *reason, const char* token); + + bool withinLoopBody() const; + bool isLoopIndex(const TIntermSymbol* symbol) const; + bool validateLoopType(TIntermLoop* node); + bool validateForLoopHeader(TIntermLoop* node, TLoopInfo* info); + bool validateForLoopInit(TIntermLoop* node, TLoopInfo* info); + bool validateForLoopCond(TIntermLoop* node, TLoopInfo* info); + bool validateForLoopExpr(TIntermLoop* node, TLoopInfo* info); + // Returns true if none of the loop indices is used as the argument to + // the given function out or inout parameter. + bool validateFunctionCall(TIntermAggregate* node); + bool validateOperation(TIntermOperator* node, TIntermNode* operand); + + // Returns true if indexing does not exceed the minimum functionality + // mandated in GLSL 1.0 spec, Appendix A, Section 5. + bool isConstExpr(TIntermNode* node); + bool isConstIndexExpr(TIntermNode* node); + bool validateIndexing(TIntermBinary* node); + + ShShaderType mShaderType; + TInfoSinkBase& mSink; + int mNumErrors; + TLoopStack mLoopStack; +}; + diff --git a/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.cpp b/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.cpp new file mode 100644 index 0000000..ad2e08f --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.cpp @@ -0,0 +1,210 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/VariableInfo.h" + +static TString arrayBrackets(int index) +{ + TStringStream stream; + stream << "[" << index << "]"; + return stream.str(); +} + +// Returns the data type for an attribute or uniform. +static ShDataType getVariableDataType(const TType& type) +{ + switch (type.getBasicType()) { + case EbtFloat: + if (type.isMatrix()) { + switch (type.getNominalSize()) { + case 2: return SH_FLOAT_MAT2; + case 3: return SH_FLOAT_MAT3; + case 4: return SH_FLOAT_MAT4; + default: UNREACHABLE(); + } + } else if (type.isVector()) { + switch (type.getNominalSize()) { + case 2: return SH_FLOAT_VEC2; + case 3: return SH_FLOAT_VEC3; + case 4: return SH_FLOAT_VEC4; + default: UNREACHABLE(); + } + } else { + return SH_FLOAT; + } + case EbtInt: + if (type.isMatrix()) { + UNREACHABLE(); + } else if (type.isVector()) { + switch (type.getNominalSize()) { + case 2: return SH_INT_VEC2; + case 3: return SH_INT_VEC3; + case 4: return SH_INT_VEC4; + default: UNREACHABLE(); + } + } else { + return SH_INT; + } + case EbtBool: + if (type.isMatrix()) { + UNREACHABLE(); + } else if (type.isVector()) { + switch (type.getNominalSize()) { + case 2: return SH_BOOL_VEC2; + case 3: return SH_BOOL_VEC3; + case 4: return SH_BOOL_VEC4; + default: UNREACHABLE(); + } + } else { + return SH_BOOL; + } + case EbtSampler2D: return SH_SAMPLER_2D; + case EbtSamplerCube: return SH_SAMPLER_CUBE; + default: UNREACHABLE(); + } + return SH_NONE; +} + +static void getBuiltInVariableInfo(const TType& type, + const TString& name, + TVariableInfoList& infoList); +static void getUserDefinedVariableInfo(const TType& type, + const TString& name, + TVariableInfoList& infoList); + +// Returns info for an attribute or uniform. +static void getVariableInfo(const TType& type, + const TString& name, + TVariableInfoList& infoList) +{ + if (type.getBasicType() == EbtStruct) { + if (type.isArray()) { + for (int i = 0; i < type.getArraySize(); ++i) { + TString lname = name + arrayBrackets(i); + getUserDefinedVariableInfo(type, lname, infoList); + } + } else { + getUserDefinedVariableInfo(type, name, infoList); + } + } else { + getBuiltInVariableInfo(type, name, infoList); + } +} + +void getBuiltInVariableInfo(const TType& type, + const TString& name, + TVariableInfoList& infoList) +{ + ASSERT(type.getBasicType() != EbtStruct); + + TVariableInfo varInfo; + if (type.isArray()) { + varInfo.name = (name + "[0]").c_str(); + varInfo.size = type.getArraySize(); + } else { + varInfo.name = name.c_str(); + varInfo.size = 1; + } + varInfo.type = getVariableDataType(type); + infoList.push_back(varInfo); +} + +void getUserDefinedVariableInfo(const TType& type, + const TString& name, + TVariableInfoList& infoList) +{ + ASSERT(type.getBasicType() == EbtStruct); + + TString lname = name + "."; + const TTypeList* structure = type.getStruct(); + for (size_t i = 0; i < structure->size(); ++i) { + const TType* fieldType = (*structure)[i].type; + getVariableInfo(*fieldType, + lname + fieldType->getFieldName(), + infoList); + } +} + +CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs, + TVariableInfoList& uniforms) + : mAttribs(attribs), + mUniforms(uniforms) +{ +} + +// We are only interested in attribute and uniform variable declaration. +void CollectAttribsUniforms::visitSymbol(TIntermSymbol*) +{ +} + +void CollectAttribsUniforms::visitConstantUnion(TIntermConstantUnion*) +{ +} + +bool CollectAttribsUniforms::visitBinary(Visit, TIntermBinary*) +{ + return false; +} + +bool CollectAttribsUniforms::visitUnary(Visit, TIntermUnary*) +{ + return false; +} + +bool CollectAttribsUniforms::visitSelection(Visit, TIntermSelection*) +{ + return false; +} + +bool CollectAttribsUniforms::visitAggregate(Visit, TIntermAggregate* node) +{ + bool visitChildren = false; + + switch (node->getOp()) + { + case EOpSequence: + // We need to visit sequence children to get to variable declarations. + visitChildren = true; + break; + case EOpDeclaration: { + const TIntermSequence& sequence = node->getSequence(); + TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier(); + if (qualifier == EvqAttribute || qualifier == EvqUniform) + { + TVariableInfoList& infoList = qualifier == EvqAttribute ? + mAttribs : mUniforms; + for (TIntermSequence::const_iterator i = sequence.begin(); + i != sequence.end(); ++i) + { + const TIntermSymbol* variable = (*i)->getAsSymbolNode(); + // The only case in which the sequence will not contain a + // TIntermSymbol node is initialization. It will contain a + // TInterBinary node in that case. Since attributes and unifroms + // cannot be initialized in a shader, we must have only + // TIntermSymbol nodes in the sequence. + ASSERT(variable != NULL); + getVariableInfo(variable->getType(), variable->getSymbol(), + infoList); + } + } + break; + } + default: break; + } + + return visitChildren; +} + +bool CollectAttribsUniforms::visitLoop(Visit, TIntermLoop*) +{ + return false; +} + +bool CollectAttribsUniforms::visitBranch(Visit, TIntermBranch*) +{ + return false; +} + diff --git a/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.h b/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.h new file mode 100644 index 0000000..15a5c57 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/VariableInfo.h @@ -0,0 +1,38 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "GLSLANG/ShaderLang.h" +#include "compiler/intermediate.h" + +// Provides information about a variable. +// It is currently being used to store info about active attribs and uniforms. +struct TVariableInfo { + TPersistString name; + ShDataType type; + int size; +}; +typedef std::vector<TVariableInfo> TVariableInfoList; + +// Traverses intermediate tree to collect all attributes and uniforms. +class CollectAttribsUniforms : public TIntermTraverser { +public: + CollectAttribsUniforms(TVariableInfoList& attribs, + TVariableInfoList& uniforms); + + virtual void visitSymbol(TIntermSymbol*); + virtual void visitConstantUnion(TIntermConstantUnion*); + virtual bool visitBinary(Visit, TIntermBinary*); + virtual bool visitUnary(Visit, TIntermUnary*); + virtual bool visitSelection(Visit, TIntermSelection*); + virtual bool visitAggregate(Visit, TIntermAggregate*); + virtual bool visitLoop(Visit, TIntermLoop*); + virtual bool visitBranch(Visit, TIntermBranch*); + +private: + TVariableInfoList& mAttribs; + TVariableInfoList& mUniforms; +}; + diff --git a/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.cpp new file mode 100644 index 0000000..3f87820 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.cpp @@ -0,0 +1,108 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/VersionGLSL.h" + +static const int GLSL_VERSION_110 = 110; +static const int GLSL_VERSION_120 = 120; + +// We need to scan for two things: +// 1. "invariant" keyword: This can occur in both - vertex and fragment shaders +// but only at the global scope. +// 2. "gl_PointCoord" built-in variable: This can only occur in fragment shader +// but inside any scope. +// So we need to scan the entire fragment shader but only the global scope +// of vertex shader. +// +// TODO(alokp): The following two cases of invariant decalaration get lost +// during parsing - they do not get carried over to the intermediate tree. +// Handle these cases: +// 1. When a pragma is used to force all output variables to be invariant: +// - #pragma STDGL invariant(all) +// 2. When a previously decalared or built-in variable is marked invariant: +// - invariant gl_Position; +// - varying vec3 color; invariant color; +// +TVersionGLSL::TVersionGLSL(ShShaderType type) + : mShaderType(type), + mVersion(GLSL_VERSION_110) +{ +} + +void TVersionGLSL::visitSymbol(TIntermSymbol* node) +{ + ASSERT(mShaderType == SH_FRAGMENT_SHADER); + + if (node->getSymbol() == "gl_PointCoord") + updateVersion(GLSL_VERSION_120); +} + +void TVersionGLSL::visitConstantUnion(TIntermConstantUnion*) +{ + ASSERT(mShaderType == SH_FRAGMENT_SHADER); +} + +bool TVersionGLSL::visitBinary(Visit, TIntermBinary*) +{ + ASSERT(mShaderType == SH_FRAGMENT_SHADER); + return true; +} + +bool TVersionGLSL::visitUnary(Visit, TIntermUnary*) +{ + ASSERT(mShaderType == SH_FRAGMENT_SHADER); + return true; +} + +bool TVersionGLSL::visitSelection(Visit, TIntermSelection*) +{ + ASSERT(mShaderType == SH_FRAGMENT_SHADER); + return true; +} + +bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate* node) +{ + // We need to scan the entire fragment shader but only the global scope + // of vertex shader. + bool visitChildren = mShaderType == SH_FRAGMENT_SHADER ? true : false; + + switch (node->getOp()) { + case EOpSequence: + // We need to visit sequence children to get to global or inner scope. + visitChildren = true; + break; + case EOpDeclaration: { + const TIntermSequence& sequence = node->getSequence(); + TQualifier qualifier = sequence.front()->getAsTyped()->getQualifier(); + if ((qualifier == EvqInvariantVaryingIn) || + (qualifier == EvqInvariantVaryingOut)) { + updateVersion(GLSL_VERSION_120); + } + break; + } + default: break; + } + + return visitChildren; +} + +bool TVersionGLSL::visitLoop(Visit, TIntermLoop*) +{ + ASSERT(mShaderType == SH_FRAGMENT_SHADER); + return true; +} + +bool TVersionGLSL::visitBranch(Visit, TIntermBranch*) +{ + ASSERT(mShaderType == SH_FRAGMENT_SHADER); + return true; +} + +void TVersionGLSL::updateVersion(int version) +{ + mVersion = std::max(version, mVersion); +} + diff --git a/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h b/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h new file mode 100644 index 0000000..64d002b --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h @@ -0,0 +1,50 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_VERSIONGLSL_H_ +#define COMPILER_VERSIONGLSL_H_ + +#include "GLSLANG/ShaderLang.h" +#include "compiler/intermediate.h" + +// Traverses the intermediate tree to return the minimum GLSL version +// required to legally access all built-in features used in the shader. +// GLSL 1.1 which is mandated by OpenGL 2.0 provides: +// - #version and #extension to declare version and extensions. +// - built-in functions refract, exp, and log. +// - updated step() to compare x < edge instead of x <= edge. +// GLSL 1.2 which is mandated by OpenGL 2.1 provides: +// - many changes to reduce differences when compared to the ES specification. +// - invariant keyword and its support. +// - c++ style name hiding rules. +// - built-in variable gl_PointCoord for fragment shaders. +// +class TVersionGLSL : public TIntermTraverser { +public: + TVersionGLSL(ShShaderType type); + + // Returns 120 if "invariant" keyword or "gl_PointCoord" is used + // in the shader. Else 110 is returned. + int getVersion() { return mVersion; } + + virtual void visitSymbol(TIntermSymbol*); + virtual void visitConstantUnion(TIntermConstantUnion*); + virtual bool visitBinary(Visit, TIntermBinary*); + virtual bool visitUnary(Visit, TIntermUnary*); + virtual bool visitSelection(Visit, TIntermSelection*); + virtual bool visitAggregate(Visit, TIntermAggregate*); + virtual bool visitLoop(Visit, TIntermLoop*); + virtual bool visitBranch(Visit, TIntermBranch*); + +protected: + void updateVersion(int version); + +private: + ShShaderType mShaderType; + int mVersion; +}; + +#endif // COMPILER_VERSIONGLSL_H_ diff --git a/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_lexer.sh b/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_lexer.sh new file mode 100644 index 0000000..268479d --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_lexer.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Generates GLSL ES lexer - glslang_lex.cpp + +script_dir=$(dirname $0) +input_file=$script_dir/glslang.l +output_file=$script_dir/glslang_lex.cpp +flex --noline --nounistd --outfile=$output_file $input_file diff --git a/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_parser.sh b/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_parser.sh new file mode 100644 index 0000000..889f5c0 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/generate_glslang_parser.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Generates GLSL ES parser - glslang_tab.h and glslang_tab.cpp + +script_dir=$(dirname $0) +input_file=$script_dir/glslang.y +output_header=$script_dir/glslang_tab.h +output_source=$script_dir/glslang_tab.cpp +bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file diff --git a/Source/ThirdParty/ANGLE/src/compiler/glslang.h b/Source/ThirdParty/ANGLE/src/compiler/glslang.h new file mode 100644 index 0000000..26f1457 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/glslang.h @@ -0,0 +1,16 @@ +// +// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +struct TParseContext; +extern int glslang_initialize(TParseContext* context); +extern int glslang_finalize(TParseContext* context); + +extern void glslang_scan(int count, + const char* const string[], + const int length[], + TParseContext* context); +extern int glslang_parse(TParseContext* context); + diff --git a/Source/ThirdParty/ANGLE/src/compiler/glslang.l b/Source/ThirdParty/ANGLE/src/compiler/glslang.l index 02c226f..5a7c5d5 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/glslang.l +++ b/Source/ThirdParty/ANGLE/src/compiler/glslang.l @@ -4,34 +4,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -*/ -/* Based on -ANSI C grammar, Lex specification - -In 1985, Jeff Lee published this Lex specification together with a Yacc -grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted -both to net.sources in 1987; that original, as mentioned in the answer -to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net, -file usenet/net.sources/ansi.c.grammar.Z. -I intend to keep this version as close to the current C Standard grammar -as possible; please let me know if you discover discrepancies. +This file contains the Lex specification for GLSL ES. +Based on ANSI C grammar, Lex specification: +http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -Jutta Degener, 1995 +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh, +WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). */ -D [0-9] -L [a-zA-Z_] -H [a-fA-F0-9] -E [Ee][+-]?{D}+ -O [0-7] +%top{ +// +// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// -%option nounput -%{ -#include <stdio.h> -#include <stdlib.h> +// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT! +} +%{ +#include "compiler/glslang.h" #include "compiler/ParseHelper.h" +#include "compiler/util.h" #include "glslang_tab.h" /* windows only pragma */ @@ -39,407 +34,304 @@ O [0-7] #pragma warning(disable : 4102) #endif -int yy_input(char* buf, int max_size); - -extern int yyparse(void*); -#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal) -#define parseContext (*((TParseContext*)(parseContextLocal))) - -#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size)) +#define YY_USER_ACTION yylval->lex.line = yylineno; +#define YY_INPUT(buf, result, max_size) \ + result = string_input(buf, max_size, yyscanner); +static int string_input(char* buf, int max_size, yyscan_t yyscanner); +static int check_type(yyscan_t yyscanner); +static int reserved_word(yyscan_t yyscanner); %} -/* -TODO(alokp): yylineno is only here to support old flex.exe in compiler/tools. -Remove it when we can exclusively use the newer version. -*/ -%option yylineno - -%option noyywrap -%option never-interactive -%x FIELDS +%option noyywrap nounput never-interactive +%option yylineno reentrant bison-bridge +%option stack +%option extra-type="TParseContext*" +%x COMMENT FIELDS +D [0-9] +L [a-zA-Z_] +H [a-fA-F0-9] +E [Ee][+-]?{D}+ +O [0-7] %% -<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ }; - -"invariant" { pyylval->lex.line = yylineno; return(INVARIANT); } -"highp" { pyylval->lex.line = yylineno; return(HIGH_PRECISION); } -"mediump" { pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); } -"lowp" { pyylval->lex.line = yylineno; return(LOW_PRECISION); } -"precision" { pyylval->lex.line = yylineno; return(PRECISION); } - -"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); } -"const" { pyylval->lex.line = yylineno; return(CONST_QUAL); } -"uniform" { pyylval->lex.line = yylineno; return(UNIFORM); } -"varying" { pyylval->lex.line = yylineno; return(VARYING); } - -"break" { pyylval->lex.line = yylineno; return(BREAK); } -"continue" { pyylval->lex.line = yylineno; return(CONTINUE); } -"do" { pyylval->lex.line = yylineno; return(DO); } -"for" { pyylval->lex.line = yylineno; return(FOR); } -"while" { pyylval->lex.line = yylineno; return(WHILE); } - -"if" { pyylval->lex.line = yylineno; return(IF); } -"else" { pyylval->lex.line = yylineno; return(ELSE); } - -"in" { pyylval->lex.line = yylineno; return(IN_QUAL); } -"out" { pyylval->lex.line = yylineno; return(OUT_QUAL); } -"inout" { pyylval->lex.line = yylineno; return(INOUT_QUAL); } - -"float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); } -"int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); } -"void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); } -"bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); } -"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); } -"false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); } - -"discard" { pyylval->lex.line = yylineno; return(DISCARD); } -"return" { pyylval->lex.line = yylineno; return(RETURN); } - -"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); } -"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); } -"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); } - -"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); } -"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); } -"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); } -"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); } -"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); } -"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); } -"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); } -"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); } -"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); } - -"sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; } -"samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; } - -"struct" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(STRUCT); } - -"asm" { PaReservedWord(); return 0; } - -"class" { PaReservedWord(); return 0; } -"union" { PaReservedWord(); return 0; } -"enum" { PaReservedWord(); return 0; } -"typedef" { PaReservedWord(); return 0; } -"template" { PaReservedWord(); return 0; } -"this" { PaReservedWord(); return 0; } -"packed" { PaReservedWord(); return 0; } - -"goto" { PaReservedWord(); return 0; } -"switch" { PaReservedWord(); return 0; } -"default" { PaReservedWord(); return 0; } - -"inline" { PaReservedWord(); return 0; } -"noinline" { PaReservedWord(); return 0; } -"volatile" { PaReservedWord(); return 0; } -"public" { PaReservedWord(); return 0; } -"static" { PaReservedWord(); return 0; } -"extern" { PaReservedWord(); return 0; } -"external" { PaReservedWord(); return 0; } -"interface" { PaReservedWord(); return 0; } - -"long" { PaReservedWord(); return 0; } -"short" { PaReservedWord(); return 0; } -"double" { PaReservedWord(); return 0; } -"half" { PaReservedWord(); return 0; } -"fixed" { PaReservedWord(); return 0; } -"unsigned" { PaReservedWord(); return 0; } - -"input" { PaReservedWord(); return 0; } -"output" { PaReservedWord(); return 0; } - -"hvec2" { PaReservedWord(); return 0; } -"hvec3" { PaReservedWord(); return 0; } -"hvec4" { PaReservedWord(); return 0; } -"fvec2" { PaReservedWord(); return 0; } -"fvec3" { PaReservedWord(); return 0; } -"fvec4" { PaReservedWord(); return 0; } -"dvec2" { PaReservedWord(); return 0; } -"dvec3" { PaReservedWord(); return 0; } -"dvec4" { PaReservedWord(); return 0; } - -"sizeof" { PaReservedWord(); return 0; } -"cast" { PaReservedWord(); return 0; } - -"namespace" { PaReservedWord(); return 0; } -"using" { PaReservedWord(); return 0; } - -{L}({L}|{D})* { - pyylval->lex.line = yylineno; - pyylval->lex.string = NewPoolTString(yytext); - return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); + +%{ + TParseContext* context = yyextra; +%} + + /* Single-line comments */ +"//"[^\n]* ; + + /* Multi-line comments */ +"/*" { yy_push_state(COMMENT, yyscanner); } +<COMMENT>. | +<COMMENT>\n ; +<COMMENT>"*/" { yy_pop_state(yyscanner); } + +"invariant" { return(INVARIANT); } +"highp" { return(HIGH_PRECISION); } +"mediump" { return(MEDIUM_PRECISION); } +"lowp" { return(LOW_PRECISION); } +"precision" { return(PRECISION); } + +"attribute" { return(ATTRIBUTE); } +"const" { return(CONST_QUAL); } +"uniform" { return(UNIFORM); } +"varying" { return(VARYING); } + +"break" { return(BREAK); } +"continue" { return(CONTINUE); } +"do" { return(DO); } +"for" { return(FOR); } +"while" { return(WHILE); } + +"if" { return(IF); } +"else" { return(ELSE); } + +"in" { return(IN_QUAL); } +"out" { return(OUT_QUAL); } +"inout" { return(INOUT_QUAL); } + +"float" { context->lexAfterType = true; return(FLOAT_TYPE); } +"int" { context->lexAfterType = true; return(INT_TYPE); } +"void" { context->lexAfterType = true; return(VOID_TYPE); } +"bool" { context->lexAfterType = true; return(BOOL_TYPE); } +"true" { yylval->lex.b = true; return(BOOLCONSTANT); } +"false" { yylval->lex.b = false; return(BOOLCONSTANT); } + +"discard" { return(DISCARD); } +"return" { return(RETURN); } + +"mat2" { context->lexAfterType = true; return(MATRIX2); } +"mat3" { context->lexAfterType = true; return(MATRIX3); } +"mat4" { context->lexAfterType = true; return(MATRIX4); } + +"vec2" { context->lexAfterType = true; return (VEC2); } +"vec3" { context->lexAfterType = true; return (VEC3); } +"vec4" { context->lexAfterType = true; return (VEC4); } +"ivec2" { context->lexAfterType = true; return (IVEC2); } +"ivec3" { context->lexAfterType = true; return (IVEC3); } +"ivec4" { context->lexAfterType = true; return (IVEC4); } +"bvec2" { context->lexAfterType = true; return (BVEC2); } +"bvec3" { context->lexAfterType = true; return (BVEC3); } +"bvec4" { context->lexAfterType = true; return (BVEC4); } + +"sampler2D" { context->lexAfterType = true; return SAMPLER2D; } +"samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; } + +"struct" { context->lexAfterType = true; return(STRUCT); } + +"asm" { return reserved_word(yyscanner); } + +"class" { return reserved_word(yyscanner); } +"union" { return reserved_word(yyscanner); } +"enum" { return reserved_word(yyscanner); } +"typedef" { return reserved_word(yyscanner); } +"template" { return reserved_word(yyscanner); } +"this" { return reserved_word(yyscanner); } +"packed" { return reserved_word(yyscanner); } + +"goto" { return reserved_word(yyscanner); } +"switch" { return reserved_word(yyscanner); } +"default" { return reserved_word(yyscanner); } + +"inline" { return reserved_word(yyscanner); } +"noinline" { return reserved_word(yyscanner); } +"volatile" { return reserved_word(yyscanner); } +"public" { return reserved_word(yyscanner); } +"static" { return reserved_word(yyscanner); } +"extern" { return reserved_word(yyscanner); } +"external" { return reserved_word(yyscanner); } +"interface" { return reserved_word(yyscanner); } + +"long" { return reserved_word(yyscanner); } +"short" { return reserved_word(yyscanner); } +"double" { return reserved_word(yyscanner); } +"half" { return reserved_word(yyscanner); } +"fixed" { return reserved_word(yyscanner); } +"unsigned" { return reserved_word(yyscanner); } + +"input" { return reserved_word(yyscanner); } +"output" { return reserved_word(yyscanner); } + +"hvec2" { return reserved_word(yyscanner); } +"hvec3" { return reserved_word(yyscanner); } +"hvec4" { return reserved_word(yyscanner); } +"fvec2" { return reserved_word(yyscanner); } +"fvec3" { return reserved_word(yyscanner); } +"fvec4" { return reserved_word(yyscanner); } +"dvec2" { return reserved_word(yyscanner); } +"dvec3" { return reserved_word(yyscanner); } +"dvec4" { return reserved_word(yyscanner); } + +"sizeof" { return reserved_word(yyscanner); } +"cast" { return reserved_word(yyscanner); } + +"namespace" { return reserved_word(yyscanner); } +"using" { return reserved_word(yyscanner); } + +{L}({L}|{D})* { + yylval->lex.string = NewPoolTString(yytext); + return check_type(yyscanner); } -0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } -0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } -0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;} -{D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } - -{D}+{E} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } -{D}+"."{D}*({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } -"."{D}+({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } - -"/*" { int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; } - -"+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); } -"-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); } -"*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); } -"/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); } -"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); } -"<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); } -">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); } -"&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); } -"^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); } -"|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); } - -"++" { pyylval->lex.line = yylineno; return(INC_OP); } -"--" { pyylval->lex.line = yylineno; return(DEC_OP); } -"&&" { pyylval->lex.line = yylineno; return(AND_OP); } -"||" { pyylval->lex.line = yylineno; return(OR_OP); } -"^^" { pyylval->lex.line = yylineno; return(XOR_OP); } -"<=" { pyylval->lex.line = yylineno; return(LE_OP); } -">=" { pyylval->lex.line = yylineno; return(GE_OP); } -"==" { pyylval->lex.line = yylineno; return(EQ_OP); } -"!=" { pyylval->lex.line = yylineno; return(NE_OP); } -"<<" { pyylval->lex.line = yylineno; return(LEFT_OP); } -">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); } -";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); } -("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); } -("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); } -"," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); } -":" { pyylval->lex.line = yylineno; return(COLON); } -"=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); } -"(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); } -")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); } -("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); } -("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); } +0[xX]{H}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } +0{O}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } +0{D}+ { context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;} +{D}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } + +{D}+{E} { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); } +{D}+"."{D}*({E})? { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); } +"."{D}+({E})? { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); } + +"+=" { return(ADD_ASSIGN); } +"-=" { return(SUB_ASSIGN); } +"*=" { return(MUL_ASSIGN); } +"/=" { return(DIV_ASSIGN); } +"%=" { return(MOD_ASSIGN); } +"<<=" { return(LEFT_ASSIGN); } +">>=" { return(RIGHT_ASSIGN); } +"&=" { return(AND_ASSIGN); } +"^=" { return(XOR_ASSIGN); } +"|=" { return(OR_ASSIGN); } + +"++" { return(INC_OP); } +"--" { return(DEC_OP); } +"&&" { return(AND_OP); } +"||" { return(OR_OP); } +"^^" { return(XOR_OP); } +"<=" { return(LE_OP); } +">=" { return(GE_OP); } +"==" { return(EQ_OP); } +"!=" { return(NE_OP); } +"<<" { return(LEFT_OP); } +">>" { return(RIGHT_OP); } +";" { context->lexAfterType = false; return(SEMICOLON); } +("{"|"<%") { context->lexAfterType = false; return(LEFT_BRACE); } +("}"|"%>") { return(RIGHT_BRACE); } +"," { if (context->inTypeParen) context->lexAfterType = false; return(COMMA); } +":" { return(COLON); } +"=" { context->lexAfterType = false; return(EQUAL); } +"(" { context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); } +")" { context->inTypeParen = false; return(RIGHT_PAREN); } +("["|"<:") { return(LEFT_BRACKET); } +("]"|":>") { return(RIGHT_BRACKET); } "." { BEGIN(FIELDS); return(DOT); } -"!" { pyylval->lex.line = yylineno; return(BANG); } -"-" { pyylval->lex.line = yylineno; return(DASH); } -"~" { pyylval->lex.line = yylineno; return(TILDE); } -"+" { pyylval->lex.line = yylineno; return(PLUS); } -"*" { pyylval->lex.line = yylineno; return(STAR); } -"/" { pyylval->lex.line = yylineno; return(SLASH); } -"%" { pyylval->lex.line = yylineno; return(PERCENT); } -"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); } -">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); } -"|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); } -"^" { pyylval->lex.line = yylineno; return(CARET); } -"&" { pyylval->lex.line = yylineno; return(AMPERSAND); } -"?" { pyylval->lex.line = yylineno; return(QUESTION); } +"!" { return(BANG); } +"-" { return(DASH); } +"~" { return(TILDE); } +"+" { return(PLUS); } +"*" { return(STAR); } +"/" { return(SLASH); } +"%" { return(PERCENT); } +"<" { return(LEFT_ANGLE); } +">" { return(RIGHT_ANGLE); } +"|" { return(VERTICAL_BAR); } +"^" { return(CARET); } +"&" { return(AMPERSAND); } +"?" { return(QUESTION); } <FIELDS>{L}({L}|{D})* { -BEGIN(INITIAL); - pyylval->lex.line = yylineno; - pyylval->lex.string = NewPoolTString(yytext); - return FIELD_SELECTION; } + BEGIN(INITIAL); + yylval->lex.string = NewPoolTString(yytext); + return FIELD_SELECTION; +} <FIELDS>[ \t\v\f\r] {} [ \t\v\n\f\r] { } -<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();} -<*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n"; - return 0; } +<*><<EOF>> { context->AfterEOF = true; yyterminate(); } +<*>. { context->warning(yylineno, "Unknown char", yytext, ""); return 0; } %% - -//Including Pre-processor. extern "C" { - #include "compiler/preprocessor/preprocess.h" -} - -// -// The YY_INPUT macro just calls this. Maybe this could be just put into -// the macro directly. -// - -int yy_input(char* buf, int max_size) -{ - int len; - - if ((len = yylex_CPP(buf, max_size)) == 0) - return 0; - if (len >= max_size) - YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - buf[len] = ' '; - return len+1; -} - - -// -// Parse an array of strings using yyparse. We set up globals used by -// yywrap. -// -// Returns 0 for success, as per yyparse(). -// -int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal) -{ - int argv0len; - - ScanFromString(argv[0]); - - //Storing the Current Compiler Parse context into the cpp structure. - cpp->pC = (void*)&parseContextLocal; - - if (!argv || argc == 0) - return 1; - - for (int i = 0; i < argc; ++i) { - if (!argv[i]) { - parseContextLocal.error(0, "Null shader source string", "", ""); - parseContextLocal.recover(); - return 1; - } - } - - if (!strLen) { - argv0len = (int) strlen(argv[0]); - strLen = &argv0len; - } - yyrestart(0); - (&parseContextLocal)->AfterEOF = false; - cpp->PaWhichStr = 0; - cpp->PaArgv = argv; - cpp->PaArgc = argc; - cpp->PaStrLen = strLen; - cpp->pastFirstStatement = 0; - yylineno = 1; - - if (*cpp->PaStrLen >= 0) { - int ret = yyparse((void*)(&parseContextLocal)); - if (ret || cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0) - return 1; - else - return 0; - } - else - return 0; -} - -void yyerror(const char *s) -{ - if (((TParseContext *)cpp->pC)->AfterEOF) { - if (cpp->tokensBeforeEOF == 1) { - GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, ""); - GlobalParseContext->recover(); - } - } else { - GlobalParseContext->error(yylineno, "syntax error", yytext, s, ""); - GlobalParseContext->recover(); - } -} +// Preprocessor interface. +#include "compiler/preprocessor/preprocess.h" -void PaReservedWord() -{ - GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", ""); - GlobalParseContext->recover(); -} - -int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol) -{ - symbol = parseContextLocal.symbolTable.find(id); - if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) { - TVariable* variable = static_cast<TVariable*>(symbol); - if (variable->isUserType()) { - parseContextLocal.lexAfterType = true; - return TYPE_NAME; - } - } - - return IDENTIFIER; -} - -int PaParseComment(int &lineno, TParseContext& parseContextLocal) -{ - int transitionFlag = 0; - int nextChar; - - while (transitionFlag != 2) { - nextChar = yyinput(); - if (nextChar == '\n') - lineno++; - switch (nextChar) { - case '*' : - transitionFlag = 1; - break; - case '/' : /* if star is the previous character, then it is the end of comment */ - if (transitionFlag == 1) { - return 1 ; - } - break; - case EOF : - /* Raise error message here */ - parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", ""); - GlobalParseContext->recover(); - return YY_NULL; - default : /* Any other character will be a part of the comment */ - transitionFlag = 0; - } - } - return 1; -} - -extern "C" { +#define SETUP_CONTEXT(pp) \ + TParseContext* context = (TParseContext*) pp->pC; \ + struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; +// Preprocessor callbacks. void CPPDebugLogMsg(const char *msg) { - ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg); + SETUP_CONTEXT(cpp); + context->infoSink.debug.message(EPrefixNone, msg); } void CPPWarningToInfoLog(const char *msg) { - ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno); + SETUP_CONTEXT(cpp); + context->warning(yylineno, msg, "", ""); } void CPPShInfoLogMsg(const char *msg) { - ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,""); - GlobalParseContext->recover(); + SETUP_CONTEXT(cpp); + context->error(yylineno, msg, "", ""); + context->recover(); } void CPPErrorToInfoLog(char *msg) { - ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,""); - GlobalParseContext->recover(); + SETUP_CONTEXT(cpp); + context->error(yylineno, msg, "", ""); + context->recover(); } void SetLineNumber(int line) { - yylineno &= ~SourceLocLineMask; - yylineno |= line; + SETUP_CONTEXT(cpp); + int string = 0; + DecodeSourceLoc(yylineno, &string, NULL); + yylineno = EncodeSourceLoc(string, line); } void SetStringNumber(int string) { - yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask); + SETUP_CONTEXT(cpp); + int line = 0; + DecodeSourceLoc(yylineno, NULL, &line); + yylineno = EncodeSourceLoc(string, line); } -int GetStringNumber(void) +int GetStringNumber() { - return yylineno >> 16; + SETUP_CONTEXT(cpp); + int string = 0; + DecodeSourceLoc(yylineno, &string, NULL); + return string; } -int GetLineNumber(void) +int GetLineNumber() { - return yylineno & SourceLocLineMask; + SETUP_CONTEXT(cpp); + int line = 0; + DecodeSourceLoc(yylineno, NULL, &line); + return line; } -void IncLineNumber(void) +void IncLineNumber() { - if ((yylineno & SourceLocLineMask) <= SourceLocLineMask) - ++yylineno; + SETUP_CONTEXT(cpp); + int string = 0, line = 0; + DecodeSourceLoc(yylineno, &string, &line); + yylineno = EncodeSourceLoc(string, ++line); } -void DecLineNumber(void) +void DecLineNumber() { - if ((yylineno & SourceLocLineMask) > 0) - --yylineno; + SETUP_CONTEXT(cpp); + int string = 0, line = 0; + DecodeSourceLoc(yylineno, &string, &line); + yylineno = EncodeSourceLoc(string, --line); } void HandlePragma(const char **tokens, int numTokens) -{ +{ + SETUP_CONTEXT(cpp); if (!strcmp(tokens[0], "optimize")) { if (numTokens != 4) { CPPShInfoLogMsg("optimize pragma syntax is incorrect"); @@ -452,9 +344,9 @@ void HandlePragma(const char **tokens, int numTokens) } if (!strcmp(tokens[2], "on")) - ((TParseContext *)cpp->pC)->contextPragma.optimize = true; + context->contextPragma.optimize = true; else if (!strcmp(tokens[2], "off")) - ((TParseContext *)cpp->pC)->contextPragma.optimize = false; + context->contextPragma.optimize = false; else { CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma"); return; @@ -476,9 +368,9 @@ void HandlePragma(const char **tokens, int numTokens) } if (!strcmp(tokens[2], "on")) - ((TParseContext *)cpp->pC)->contextPragma.debug = true; + context->contextPragma.debug = true; else if (!strcmp(tokens[2], "off")) - ((TParseContext *)cpp->pC)->contextPragma.debug = false; + context->contextPragma.debug = false; else { CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma"); return; @@ -489,7 +381,6 @@ void HandlePragma(const char **tokens, int numTokens) return; } } else { - #ifdef PRAGMA_TABLE // // implementation specific pragma @@ -524,21 +415,24 @@ void HandlePragma(const char **tokens, int numTokens) void StoreStr(char *string) { + SETUP_CONTEXT(cpp); TString strSrc; strSrc = TString(string); - ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc; + context->HashErrMsg = context->HashErrMsg + " " + strSrc; } const char* GetStrfromTStr(void) { - cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str(); + SETUP_CONTEXT(cpp); + cpp->ErrMsg = context->HashErrMsg.c_str(); return cpp->ErrMsg; } void ResetTString(void) { - ((TParseContext *)cpp->pC)->HashErrMsg = ""; + SETUP_CONTEXT(cpp); + context->HashErrMsg = ""; } TBehavior GetBehavior(const char* behavior) @@ -557,8 +451,9 @@ TBehavior GetBehavior(const char* behavior) } } -void updateExtensionBehavior(const char* extName, const char* behavior) +void updateExtensionBehavior(const char* extName, const char* behavior) { + SETUP_CONTEXT(cpp); TBehavior behaviorVal = GetBehavior(behavior); TMap<TString, TBehavior>:: iterator iter; TString msg; @@ -569,12 +464,12 @@ void updateExtensionBehavior(const char* extName, const char* behavior) CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); return; } else { - for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter) + for (iter = context->extensionBehavior.begin(); iter != context->extensionBehavior.end(); ++iter) iter->second = behaviorVal; } } else { - iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName)); - if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) { + iter = context->extensionBehavior.find(TString(extName)); + if (iter == context->extensionBehavior.end()) { switch (behaviorVal) { case EBhRequire: CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); @@ -583,7 +478,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior) case EBhWarn: case EBhDisable: msg = TString("extension '") + extName + "' is not supported"; - ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); + context->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); break; } return; @@ -591,10 +486,85 @@ void updateExtensionBehavior(const char* extName, const char* behavior) iter->second = behaviorVal; } } - } // extern "C" -void setInitialState() -{ - yy_start = 1; +int string_input(char* buf, int max_size, yyscan_t yyscanner) { + int len; + + if ((len = yylex_CPP(buf, max_size)) == 0) + return 0; + if (len >= max_size) + YY_FATAL_ERROR("input buffer overflow, can't enlarge buffer because scanner uses REJECT"); + + buf[len] = ' '; + return len+1; +} + +int check_type(yyscan_t yyscanner) { + struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; + + int token = IDENTIFIER; + TSymbol* symbol = yyextra->symbolTable.find(yytext); + if (yyextra->lexAfterType == false && symbol && symbol->isVariable()) { + TVariable* variable = static_cast<TVariable*>(symbol); + if (variable->isUserType()) { + yyextra->lexAfterType = true; + token = TYPE_NAME; + } + } + yylval->lex.symbol = symbol; + return token; +} + +int reserved_word(yyscan_t yyscanner) { + struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; + + yyextra->error(yylineno, "Illegal use of reserved word", yytext, ""); + yyextra->recover(); + return 0; } + +void yyerror(TParseContext* context, const char* reason) { + struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; + + if (context->AfterEOF) { + context->error(yylineno, reason, "unexpected EOF", ""); + } else { + context->error(yylineno, reason, yytext, ""); + } + context->recover(); +} + +int glslang_initialize(TParseContext* context) { + yyscan_t scanner = NULL; + if (yylex_init_extra(context, &scanner)) + return 1; + + context->scanner = scanner; + return 0; +} + +int glslang_finalize(TParseContext* context) { + yyscan_t scanner = context->scanner; + if (scanner == NULL) return 0; + + context->scanner = NULL; + return yylex_destroy(scanner); +} + +void glslang_scan(int count, const char* const string[], const int length[], + TParseContext* context) { + yyrestart(NULL, context->scanner); + yyset_lineno(EncodeSourceLoc(0, 1), context->scanner); + context->AfterEOF = false; + + // Init preprocessor. + cpp->pC = context; + cpp->PaWhichStr = 0; + cpp->PaArgv = string; + cpp->PaArgc = count; + cpp->PaStrLen = length; + cpp->pastFirstStatement = 0; + ScanFromString(string[0]); +} + diff --git a/Source/ThirdParty/ANGLE/src/compiler/glslang.y b/Source/ThirdParty/ANGLE/src/compiler/glslang.y index d0d29df..5eae4b5 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/glslang.y +++ b/Source/ThirdParty/ANGLE/src/compiler/glslang.y @@ -1,89 +1,38 @@ +/* // // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -/** - * This is bison grammar and production code for parsing the OpenGL 2.0 shading - * languages. - */ -%{ - -/* Based on: -ANSI C Yacc grammar +This file contains the Yacc grammar for GLSL ES. +Based on ANSI C Yacc grammar: +http://www.lysator.liu.se/c/ANSI-C-grammar-y.html -In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a -matching Lex specification) for the April 30, 1985 draft version of the -ANSI C standard. Tom Stockfisch reposted it to net.sources in 1987; that -original, as mentioned in the answer to question 17.25 of the comp.lang.c -FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z. +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_parser.sh, +WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). +*/ -I intend to keep this version as close to the current C Standard grammar as -possible; please let me know if you discover discrepancies. +%{ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// -Jutta Degener, 1995 -*/ +// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT! #include "compiler/SymbolTable.h" #include "compiler/ParseHelper.h" #include "GLSLANG/ShaderLang.h" -#define YYPARSE_PARAM parseContextLocal -/* -TODO(alokp): YYPARSE_PARAM_DECL is only here to support old bison.exe in -compiler/tools. Remove it when we can exclusively use the newer version. -*/ -#define YYPARSE_PARAM_DECL void* -#define parseContext ((TParseContext*)(parseContextLocal)) -#define YYLEX_PARAM parseContextLocal -#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal) -extern void yyerror(const char*); - -#define FRAG_VERT_ONLY(S, L) { \ - if (parseContext->language != EShLangFragment && \ - parseContext->language != EShLangVertex) { \ - parseContext->error(L, " supported in vertex/fragment shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} - -#define VERTEX_ONLY(S, L) { \ - if (parseContext->language != EShLangVertex) { \ - parseContext->error(L, " supported in vertex shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} - -#define FRAG_ONLY(S, L) { \ - if (parseContext->language != EShLangFragment) { \ - parseContext->error(L, " supported in fragment shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} - -#define PACK_ONLY(S, L) { \ - if (parseContext->language != EShLangPack) { \ - parseContext->error(L, " supported in pack shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} +#define YYLEX_PARAM context->scanner +%} -#define UNPACK_ONLY(S, L) { \ - if (parseContext->language != EShLangUnpack) { \ - parseContext->error(L, " supported in unpack shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} +%expect 1 /* One shift reduce conflict because of if | else */ +%pure-parser +%parse-param {TParseContext* context} -#define PACK_UNPACK_ONLY(S, L) { \ - if (parseContext->language != EShLangUnpack && \ - parseContext->language != EShLangPack) { \ - parseContext->error(L, " supported in pack/unpack shaders only ", S, "", ""); \ - parseContext->recover(); \ - } \ -} -%} %union { struct { TSourceLoc line; @@ -117,11 +66,32 @@ extern void yyerror(const char*); } %{ - extern int yylex(YYSTYPE*, void*); +extern int yylex(YYSTYPE* yylval_param, void* yyscanner); +extern void yyerror(TParseContext* context, const char* reason); + +#define FRAG_VERT_ONLY(S, L) { \ + if (context->shaderType != SH_FRAGMENT_SHADER && \ + context->shaderType != SH_VERTEX_SHADER) { \ + context->error(L, " supported in vertex/fragment shaders only ", S, "", ""); \ + context->recover(); \ + } \ +} + +#define VERTEX_ONLY(S, L) { \ + if (context->shaderType != SH_VERTEX_SHADER) { \ + context->error(L, " supported in vertex shaders only ", S, "", ""); \ + context->recover(); \ + } \ +} + +#define FRAG_ONLY(S, L) { \ + if (context->shaderType != SH_FRAGMENT_SHADER) { \ + context->error(L, " supported in fragment shaders only ", S, "", ""); \ + context->recover(); \ + } \ +} %} -%pure_parser /* Just in case is called from multiple threads */ -%expect 1 /* One shift reduce conflict because of if | else */ %token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION %token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE %token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN @@ -185,17 +155,17 @@ variable_identifier const TSymbol* symbol = $1.symbol; const TVariable* variable; if (symbol == 0) { - parseContext->error($1.line, "undeclared identifier", $1.string->c_str(), ""); - parseContext->recover(); + context->error($1.line, "undeclared identifier", $1.string->c_str(), ""); + context->recover(); TType type(EbtFloat, EbpUndefined); TVariable* fakeVariable = new TVariable($1.string, type); - parseContext->symbolTable.insert(*fakeVariable); + context->symbolTable.insert(*fakeVariable); variable = fakeVariable; } else { // This identifier can only be a variable type symbol if (! symbol->isVariable()) { - parseContext->error($1.line, "variable expected", $1.string->c_str(), ""); - parseContext->recover(); + context->error($1.line, "variable expected", $1.string->c_str(), ""); + context->recover(); } variable = static_cast<const TVariable*>(symbol); } @@ -206,9 +176,9 @@ variable_identifier if (variable->getType().getQualifier() == EvqConst ) { ConstantUnion* constArray = variable->getConstPointer(); TType t(variable->getType()); - $$ = parseContext->intermediate.addConstantUnion(constArray, t, $1.line); + $$ = context->intermediate.addConstantUnion(constArray, t, $1.line); } else - $$ = parseContext->intermediate.addSymbol(variable->getUniqueId(), + $$ = context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line); } @@ -224,22 +194,22 @@ primary_expression // check for overflow for constants // if (abs($1.i) >= (1 << 16)) { - parseContext->error($1.line, " integer constant overflow", "", ""); - parseContext->recover(); + context->error($1.line, " integer constant overflow", "", ""); + context->recover(); } ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setIConst($1.i); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line); } | FLOATCONSTANT { ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setFConst($1.f); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line); } | BOOLCONSTANT { ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst($1.b); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $1.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $1.line); } | LEFT_PAREN expression RIGHT_PAREN { $$ = $2; @@ -253,57 +223,57 @@ postfix_expression | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET { if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) { if ($1->getAsSymbolNode()) - parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), ""); + context->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), ""); else - parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", ""); - parseContext->recover(); + context->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", ""); + context->recover(); } if ($1->getType().getQualifier() == EvqConst && $3->getQualifier() == EvqConst) { if ($1->isArray()) { // constant folding for arrays - $$ = parseContext->addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line); + $$ = context->addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line); } else if ($1->isVector()) { // constant folding for vectors TVectorFields fields; fields.num = 1; fields.offsets[0] = $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(); // need to do it this way because v.xy sends fields integer array - $$ = parseContext->addConstVectorNode(fields, $1, $2.line); + $$ = context->addConstVectorNode(fields, $1, $2.line); } else if ($1->isMatrix()) { // constant folding for matrices - $$ = parseContext->addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line); + $$ = context->addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line); } } else { if ($3->getQualifier() == EvqConst) { if (($1->isVector() || $1->isMatrix()) && $1->getType().getNominalSize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() && !$1->isArray() ) { - parseContext->error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); - parseContext->recover(); + context->error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); + context->recover(); } else { if ($1->isArray()) { if ($1->getType().getArraySize() == 0) { if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()) { - if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line)) - parseContext->recover(); + if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line)) + context->recover(); } else { - if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line)) - parseContext->recover(); + if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line)) + context->recover(); } } else if ( $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() >= $1->getType().getArraySize()) { - parseContext->error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); - parseContext->recover(); + context->error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); + context->recover(); } } - $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line); + $$ = context->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line); } } else { if ($1->isArray() && $1->getType().getArraySize() == 0) { - parseContext->error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable"); - parseContext->recover(); + context->error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable"); + context->recover(); } - $$ = parseContext->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line); + $$ = context->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line); } } if ($$ == 0) { ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setFConst(0.0f); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), $2.line); } else if ($1->isArray()) { if ($1->getType().getStruct()) $$->setType(TType($1->getType().getStruct(), $1->getType().getTypeName())); @@ -328,22 +298,22 @@ postfix_expression } | postfix_expression DOT FIELD_SELECTION { if ($1->isArray()) { - parseContext->error($3.line, "cannot apply dot operator to an array", ".", ""); - parseContext->recover(); + context->error($3.line, "cannot apply dot operator to an array", ".", ""); + context->recover(); } if ($1->isVector()) { TVectorFields fields; - if (! parseContext->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) { + if (! context->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) { fields.num = 1; fields.offsets[0] = 0; - parseContext->recover(); + context->recover(); } if ($1->getType().getQualifier() == EvqConst) { // constant folding for vector fields - $$ = parseContext->addConstVectorNode(fields, $1, $3.line); + $$ = context->addConstVectorNode(fields, $1, $3.line); if ($$ == 0) { - parseContext->recover(); + context->recover(); $$ = $1; } else @@ -352,47 +322,47 @@ postfix_expression if (fields.num == 1) { ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setIConst(fields.offsets[0]); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line); - $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line); + $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); $$->setType(TType($1->getBasicType(), $1->getPrecision())); } else { TString vectorString = *$3.string; - TIntermTyped* index = parseContext->intermediate.addSwizzle(fields, $3.line); - $$ = parseContext->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line); + TIntermTyped* index = context->intermediate.addSwizzle(fields, $3.line); + $$ = context->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line); $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, (int) vectorString.size())); } } } else if ($1->isMatrix()) { TMatrixFields fields; - if (! parseContext->parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) { + if (! context->parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) { fields.wholeRow = false; fields.wholeCol = false; fields.row = 0; fields.col = 0; - parseContext->recover(); + context->recover(); } if (fields.wholeRow || fields.wholeCol) { - parseContext->error($2.line, " non-scalar fields not implemented yet", ".", ""); - parseContext->recover(); + context->error($2.line, " non-scalar fields not implemented yet", ".", ""); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setIConst(0); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line); - $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line); + $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); $$->setType(TType($1->getBasicType(), $1->getPrecision(),EvqTemporary, $1->getNominalSize())); } else { ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setIConst(fields.col * $1->getNominalSize() + fields.row); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line); - $$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line); + $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); $$->setType(TType($1->getBasicType(), $1->getPrecision())); } } else if ($1->getBasicType() == EbtStruct) { bool fieldFound = false; const TTypeList* fields = $1->getType().getStruct(); if (fields == 0) { - parseContext->error($2.line, "structure has no fields", "Internal Error", ""); - parseContext->recover(); + context->error($2.line, "structure has no fields", "Internal Error", ""); + context->recover(); $$ = $1; } else { unsigned int i; @@ -404,9 +374,9 @@ postfix_expression } if (fieldFound) { if ($1->getType().getQualifier() == EvqConst) { - $$ = parseContext->addConstStruct(*$3.string, $1, $2.line); + $$ = context->addConstStruct(*$3.string, $1, $2.line); if ($$ == 0) { - parseContext->recover(); + context->recover(); $$ = $1; } else { @@ -418,40 +388,40 @@ postfix_expression } else { ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setIConst(i); - TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line); - $$ = parseContext->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line); + $$ = context->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line); $$->setType(*(*fields)[i].type); } } else { - parseContext->error($2.line, " no such field in structure", $3.string->c_str(), ""); - parseContext->recover(); + context->error($2.line, " no such field in structure", $3.string->c_str(), ""); + context->recover(); $$ = $1; } } } else { - parseContext->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), ""); - parseContext->recover(); + context->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), ""); + context->recover(); $$ = $1; } // don't delete $3.string, it's from the pool } | postfix_expression INC_OP { - if (parseContext->lValueErrorCheck($2.line, "++", $1)) - parseContext->recover(); - $$ = parseContext->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, parseContext->symbolTable); + if (context->lValueErrorCheck($2.line, "++", $1)) + context->recover(); + $$ = context->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->unaryOpError($2.line, "++", $1->getCompleteString()); - parseContext->recover(); + context->unaryOpError($2.line, "++", $1->getCompleteString()); + context->recover(); $$ = $1; } } | postfix_expression DEC_OP { - if (parseContext->lValueErrorCheck($2.line, "--", $1)) - parseContext->recover(); - $$ = parseContext->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, parseContext->symbolTable); + if (context->lValueErrorCheck($2.line, "--", $1)) + context->recover(); + $$ = context->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->unaryOpError($2.line, "--", $1->getCompleteString()); - parseContext->recover(); + context->unaryOpError($2.line, "--", $1->getCompleteString()); + context->recover(); $$ = $1; } } @@ -459,8 +429,8 @@ postfix_expression integer_expression : expression { - if (parseContext->integerErrorCheck($1, "[]")) - parseContext->recover(); + if (context->integerErrorCheck($1, "[]")) + context->recover(); $$ = $1; } ; @@ -478,18 +448,18 @@ function_call // Their parameters will be verified algorithmically. // TType type(EbtVoid, EbpUndefined); // use this to get the type back - if (parseContext->constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) { + if (context->constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) { $$ = 0; } else { // // It's a constructor, of type 'type'. // - $$ = parseContext->addConstructor($1.intermNode, &type, op, fnCall, $1.line); + $$ = context->addConstructor($1.intermNode, &type, op, fnCall, $1.line); } if ($$ == 0) { - parseContext->recover(); - $$ = parseContext->intermediate.setAggregateOperator(0, op, $1.line); + context->recover(); + $$ = context->intermediate.setAggregateOperator(0, op, $1.line); } $$->setType(type); } else { @@ -498,12 +468,15 @@ function_call // const TFunction* fnCandidate; bool builtIn; - fnCandidate = parseContext->findFunction($1.line, fnCall, &builtIn); + fnCandidate = context->findFunction($1.line, fnCall, &builtIn); if (fnCandidate) { // - // A declared function. But, it might still map to a built-in - // operation. + // A declared function. // + if (builtIn && !fnCandidate->getExtension().empty() && + context->extensionErrorCheck($1.line, fnCandidate->getExtension())) { + context->recover(); + } op = fnCandidate->getBuiltInOp(); if (builtIn && op != EOpNull) { // @@ -513,20 +486,20 @@ function_call // // Treat it like a built-in unary operator. // - $$ = parseContext->intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext->symbolTable); + $$ = context->intermediate.addUnaryMath(op, $1.intermNode, 0, context->symbolTable); if ($$ == 0) { - parseContext->error($1.intermNode->getLine(), " wrong operand type", "Internal Error", + context->error($1.intermNode->getLine(), " wrong operand type", "Internal Error", "built in unary operator function. Type: %s", static_cast<TIntermTyped*>($1.intermNode)->getCompleteString().c_str()); YYERROR; } } else { - $$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, op, $1.line); + $$ = context->intermediate.setAggregateOperator($1.intermAggregate, op, $1.line); } } else { // This is a real function call - $$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line); + $$ = context->intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line); $$->setType(fnCandidate->getReturnType()); // this is how we know whether the given function is a builtIn function or a user defined function @@ -537,16 +510,14 @@ function_call $$->getAsAggregate()->setName(fnCandidate->getMangledName()); TQualifier qual; - TQualifierList& qualifierList = $$->getAsAggregate()->getQualifier(); for (int i = 0; i < fnCandidate->getParamCount(); ++i) { - qual = (*fnCandidate)[i].type->getQualifier(); + qual = fnCandidate->getParam(i).type->getQualifier(); if (qual == EvqOut || qual == EvqInOut) { - if (parseContext->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) { - parseContext->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", ""); - parseContext->recover(); + if (context->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) { + context->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", ""); + context->recover(); } } - qualifierList.push_back(qual); } } $$->setType(fnCandidate->getReturnType()); @@ -555,8 +526,8 @@ function_call // Put on a dummy node for error recovery ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setFConst(0.0f); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line); - parseContext->recover(); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line); + context->recover(); } } delete fnCall; @@ -568,8 +539,8 @@ function_call_or_method $$ = $1; } | postfix_expression DOT function_call_generic { - parseContext->error($3.line, "methods are not supported", "", ""); - parseContext->recover(); + context->error($3.line, "methods are not supported", "", ""); + context->recover(); $$ = $3; } ; @@ -607,7 +578,7 @@ function_call_header_with_parameters TParameter param = { 0, new TType($3->getType()) }; $1.function->addParameter(param); $$.function = $1.function; - $$.intermNode = parseContext->intermediate.growAggregate($1.intermNode, $3, $2.line); + $$.intermNode = context->intermediate.growAggregate($1.intermNode, $3, $2.line); } ; @@ -625,19 +596,16 @@ function_identifier // Constructor // if ($1.array) { - if (parseContext->extensionErrorCheck($1.line, "GL_3DL_array_objects")) { - parseContext->recover(); - $1.setArray(false); - } + // Constructors for arrays are not allowed. + context->error($1.line, "cannot construct this type", "array", ""); + context->recover(); + $1.setArray(false); } + TOperator op = EOpNull; if ($1.userDef) { - TString tempString = ""; - TType type($1); - TFunction *function = new TFunction(&tempString, type, EOpConstructStruct); - $$ = function; + op = EOpConstructStruct; } else { - TOperator op = EOpNull; switch ($1.type) { case EbtFloat: if ($1.matrix) { @@ -671,29 +639,30 @@ function_identifier case 4: FRAG_VERT_ONLY("bvec4", $1.line); op = EOpConstructBVec4; break; } break; + default: break; } if (op == EOpNull) { - parseContext->error($1.line, "cannot construct this type", getBasicString($1.type), ""); - parseContext->recover(); + context->error($1.line, "cannot construct this type", getBasicString($1.type), ""); + context->recover(); $1.type = EbtFloat; op = EOpConstructFloat; } - TString tempString = ""; - TType type($1); - TFunction *function = new TFunction(&tempString, type, op); - $$ = function; } + TString tempString; + TType type($1); + TFunction *function = new TFunction(&tempString, type, op); + $$ = function; } | IDENTIFIER { - if (parseContext->reservedErrorCheck($1.line, *$1.string)) - parseContext->recover(); + if (context->reservedErrorCheck($1.line, *$1.string)) + context->recover(); TType type(EbtVoid, EbpUndefined); TFunction *function = new TFunction($1.string, type); $$ = function; } | FIELD_SELECTION { - if (parseContext->reservedErrorCheck($1.line, *$1.string)) - parseContext->recover(); + if (context->reservedErrorCheck($1.line, *$1.string)) + context->recover(); TType type(EbtVoid, EbpUndefined); TFunction *function = new TFunction($1.string, type); $$ = function; @@ -705,28 +674,28 @@ unary_expression $$ = $1; } | INC_OP unary_expression { - if (parseContext->lValueErrorCheck($1.line, "++", $2)) - parseContext->recover(); - $$ = parseContext->intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, parseContext->symbolTable); + if (context->lValueErrorCheck($1.line, "++", $2)) + context->recover(); + $$ = context->intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, context->symbolTable); if ($$ == 0) { - parseContext->unaryOpError($1.line, "++", $2->getCompleteString()); - parseContext->recover(); + context->unaryOpError($1.line, "++", $2->getCompleteString()); + context->recover(); $$ = $2; } } | DEC_OP unary_expression { - if (parseContext->lValueErrorCheck($1.line, "--", $2)) - parseContext->recover(); - $$ = parseContext->intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, parseContext->symbolTable); + if (context->lValueErrorCheck($1.line, "--", $2)) + context->recover(); + $$ = context->intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, context->symbolTable); if ($$ == 0) { - parseContext->unaryOpError($1.line, "--", $2->getCompleteString()); - parseContext->recover(); + context->unaryOpError($1.line, "--", $2->getCompleteString()); + context->recover(); $$ = $2; } } | unary_operator unary_expression { if ($1.op != EOpNull) { - $$ = parseContext->intermediate.addUnaryMath($1.op, $2, $1.line, parseContext->symbolTable); + $$ = context->intermediate.addUnaryMath($1.op, $2, $1.line, context->symbolTable); if ($$ == 0) { const char* errorOp = ""; switch($1.op) { @@ -734,8 +703,8 @@ unary_expression case EOpLogicalNot: errorOp = "!"; break; default: break; } - parseContext->unaryOpError($1.line, errorOp, $2->getCompleteString()); - parseContext->recover(); + context->unaryOpError($1.line, errorOp, $2->getCompleteString()); + context->recover(); $$ = $2; } } else @@ -755,19 +724,19 @@ multiplicative_expression : unary_expression { $$ = $1; } | multiplicative_expression STAR unary_expression { FRAG_VERT_ONLY("*", $2.line); - $$ = parseContext->intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); $$ = $1; } } | multiplicative_expression SLASH unary_expression { FRAG_VERT_ONLY("/", $2.line); - $$ = parseContext->intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); $$ = $1; } } @@ -776,18 +745,18 @@ multiplicative_expression additive_expression : multiplicative_expression { $$ = $1; } | additive_expression PLUS multiplicative_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); $$ = $1; } } | additive_expression DASH multiplicative_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); $$ = $1; } } @@ -800,43 +769,43 @@ shift_expression relational_expression : shift_expression { $$ = $1; } | relational_expression LEFT_ANGLE shift_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); } } | relational_expression RIGHT_ANGLE shift_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); } } | relational_expression LE_OP shift_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); } } | relational_expression GE_OP shift_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); } } ; @@ -844,26 +813,24 @@ relational_expression equality_expression : relational_expression { $$ = $1; } | equality_expression EQ_OP relational_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); - } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects")) - parseContext->recover(); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + } } | equality_expression NE_OP relational_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); - } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects")) - parseContext->recover(); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + } } ; @@ -882,13 +849,13 @@ inclusive_or_expression logical_and_expression : inclusive_or_expression { $$ = $1; } | logical_and_expression AND_OP inclusive_or_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); } } ; @@ -896,13 +863,13 @@ logical_and_expression logical_xor_expression : logical_and_expression { $$ = $1; } | logical_xor_expression XOR_OP logical_and_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); } } ; @@ -910,13 +877,13 @@ logical_xor_expression logical_or_expression : logical_xor_expression { $$ = $1; } | logical_or_expression OR_OP logical_xor_expression { - $$ = parseContext->intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, parseContext->symbolTable); + $$ = context->intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, context->symbolTable); if ($$ == 0) { - parseContext->binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); ConstantUnion *unionArray = new ConstantUnion[1]; unionArray->setBConst(false); - $$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); + $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line); } } ; @@ -924,16 +891,16 @@ logical_or_expression conditional_expression : logical_or_expression { $$ = $1; } | logical_or_expression QUESTION expression COLON assignment_expression { - if (parseContext->boolErrorCheck($2.line, $1)) - parseContext->recover(); + if (context->boolErrorCheck($2.line, $1)) + context->recover(); - $$ = parseContext->intermediate.addSelection($1, $3, $5, $2.line); + $$ = context->intermediate.addSelection($1, $3, $5, $2.line); if ($3->getType() != $5->getType()) $$ = 0; if ($$ == 0) { - parseContext->binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString()); + context->recover(); $$ = $5; } } @@ -942,15 +909,14 @@ conditional_expression assignment_expression : conditional_expression { $$ = $1; } | unary_expression assignment_operator assignment_expression { - if (parseContext->lValueErrorCheck($2.line, "assign", $1)) - parseContext->recover(); - $$ = parseContext->intermediate.addAssign($2.op, $1, $3, $2.line); + if (context->lValueErrorCheck($2.line, "assign", $1)) + context->recover(); + $$ = context->intermediate.addAssign($2.op, $1, $3, $2.line); if ($$ == 0) { - parseContext->assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); $$ = $1; - } else if (($1->isArray() || $3->isArray()) && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects")) - parseContext->recover(); + } } ; @@ -967,10 +933,10 @@ expression $$ = $1; } | expression COMMA assignment_expression { - $$ = parseContext->intermediate.addComma($1, $3, $2.line); + $$ = context->intermediate.addComma($1, $3, $2.line); if ($$ == 0) { - parseContext->binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString()); - parseContext->recover(); + context->binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString()); + context->recover(); $$ = $3; } } @@ -978,8 +944,8 @@ expression constant_expression : conditional_expression { - if (parseContext->constErrorCheck($1)) - parseContext->recover(); + if (context->constErrorCheck($1)) + context->recover(); $$ = $1; } ; @@ -994,16 +960,16 @@ declaration for (int i = 0; i < function.getParamCount(); i++) { - TParameter ¶m = function[i]; + const TParameter ¶m = function.getParam(i); if (param.name != 0) { TVariable *variable = new TVariable(param.name, *param.type); - prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line), $1.line); + prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line), $1.line); } else { - prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line); + prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line); } } @@ -1016,7 +982,7 @@ declaration $$ = $1.intermAggregate; } | PRECISION precision_qualifier type_specifier_no_prec SEMICOLON { - parseContext->symbolTable.setDefaultPrecision( $3.type, $2 ); + context->symbolTable.setDefaultPrecision( $3.type, $2 ); $$ = 0; } ; @@ -1031,16 +997,16 @@ function_prototype // // Redeclarations are allowed. But, return types and parameter qualifiers must match. // - TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find($1->getMangledName())); + TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find($1->getMangledName())); if (prevDec) { if (prevDec->getReturnType() != $1->getReturnType()) { - parseContext->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), ""); - parseContext->recover(); + context->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), ""); + context->recover(); } for (int i = 0; i < prevDec->getParamCount(); ++i) { - if ((*prevDec)[i].type->getQualifier() != (*$1)[i].type->getQualifier()) { - parseContext->error($2.line, "overloaded functions must have the same parameter qualifiers", (*$1)[i].type->getQualifierString(), ""); - parseContext->recover(); + if (prevDec->getParam(i).type->getQualifier() != $1->getParam(i).type->getQualifier()) { + context->error($2.line, "overloaded functions must have the same parameter qualifiers", $1->getParam(i).type->getQualifierString(), ""); + context->recover(); } } } @@ -1053,7 +1019,7 @@ function_prototype $$.function = $1; $$.line = $2.line; - parseContext->symbolTable.insert(*$$.function); + context->symbolTable.insert(*$$.function); } ; @@ -1085,8 +1051,8 @@ function_header_with_parameters // // This parameter > first is void // - parseContext->error($2.line, "cannot be an argument type except for '(void)'", "void", ""); - parseContext->recover(); + context->error($2.line, "cannot be an argument type except for '(void)'", "void", ""); + context->recover(); delete $3.param.type; } else { // Add the parameter @@ -1099,12 +1065,12 @@ function_header_with_parameters function_header : fully_specified_type IDENTIFIER LEFT_PAREN { if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) { - parseContext->error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), ""); - parseContext->recover(); + context->error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), ""); + context->recover(); } // make sure a sampler is not involved as well... - if (parseContext->structQualifierErrorCheck($2.line, $1)) - parseContext->recover(); + if (context->structQualifierErrorCheck($2.line, $1)) + context->recover(); // Add the function as a prototype after parsing it (we do not support recursion) TFunction *function; @@ -1118,26 +1084,26 @@ parameter_declarator // Type + name : type_specifier IDENTIFIER { if ($1.type == EbtVoid) { - parseContext->error($2.line, "illegal use of type 'void'", $2.string->c_str(), ""); - parseContext->recover(); + context->error($2.line, "illegal use of type 'void'", $2.string->c_str(), ""); + context->recover(); } - if (parseContext->reservedErrorCheck($2.line, *$2.string)) - parseContext->recover(); + if (context->reservedErrorCheck($2.line, *$2.string)) + context->recover(); TParameter param = {$2.string, new TType($1)}; $$.line = $2.line; $$.param = param; } | type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { // Check that we can make an array out of this type - if (parseContext->arrayTypeErrorCheck($3.line, $1)) - parseContext->recover(); + if (context->arrayTypeErrorCheck($3.line, $1)) + context->recover(); - if (parseContext->reservedErrorCheck($2.line, *$2.string)) - parseContext->recover(); + if (context->reservedErrorCheck($2.line, *$2.string)) + context->recover(); int size; - if (parseContext->arraySizeErrorCheck($3.line, $4, size)) - parseContext->recover(); + if (context->arraySizeErrorCheck($3.line, $4, size)) + context->recover(); $1.setArray(true, size); TType* type = new TType($1); @@ -1158,30 +1124,30 @@ parameter_declaration // : type_qualifier parameter_qualifier parameter_declarator { $$ = $3; - if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type)) - parseContext->recover(); + if (context->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type)) + context->recover(); } | parameter_qualifier parameter_declarator { $$ = $2; - if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type)) - parseContext->recover(); - if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type)) - parseContext->recover(); + if (context->parameterSamplerErrorCheck($2.line, $1, *$2.param.type)) + context->recover(); + if (context->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type)) + context->recover(); } // // Only type // | type_qualifier parameter_qualifier parameter_type_specifier { $$ = $3; - if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type)) - parseContext->recover(); + if (context->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type)) + context->recover(); } | parameter_qualifier parameter_type_specifier { $$ = $2; - if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type)) - parseContext->recover(); - if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type)) - parseContext->recover(); + if (context->parameterSamplerErrorCheck($2.line, $1, *$2.param.type)) + context->recover(); + if (context->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type)) + context->recover(); } ; @@ -1212,152 +1178,83 @@ init_declarator_list $$ = $1; if ($$.type.precision == EbpUndefined) { - $$.type.precision = parseContext->symbolTable.getDefaultPrecision($1.type.type); - if (parseContext->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) { - parseContext->recover(); + $$.type.precision = context->symbolTable.getDefaultPrecision($1.type.type); + if (context->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) { + context->recover(); } } } | init_declarator_list COMMA IDENTIFIER { - $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, parseContext->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line), $3.line); + $$.intermAggregate = context->intermediate.growAggregate($1.intermNode, context->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line), $3.line); - if (parseContext->structQualifierErrorCheck($3.line, $$.type)) - parseContext->recover(); + if (context->structQualifierErrorCheck($3.line, $$.type)) + context->recover(); - if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $$.type)) - parseContext->recover(); + if (context->nonInitConstErrorCheck($3.line, *$3.string, $$.type)) + context->recover(); - if (parseContext->nonInitErrorCheck($3.line, *$3.string, $$.type)) - parseContext->recover(); + if (context->nonInitErrorCheck($3.line, *$3.string, $$.type)) + context->recover(); } | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET { - if (parseContext->structQualifierErrorCheck($3.line, $1.type)) - parseContext->recover(); + if (context->structQualifierErrorCheck($3.line, $1.type)) + context->recover(); - if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type)) - parseContext->recover(); + if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type)) + context->recover(); $$ = $1; - if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type)) - parseContext->recover(); + if (context->arrayTypeErrorCheck($4.line, $1.type) || context->arrayQualifierErrorCheck($4.line, $1.type)) + context->recover(); else { $1.type.setArray(true); TVariable* variable; - if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable)) - parseContext->recover(); + if (context->arrayErrorCheck($4.line, *$3.string, $1.type, variable)) + context->recover(); } } | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { - if (parseContext->structQualifierErrorCheck($3.line, $1.type)) - parseContext->recover(); + if (context->structQualifierErrorCheck($3.line, $1.type)) + context->recover(); - if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type)) - parseContext->recover(); + if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type)) + context->recover(); $$ = $1; - if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type)) - parseContext->recover(); + if (context->arrayTypeErrorCheck($4.line, $1.type) || context->arrayQualifierErrorCheck($4.line, $1.type)) + context->recover(); else { int size; - if (parseContext->arraySizeErrorCheck($4.line, $5, size)) - parseContext->recover(); + if (context->arraySizeErrorCheck($4.line, $5, size)) + context->recover(); $1.type.setArray(true, size); TVariable* variable; - if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable)) - parseContext->recover(); + if (context->arrayErrorCheck($4.line, *$3.string, $1.type, variable)) + context->recover(); TType type = TType($1.type); type.setArraySize(size); - $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, parseContext->intermediate.addSymbol(0, *$3.string, type, $3.line), $3.line); - } - } - | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer { - if (parseContext->structQualifierErrorCheck($3.line, $1.type)) - parseContext->recover(); - - $$ = $1; - - TVariable* variable = 0; - if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type)) - parseContext->recover(); - else { - $1.type.setArray(true, $7->getType().getArraySize()); - if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable)) - parseContext->recover(); - } - - if (parseContext->extensionErrorCheck($$.line, "GL_3DL_array_objects")) - parseContext->recover(); - else { - TIntermNode* intermNode; - if (!parseContext->executeInitializer($3.line, *$3.string, $1.type, $7, intermNode, variable)) { - // - // build the intermediate representation - // - if (intermNode) - $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $6.line); - else - $$.intermAggregate = $1.intermAggregate; - } else { - parseContext->recover(); - $$.intermAggregate = 0; - } - } - } - | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer { - if (parseContext->structQualifierErrorCheck($3.line, $1.type)) - parseContext->recover(); - - $$ = $1; - - TVariable* variable = 0; - if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type)) - parseContext->recover(); - else { - int size; - if (parseContext->arraySizeErrorCheck($4.line, $5, size)) - parseContext->recover(); - $1.type.setArray(true, size); - if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable)) - parseContext->recover(); - } - - if (parseContext->extensionErrorCheck($$.line, "GL_3DL_array_objects")) - parseContext->recover(); - else { - TIntermNode* intermNode; - if (!parseContext->executeInitializer($3.line, *$3.string, $1.type, $8, intermNode, variable)) { - // - // build the intermediate representation - // - if (intermNode) - $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $7.line); - else - $$.intermAggregate = $1.intermAggregate; - } else { - parseContext->recover(); - $$.intermAggregate = 0; - } + $$.intermAggregate = context->intermediate.growAggregate($1.intermNode, context->intermediate.addSymbol(0, *$3.string, type, $3.line), $3.line); } } | init_declarator_list COMMA IDENTIFIER EQUAL initializer { - if (parseContext->structQualifierErrorCheck($3.line, $1.type)) - parseContext->recover(); + if (context->structQualifierErrorCheck($3.line, $1.type)) + context->recover(); $$ = $1; TIntermNode* intermNode; - if (!parseContext->executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) { + if (!context->executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) { // // build the intermediate representation // if (intermNode) - $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $4.line); + $$.intermAggregate = context->intermediate.growAggregate($1.intermNode, intermNode, $4.line); else $$.intermAggregate = $1.intermAggregate; } else { - parseContext->recover(); + context->recover(); $$.intermAggregate = 0; } } @@ -1366,88 +1263,88 @@ init_declarator_list single_declaration : fully_specified_type { $$.type = $1; - $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line); + $$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line); } | fully_specified_type IDENTIFIER { - $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line); + $$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line); - if (parseContext->structQualifierErrorCheck($2.line, $$.type)) - parseContext->recover(); + if (context->structQualifierErrorCheck($2.line, $$.type)) + context->recover(); - if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $$.type)) - parseContext->recover(); + if (context->nonInitConstErrorCheck($2.line, *$2.string, $$.type)) + context->recover(); $$.type = $1; - if (parseContext->nonInitErrorCheck($2.line, *$2.string, $$.type)) - parseContext->recover(); + if (context->nonInitErrorCheck($2.line, *$2.string, $$.type)) + context->recover(); } | fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET { - $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line); + $$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line); - if (parseContext->structQualifierErrorCheck($2.line, $1)) - parseContext->recover(); + if (context->structQualifierErrorCheck($2.line, $1)) + context->recover(); - if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $1)) - parseContext->recover(); + if (context->nonInitConstErrorCheck($2.line, *$2.string, $1)) + context->recover(); $$.type = $1; - if (parseContext->arrayTypeErrorCheck($3.line, $1) || parseContext->arrayQualifierErrorCheck($3.line, $1)) - parseContext->recover(); + if (context->arrayTypeErrorCheck($3.line, $1) || context->arrayQualifierErrorCheck($3.line, $1)) + context->recover(); else { $1.setArray(true); TVariable* variable; - if (parseContext->arrayErrorCheck($3.line, *$2.string, $1, variable)) - parseContext->recover(); + if (context->arrayErrorCheck($3.line, *$2.string, $1, variable)) + context->recover(); } } | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { TType type = TType($1); int size; - if (parseContext->arraySizeErrorCheck($2.line, $4, size)) - parseContext->recover(); + if (context->arraySizeErrorCheck($2.line, $4, size)) + context->recover(); type.setArraySize(size); - $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line); + $$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line); - if (parseContext->structQualifierErrorCheck($2.line, $1)) - parseContext->recover(); + if (context->structQualifierErrorCheck($2.line, $1)) + context->recover(); - if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $1)) - parseContext->recover(); + if (context->nonInitConstErrorCheck($2.line, *$2.string, $1)) + context->recover(); $$.type = $1; - if (parseContext->arrayTypeErrorCheck($3.line, $1) || parseContext->arrayQualifierErrorCheck($3.line, $1)) - parseContext->recover(); + if (context->arrayTypeErrorCheck($3.line, $1) || context->arrayQualifierErrorCheck($3.line, $1)) + context->recover(); else { int size; - if (parseContext->arraySizeErrorCheck($3.line, $4, size)) - parseContext->recover(); + if (context->arraySizeErrorCheck($3.line, $4, size)) + context->recover(); $1.setArray(true, size); TVariable* variable; - if (parseContext->arrayErrorCheck($3.line, *$2.string, $1, variable)) - parseContext->recover(); + if (context->arrayErrorCheck($3.line, *$2.string, $1, variable)) + context->recover(); } } | fully_specified_type IDENTIFIER EQUAL initializer { - if (parseContext->structQualifierErrorCheck($2.line, $1)) - parseContext->recover(); + if (context->structQualifierErrorCheck($2.line, $1)) + context->recover(); $$.type = $1; TIntermNode* intermNode; - if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) { + if (!context->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) { // // Build intermediate representation // if(intermNode) - $$.intermAggregate = parseContext->intermediate.makeAggregate(intermNode, $3.line); + $$.intermAggregate = context->intermediate.makeAggregate(intermNode, $3.line); else $$.intermAggregate = 0; } else { - parseContext->recover(); + context->recover(); $$.intermAggregate = 0; } } @@ -1479,14 +1376,14 @@ single_declaration // //input_or_output // : INPUT { -// if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "input")) -// parseContext->recover(); +// if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "input")) +// context->recover(); // UNPACK_ONLY("input", $1.line); // $$.qualifier = EvqInput; // } // | OUTPUT { -// if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "output")) -// parseContext->recover(); +// if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "output")) +// context->recover(); // PACK_ONLY("output", $1.line); // $$.qualifier = EvqOutput; // } @@ -1515,12 +1412,12 @@ single_declaration // //buffer_declaration // : type_specifier IDENTIFIER COLON constant_expression SEMICOLON { -// if (parseContext->reservedErrorCheck($2.line, *$2.string, parseContext)) -// parseContext->recover(); +// if (context->reservedErrorCheck($2.line, *$2.string, context)) +// context->recover(); // $$.variable = new TVariable($2.string, $1); -// if (! parseContext->symbolTable.insert(*$$.variable)) { -// parseContext->error($2.line, "redefinition", $$.variable->getName().c_str(), ""); -// parseContext->recover(); +// if (! context->symbolTable.insert(*$$.variable)) { +// context->error($2.line, "redefinition", $$.variable->getName().c_str(), ""); +// context->recover(); // // don't have to delete $$.variable, the pool pop will take care of it // } // } @@ -1531,31 +1428,27 @@ fully_specified_type $$ = $1; if ($1.array) { - if (parseContext->extensionErrorCheck($1.line, "GL_3DL_array_objects")) { - parseContext->recover(); - $1.setArray(false); - } + context->error($1.line, "not supported", "first-class array", ""); + context->recover(); + $1.setArray(false); } } | type_qualifier type_specifier { - if ($2.array && parseContext->extensionErrorCheck($2.line, "GL_3DL_array_objects")) { - parseContext->recover(); - $2.setArray(false); - } - if ($2.array && parseContext->arrayQualifierErrorCheck($2.line, $1)) { - parseContext->recover(); + if ($2.array) { + context->error($2.line, "not supported", "first-class array", ""); + context->recover(); $2.setArray(false); } if ($1.qualifier == EvqAttribute && ($2.type == EbtBool || $2.type == EbtInt)) { - parseContext->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), ""); - parseContext->recover(); + context->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), ""); + context->recover(); } if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) && ($2.type == EbtBool || $2.type == EbtInt)) { - parseContext->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), ""); - parseContext->recover(); + context->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), ""); + context->recover(); } $$ = $2; $$.qualifier = $1.qualifier; @@ -1568,29 +1461,29 @@ type_qualifier } | ATTRIBUTE { VERTEX_ONLY("attribute", $1.line); - if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "attribute")) - parseContext->recover(); + if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "attribute")) + context->recover(); $$.setBasic(EbtVoid, EvqAttribute, $1.line); } | VARYING { - if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "varying")) - parseContext->recover(); - if (parseContext->language == EShLangVertex) + if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "varying")) + context->recover(); + if (context->shaderType == SH_VERTEX_SHADER) $$.setBasic(EbtVoid, EvqVaryingOut, $1.line); else $$.setBasic(EbtVoid, EvqVaryingIn, $1.line); } | INVARIANT VARYING { - if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "invariant varying")) - parseContext->recover(); - if (parseContext->language == EShLangVertex) + if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "invariant varying")) + context->recover(); + if (context->shaderType == SH_VERTEX_SHADER) $$.setBasic(EbtVoid, EvqInvariantVaryingOut, $1.line); else $$.setBasic(EbtVoid, EvqInvariantVaryingIn, $1.line); } | UNIFORM { - if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "uniform")) - parseContext->recover(); + if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "uniform")) + context->recover(); $$.setBasic(EbtVoid, EvqUniform, $1.line); } ; @@ -1624,12 +1517,12 @@ type_specifier_no_prec | type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET { $$ = $1; - if (parseContext->arrayTypeErrorCheck($2.line, $1)) - parseContext->recover(); + if (context->arrayTypeErrorCheck($2.line, $1)) + context->recover(); else { int size; - if (parseContext->arraySizeErrorCheck($2.line, $3, size)) - parseContext->recover(); + if (context->arraySizeErrorCheck($2.line, $3, size)) + context->recover(); $$.setArray(true, size); } } @@ -1637,103 +1530,103 @@ type_specifier_no_prec type_specifier_nonarray : VOID_TYPE { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtVoid, qual, $1.line); } | FLOAT_TYPE { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, $1.line); } | INT_TYPE { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, $1.line); } | BOOL_TYPE { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, $1.line); } // | UNSIGNED INT_TYPE { // PACK_UNPACK_ONLY("unsigned", $1.line); -// TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; +// TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; // $$.setBasic(EbtInt, qual, $1.line); // } | VEC2 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, $1.line); $$.setAggregate(2); } | VEC3 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, $1.line); $$.setAggregate(3); } | VEC4 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, $1.line); $$.setAggregate(4); } | BVEC2 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, $1.line); $$.setAggregate(2); } | BVEC3 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, $1.line); $$.setAggregate(3); } | BVEC4 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtBool, qual, $1.line); $$.setAggregate(4); } | IVEC2 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, $1.line); $$.setAggregate(2); } | IVEC3 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, $1.line); $$.setAggregate(3); } | IVEC4 { - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtInt, qual, $1.line); $$.setAggregate(4); } | MATRIX2 { FRAG_VERT_ONLY("mat2", $1.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, $1.line); $$.setAggregate(2, true); } | MATRIX3 { FRAG_VERT_ONLY("mat3", $1.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, $1.line); $$.setAggregate(3, true); } | MATRIX4 { FRAG_VERT_ONLY("mat4", $1.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtFloat, qual, $1.line); $$.setAggregate(4, true); } | SAMPLER2D { FRAG_VERT_ONLY("sampler2D", $1.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSampler2D, qual, $1.line); } | SAMPLERCUBE { FRAG_VERT_ONLY("samplerCube", $1.line); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSamplerCube, qual, $1.line); } | struct_specifier { FRAG_VERT_ONLY("struct", $1.line); $$ = $1; - $$.qualifier = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + $$.qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; } | TYPE_NAME { // @@ -1741,7 +1634,7 @@ type_specifier_nonarray // type. // TType& structure = static_cast<TVariable*>($1.symbol)->getType(); - TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtStruct, qual, $1.line); $$.userDef = &structure; } @@ -1749,14 +1642,14 @@ type_specifier_nonarray struct_specifier : STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE { - if (parseContext->reservedErrorCheck($2.line, *$2.string)) - parseContext->recover(); + if (context->reservedErrorCheck($2.line, *$2.string)) + context->recover(); TType* structure = new TType($4, *$2.string); TVariable* userTypeDef = new TVariable($2.string, *structure, true); - if (! parseContext->symbolTable.insert(*userTypeDef)) { - parseContext->error($2.line, "redefinition", $2.string->c_str(), "struct"); - parseContext->recover(); + if (! context->symbolTable.insert(*userTypeDef)) { + context->error($2.line, "redefinition", $2.string->c_str(), "struct"); + context->recover(); } $$.setBasic(EbtStruct, EvqTemporary, $1.line); $$.userDef = structure; @@ -1777,8 +1670,8 @@ struct_declaration_list for (unsigned int i = 0; i < $2->size(); ++i) { for (unsigned int j = 0; j < $$->size(); ++j) { if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName()) { - parseContext->error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str()); - parseContext->recover(); + context->error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str()); + context->recover(); } } $$->push_back((*$2)[i]); @@ -1790,8 +1683,8 @@ struct_declaration : type_specifier struct_declarator_list SEMICOLON { $$ = $2; - if (parseContext->voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) { - parseContext->recover(); + if (context->voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) { + context->recover(); } for (unsigned int i = 0; i < $$->size(); ++i) { // @@ -1804,8 +1697,8 @@ struct_declaration // don't allow arrays of arrays if (type->isArray()) { - if (parseContext->arrayTypeErrorCheck($1.line, $1)) - parseContext->recover(); + if (context->arrayTypeErrorCheck($1.line, $1)) + context->recover(); } if ($1.array) type->setArraySize($1.arraySize); @@ -1829,24 +1722,24 @@ struct_declarator_list struct_declarator : IDENTIFIER { - if (parseContext->reservedErrorCheck($1.line, *$1.string)) - parseContext->recover(); + if (context->reservedErrorCheck($1.line, *$1.string)) + context->recover(); $$.type = new TType(EbtVoid, EbpUndefined); $$.line = $1.line; $$.type->setFieldName(*$1.string); } | IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { - if (parseContext->reservedErrorCheck($1.line, *$1.string)) - parseContext->recover(); + if (context->reservedErrorCheck($1.line, *$1.string)) + context->recover(); $$.type = new TType(EbtVoid, EbpUndefined); $$.line = $1.line; $$.type->setFieldName(*$1.string); int size; - if (parseContext->arraySizeErrorCheck($2.line, $3, size)) - parseContext->recover(); + if (context->arraySizeErrorCheck($2.line, $3, size)) + context->recover(); $$.type->setArraySize(size); } ; @@ -1876,7 +1769,7 @@ simple_statement compound_statement : LEFT_BRACE RIGHT_BRACE { $$ = 0; } - | LEFT_BRACE { parseContext->symbolTable.push(); } statement_list { parseContext->symbolTable.pop(); } RIGHT_BRACE { + | LEFT_BRACE { context->symbolTable.push(); } statement_list { context->symbolTable.pop(); } RIGHT_BRACE { if ($3 != 0) $3->setOp(EOpSequence); $$ = $3; @@ -1902,10 +1795,10 @@ compound_statement_no_new_scope statement_list : statement { - $$ = parseContext->intermediate.makeAggregate($1, 0); + $$ = context->intermediate.makeAggregate($1, 0); } | statement_list statement { - $$ = parseContext->intermediate.growAggregate($1, $2, 0); + $$ = context->intermediate.growAggregate($1, $2, 0); } ; @@ -1916,9 +1809,9 @@ expression_statement selection_statement : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement { - if (parseContext->boolErrorCheck($1.line, $3)) - parseContext->recover(); - $$ = parseContext->intermediate.addSelection($3, $5, $1.line); + if (context->boolErrorCheck($1.line, $3)) + context->recover(); + $$ = context->intermediate.addSelection($3, $5, $1.line); } ; @@ -1939,42 +1832,42 @@ condition // In 1996 c++ draft, conditions can include single declarations : expression { $$ = $1; - if (parseContext->boolErrorCheck($1->getLine(), $1)) - parseContext->recover(); + if (context->boolErrorCheck($1->getLine(), $1)) + context->recover(); } | fully_specified_type IDENTIFIER EQUAL initializer { TIntermNode* intermNode; - if (parseContext->structQualifierErrorCheck($2.line, $1)) - parseContext->recover(); - if (parseContext->boolErrorCheck($2.line, $1)) - parseContext->recover(); + if (context->structQualifierErrorCheck($2.line, $1)) + context->recover(); + if (context->boolErrorCheck($2.line, $1)) + context->recover(); - if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) + if (!context->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) $$ = $4; else { - parseContext->recover(); + context->recover(); $$ = 0; } } ; iteration_statement - : WHILE LEFT_PAREN { parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope { - parseContext->symbolTable.pop(); - $$ = parseContext->intermediate.addLoop(0, $6, $4, 0, true, $1.line); - --parseContext->loopNestingLevel; + : WHILE LEFT_PAREN { context->symbolTable.push(); ++context->loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope { + context->symbolTable.pop(); + $$ = context->intermediate.addLoop(ELoopWhile, 0, $4, 0, $6, $1.line); + --context->loopNestingLevel; } - | DO { ++parseContext->loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON { - if (parseContext->boolErrorCheck($8.line, $6)) - parseContext->recover(); + | DO { ++context->loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON { + if (context->boolErrorCheck($8.line, $6)) + context->recover(); - $$ = parseContext->intermediate.addLoop(0, $3, $6, 0, false, $4.line); - --parseContext->loopNestingLevel; + $$ = context->intermediate.addLoop(ELoopDoWhile, 0, $6, 0, $3, $4.line); + --context->loopNestingLevel; } - | FOR LEFT_PAREN { parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope { - parseContext->symbolTable.pop(); - $$ = parseContext->intermediate.addLoop($4, $7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.line); - --parseContext->loopNestingLevel; + | FOR LEFT_PAREN { context->symbolTable.push(); ++context->loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope { + context->symbolTable.pop(); + $$ = context->intermediate.addLoop(ELoopFor, $4, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), $7, $1.line); + --context->loopNestingLevel; } ; @@ -2009,40 +1902,40 @@ for_rest_statement jump_statement : CONTINUE SEMICOLON { - if (parseContext->loopNestingLevel <= 0) { - parseContext->error($1.line, "continue statement only allowed in loops", "", ""); - parseContext->recover(); + if (context->loopNestingLevel <= 0) { + context->error($1.line, "continue statement only allowed in loops", "", ""); + context->recover(); } - $$ = parseContext->intermediate.addBranch(EOpContinue, $1.line); + $$ = context->intermediate.addBranch(EOpContinue, $1.line); } | BREAK SEMICOLON { - if (parseContext->loopNestingLevel <= 0) { - parseContext->error($1.line, "break statement only allowed in loops", "", ""); - parseContext->recover(); + if (context->loopNestingLevel <= 0) { + context->error($1.line, "break statement only allowed in loops", "", ""); + context->recover(); } - $$ = parseContext->intermediate.addBranch(EOpBreak, $1.line); + $$ = context->intermediate.addBranch(EOpBreak, $1.line); } | RETURN SEMICOLON { - $$ = parseContext->intermediate.addBranch(EOpReturn, $1.line); - if (parseContext->currentFunctionType->getBasicType() != EbtVoid) { - parseContext->error($1.line, "non-void function must return a value", "return", ""); - parseContext->recover(); + $$ = context->intermediate.addBranch(EOpReturn, $1.line); + if (context->currentFunctionType->getBasicType() != EbtVoid) { + context->error($1.line, "non-void function must return a value", "return", ""); + context->recover(); } } | RETURN expression SEMICOLON { - $$ = parseContext->intermediate.addBranch(EOpReturn, $2, $1.line); - parseContext->functionReturnsValue = true; - if (parseContext->currentFunctionType->getBasicType() == EbtVoid) { - parseContext->error($1.line, "void function cannot return a value", "return", ""); - parseContext->recover(); - } else if (*(parseContext->currentFunctionType) != $2->getType()) { - parseContext->error($1.line, "function return is not matching type:", "return", ""); - parseContext->recover(); + $$ = context->intermediate.addBranch(EOpReturn, $2, $1.line); + context->functionReturnsValue = true; + if (context->currentFunctionType->getBasicType() == EbtVoid) { + context->error($1.line, "void function cannot return a value", "return", ""); + context->recover(); + } else if (*(context->currentFunctionType) != $2->getType()) { + context->error($1.line, "function return is not matching type:", "return", ""); + context->recover(); } } | DISCARD SEMICOLON { FRAG_ONLY("discard", $1.line); - $$ = parseContext->intermediate.addBranch(EOpKill, $1.line); + $$ = context->intermediate.addBranch(EOpKill, $1.line); } ; @@ -2051,11 +1944,11 @@ jump_statement translation_unit : external_declaration { $$ = $1; - parseContext->treeRoot = $$; + context->treeRoot = $$; } | translation_unit external_declaration { - $$ = parseContext->intermediate.growAggregate($1, $2, 0); - parseContext->treeRoot = $$; + $$ = context->intermediate.growAggregate($1, $2, 0); + context->treeRoot = $$; } ; @@ -2070,8 +1963,8 @@ external_declaration function_definition : function_prototype { - TFunction& function = *($1.function); - TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find(function.getMangledName())); + TFunction* function = $1.function; + TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName())); // // Note: 'prevDec' could be 'function' if this is the first time we've seen function // as it would have just been put in the symbol table. Otherwise, we're looking up @@ -2081,35 +1974,35 @@ function_definition // // Then this function already has a body. // - parseContext->error($1.line, "function already has a body", function.getName().c_str(), ""); - parseContext->recover(); + context->error($1.line, "function already has a body", function->getName().c_str(), ""); + context->recover(); } prevDec->setDefined(); // // Raise error message if main function takes any parameters or return anything other than void // - if (function.getName() == "main") { - if (function.getParamCount() > 0) { - parseContext->error($1.line, "function cannot take any parameter(s)", function.getName().c_str(), ""); - parseContext->recover(); + if (function->getName() == "main") { + if (function->getParamCount() > 0) { + context->error($1.line, "function cannot take any parameter(s)", function->getName().c_str(), ""); + context->recover(); } - if (function.getReturnType().getBasicType() != EbtVoid) { - parseContext->error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value"); - parseContext->recover(); + if (function->getReturnType().getBasicType() != EbtVoid) { + context->error($1.line, "", function->getReturnType().getBasicString(), "main function cannot return a value"); + context->recover(); } } // // New symbol table scope for body of function plus its arguments // - parseContext->symbolTable.push(); + context->symbolTable.push(); // // Remember the return type for later checking for RETURN statements. // - parseContext->currentFunctionType = &(prevDec->getReturnType()); - parseContext->functionReturnsValue = false; + context->currentFunctionType = &(prevDec->getReturnType()); + context->functionReturnsValue = false; // // Insert parameters into the symbol table. @@ -2120,59 +2013,60 @@ function_definition // knows where to find parameters. // TIntermAggregate* paramNodes = new TIntermAggregate; - for (int i = 0; i < function.getParamCount(); i++) { - TParameter& param = function[i]; + for (int i = 0; i < function->getParamCount(); i++) { + const TParameter& param = function->getParam(i); if (param.name != 0) { TVariable *variable = new TVariable(param.name, *param.type); // // Insert the parameters with name in the symbol table. // - if (! parseContext->symbolTable.insert(*variable)) { - parseContext->error($1.line, "redefinition", variable->getName().c_str(), ""); - parseContext->recover(); + if (! context->symbolTable.insert(*variable)) { + context->error($1.line, "redefinition", variable->getName().c_str(), ""); + context->recover(); delete variable; } - // - // Transfer ownership of name pointer to symbol table. - // - param.name = 0; // // Add the parameter to the HIL // - paramNodes = parseContext->intermediate.growAggregate( + paramNodes = context->intermediate.growAggregate( paramNodes, - parseContext->intermediate.addSymbol(variable->getUniqueId(), + context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line), $1.line); } else { - paramNodes = parseContext->intermediate.growAggregate(paramNodes, parseContext->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line); + paramNodes = context->intermediate.growAggregate(paramNodes, context->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line); } } - parseContext->intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line); + context->intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line); $1.intermAggregate = paramNodes; - parseContext->loopNestingLevel = 0; + context->loopNestingLevel = 0; } compound_statement_no_new_scope { //?? Check that all paths return a value if return type != void ? // May be best done as post process phase on intermediate code - if (parseContext->currentFunctionType->getBasicType() != EbtVoid && ! parseContext->functionReturnsValue) { - parseContext->error($1.line, "function does not return a value:", "", $1.function->getName().c_str()); - parseContext->recover(); + if (context->currentFunctionType->getBasicType() != EbtVoid && ! context->functionReturnsValue) { + context->error($1.line, "function does not return a value:", "", $1.function->getName().c_str()); + context->recover(); } - parseContext->symbolTable.pop(); - $$ = parseContext->intermediate.growAggregate($1.intermAggregate, $3, 0); - parseContext->intermediate.setAggregateOperator($$, EOpFunction, $1.line); + context->symbolTable.pop(); + $$ = context->intermediate.growAggregate($1.intermAggregate, $3, 0); + context->intermediate.setAggregateOperator($$, EOpFunction, $1.line); $$->getAsAggregate()->setName($1.function->getMangledName().c_str()); $$->getAsAggregate()->setType($1.function->getReturnType()); // store the pragma information for debug and optimize and other vendor specific // information. This information can be queried from the parse tree - $$->getAsAggregate()->setOptimize(parseContext->contextPragma.optimize); - $$->getAsAggregate()->setDebug(parseContext->contextPragma.debug); - $$->getAsAggregate()->addToPragmaTable(parseContext->contextPragma.pragmaTable); + $$->getAsAggregate()->setOptimize(context->contextPragma.optimize); + $$->getAsAggregate()->setDebug(context->contextPragma.debug); + $$->getAsAggregate()->addToPragmaTable(context->contextPragma.pragmaTable); } ; %% + +int glslang_parse(TParseContext* context) { + return yyparse(context); +} + diff --git a/Source/ThirdParty/ANGLE/src/compiler/glslang_lex.cpp b/Source/ThirdParty/ANGLE/src/compiler/glslang_lex.cpp new file mode 100644 index 0000000..9d5f53f --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/glslang_lex.cpp @@ -0,0 +1,3186 @@ +#line 17 "compiler/glslang.l" +// +// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT! + + + +#line 13 "compiler/glslang_lex.cpp" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void yypop_buffer_state (yyscan_t yyscanner ); + +static void yyensure_buffer_stack (yyscan_t yyscanner ); +static void yy_load_buffer_state (yyscan_t yyscanner ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +void *yyalloc (yy_size_t ,yyscan_t yyscanner ); +void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void yyfree (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define yywrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 145 +#define YY_END_OF_BUFFER 146 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[411] = + { 0, + 0, 0, 0, 0, 0, 0, 146, 144, 143, 143, + 128, 134, 139, 123, 124, 132, 131, 120, 129, 127, + 133, 92, 92, 121, 117, 135, 122, 136, 140, 88, + 125, 126, 138, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 118, 137, 119, 130, 3, 4, 3, + 142, 145, 141, 114, 100, 119, 108, 103, 98, 106, + 96, 107, 97, 95, 2, 1, 99, 94, 90, 91, + 0, 0, 92, 126, 118, 125, 115, 111, 113, 112, + 116, 88, 104, 110, 88, 88, 88, 88, 88, 88, + + 88, 88, 88, 88, 17, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 20, 22, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 105, 109, 5, 141, + 0, 1, 94, 0, 0, 93, 89, 101, 102, 48, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 18, 88, 88, + 88, 88, 88, 88, 88, 88, 26, 88, 88, 88, + 88, 88, 88, 88, 88, 23, 88, 88, 88, 88, + + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 0, 95, + 0, 94, 88, 28, 88, 88, 85, 88, 88, 88, + 88, 88, 88, 88, 21, 51, 88, 88, 88, 88, + 88, 56, 70, 88, 88, 88, 88, 88, 88, 88, + 88, 67, 9, 33, 34, 35, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 54, 29, 88, 88, 88, 88, 88, 88, 36, + 37, 38, 27, 88, 88, 88, 15, 42, 43, 44, + 49, 12, 88, 88, 88, 88, 81, 82, 83, 88, + + 30, 71, 25, 78, 79, 80, 7, 75, 76, 77, + 88, 24, 73, 88, 88, 39, 40, 41, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 68, 88, 88, + 88, 88, 88, 88, 88, 50, 88, 87, 88, 88, + 19, 88, 88, 88, 88, 69, 64, 59, 88, 88, + 88, 88, 88, 74, 55, 88, 62, 32, 88, 84, + 63, 47, 57, 88, 88, 88, 88, 88, 88, 88, + 88, 58, 31, 88, 88, 88, 8, 88, 88, 88, + 88, 88, 52, 13, 88, 14, 88, 88, 16, 65, + 88, 88, 88, 60, 88, 88, 88, 53, 72, 61, + + 11, 66, 6, 86, 10, 45, 88, 88, 46, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 1, 1, 1, 5, 6, 1, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 16, 16, 16, 20, 20, 21, 22, 23, + 24, 25, 26, 1, 27, 27, 28, 29, 30, 27, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 32, 31, 31, + 33, 1, 34, 35, 31, 1, 36, 37, 38, 39, + + 40, 41, 42, 43, 44, 31, 45, 46, 47, 48, + 49, 50, 31, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[64] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, + 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, + 4, 4, 1, 1, 1, 3, 3, 3, 3, 3, + 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[416] = + { 0, + 0, 0, 61, 62, 71, 0, 606, 607, 607, 607, + 581, 42, 129, 607, 607, 580, 126, 607, 125, 123, + 137, 149, 157, 578, 607, 175, 578, 44, 607, 0, + 607, 607, 120, 95, 103, 142, 146, 136, 156, 552, + 168, 162, 551, 120, 158, 545, 173, 558, 172, 178, + 111, 186, 554, 607, 159, 607, 607, 607, 607, 582, + 607, 607, 0, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 222, 607, 0, 607, 228, 254, 262, + 281, 0, 290, 607, 607, 607, 571, 607, 607, 607, + 570, 0, 607, 607, 546, 539, 542, 550, 549, 536, + + 551, 538, 544, 532, 529, 542, 529, 526, 526, 532, + 520, 527, 524, 534, 520, 526, 529, 530, 0, 204, + 529, 207, 515, 528, 519, 521, 511, 525, 522, 524, + 507, 512, 509, 498, 183, 512, 508, 510, 499, 502, + 212, 507, 499, 511, 186, 504, 607, 607, 607, 0, + 306, 0, 316, 332, 270, 342, 0, 607, 607, 0, + 496, 500, 509, 506, 490, 490, 161, 505, 502, 502, + 500, 497, 489, 495, 482, 493, 496, 0, 493, 481, + 488, 485, 489, 482, 471, 470, 483, 486, 483, 478, + 469, 294, 474, 477, 468, 465, 469, 475, 466, 457, + + 460, 458, 468, 454, 452, 452, 454, 451, 462, 461, + 278, 456, 451, 440, 320, 458, 460, 449, 348, 354, + 360, 366, 450, 0, 448, 336, 0, 440, 438, 446, + 435, 452, 441, 370, 0, 0, 435, 445, 445, 430, + 373, 0, 0, 432, 376, 433, 427, 426, 427, 426, + 379, 0, 0, 0, 0, 0, 422, 423, 428, 419, + 432, 427, 426, 418, 422, 414, 417, 421, 426, 425, + 416, 0, 0, 422, 411, 411, 416, 415, 412, 0, + 0, 0, 0, 402, 414, 416, 0, 0, 0, 0, + 0, 0, 404, 405, 399, 409, 0, 0, 0, 400, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 407, 0, 0, 405, 401, 0, 0, 0, 397, 393, + 398, 388, 401, 387, 400, 389, 396, 0, 394, 396, + 380, 389, 395, 390, 378, 0, 380, 0, 379, 382, + 0, 371, 370, 370, 383, 0, 385, 0, 384, 383, + 368, 381, 368, 0, 0, 371, 0, 0, 363, 0, + 0, 0, 0, 360, 371, 364, 368, 303, 297, 288, + 300, 0, 0, 283, 290, 269, 0, 277, 274, 255, + 232, 255, 0, 0, 244, 0, 236, 226, 0, 0, + 225, 208, 211, 0, 185, 202, 131, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 134, 117, 0, 607, + 398, 400, 402, 406, 142 + } ; + +static yyconst flex_int16_t yy_def[416] = + { 0, + 410, 1, 411, 411, 410, 5, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 412, + 410, 410, 410, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 413, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 414, 410, 410, 410, 410, + 410, 415, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 412, 410, 410, 412, 412, 412, 412, 412, 412, + + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 410, 410, 410, 413, + 410, 414, 410, 410, 410, 410, 415, 410, 410, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 410, 410, + 410, 410, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + + 412, 412, 412, 412, 412, 412, 412, 412, 412, 0, + 410, 410, 410, 410, 410 + } ; + +static yyconst flex_int16_t yy_nxt[671] = + { 0, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 23, 23, 23, 23, + 24, 25, 26, 27, 28, 29, 30, 30, 30, 30, + 30, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 30, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 30, 30, 30, 54, + 55, 56, 57, 59, 59, 65, 66, 90, 91, 60, + 60, 8, 61, 62, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 63, 63, 63, + + 63, 63, 63, 8, 8, 8, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 8, 8, 8, 8, 67, 70, 72, 74, 74, 74, + 74, 74, 74, 93, 157, 75, 95, 96, 73, 71, + 76, 97, 68, 98, 94, 123, 409, 99, 141, 124, + 77, 78, 142, 79, 79, 79, 79, 79, 80, 78, + 408, 83, 83, 83, 83, 83, 83, 100, 81, 85, + 82, 107, 147, 108, 407, 103, 81, 101, 81, 104, + 102, 110, 109, 125, 105, 86, 81, 87, 88, 111, + + 106, 112, 119, 116, 113, 82, 126, 132, 128, 120, + 114, 117, 229, 230, 133, 134, 121, 137, 204, 148, + 138, 143, 118, 129, 135, 144, 130, 136, 139, 216, + 406, 217, 405, 205, 145, 140, 74, 74, 74, 74, + 74, 74, 153, 153, 153, 153, 153, 153, 396, 184, + 404, 151, 185, 186, 190, 211, 187, 154, 188, 397, + 403, 151, 191, 212, 402, 401, 78, 154, 79, 79, + 79, 79, 79, 80, 78, 400, 80, 80, 80, 80, + 80, 80, 399, 81, 156, 156, 156, 156, 156, 156, + 155, 81, 155, 81, 398, 156, 156, 156, 156, 156, + + 156, 81, 78, 395, 83, 83, 83, 83, 83, 83, + 254, 255, 256, 394, 393, 219, 392, 219, 275, 81, + 220, 220, 220, 220, 220, 220, 276, 391, 390, 81, + 153, 153, 153, 153, 153, 153, 280, 281, 282, 389, + 388, 221, 387, 221, 386, 154, 222, 222, 222, 222, + 222, 222, 288, 289, 290, 154, 156, 156, 156, 156, + 156, 156, 220, 220, 220, 220, 220, 220, 220, 220, + 220, 220, 220, 220, 222, 222, 222, 222, 222, 222, + 222, 222, 222, 222, 222, 222, 297, 298, 299, 304, + 305, 306, 308, 309, 310, 316, 317, 318, 58, 58, + + 58, 58, 92, 92, 150, 150, 152, 385, 152, 152, + 384, 383, 382, 381, 380, 379, 378, 377, 376, 375, + 374, 373, 372, 371, 370, 369, 368, 367, 366, 365, + 364, 363, 362, 361, 360, 359, 358, 357, 356, 355, + 354, 353, 352, 351, 350, 349, 348, 347, 346, 345, + 344, 343, 342, 341, 340, 339, 338, 337, 336, 335, + 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, + 324, 323, 322, 321, 320, 319, 315, 314, 313, 312, + 311, 307, 303, 302, 301, 300, 296, 295, 294, 293, + 292, 291, 287, 286, 285, 284, 283, 279, 278, 277, + + 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, + 264, 263, 262, 261, 260, 259, 258, 257, 253, 252, + 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, + 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, + 231, 228, 227, 226, 225, 224, 223, 218, 215, 214, + 213, 210, 209, 208, 207, 206, 203, 202, 201, 200, + 199, 198, 197, 196, 195, 194, 193, 192, 189, 183, + 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, + 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, + 162, 161, 160, 159, 158, 149, 146, 131, 127, 122, + + 115, 89, 84, 69, 64, 410, 7, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410 + } ; + +static yyconst flex_int16_t yy_chk[671] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 3, 4, 12, 12, 28, 28, 3, + 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 13, 17, 19, 20, 20, 20, + 20, 20, 20, 33, 415, 21, 34, 34, 19, 17, + 21, 35, 13, 35, 33, 44, 408, 35, 51, 44, + 21, 22, 51, 22, 22, 22, 22, 22, 22, 23, + 407, 23, 23, 23, 23, 23, 23, 36, 22, 26, + 22, 38, 55, 38, 397, 37, 23, 36, 22, 37, + 36, 39, 38, 45, 37, 26, 23, 26, 26, 39, + + 37, 39, 42, 41, 39, 22, 45, 49, 47, 42, + 39, 41, 167, 167, 49, 49, 42, 50, 135, 55, + 50, 52, 41, 47, 49, 52, 47, 49, 50, 145, + 396, 145, 395, 135, 52, 50, 74, 74, 74, 74, + 74, 74, 78, 78, 78, 78, 78, 78, 381, 120, + 393, 74, 120, 120, 122, 141, 120, 78, 120, 381, + 392, 74, 122, 141, 391, 388, 79, 78, 79, 79, + 79, 79, 79, 79, 80, 387, 80, 80, 80, 80, + 80, 80, 385, 79, 155, 155, 155, 155, 155, 155, + 81, 80, 81, 79, 382, 81, 81, 81, 81, 81, + + 81, 80, 83, 380, 83, 83, 83, 83, 83, 83, + 192, 192, 192, 379, 378, 151, 376, 151, 211, 83, + 151, 151, 151, 151, 151, 151, 211, 375, 374, 83, + 153, 153, 153, 153, 153, 153, 215, 215, 215, 371, + 370, 154, 369, 154, 368, 153, 154, 154, 154, 154, + 154, 154, 226, 226, 226, 153, 156, 156, 156, 156, + 156, 156, 219, 219, 219, 219, 219, 219, 220, 220, + 220, 220, 220, 220, 221, 221, 221, 221, 221, 221, + 222, 222, 222, 222, 222, 222, 234, 234, 234, 241, + 241, 241, 245, 245, 245, 251, 251, 251, 411, 411, + + 411, 411, 412, 412, 413, 413, 414, 367, 414, 414, + 366, 365, 364, 359, 356, 353, 352, 351, 350, 349, + 347, 345, 344, 343, 342, 340, 339, 337, 335, 334, + 333, 332, 331, 330, 329, 327, 326, 325, 324, 323, + 322, 321, 320, 319, 315, 314, 311, 300, 296, 295, + 294, 293, 286, 285, 284, 279, 278, 277, 276, 275, + 274, 271, 270, 269, 268, 267, 266, 265, 264, 263, + 262, 261, 260, 259, 258, 257, 250, 249, 248, 247, + 246, 244, 240, 239, 238, 237, 233, 232, 231, 230, + 229, 228, 225, 223, 218, 217, 216, 214, 213, 212, + + 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, + 200, 199, 198, 197, 196, 195, 194, 193, 191, 190, + 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, + 179, 177, 176, 175, 174, 173, 172, 171, 170, 169, + 168, 166, 165, 164, 163, 162, 161, 146, 144, 143, + 142, 140, 139, 138, 137, 136, 134, 133, 132, 131, + 130, 129, 128, 127, 126, 125, 124, 123, 121, 118, + 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, + 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, + 97, 96, 95, 91, 87, 60, 53, 48, 46, 43, + + 40, 27, 24, 16, 11, 7, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 410, 410, 410, 410 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[146] = + { 0, +0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, }; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +/* +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +This file contains the Lex specification for GLSL ES. +Based on ANSI C grammar, Lex specification: +http://www.lysator.liu.se/c/ANSI-C-grammar-l.html + +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh, +WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). +*/ + +#include "compiler/glslang.h" +#include "compiler/ParseHelper.h" +#include "compiler/util.h" +#include "glslang_tab.h" + +/* windows only pragma */ +#ifdef _MSC_VER +#pragma warning(disable : 4102) +#endif + +#define YY_USER_ACTION yylval->lex.line = yylineno; +#define YY_INPUT(buf, result, max_size) \ + result = string_input(buf, max_size, yyscanner); + +static int string_input(char* buf, int max_size, yyscan_t yyscanner); +static int check_type(yyscan_t yyscanner); +static int reserved_word(yyscan_t yyscanner); + +#define INITIAL 0 +#define COMMENT 1 +#define FIELDS 2 + +#define YY_EXTRA_TYPE TParseContext* + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy (yyscan_t yyscanner ); + +int yyget_debug (yyscan_t yyscanner ); + +void yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); + +void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *yyget_in (yyscan_t yyscanner ); + +void yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *yyget_out (yyscan_t yyscanner ); + +void yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +int yyget_leng (yyscan_t yyscanner ); + +char *yyget_text (yyscan_t yyscanner ); + +int yyget_lineno (yyscan_t yyscanner ); + +void yyset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * yyget_lval (yyscan_t yyscanner ); + +void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap (yyscan_t yyscanner ); +#else +extern int yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + + static void yy_push_state (int new_state ,yyscan_t yyscanner); + + static void yy_pop_state (yyscan_t yyscanner ); + + static int yy_top_state (yyscan_t yyscanner ); + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param ,yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + TParseContext* context = yyextra; + + /* Single-line comments */ + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + yy_load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 411 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 410 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +; + YY_BREAK +/* Multi-line comments */ +case 2: +YY_RULE_SETUP +{ yy_push_state(COMMENT, yyscanner); } + YY_BREAK +case 3: +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +; + YY_BREAK +case 5: +YY_RULE_SETUP +{ yy_pop_state(yyscanner); } + YY_BREAK +case 6: +YY_RULE_SETUP +{ return(INVARIANT); } + YY_BREAK +case 7: +YY_RULE_SETUP +{ return(HIGH_PRECISION); } + YY_BREAK +case 8: +YY_RULE_SETUP +{ return(MEDIUM_PRECISION); } + YY_BREAK +case 9: +YY_RULE_SETUP +{ return(LOW_PRECISION); } + YY_BREAK +case 10: +YY_RULE_SETUP +{ return(PRECISION); } + YY_BREAK +case 11: +YY_RULE_SETUP +{ return(ATTRIBUTE); } + YY_BREAK +case 12: +YY_RULE_SETUP +{ return(CONST_QUAL); } + YY_BREAK +case 13: +YY_RULE_SETUP +{ return(UNIFORM); } + YY_BREAK +case 14: +YY_RULE_SETUP +{ return(VARYING); } + YY_BREAK +case 15: +YY_RULE_SETUP +{ return(BREAK); } + YY_BREAK +case 16: +YY_RULE_SETUP +{ return(CONTINUE); } + YY_BREAK +case 17: +YY_RULE_SETUP +{ return(DO); } + YY_BREAK +case 18: +YY_RULE_SETUP +{ return(FOR); } + YY_BREAK +case 19: +YY_RULE_SETUP +{ return(WHILE); } + YY_BREAK +case 20: +YY_RULE_SETUP +{ return(IF); } + YY_BREAK +case 21: +YY_RULE_SETUP +{ return(ELSE); } + YY_BREAK +case 22: +YY_RULE_SETUP +{ return(IN_QUAL); } + YY_BREAK +case 23: +YY_RULE_SETUP +{ return(OUT_QUAL); } + YY_BREAK +case 24: +YY_RULE_SETUP +{ return(INOUT_QUAL); } + YY_BREAK +case 25: +YY_RULE_SETUP +{ context->lexAfterType = true; return(FLOAT_TYPE); } + YY_BREAK +case 26: +YY_RULE_SETUP +{ context->lexAfterType = true; return(INT_TYPE); } + YY_BREAK +case 27: +YY_RULE_SETUP +{ context->lexAfterType = true; return(VOID_TYPE); } + YY_BREAK +case 28: +YY_RULE_SETUP +{ context->lexAfterType = true; return(BOOL_TYPE); } + YY_BREAK +case 29: +YY_RULE_SETUP +{ yylval->lex.b = true; return(BOOLCONSTANT); } + YY_BREAK +case 30: +YY_RULE_SETUP +{ yylval->lex.b = false; return(BOOLCONSTANT); } + YY_BREAK +case 31: +YY_RULE_SETUP +{ return(DISCARD); } + YY_BREAK +case 32: +YY_RULE_SETUP +{ return(RETURN); } + YY_BREAK +case 33: +YY_RULE_SETUP +{ context->lexAfterType = true; return(MATRIX2); } + YY_BREAK +case 34: +YY_RULE_SETUP +{ context->lexAfterType = true; return(MATRIX3); } + YY_BREAK +case 35: +YY_RULE_SETUP +{ context->lexAfterType = true; return(MATRIX4); } + YY_BREAK +case 36: +YY_RULE_SETUP +{ context->lexAfterType = true; return (VEC2); } + YY_BREAK +case 37: +YY_RULE_SETUP +{ context->lexAfterType = true; return (VEC3); } + YY_BREAK +case 38: +YY_RULE_SETUP +{ context->lexAfterType = true; return (VEC4); } + YY_BREAK +case 39: +YY_RULE_SETUP +{ context->lexAfterType = true; return (IVEC2); } + YY_BREAK +case 40: +YY_RULE_SETUP +{ context->lexAfterType = true; return (IVEC3); } + YY_BREAK +case 41: +YY_RULE_SETUP +{ context->lexAfterType = true; return (IVEC4); } + YY_BREAK +case 42: +YY_RULE_SETUP +{ context->lexAfterType = true; return (BVEC2); } + YY_BREAK +case 43: +YY_RULE_SETUP +{ context->lexAfterType = true; return (BVEC3); } + YY_BREAK +case 44: +YY_RULE_SETUP +{ context->lexAfterType = true; return (BVEC4); } + YY_BREAK +case 45: +YY_RULE_SETUP +{ context->lexAfterType = true; return SAMPLER2D; } + YY_BREAK +case 46: +YY_RULE_SETUP +{ context->lexAfterType = true; return SAMPLERCUBE; } + YY_BREAK +case 47: +YY_RULE_SETUP +{ context->lexAfterType = true; return(STRUCT); } + YY_BREAK +case 48: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 49: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 50: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 51: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 52: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 53: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 54: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 55: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 56: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 57: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 58: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 59: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 60: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 61: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 62: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 63: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 64: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 65: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 66: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 67: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 68: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 69: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 70: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 71: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 72: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 73: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 74: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 75: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 76: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 77: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 78: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 79: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 80: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 81: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 82: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 83: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 84: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 85: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 86: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 87: +YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 88: +YY_RULE_SETUP +{ + yylval->lex.string = NewPoolTString(yytext); + return check_type(yyscanner); +} + YY_BREAK +case 89: +YY_RULE_SETUP +{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } + YY_BREAK +case 90: +YY_RULE_SETUP +{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } + YY_BREAK +case 91: +YY_RULE_SETUP +{ context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;} + YY_BREAK +case 92: +YY_RULE_SETUP +{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } + YY_BREAK +case 93: +YY_RULE_SETUP +{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); } + YY_BREAK +case 94: +YY_RULE_SETUP +{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); } + YY_BREAK +case 95: +YY_RULE_SETUP +{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); } + YY_BREAK +case 96: +YY_RULE_SETUP +{ return(ADD_ASSIGN); } + YY_BREAK +case 97: +YY_RULE_SETUP +{ return(SUB_ASSIGN); } + YY_BREAK +case 98: +YY_RULE_SETUP +{ return(MUL_ASSIGN); } + YY_BREAK +case 99: +YY_RULE_SETUP +{ return(DIV_ASSIGN); } + YY_BREAK +case 100: +YY_RULE_SETUP +{ return(MOD_ASSIGN); } + YY_BREAK +case 101: +YY_RULE_SETUP +{ return(LEFT_ASSIGN); } + YY_BREAK +case 102: +YY_RULE_SETUP +{ return(RIGHT_ASSIGN); } + YY_BREAK +case 103: +YY_RULE_SETUP +{ return(AND_ASSIGN); } + YY_BREAK +case 104: +YY_RULE_SETUP +{ return(XOR_ASSIGN); } + YY_BREAK +case 105: +YY_RULE_SETUP +{ return(OR_ASSIGN); } + YY_BREAK +case 106: +YY_RULE_SETUP +{ return(INC_OP); } + YY_BREAK +case 107: +YY_RULE_SETUP +{ return(DEC_OP); } + YY_BREAK +case 108: +YY_RULE_SETUP +{ return(AND_OP); } + YY_BREAK +case 109: +YY_RULE_SETUP +{ return(OR_OP); } + YY_BREAK +case 110: +YY_RULE_SETUP +{ return(XOR_OP); } + YY_BREAK +case 111: +YY_RULE_SETUP +{ return(LE_OP); } + YY_BREAK +case 112: +YY_RULE_SETUP +{ return(GE_OP); } + YY_BREAK +case 113: +YY_RULE_SETUP +{ return(EQ_OP); } + YY_BREAK +case 114: +YY_RULE_SETUP +{ return(NE_OP); } + YY_BREAK +case 115: +YY_RULE_SETUP +{ return(LEFT_OP); } + YY_BREAK +case 116: +YY_RULE_SETUP +{ return(RIGHT_OP); } + YY_BREAK +case 117: +YY_RULE_SETUP +{ context->lexAfterType = false; return(SEMICOLON); } + YY_BREAK +case 118: +YY_RULE_SETUP +{ context->lexAfterType = false; return(LEFT_BRACE); } + YY_BREAK +case 119: +YY_RULE_SETUP +{ return(RIGHT_BRACE); } + YY_BREAK +case 120: +YY_RULE_SETUP +{ if (context->inTypeParen) context->lexAfterType = false; return(COMMA); } + YY_BREAK +case 121: +YY_RULE_SETUP +{ return(COLON); } + YY_BREAK +case 122: +YY_RULE_SETUP +{ context->lexAfterType = false; return(EQUAL); } + YY_BREAK +case 123: +YY_RULE_SETUP +{ context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); } + YY_BREAK +case 124: +YY_RULE_SETUP +{ context->inTypeParen = false; return(RIGHT_PAREN); } + YY_BREAK +case 125: +YY_RULE_SETUP +{ return(LEFT_BRACKET); } + YY_BREAK +case 126: +YY_RULE_SETUP +{ return(RIGHT_BRACKET); } + YY_BREAK +case 127: +YY_RULE_SETUP +{ BEGIN(FIELDS); return(DOT); } + YY_BREAK +case 128: +YY_RULE_SETUP +{ return(BANG); } + YY_BREAK +case 129: +YY_RULE_SETUP +{ return(DASH); } + YY_BREAK +case 130: +YY_RULE_SETUP +{ return(TILDE); } + YY_BREAK +case 131: +YY_RULE_SETUP +{ return(PLUS); } + YY_BREAK +case 132: +YY_RULE_SETUP +{ return(STAR); } + YY_BREAK +case 133: +YY_RULE_SETUP +{ return(SLASH); } + YY_BREAK +case 134: +YY_RULE_SETUP +{ return(PERCENT); } + YY_BREAK +case 135: +YY_RULE_SETUP +{ return(LEFT_ANGLE); } + YY_BREAK +case 136: +YY_RULE_SETUP +{ return(RIGHT_ANGLE); } + YY_BREAK +case 137: +YY_RULE_SETUP +{ return(VERTICAL_BAR); } + YY_BREAK +case 138: +YY_RULE_SETUP +{ return(CARET); } + YY_BREAK +case 139: +YY_RULE_SETUP +{ return(AMPERSAND); } + YY_BREAK +case 140: +YY_RULE_SETUP +{ return(QUESTION); } + YY_BREAK +case 141: +YY_RULE_SETUP +{ + BEGIN(INITIAL); + yylval->lex.string = NewPoolTString(yytext); + return FIELD_SELECTION; +} + YY_BREAK +case 142: +YY_RULE_SETUP +{} + YY_BREAK +case 143: +/* rule 143 can match eol */ +YY_RULE_SETUP +{ } + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT): +case YY_STATE_EOF(FIELDS): +{ context->AfterEOF = true; yyterminate(); } + YY_BREAK +case 144: +YY_RULE_SETUP +{ context->warning(yylineno, "Unknown char", yytext, ""); return 0; } + YY_BREAK +case 145: +YY_RULE_SETUP +ECHO; + YY_BREAK + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 411 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 411 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 410); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + if ( c == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + yy_load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ,yyscanner ); + + yyfree((void *) b ,yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + + static void yy_push_state (int new_state , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) + { + yy_size_t new_size; + + yyg->yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yyg->yy_start_stack_depth * sizeof( int ); + + if ( ! yyg->yy_start_stack ) + yyg->yy_start_stack = (int *) yyalloc(new_size ,yyscanner ); + + else + yyg->yy_start_stack = (int *) yyrealloc((void *) yyg->yy_start_stack,new_size ,yyscanner ); + + if ( ! yyg->yy_start_stack ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); +} + + static void yy_pop_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( --yyg->yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); +} + + static int yy_top_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "yyset_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void yyset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "yyset_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void yyset_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int yylex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ + +int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +extern "C" { +// Preprocessor interface. +#include "compiler/preprocessor/preprocess.h" + +#define SETUP_CONTEXT(pp) \ + TParseContext* context = (TParseContext*) pp->pC; \ + struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; + +// Preprocessor callbacks. +void CPPDebugLogMsg(const char *msg) +{ + SETUP_CONTEXT(cpp); + context->infoSink.debug.message(EPrefixNone, msg); +} + +void CPPWarningToInfoLog(const char *msg) +{ + SETUP_CONTEXT(cpp); + context->warning(yylineno, msg, "", ""); +} + +void CPPShInfoLogMsg(const char *msg) +{ + SETUP_CONTEXT(cpp); + context->error(yylineno, msg, "", ""); + context->recover(); +} + +void CPPErrorToInfoLog(char *msg) +{ + SETUP_CONTEXT(cpp); + context->error(yylineno, msg, "", ""); + context->recover(); +} + +void SetLineNumber(int line) +{ + SETUP_CONTEXT(cpp); + int string = 0; + DecodeSourceLoc(yylineno, &string, NULL); + yylineno = EncodeSourceLoc(string, line); +} + +void SetStringNumber(int string) +{ + SETUP_CONTEXT(cpp); + int line = 0; + DecodeSourceLoc(yylineno, NULL, &line); + yylineno = EncodeSourceLoc(string, line); +} + +int GetStringNumber() +{ + SETUP_CONTEXT(cpp); + int string = 0; + DecodeSourceLoc(yylineno, &string, NULL); + return string; +} + +int GetLineNumber() +{ + SETUP_CONTEXT(cpp); + int line = 0; + DecodeSourceLoc(yylineno, NULL, &line); + return line; +} + +void IncLineNumber() +{ + SETUP_CONTEXT(cpp); + int string = 0, line = 0; + DecodeSourceLoc(yylineno, &string, &line); + yylineno = EncodeSourceLoc(string, ++line); +} + +void DecLineNumber() +{ + SETUP_CONTEXT(cpp); + int string = 0, line = 0; + DecodeSourceLoc(yylineno, &string, &line); + yylineno = EncodeSourceLoc(string, --line); +} + +void HandlePragma(const char **tokens, int numTokens) +{ + SETUP_CONTEXT(cpp); + if (!strcmp(tokens[0], "optimize")) { + if (numTokens != 4) { + CPPShInfoLogMsg("optimize pragma syntax is incorrect"); + return; + } + + if (strcmp(tokens[1], "(")) { + CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword"); + return; + } + + if (!strcmp(tokens[2], "on")) + context->contextPragma.optimize = true; + else if (!strcmp(tokens[2], "off")) + context->contextPragma.optimize = false; + else { + CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma"); + return; + } + + if (strcmp(tokens[3], ")")) { + CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma"); + return; + } + } else if (!strcmp(tokens[0], "debug")) { + if (numTokens != 4) { + CPPShInfoLogMsg("debug pragma syntax is incorrect"); + return; + } + + if (strcmp(tokens[1], "(")) { + CPPShInfoLogMsg("\"(\" expected after 'debug' keyword"); + return; + } + + if (!strcmp(tokens[2], "on")) + context->contextPragma.debug = true; + else if (!strcmp(tokens[2], "off")) + context->contextPragma.debug = false; + else { + CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma"); + return; + } + + if (strcmp(tokens[3], ")")) { + CPPShInfoLogMsg("\")\" expected to end 'debug' pragma"); + return; + } + } else { +#ifdef PRAGMA_TABLE + // + // implementation specific pragma + // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma + // For now, just ignore the pragma that the implementation cannot recognize + // An Example of one such implementation for a pragma that has a syntax like + // #pragma pragmaname(pragmavalue) + // This implementation stores the current pragmavalue against the pragma name in pragmaTable. + // + if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) { + TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable; + TPragmaTable::iterator iter; + iter = pragmaTable.find(TString(tokens[0])); + if (iter != pragmaTable.end()) { + iter->second = tokens[2]; + } else { + pragmaTable[ tokens[0] ] = tokens[2]; + } + } else if (numTokens >= 2) { + TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable; + TPragmaTable::iterator iter; + iter = pragmaTable.find(TString(tokens[0])); + if (iter != pragmaTable.end()) { + iter->second = tokens[1]; + } else { + pragmaTable[ tokens[0] ] = tokens[1]; + } + } +#endif // PRAGMA_TABLE + } +} + +void StoreStr(char *string) +{ + SETUP_CONTEXT(cpp); + TString strSrc; + strSrc = TString(string); + + context->HashErrMsg = context->HashErrMsg + " " + strSrc; +} + +const char* GetStrfromTStr(void) +{ + SETUP_CONTEXT(cpp); + cpp->ErrMsg = context->HashErrMsg.c_str(); + return cpp->ErrMsg; +} + +void ResetTString(void) +{ + SETUP_CONTEXT(cpp); + context->HashErrMsg = ""; +} + +TBehavior GetBehavior(const char* behavior) +{ + if (!strcmp("require", behavior)) + return EBhRequire; + else if (!strcmp("enable", behavior)) + return EBhEnable; + else if (!strcmp("disable", behavior)) + return EBhDisable; + else if (!strcmp("warn", behavior)) + return EBhWarn; + else { + CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str()); + return EBhDisable; + } +} + +void updateExtensionBehavior(const char* extName, const char* behavior) +{ + SETUP_CONTEXT(cpp); + TBehavior behaviorVal = GetBehavior(behavior); + TMap<TString, TBehavior>:: iterator iter; + TString msg; + + // special cased for all extension + if (!strcmp(extName, "all")) { + if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) { + CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); + return; + } else { + for (iter = context->extensionBehavior.begin(); iter != context->extensionBehavior.end(); ++iter) + iter->second = behaviorVal; + } + } else { + iter = context->extensionBehavior.find(TString(extName)); + if (iter == context->extensionBehavior.end()) { + switch (behaviorVal) { + case EBhRequire: + CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); + break; + case EBhEnable: + case EBhWarn: + case EBhDisable: + msg = TString("extension '") + extName + "' is not supported"; + context->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno); + break; + } + return; + } else + iter->second = behaviorVal; + } +} +} // extern "C" + +int string_input(char* buf, int max_size, yyscan_t yyscanner) { + int len; + + if ((len = yylex_CPP(buf, max_size)) == 0) + return 0; + if (len >= max_size) + YY_FATAL_ERROR("input buffer overflow, can't enlarge buffer because scanner uses REJECT"); + + buf[len] = ' '; + return len+1; +} + +int check_type(yyscan_t yyscanner) { + struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; + + int token = IDENTIFIER; + TSymbol* symbol = yyextra->symbolTable.find(yytext); + if (yyextra->lexAfterType == false && symbol && symbol->isVariable()) { + TVariable* variable = static_cast<TVariable*>(symbol); + if (variable->isUserType()) { + yyextra->lexAfterType = true; + token = TYPE_NAME; + } + } + yylval->lex.symbol = symbol; + return token; +} + +int reserved_word(yyscan_t yyscanner) { + struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; + + yyextra->error(yylineno, "Illegal use of reserved word", yytext, ""); + yyextra->recover(); + return 0; +} + +void yyerror(TParseContext* context, const char* reason) { + struct yyguts_t* yyg = (struct yyguts_t*) context->scanner; + + if (context->AfterEOF) { + context->error(yylineno, reason, "unexpected EOF", ""); + } else { + context->error(yylineno, reason, yytext, ""); + } + context->recover(); +} + +int glslang_initialize(TParseContext* context) { + yyscan_t scanner = NULL; + if (yylex_init_extra(context,&scanner)) + return 1; + + context->scanner = scanner; + return 0; +} + +int glslang_finalize(TParseContext* context) { + yyscan_t scanner = context->scanner; + if (scanner == NULL) return 0; + + context->scanner = NULL; + return yylex_destroy(scanner); +} + +void glslang_scan(int count, const char* const string[], const int length[], + TParseContext* context) { + yyrestart(NULL,context->scanner); + yyset_lineno(EncodeSourceLoc(0, 1),context->scanner); + context->AfterEOF = false; + + // Init preprocessor. + cpp->pC = context; + cpp->PaWhichStr = 0; + cpp->PaArgv = string; + cpp->PaArgc = count; + cpp->PaStrLen = length; + cpp->pastFirstStatement = 0; + ScanFromString(string[0]); +} + diff --git a/Source/ThirdParty/ANGLE/src/compiler/glslang_tab.cpp b/Source/ThirdParty/ANGLE/src/compiler/glslang_tab.cpp new file mode 100644 index 0000000..d00c7a3 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/glslang_tab.cpp @@ -0,0 +1,4710 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INVARIANT = 258, + HIGH_PRECISION = 259, + MEDIUM_PRECISION = 260, + LOW_PRECISION = 261, + PRECISION = 262, + ATTRIBUTE = 263, + CONST_QUAL = 264, + BOOL_TYPE = 265, + FLOAT_TYPE = 266, + INT_TYPE = 267, + BREAK = 268, + CONTINUE = 269, + DO = 270, + ELSE = 271, + FOR = 272, + IF = 273, + DISCARD = 274, + RETURN = 275, + BVEC2 = 276, + BVEC3 = 277, + BVEC4 = 278, + IVEC2 = 279, + IVEC3 = 280, + IVEC4 = 281, + VEC2 = 282, + VEC3 = 283, + VEC4 = 284, + MATRIX2 = 285, + MATRIX3 = 286, + MATRIX4 = 287, + IN_QUAL = 288, + OUT_QUAL = 289, + INOUT_QUAL = 290, + UNIFORM = 291, + VARYING = 292, + STRUCT = 293, + VOID_TYPE = 294, + WHILE = 295, + SAMPLER2D = 296, + SAMPLERCUBE = 297, + IDENTIFIER = 298, + TYPE_NAME = 299, + FLOATCONSTANT = 300, + INTCONSTANT = 301, + BOOLCONSTANT = 302, + FIELD_SELECTION = 303, + LEFT_OP = 304, + RIGHT_OP = 305, + INC_OP = 306, + DEC_OP = 307, + LE_OP = 308, + GE_OP = 309, + EQ_OP = 310, + NE_OP = 311, + AND_OP = 312, + OR_OP = 313, + XOR_OP = 314, + MUL_ASSIGN = 315, + DIV_ASSIGN = 316, + ADD_ASSIGN = 317, + MOD_ASSIGN = 318, + LEFT_ASSIGN = 319, + RIGHT_ASSIGN = 320, + AND_ASSIGN = 321, + XOR_ASSIGN = 322, + OR_ASSIGN = 323, + SUB_ASSIGN = 324, + LEFT_PAREN = 325, + RIGHT_PAREN = 326, + LEFT_BRACKET = 327, + RIGHT_BRACKET = 328, + LEFT_BRACE = 329, + RIGHT_BRACE = 330, + DOT = 331, + COMMA = 332, + COLON = 333, + EQUAL = 334, + SEMICOLON = 335, + BANG = 336, + DASH = 337, + TILDE = 338, + PLUS = 339, + STAR = 340, + SLASH = 341, + PERCENT = 342, + LEFT_ANGLE = 343, + RIGHT_ANGLE = 344, + VERTICAL_BAR = 345, + CARET = 346, + AMPERSAND = 347, + QUESTION = 348 + }; +#endif +/* Tokens. */ +#define INVARIANT 258 +#define HIGH_PRECISION 259 +#define MEDIUM_PRECISION 260 +#define LOW_PRECISION 261 +#define PRECISION 262 +#define ATTRIBUTE 263 +#define CONST_QUAL 264 +#define BOOL_TYPE 265 +#define FLOAT_TYPE 266 +#define INT_TYPE 267 +#define BREAK 268 +#define CONTINUE 269 +#define DO 270 +#define ELSE 271 +#define FOR 272 +#define IF 273 +#define DISCARD 274 +#define RETURN 275 +#define BVEC2 276 +#define BVEC3 277 +#define BVEC4 278 +#define IVEC2 279 +#define IVEC3 280 +#define IVEC4 281 +#define VEC2 282 +#define VEC3 283 +#define VEC4 284 +#define MATRIX2 285 +#define MATRIX3 286 +#define MATRIX4 287 +#define IN_QUAL 288 +#define OUT_QUAL 289 +#define INOUT_QUAL 290 +#define UNIFORM 291 +#define VARYING 292 +#define STRUCT 293 +#define VOID_TYPE 294 +#define WHILE 295 +#define SAMPLER2D 296 +#define SAMPLERCUBE 297 +#define IDENTIFIER 298 +#define TYPE_NAME 299 +#define FLOATCONSTANT 300 +#define INTCONSTANT 301 +#define BOOLCONSTANT 302 +#define FIELD_SELECTION 303 +#define LEFT_OP 304 +#define RIGHT_OP 305 +#define INC_OP 306 +#define DEC_OP 307 +#define LE_OP 308 +#define GE_OP 309 +#define EQ_OP 310 +#define NE_OP 311 +#define AND_OP 312 +#define OR_OP 313 +#define XOR_OP 314 +#define MUL_ASSIGN 315 +#define DIV_ASSIGN 316 +#define ADD_ASSIGN 317 +#define MOD_ASSIGN 318 +#define LEFT_ASSIGN 319 +#define RIGHT_ASSIGN 320 +#define AND_ASSIGN 321 +#define XOR_ASSIGN 322 +#define OR_ASSIGN 323 +#define SUB_ASSIGN 324 +#define LEFT_PAREN 325 +#define RIGHT_PAREN 326 +#define LEFT_BRACKET 327 +#define RIGHT_BRACKET 328 +#define LEFT_BRACE 329 +#define RIGHT_BRACE 330 +#define DOT 331 +#define COMMA 332 +#define COLON 333 +#define EQUAL 334 +#define SEMICOLON 335 +#define BANG 336 +#define DASH 337 +#define TILDE 338 +#define PLUS 339 +#define STAR 340 +#define SLASH 341 +#define PERCENT 342 +#define LEFT_ANGLE 343 +#define RIGHT_ANGLE 344 +#define VERTICAL_BAR 345 +#define CARET 346 +#define AMPERSAND 347 +#define QUESTION 348 + + + + +/* Copy the first part of user declarations. */ + + +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT! + +#include "compiler/SymbolTable.h" +#include "compiler/ParseHelper.h" +#include "GLSLANG/ShaderLang.h" + +#define YYLEX_PARAM context->scanner + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE + +{ + struct { + TSourceLoc line; + union { + TString *string; + float f; + int i; + bool b; + }; + TSymbol* symbol; + } lex; + struct { + TSourceLoc line; + TOperator op; + union { + TIntermNode* intermNode; + TIntermNodePair nodePair; + TIntermTyped* intermTypedNode; + TIntermAggregate* intermAggregate; + }; + union { + TPublicType type; + TPrecision precision; + TQualifier qualifier; + TFunction* function; + TParameter param; + TTypeLine typeLine; + TTypeList* typeList; + }; + } interm; +} +/* Line 187 of yacc.c. */ + + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +extern int yylex(YYSTYPE* yylval_param, void* yyscanner); +extern void yyerror(TParseContext* context, const char* reason); + +#define FRAG_VERT_ONLY(S, L) { \ + if (context->shaderType != SH_FRAGMENT_SHADER && \ + context->shaderType != SH_VERTEX_SHADER) { \ + context->error(L, " supported in vertex/fragment shaders only ", S, "", ""); \ + context->recover(); \ + } \ +} + +#define VERTEX_ONLY(S, L) { \ + if (context->shaderType != SH_VERTEX_SHADER) { \ + context->error(L, " supported in vertex shaders only ", S, "", ""); \ + context->recover(); \ + } \ +} + +#define FRAG_ONLY(S, L) { \ + if (context->shaderType != SH_FRAGMENT_SHADER) { \ + context->error(L, " supported in fragment shaders only ", S, "", ""); \ + context->recover(); \ + } \ +} + + +/* Line 216 of yacc.c. */ + + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 69 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 1334 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 94 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 78 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 193 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 296 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 348 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 5, 7, 9, 11, 13, 17, 19, + 24, 26, 30, 33, 36, 38, 40, 42, 46, 49, + 52, 55, 57, 60, 64, 67, 69, 71, 73, 75, + 78, 81, 84, 86, 88, 90, 92, 96, 100, 102, + 106, 110, 112, 114, 118, 122, 126, 130, 132, 136, + 140, 142, 144, 146, 148, 152, 154, 158, 160, 164, + 166, 172, 174, 178, 180, 182, 184, 186, 188, 190, + 194, 196, 199, 202, 207, 210, 212, 214, 217, 221, + 225, 228, 234, 238, 241, 245, 248, 249, 251, 253, + 255, 257, 259, 263, 269, 276, 282, 284, 287, 292, + 298, 303, 306, 308, 311, 313, 315, 317, 320, 322, + 324, 327, 329, 331, 333, 335, 340, 342, 344, 346, + 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, + 368, 370, 372, 374, 376, 378, 380, 386, 391, 393, + 396, 400, 402, 406, 408, 413, 415, 417, 419, 421, + 423, 425, 427, 429, 431, 434, 435, 436, 442, 444, + 446, 449, 453, 455, 458, 460, 463, 469, 473, 475, + 477, 482, 483, 490, 491, 500, 501, 509, 511, 513, + 515, 516, 519, 523, 526, 529, 532, 536, 539, 541, + 544, 546, 548, 549 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 168, 0, -1, 43, -1, 95, -1, 46, -1, 45, + -1, 47, -1, 70, 122, 71, -1, 96, -1, 97, + 72, 98, 73, -1, 99, -1, 97, 76, 48, -1, + 97, 51, -1, 97, 52, -1, 122, -1, 100, -1, + 101, -1, 97, 76, 101, -1, 103, 71, -1, 102, + 71, -1, 104, 39, -1, 104, -1, 104, 120, -1, + 103, 77, 120, -1, 105, 70, -1, 137, -1, 43, + -1, 48, -1, 97, -1, 51, 106, -1, 52, 106, + -1, 107, 106, -1, 84, -1, 82, -1, 81, -1, + 106, -1, 108, 85, 106, -1, 108, 86, 106, -1, + 108, -1, 109, 84, 108, -1, 109, 82, 108, -1, + 109, -1, 110, -1, 111, 88, 110, -1, 111, 89, + 110, -1, 111, 53, 110, -1, 111, 54, 110, -1, + 111, -1, 112, 55, 111, -1, 112, 56, 111, -1, + 112, -1, 113, -1, 114, -1, 115, -1, 116, 57, + 115, -1, 116, -1, 117, 59, 116, -1, 117, -1, + 118, 58, 117, -1, 118, -1, 118, 93, 122, 78, + 120, -1, 119, -1, 106, 121, 120, -1, 79, -1, + 60, -1, 61, -1, 62, -1, 69, -1, 120, -1, + 122, 77, 120, -1, 119, -1, 125, 80, -1, 133, + 80, -1, 7, 138, 139, 80, -1, 126, 71, -1, + 128, -1, 127, -1, 128, 130, -1, 127, 77, 130, + -1, 135, 43, 70, -1, 137, 43, -1, 137, 43, + 72, 123, 73, -1, 136, 131, 129, -1, 131, 129, + -1, 136, 131, 132, -1, 131, 132, -1, -1, 33, + -1, 34, -1, 35, -1, 137, -1, 134, -1, 133, + 77, 43, -1, 133, 77, 43, 72, 73, -1, 133, + 77, 43, 72, 123, 73, -1, 133, 77, 43, 79, + 146, -1, 135, -1, 135, 43, -1, 135, 43, 72, + 73, -1, 135, 43, 72, 123, 73, -1, 135, 43, + 79, 146, -1, 3, 43, -1, 137, -1, 136, 137, + -1, 9, -1, 8, -1, 37, -1, 3, 37, -1, + 36, -1, 139, -1, 138, 139, -1, 4, -1, 5, + -1, 6, -1, 140, -1, 140, 72, 123, 73, -1, + 39, -1, 11, -1, 12, -1, 10, -1, 27, -1, + 28, -1, 29, -1, 21, -1, 22, -1, 23, -1, + 24, -1, 25, -1, 26, -1, 30, -1, 31, -1, + 32, -1, 41, -1, 42, -1, 141, -1, 44, -1, + 38, 43, 74, 142, 75, -1, 38, 74, 142, 75, + -1, 143, -1, 142, 143, -1, 137, 144, 80, -1, + 145, -1, 144, 77, 145, -1, 43, -1, 43, 72, + 123, 73, -1, 120, -1, 124, -1, 150, -1, 149, + -1, 147, -1, 156, -1, 157, -1, 160, -1, 167, + -1, 74, 75, -1, -1, -1, 74, 151, 155, 152, + 75, -1, 154, -1, 149, -1, 74, 75, -1, 74, + 155, 75, -1, 148, -1, 155, 148, -1, 80, -1, + 122, 80, -1, 18, 70, 122, 71, 158, -1, 148, + 16, 148, -1, 148, -1, 122, -1, 135, 43, 79, + 146, -1, -1, 40, 70, 161, 159, 71, 153, -1, + -1, 15, 162, 148, 40, 70, 122, 71, 80, -1, + -1, 17, 70, 163, 164, 166, 71, 153, -1, 156, + -1, 147, -1, 159, -1, -1, 165, 80, -1, 165, + 80, 122, -1, 14, 80, -1, 13, 80, -1, 20, + 80, -1, 20, 122, 80, -1, 19, 80, -1, 169, + -1, 168, 169, -1, 170, -1, 124, -1, -1, 125, + 171, 154, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 153, 153, 188, 191, 204, 209, 214, 220, 223, + 296, 299, 408, 418, 431, 439, 538, 541, 549, 553, + 560, 564, 571, 577, 586, 594, 656, 663, 673, 676, + 686, 696, 717, 718, 719, 724, 725, 734, 746, 747, + 755, 766, 770, 771, 781, 791, 801, 814, 815, 825, + 838, 842, 846, 850, 851, 864, 865, 878, 879, 892, + 893, 910, 911, 924, 925, 926, 927, 928, 932, 935, + 946, 954, 979, 984, 991, 1027, 1030, 1037, 1045, 1066, + 1085, 1096, 1125, 1130, 1140, 1145, 1155, 1158, 1161, 1164, + 1170, 1177, 1187, 1199, 1217, 1241, 1264, 1268, 1282, 1302, + 1331, 1351, 1427, 1436, 1459, 1462, 1468, 1476, 1484, 1492, + 1495, 1502, 1505, 1508, 1514, 1517, 1532, 1536, 1540, 1544, + 1553, 1558, 1563, 1568, 1573, 1578, 1583, 1588, 1593, 1598, + 1604, 1610, 1616, 1621, 1626, 1631, 1644, 1657, 1665, 1668, + 1683, 1714, 1718, 1724, 1732, 1748, 1752, 1756, 1757, 1763, + 1764, 1765, 1766, 1767, 1771, 1772, 1772, 1772, 1780, 1781, + 1786, 1789, 1797, 1800, 1806, 1807, 1811, 1819, 1823, 1833, + 1838, 1855, 1855, 1860, 1860, 1867, 1867, 1875, 1878, 1884, + 1887, 1893, 1897, 1904, 1911, 1918, 1925, 1936, 1945, 1949, + 1956, 1959, 1965, 1965 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INVARIANT", "HIGH_PRECISION", + "MEDIUM_PRECISION", "LOW_PRECISION", "PRECISION", "ATTRIBUTE", + "CONST_QUAL", "BOOL_TYPE", "FLOAT_TYPE", "INT_TYPE", "BREAK", "CONTINUE", + "DO", "ELSE", "FOR", "IF", "DISCARD", "RETURN", "BVEC2", "BVEC3", + "BVEC4", "IVEC2", "IVEC3", "IVEC4", "VEC2", "VEC3", "VEC4", "MATRIX2", + "MATRIX3", "MATRIX4", "IN_QUAL", "OUT_QUAL", "INOUT_QUAL", "UNIFORM", + "VARYING", "STRUCT", "VOID_TYPE", "WHILE", "SAMPLER2D", "SAMPLERCUBE", + "IDENTIFIER", "TYPE_NAME", "FLOATCONSTANT", "INTCONSTANT", + "BOOLCONSTANT", "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", + "DEC_OP", "LE_OP", "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", + "XOR_OP", "MUL_ASSIGN", "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", + "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", + "SUB_ASSIGN", "LEFT_PAREN", "RIGHT_PAREN", "LEFT_BRACKET", + "RIGHT_BRACKET", "LEFT_BRACE", "RIGHT_BRACE", "DOT", "COMMA", "COLON", + "EQUAL", "SEMICOLON", "BANG", "DASH", "TILDE", "PLUS", "STAR", "SLASH", + "PERCENT", "LEFT_ANGLE", "RIGHT_ANGLE", "VERTICAL_BAR", "CARET", + "AMPERSAND", "QUESTION", "$accept", "variable_identifier", + "primary_expression", "postfix_expression", "integer_expression", + "function_call", "function_call_or_method", "function_call_generic", + "function_call_header_no_parameters", + "function_call_header_with_parameters", "function_call_header", + "function_identifier", "unary_expression", "unary_operator", + "multiplicative_expression", "additive_expression", "shift_expression", + "relational_expression", "equality_expression", "and_expression", + "exclusive_or_expression", "inclusive_or_expression", + "logical_and_expression", "logical_xor_expression", + "logical_or_expression", "conditional_expression", + "assignment_expression", "assignment_operator", "expression", + "constant_expression", "declaration", "function_prototype", + "function_declarator", "function_header_with_parameters", + "function_header", "parameter_declarator", "parameter_declaration", + "parameter_qualifier", "parameter_type_specifier", + "init_declarator_list", "single_declaration", "fully_specified_type", + "type_qualifier", "type_specifier", "precision_qualifier", + "type_specifier_no_prec", "type_specifier_nonarray", "struct_specifier", + "struct_declaration_list", "struct_declaration", + "struct_declarator_list", "struct_declarator", "initializer", + "declaration_statement", "statement", "simple_statement", + "compound_statement", "@1", "@2", "statement_no_new_scope", + "compound_statement_no_new_scope", "statement_list", + "expression_statement", "selection_statement", + "selection_rest_statement", "condition", "iteration_statement", "@3", + "@4", "@5", "for_init_statement", "conditionopt", "for_rest_statement", + "jump_statement", "translation_unit", "external_declaration", + "function_definition", "@6", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 94, 95, 96, 96, 96, 96, 96, 97, 97, + 97, 97, 97, 97, 98, 99, 100, 100, 101, 101, + 102, 102, 103, 103, 104, 105, 105, 105, 106, 106, + 106, 106, 107, 107, 107, 108, 108, 108, 109, 109, + 109, 110, 111, 111, 111, 111, 111, 112, 112, 112, + 113, 114, 115, 116, 116, 117, 117, 118, 118, 119, + 119, 120, 120, 121, 121, 121, 121, 121, 122, 122, + 123, 124, 124, 124, 125, 126, 126, 127, 127, 128, + 129, 129, 130, 130, 130, 130, 131, 131, 131, 131, + 132, 133, 133, 133, 133, 133, 134, 134, 134, 134, + 134, 134, 135, 135, 136, 136, 136, 136, 136, 137, + 137, 138, 138, 138, 139, 139, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 141, 141, 142, 142, + 143, 144, 144, 145, 145, 146, 147, 148, 148, 149, + 149, 149, 149, 149, 150, 151, 152, 150, 153, 153, + 154, 154, 155, 155, 156, 156, 157, 158, 158, 159, + 159, 161, 160, 162, 160, 163, 160, 164, 164, 165, + 165, 166, 166, 167, 167, 167, 167, 167, 168, 168, + 169, 169, 171, 170 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 1, 1, 1, 3, 1, 4, + 1, 3, 2, 2, 1, 1, 1, 3, 2, 2, + 2, 1, 2, 3, 2, 1, 1, 1, 1, 2, + 2, 2, 1, 1, 1, 1, 3, 3, 1, 3, + 3, 1, 1, 3, 3, 3, 3, 1, 3, 3, + 1, 1, 1, 1, 3, 1, 3, 1, 3, 1, + 5, 1, 3, 1, 1, 1, 1, 1, 1, 3, + 1, 2, 2, 4, 2, 1, 1, 2, 3, 3, + 2, 5, 3, 2, 3, 2, 0, 1, 1, 1, + 1, 1, 3, 5, 6, 5, 1, 2, 4, 5, + 4, 2, 1, 2, 1, 1, 1, 2, 1, 1, + 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 5, 4, 1, 2, + 3, 1, 3, 1, 4, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 0, 0, 5, 1, 1, + 2, 3, 1, 2, 1, 2, 5, 3, 1, 1, + 4, 0, 6, 0, 8, 0, 7, 1, 1, 1, + 0, 2, 3, 2, 2, 2, 3, 2, 1, 2, + 1, 1, 0, 3 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 0, 111, 112, 113, 0, 105, 104, 119, 117, + 118, 123, 124, 125, 126, 127, 128, 120, 121, 122, + 129, 130, 131, 108, 106, 0, 116, 132, 133, 135, + 191, 192, 0, 76, 86, 0, 91, 96, 0, 102, + 0, 109, 114, 134, 0, 188, 190, 107, 101, 0, + 0, 0, 71, 0, 74, 86, 0, 87, 88, 89, + 77, 0, 86, 0, 72, 97, 103, 110, 0, 1, + 189, 0, 0, 0, 0, 138, 0, 193, 78, 83, + 85, 90, 0, 92, 79, 0, 0, 2, 5, 4, + 6, 27, 0, 0, 0, 34, 33, 32, 3, 8, + 28, 10, 15, 16, 0, 0, 21, 0, 35, 0, + 38, 41, 42, 47, 50, 51, 52, 53, 55, 57, + 59, 70, 0, 25, 73, 0, 143, 0, 141, 137, + 139, 0, 0, 173, 0, 0, 0, 0, 0, 155, + 160, 164, 35, 61, 68, 0, 146, 0, 102, 149, + 162, 148, 147, 0, 150, 151, 152, 153, 80, 82, + 84, 0, 0, 98, 0, 145, 100, 29, 30, 0, + 12, 13, 0, 0, 19, 18, 0, 116, 22, 24, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 115, 136, 0, 0, 140, + 184, 183, 0, 175, 0, 187, 185, 0, 171, 154, + 0, 64, 65, 66, 67, 63, 0, 0, 165, 161, + 163, 0, 93, 0, 95, 99, 7, 0, 14, 26, + 11, 17, 23, 36, 37, 40, 39, 45, 46, 43, + 44, 48, 49, 54, 56, 58, 0, 0, 142, 0, + 0, 0, 186, 0, 156, 62, 69, 0, 94, 9, + 0, 144, 0, 178, 177, 180, 0, 169, 0, 0, + 0, 81, 60, 0, 179, 0, 0, 168, 166, 0, + 0, 157, 0, 181, 0, 0, 0, 159, 172, 158, + 0, 182, 176, 167, 170, 174 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 98, 99, 100, 227, 101, 102, 103, 104, 105, + 106, 107, 142, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 143, 144, 216, 145, 122, + 146, 147, 32, 33, 34, 79, 60, 61, 80, 35, + 36, 37, 38, 123, 40, 41, 42, 43, 74, 75, + 127, 128, 166, 149, 150, 151, 152, 210, 270, 288, + 289, 153, 154, 155, 278, 269, 156, 253, 202, 250, + 265, 275, 276, 157, 44, 45, 46, 53 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -250 +static const yytype_int16 yypact[] = +{ + 1225, 36, -250, -250, -250, 150, -250, -250, -250, -250, + -250, -250, -250, -250, -250, -250, -250, -250, -250, -250, + -250, -250, -250, -250, -250, -33, -250, -250, -250, -250, + -250, -60, -22, -17, 21, -62, -250, 22, 1266, -250, + 1290, -250, 11, -250, 1138, -250, -250, -250, -250, 1290, + 14, 1266, -250, 27, -250, 34, 41, -250, -250, -250, + -250, 1266, 129, 61, -250, 17, -250, -250, 908, -250, + -250, 31, 1266, 72, 1042, -250, 283, -250, -250, -250, + -250, 90, 1266, -46, -250, 194, 908, 65, -250, -250, + -250, -250, 908, 908, 908, -250, -250, -250, -250, -250, + -40, -250, -250, -250, 80, -25, 975, 87, -250, 908, + 35, 13, -250, -26, 68, -250, -250, -250, 110, 109, + -54, -250, 96, -250, -250, 1083, 98, 33, -250, -250, + -250, 91, 92, -250, 104, 107, 99, 760, 108, 105, + -250, -250, 24, -250, -250, 37, -250, -60, 112, -250, + -250, -250, -250, 365, -250, -250, -250, -250, 111, -250, + -250, 827, 908, -250, 113, -250, -250, -250, -250, 4, + -250, -250, 908, 1179, -250, -250, 908, 114, -250, -250, + -250, 908, 908, 908, 908, 908, 908, 908, 908, 908, + 908, 908, 908, 908, 908, -250, -250, 908, 72, -250, + -250, -250, 447, -250, 908, -250, -250, 42, -250, -250, + 447, -250, -250, -250, -250, -250, 908, 908, -250, -250, + -250, 908, -250, 115, -250, -250, -250, 116, 117, -250, + 120, -250, -250, -250, -250, 35, 35, -250, -250, -250, + -250, -26, -26, -250, 110, 109, 51, 119, -250, 144, + 611, 23, -250, 693, 447, -250, -250, 122, -250, -250, + 908, -250, 123, -250, -250, 693, 447, 117, 153, 126, + 128, -250, -250, 908, -250, 127, 137, 171, -250, 130, + 529, -250, 28, 908, 529, 447, 908, -250, -250, -250, + 131, 117, -250, -250, -250, -250 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -250, -250, -250, -250, -250, -250, -250, 39, -250, -250, + -250, -250, -45, -250, -18, -250, -79, -30, -250, -250, + -250, 38, 52, 20, -250, -63, -85, -250, -92, -71, + 6, 9, -250, -250, -250, 132, 172, 166, 148, -250, + -250, -246, -21, 0, 226, -24, -250, -250, 162, -66, + -250, 45, -159, -3, -136, -249, -250, -250, -250, -36, + 196, 46, 1, -250, -250, -13, -250, -250, -250, -250, + -250, -250, -250, -250, -250, 211, -250, -250 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -76 +static const yytype_int16 yytable[] = +{ + 39, 165, 169, 224, 193, 121, 30, 268, 130, 31, + 50, 170, 171, 62, 164, 63, 67, 220, 64, 268, + 52, 178, 121, 108, 56, 71, 161, 185, 186, 6, + 7, 287, 172, 162, 62, 287, 173, 56, 66, 194, + 108, 51, 6, 7, 39, 207, 175, 167, 168, 54, + 30, 73, 176, 31, 57, 58, 59, 23, 24, 130, + 55, 81, 187, 188, 180, 65, 249, 57, 58, 59, + 23, 24, 73, 47, 73, 226, 148, 165, 47, 48, + 228, 217, 81, 68, 211, 212, 213, 84, 72, 85, + 223, 232, -75, 214, 266, 183, 86, 184, 121, 290, + 217, 76, 246, 215, 83, 217, 237, 238, 239, 240, + 198, 124, 251, 199, 217, 126, 108, 218, 220, 217, + 181, 182, 252, 189, 190, 73, 247, 294, 217, 260, + 277, 255, 256, 158, 121, -26, 233, 234, 108, 108, + 108, 108, 108, 108, 108, 108, 108, 108, 108, 293, + 257, 174, 108, 148, 2, 3, 4, 179, 121, 241, + 242, 267, 57, 58, 59, 235, 236, 191, 192, 195, + 197, 200, 201, 267, 203, 272, 108, 204, 208, 205, + 209, 282, -25, 221, 262, -20, 225, 285, 258, 259, + -27, 291, 261, 273, 217, 271, 279, 280, 2, 3, + 4, 165, 148, 281, 8, 9, 10, 283, 284, 286, + 148, 295, 231, 245, 159, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 78, 82, 243, + 160, 49, 25, 26, 125, 27, 28, 87, 29, 88, + 89, 90, 91, 248, 244, 92, 93, 263, 292, 77, + 148, 264, 274, 148, 148, 70, 254, 0, 0, 0, + 0, 0, 0, 0, 94, 148, 148, 163, 0, 0, + 0, 0, 0, 0, 0, 95, 96, 0, 97, 0, + 148, 0, 0, 0, 148, 148, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 131, 132, 133, 0, + 134, 135, 136, 137, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 0, 0, 0, 23, + 24, 25, 26, 138, 27, 28, 87, 29, 88, 89, + 90, 91, 0, 0, 92, 93, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 94, 0, 0, 0, 139, 140, 0, + 0, 0, 0, 141, 95, 96, 0, 97, 1, 2, + 3, 4, 5, 6, 7, 8, 9, 10, 131, 132, + 133, 0, 134, 135, 136, 137, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, + 0, 23, 24, 25, 26, 138, 27, 28, 87, 29, + 88, 89, 90, 91, 0, 0, 92, 93, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 94, 0, 0, 0, 139, + 219, 0, 0, 0, 0, 141, 95, 96, 0, 97, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 131, 132, 133, 0, 134, 135, 136, 137, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 0, 0, 0, 23, 24, 25, 26, 138, 27, 28, + 87, 29, 88, 89, 90, 91, 0, 0, 92, 93, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, + 0, 139, 0, 0, 0, 0, 0, 141, 95, 96, + 0, 97, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 131, 132, 133, 0, 134, 135, 136, 137, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 0, 0, 0, 23, 24, 25, 26, 138, + 27, 28, 87, 29, 88, 89, 90, 91, 0, 0, + 92, 93, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, + 0, 0, 0, 76, 0, 0, 0, 0, 0, 141, + 95, 96, 0, 97, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, + 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 0, 0, 0, 23, 24, 25, + 26, 0, 27, 28, 87, 29, 88, 89, 90, 91, + 0, 0, 92, 93, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 94, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 141, 95, 96, 0, 97, 56, 2, 3, 4, + 0, 6, 7, 8, 9, 10, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 0, 0, 0, 23, + 24, 25, 26, 0, 27, 28, 87, 29, 88, 89, + 90, 91, 0, 0, 92, 93, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 94, 2, 3, 4, 0, 0, 0, + 8, 9, 10, 0, 95, 96, 0, 97, 0, 0, + 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 0, 0, 0, 0, 0, 25, 26, + 0, 27, 28, 87, 29, 88, 89, 90, 91, 0, + 0, 92, 93, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 94, 2, 3, 4, 0, 0, 0, 8, 9, 10, + 206, 95, 96, 0, 97, 0, 0, 0, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 0, 0, 0, 0, 0, 25, 26, 0, 27, 28, + 87, 29, 88, 89, 90, 91, 0, 0, 92, 93, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, + 222, 0, 0, 0, 0, 0, 0, 0, 95, 96, + 0, 97, 2, 3, 4, 0, 0, 0, 8, 9, + 10, 0, 0, 0, 0, 0, 0, 0, 0, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 0, 0, 0, 0, 0, 25, 26, 0, 27, + 28, 87, 29, 88, 89, 90, 91, 0, 0, 92, + 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 94, 2, + 3, 4, 0, 0, 0, 8, 9, 10, 0, 95, + 96, 0, 97, 0, 0, 0, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, + 0, 0, 0, 25, 177, 0, 27, 28, 87, 29, + 88, 89, 90, 91, 0, 0, 92, 93, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 94, 2, 3, 4, 0, + 0, 0, 8, 9, 10, 0, 95, 96, 0, 97, + 0, 0, 0, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 0, 0, 0, 0, 0, + 25, 26, 0, 27, 28, 0, 29, 2, 3, 4, + 0, 0, 0, 8, 9, 10, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 0, 129, 0, 0, + 0, 25, 26, 0, 27, 28, 0, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 0, 0, 0, 0, 0, 0, 0, 196, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 0, 0, 0, 23, 24, 25, 26, 0, 27, + 28, 0, 29, 2, 3, 4, 0, 0, 0, 8, + 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 0, 0, 0, 0, 0, 25, 26, 0, + 27, 28, 229, 29, 0, 0, 0, 230, 1, 2, + 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, + 0, 23, 24, 25, 26, 0, 27, 28, 0, 29, + 2, 3, 4, 0, 0, 0, 8, 9, 10, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, + 8, 9, 10, 0, 25, 26, 0, 27, 28, 0, + 29, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 0, 0, 0, 0, 0, 25, 26, + 0, 27, 28, 0, 29 +}; + +static const yytype_int16 yycheck[] = +{ + 0, 86, 94, 162, 58, 68, 0, 253, 74, 0, + 43, 51, 52, 34, 85, 77, 40, 153, 80, 265, + 80, 106, 85, 68, 3, 49, 72, 53, 54, 8, + 9, 280, 72, 79, 55, 284, 76, 3, 38, 93, + 85, 74, 8, 9, 44, 137, 71, 92, 93, 71, + 44, 51, 77, 44, 33, 34, 35, 36, 37, 125, + 77, 61, 88, 89, 109, 43, 202, 33, 34, 35, + 36, 37, 72, 37, 74, 71, 76, 162, 37, 43, + 172, 77, 82, 72, 60, 61, 62, 70, 74, 72, + 161, 176, 71, 69, 71, 82, 79, 84, 161, 71, + 77, 74, 194, 79, 43, 77, 185, 186, 187, 188, + 77, 80, 204, 80, 77, 43, 161, 80, 254, 77, + 85, 86, 80, 55, 56, 125, 197, 286, 77, 78, + 266, 216, 217, 43, 197, 70, 181, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 285, + 221, 71, 197, 153, 4, 5, 6, 70, 221, 189, + 190, 253, 33, 34, 35, 183, 184, 57, 59, 73, + 72, 80, 80, 265, 70, 260, 221, 70, 70, 80, + 75, 273, 70, 72, 40, 71, 73, 16, 73, 73, + 70, 283, 73, 70, 77, 73, 43, 71, 4, 5, + 6, 286, 202, 75, 10, 11, 12, 80, 71, 79, + 210, 80, 173, 193, 82, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 55, 62, 191, + 82, 5, 38, 39, 72, 41, 42, 43, 44, 45, + 46, 47, 48, 198, 192, 51, 52, 250, 284, 53, + 250, 250, 265, 253, 254, 44, 210, -1, -1, -1, + -1, -1, -1, -1, 70, 265, 266, 73, -1, -1, + -1, -1, -1, -1, -1, 81, 82, -1, 84, -1, + 280, -1, -1, -1, 284, 285, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, -1, -1, 51, 52, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 70, -1, -1, -1, 74, 75, -1, + -1, -1, -1, 80, 81, 82, -1, 84, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, -1, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, -1, -1, 51, 52, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 70, -1, -1, -1, 74, + 75, -1, -1, -1, -1, 80, 81, 82, -1, 84, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, -1, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + -1, -1, -1, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, -1, -1, 51, 52, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 70, -1, -1, + -1, 74, -1, -1, -1, -1, -1, 80, 81, 82, + -1, 84, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, -1, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, -1, -1, -1, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, -1, -1, + 51, 52, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, + -1, -1, -1, 74, -1, -1, -1, -1, -1, 80, + 81, 82, -1, 84, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, -1, -1, -1, -1, -1, -1, + -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, -1, -1, -1, 36, 37, 38, + 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, + -1, -1, 51, 52, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 80, 81, 82, -1, 84, 3, 4, 5, 6, + -1, 8, 9, 10, 11, 12, -1, -1, -1, -1, + -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, + 37, 38, 39, -1, 41, 42, 43, 44, 45, 46, + 47, 48, -1, -1, 51, 52, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 70, 4, 5, 6, -1, -1, -1, + 10, 11, 12, -1, 81, 82, -1, 84, -1, -1, + -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, -1, -1, -1, -1, -1, 38, 39, + -1, 41, 42, 43, 44, 45, 46, 47, 48, -1, + -1, 51, 52, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 70, 4, 5, 6, -1, -1, -1, 10, 11, 12, + 80, 81, 82, -1, 84, -1, -1, -1, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + -1, -1, -1, -1, -1, 38, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, -1, -1, 51, 52, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 70, -1, -1, + 73, -1, -1, -1, -1, -1, -1, -1, 81, 82, + -1, 84, 4, 5, 6, -1, -1, -1, 10, 11, + 12, -1, -1, -1, -1, -1, -1, -1, -1, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, -1, -1, -1, -1, -1, 38, 39, -1, 41, + 42, 43, 44, 45, 46, 47, 48, -1, -1, 51, + 52, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 70, 4, + 5, 6, -1, -1, -1, 10, 11, 12, -1, 81, + 82, -1, 84, -1, -1, -1, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, + -1, -1, -1, 38, 39, -1, 41, 42, 43, 44, + 45, 46, 47, 48, -1, -1, 51, 52, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 70, 4, 5, 6, -1, + -1, -1, 10, 11, 12, -1, 81, 82, -1, 84, + -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, + 38, 39, -1, 41, 42, -1, 44, 4, 5, 6, + -1, -1, -1, 10, 11, 12, -1, -1, -1, -1, + -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, -1, 75, -1, -1, + -1, 38, 39, -1, 41, 42, -1, 44, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, -1, -1, -1, -1, -1, -1, -1, 75, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, -1, -1, -1, 36, 37, 38, 39, -1, 41, + 42, -1, 44, 4, 5, 6, -1, -1, -1, 10, + 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, -1, -1, -1, -1, -1, 38, 39, -1, + 41, 42, 43, 44, -1, -1, -1, 48, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, + -1, -1, -1, -1, -1, -1, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, + -1, 36, 37, 38, 39, -1, 41, 42, -1, 44, + 4, 5, 6, -1, -1, -1, 10, 11, 12, -1, + -1, -1, -1, -1, -1, -1, -1, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, + 10, 11, 12, -1, 38, 39, -1, 41, 42, -1, + 44, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, -1, -1, -1, -1, -1, 38, 39, + -1, 41, 42, -1, 44 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 36, 37, 38, 39, 41, 42, 44, + 124, 125, 126, 127, 128, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 168, 169, 170, 37, 43, 138, + 43, 74, 80, 171, 71, 77, 3, 33, 34, 35, + 130, 131, 136, 77, 80, 43, 137, 139, 72, 0, + 169, 139, 74, 137, 142, 143, 74, 154, 130, 129, + 132, 137, 131, 43, 70, 72, 79, 43, 45, 46, + 47, 48, 51, 52, 70, 81, 82, 84, 95, 96, + 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 123, 137, 80, 142, 43, 144, 145, 75, + 143, 13, 14, 15, 17, 18, 19, 20, 40, 74, + 75, 80, 106, 119, 120, 122, 124, 125, 137, 147, + 148, 149, 150, 155, 156, 157, 160, 167, 43, 129, + 132, 72, 79, 73, 123, 120, 146, 106, 106, 122, + 51, 52, 72, 76, 71, 71, 77, 39, 120, 70, + 106, 85, 86, 82, 84, 53, 54, 88, 89, 55, + 56, 57, 59, 58, 93, 73, 75, 72, 77, 80, + 80, 80, 162, 70, 70, 80, 80, 122, 70, 75, + 151, 60, 61, 62, 69, 79, 121, 77, 80, 75, + 148, 72, 73, 123, 146, 73, 71, 98, 122, 43, + 48, 101, 120, 106, 106, 108, 108, 110, 110, 110, + 110, 111, 111, 115, 116, 117, 122, 123, 145, 148, + 163, 122, 80, 161, 155, 120, 120, 123, 73, 73, + 78, 73, 40, 147, 156, 164, 71, 122, 135, 159, + 152, 73, 120, 70, 159, 165, 166, 148, 158, 43, + 71, 75, 122, 80, 71, 16, 79, 149, 153, 154, + 71, 122, 153, 148, 146, 80 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (context, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, context); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, TParseContext* context) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, context) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + TParseContext* context; +#endif +{ + if (!yyvaluep) + return; + YYUSE (context); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, TParseContext* context) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, context) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + TParseContext* context; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, context); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, TParseContext* context) +#else +static void +yy_reduce_print (yyvsp, yyrule, context) + YYSTYPE *yyvsp; + int yyrule; + TParseContext* context; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , context); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, context); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, TParseContext* context) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, context) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + TParseContext* context; +#endif +{ + YYUSE (yyvaluep); + YYUSE (context); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (TParseContext* context); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (TParseContext* context) +#else +int +yyparse (context) + TParseContext* context; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: + + { + // The symbol table search was done in the lexical phase + const TSymbol* symbol = (yyvsp[(1) - (1)].lex).symbol; + const TVariable* variable; + if (symbol == 0) { + context->error((yyvsp[(1) - (1)].lex).line, "undeclared identifier", (yyvsp[(1) - (1)].lex).string->c_str(), ""); + context->recover(); + TType type(EbtFloat, EbpUndefined); + TVariable* fakeVariable = new TVariable((yyvsp[(1) - (1)].lex).string, type); + context->symbolTable.insert(*fakeVariable); + variable = fakeVariable; + } else { + // This identifier can only be a variable type symbol + if (! symbol->isVariable()) { + context->error((yyvsp[(1) - (1)].lex).line, "variable expected", (yyvsp[(1) - (1)].lex).string->c_str(), ""); + context->recover(); + } + variable = static_cast<const TVariable*>(symbol); + } + + // don't delete $1.string, it's used by error recovery, and the pool + // pop will reclaim the memory + + if (variable->getType().getQualifier() == EvqConst ) { + ConstantUnion* constArray = variable->getConstPointer(); + TType t(variable->getType()); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(constArray, t, (yyvsp[(1) - (1)].lex).line); + } else + (yyval.interm.intermTypedNode) = context->intermediate.addSymbol(variable->getUniqueId(), + variable->getName(), + variable->getType(), (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 3: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 4: + + { + // + // INT_TYPE is only 16-bit plus sign bit for vertex/fragment shaders, + // check for overflow for constants + // + if (abs((yyvsp[(1) - (1)].lex).i) >= (1 << 16)) { + context->error((yyvsp[(1) - (1)].lex).line, " integer constant overflow", "", ""); + context->recover(); + } + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setIConst((yyvsp[(1) - (1)].lex).i); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 5: + + { + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setFConst((yyvsp[(1) - (1)].lex).f); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 6: + + { + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst((yyvsp[(1) - (1)].lex).b); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 7: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(2) - (3)].interm.intermTypedNode); + ;} + break; + + case 8: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 9: + + { + if (!(yyvsp[(1) - (4)].interm.intermTypedNode)->isArray() && !(yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix() && !(yyvsp[(1) - (4)].interm.intermTypedNode)->isVector()) { + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode()) + context->error((yyvsp[(2) - (4)].lex).line, " left of '[' is not of type array, matrix, or vector ", (yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode()->getSymbol().c_str(), ""); + else + context->error((yyvsp[(2) - (4)].lex).line, " left of '[' is not of type array, matrix, or vector ", "expression", ""); + context->recover(); + } + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConst && (yyvsp[(3) - (4)].interm.intermTypedNode)->getQualifier() == EvqConst) { + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray()) { // constant folding for arrays + (yyval.interm.intermTypedNode) = context->addConstArrayNode((yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line); + } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector()) { // constant folding for vectors + TVectorFields fields; + fields.num = 1; + fields.offsets[0] = (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst(); // need to do it this way because v.xy sends fields integer array + (yyval.interm.intermTypedNode) = context->addConstVectorNode(fields, (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line); + } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix()) { // constant folding for matrices + (yyval.interm.intermTypedNode) = context->addConstMatrixNode((yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line); + } + } else { + if ((yyvsp[(3) - (4)].interm.intermTypedNode)->getQualifier() == EvqConst) { + if (((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector() || (yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix()) && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getNominalSize() <= (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst() && !(yyvsp[(1) - (4)].interm.intermTypedNode)->isArray() ) { + context->error((yyvsp[(2) - (4)].lex).line, "", "[", "field selection out of range '%d'", (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); + context->recover(); + } else { + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray()) { + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getArraySize() == 0) { + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getMaxArraySize() <= (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst()) { + if (context->arraySetMaxSize((yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getTypePointer(), (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, (yyvsp[(2) - (4)].lex).line)) + context->recover(); + } else { + if (context->arraySetMaxSize((yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getTypePointer(), 0, false, (yyvsp[(2) - (4)].lex).line)) + context->recover(); + } + } else if ( (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst() >= (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getArraySize()) { + context->error((yyvsp[(2) - (4)].lex).line, "", "[", "array index out of range '%d'", (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getUnionArrayPointer()->getIConst()); + context->recover(); + } + } + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(3) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line); + } + } else { + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray() && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getArraySize() == 0) { + context->error((yyvsp[(2) - (4)].lex).line, "", "[", "array must be redeclared with a size before being indexed with a variable"); + context->recover(); + } + + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexIndirect, (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(3) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line); + } + } + if ((yyval.interm.intermTypedNode) == 0) { + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setFConst(0.0f); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), (yyvsp[(2) - (4)].lex).line); + } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray()) { + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getStruct()) + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getStruct(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getTypeName())); + else + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (yyvsp[(1) - (4)].interm.intermTypedNode)->getNominalSize(), (yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix())); + + if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConst) + (yyval.interm.intermTypedNode)->getTypePointer()->setQualifier(EvqConst); + } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix() && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConst) + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqConst, (yyvsp[(1) - (4)].interm.intermTypedNode)->getNominalSize())); + else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix()) + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (yyvsp[(1) - (4)].interm.intermTypedNode)->getNominalSize())); + else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector() && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConst) + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqConst)); + else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector()) + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqTemporary)); + else + (yyval.interm.intermTypedNode)->setType((yyvsp[(1) - (4)].interm.intermTypedNode)->getType()); + ;} + break; + + case 10: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 11: + + { + if ((yyvsp[(1) - (3)].interm.intermTypedNode)->isArray()) { + context->error((yyvsp[(3) - (3)].lex).line, "cannot apply dot operator to an array", ".", ""); + context->recover(); + } + + if ((yyvsp[(1) - (3)].interm.intermTypedNode)->isVector()) { + TVectorFields fields; + if (! context->parseVectorFields(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize(), fields, (yyvsp[(3) - (3)].lex).line)) { + fields.num = 1; + fields.offsets[0] = 0; + context->recover(); + } + + if ((yyvsp[(1) - (3)].interm.intermTypedNode)->getType().getQualifier() == EvqConst) { // constant folding for vector fields + (yyval.interm.intermTypedNode) = context->addConstVectorNode(fields, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].lex).line); + if ((yyval.interm.intermTypedNode) == 0) { + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + else + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(), EvqConst, (int) (*(yyvsp[(3) - (3)].lex).string).size())); + } else { + if (fields.num == 1) { + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setIConst(fields.offsets[0]); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yyvsp[(3) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision())); + } else { + TString vectorString = *(yyvsp[(3) - (3)].lex).string; + TIntermTyped* index = context->intermediate.addSwizzle(fields, (yyvsp[(3) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpVectorSwizzle, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (int) vectorString.size())); + } + } + } else if ((yyvsp[(1) - (3)].interm.intermTypedNode)->isMatrix()) { + TMatrixFields fields; + if (! context->parseMatrixFields(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize(), fields, (yyvsp[(3) - (3)].lex).line)) { + fields.wholeRow = false; + fields.wholeCol = false; + fields.row = 0; + fields.col = 0; + context->recover(); + } + + if (fields.wholeRow || fields.wholeCol) { + context->error((yyvsp[(2) - (3)].lex).line, " non-scalar fields not implemented yet", ".", ""); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setIConst(0); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yyvsp[(3) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(),EvqTemporary, (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize())); + } else { + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setIConst(fields.col * (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize() + fields.row); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yyvsp[(3) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision())); + } + } else if ((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType() == EbtStruct) { + bool fieldFound = false; + const TTypeList* fields = (yyvsp[(1) - (3)].interm.intermTypedNode)->getType().getStruct(); + if (fields == 0) { + context->error((yyvsp[(2) - (3)].lex).line, "structure has no fields", "Internal Error", ""); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } else { + unsigned int i; + for (i = 0; i < fields->size(); ++i) { + if ((*fields)[i].type->getFieldName() == *(yyvsp[(3) - (3)].lex).string) { + fieldFound = true; + break; + } + } + if (fieldFound) { + if ((yyvsp[(1) - (3)].interm.intermTypedNode)->getType().getQualifier() == EvqConst) { + (yyval.interm.intermTypedNode) = context->addConstStruct(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line); + if ((yyval.interm.intermTypedNode) == 0) { + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + else { + (yyval.interm.intermTypedNode)->setType(*(*fields)[i].type); + // change the qualifier of the return type, not of the structure field + // as the structure definition is shared between various structures. + (yyval.interm.intermTypedNode)->getTypePointer()->setQualifier(EvqConst); + } + } else { + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setIConst(i); + TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, (yyvsp[(3) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirectStruct, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode)->setType(*(*fields)[i].type); + } + } else { + context->error((yyvsp[(2) - (3)].lex).line, " no such field in structure", (yyvsp[(3) - (3)].lex).string->c_str(), ""); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + } + } else { + context->error((yyvsp[(2) - (3)].lex).line, " field selection requires structure, vector, or matrix on left hand side", (yyvsp[(3) - (3)].lex).string->c_str(), ""); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + // don't delete $3.string, it's from the pool + ;} + break; + + case 12: + + { + if (context->lValueErrorCheck((yyvsp[(2) - (2)].lex).line, "++", (yyvsp[(1) - (2)].interm.intermTypedNode))) + context->recover(); + (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath(EOpPostIncrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yyvsp[(2) - (2)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->unaryOpError((yyvsp[(2) - (2)].lex).line, "++", (yyvsp[(1) - (2)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (2)].interm.intermTypedNode); + } + ;} + break; + + case 13: + + { + if (context->lValueErrorCheck((yyvsp[(2) - (2)].lex).line, "--", (yyvsp[(1) - (2)].interm.intermTypedNode))) + context->recover(); + (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath(EOpPostDecrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yyvsp[(2) - (2)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->unaryOpError((yyvsp[(2) - (2)].lex).line, "--", (yyvsp[(1) - (2)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (2)].interm.intermTypedNode); + } + ;} + break; + + case 14: + + { + if (context->integerErrorCheck((yyvsp[(1) - (1)].interm.intermTypedNode), "[]")) + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 15: + + { + TFunction* fnCall = (yyvsp[(1) - (1)].interm).function; + TOperator op = fnCall->getBuiltInOp(); + + if (op != EOpNull) + { + // + // Then this should be a constructor. + // Don't go through the symbol table for constructors. + // Their parameters will be verified algorithmically. + // + TType type(EbtVoid, EbpUndefined); // use this to get the type back + if (context->constructorErrorCheck((yyvsp[(1) - (1)].interm).line, (yyvsp[(1) - (1)].interm).intermNode, *fnCall, op, &type)) { + (yyval.interm.intermTypedNode) = 0; + } else { + // + // It's a constructor, of type 'type'. + // + (yyval.interm.intermTypedNode) = context->addConstructor((yyvsp[(1) - (1)].interm).intermNode, &type, op, fnCall, (yyvsp[(1) - (1)].interm).line); + } + + if ((yyval.interm.intermTypedNode) == 0) { + context->recover(); + (yyval.interm.intermTypedNode) = context->intermediate.setAggregateOperator(0, op, (yyvsp[(1) - (1)].interm).line); + } + (yyval.interm.intermTypedNode)->setType(type); + } else { + // + // Not a constructor. Find it in the symbol table. + // + const TFunction* fnCandidate; + bool builtIn; + fnCandidate = context->findFunction((yyvsp[(1) - (1)].interm).line, fnCall, &builtIn); + if (fnCandidate) { + // + // A declared function. + // + if (builtIn && !fnCandidate->getExtension().empty() && + context->extensionErrorCheck((yyvsp[(1) - (1)].interm).line, fnCandidate->getExtension())) { + context->recover(); + } + op = fnCandidate->getBuiltInOp(); + if (builtIn && op != EOpNull) { + // + // A function call mapped to a built-in operation. + // + if (fnCandidate->getParamCount() == 1) { + // + // Treat it like a built-in unary operator. + // + (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath(op, (yyvsp[(1) - (1)].interm).intermNode, 0, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->error((yyvsp[(1) - (1)].interm).intermNode->getLine(), " wrong operand type", "Internal Error", + "built in unary operator function. Type: %s", + static_cast<TIntermTyped*>((yyvsp[(1) - (1)].interm).intermNode)->getCompleteString().c_str()); + YYERROR; + } + } else { + (yyval.interm.intermTypedNode) = context->intermediate.setAggregateOperator((yyvsp[(1) - (1)].interm).intermAggregate, op, (yyvsp[(1) - (1)].interm).line); + } + } else { + // This is a real function call + + (yyval.interm.intermTypedNode) = context->intermediate.setAggregateOperator((yyvsp[(1) - (1)].interm).intermAggregate, EOpFunctionCall, (yyvsp[(1) - (1)].interm).line); + (yyval.interm.intermTypedNode)->setType(fnCandidate->getReturnType()); + + // this is how we know whether the given function is a builtIn function or a user defined function + // if builtIn == false, it's a userDefined -> could be an overloaded builtIn function also + // if builtIn == true, it's definitely a builtIn function with EOpNull + if (!builtIn) + (yyval.interm.intermTypedNode)->getAsAggregate()->setUserDefined(); + (yyval.interm.intermTypedNode)->getAsAggregate()->setName(fnCandidate->getMangledName()); + + TQualifier qual; + for (int i = 0; i < fnCandidate->getParamCount(); ++i) { + qual = fnCandidate->getParam(i).type->getQualifier(); + if (qual == EvqOut || qual == EvqInOut) { + if (context->lValueErrorCheck((yyval.interm.intermTypedNode)->getLine(), "assign", (yyval.interm.intermTypedNode)->getAsAggregate()->getSequence()[i]->getAsTyped())) { + context->error((yyvsp[(1) - (1)].interm).intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", ""); + context->recover(); + } + } + } + } + (yyval.interm.intermTypedNode)->setType(fnCandidate->getReturnType()); + } else { + // error message was put out by PaFindFunction() + // Put on a dummy node for error recovery + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setFConst(0.0f); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), (yyvsp[(1) - (1)].interm).line); + context->recover(); + } + } + delete fnCall; + ;} + break; + + case 16: + + { + (yyval.interm) = (yyvsp[(1) - (1)].interm); + ;} + break; + + case 17: + + { + context->error((yyvsp[(3) - (3)].interm).line, "methods are not supported", "", ""); + context->recover(); + (yyval.interm) = (yyvsp[(3) - (3)].interm); + ;} + break; + + case 18: + + { + (yyval.interm) = (yyvsp[(1) - (2)].interm); + (yyval.interm).line = (yyvsp[(2) - (2)].lex).line; + ;} + break; + + case 19: + + { + (yyval.interm) = (yyvsp[(1) - (2)].interm); + (yyval.interm).line = (yyvsp[(2) - (2)].lex).line; + ;} + break; + + case 20: + + { + (yyval.interm).function = (yyvsp[(1) - (2)].interm.function); + (yyval.interm).intermNode = 0; + ;} + break; + + case 21: + + { + (yyval.interm).function = (yyvsp[(1) - (1)].interm.function); + (yyval.interm).intermNode = 0; + ;} + break; + + case 22: + + { + TParameter param = { 0, new TType((yyvsp[(2) - (2)].interm.intermTypedNode)->getType()) }; + (yyvsp[(1) - (2)].interm.function)->addParameter(param); + (yyval.interm).function = (yyvsp[(1) - (2)].interm.function); + (yyval.interm).intermNode = (yyvsp[(2) - (2)].interm.intermTypedNode); + ;} + break; + + case 23: + + { + TParameter param = { 0, new TType((yyvsp[(3) - (3)].interm.intermTypedNode)->getType()) }; + (yyvsp[(1) - (3)].interm).function->addParameter(param); + (yyval.interm).function = (yyvsp[(1) - (3)].interm).function; + (yyval.interm).intermNode = context->intermediate.growAggregate((yyvsp[(1) - (3)].interm).intermNode, (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line); + ;} + break; + + case 24: + + { + (yyval.interm.function) = (yyvsp[(1) - (2)].interm.function); + ;} + break; + + case 25: + + { + // + // Constructor + // + if ((yyvsp[(1) - (1)].interm.type).array) { + // Constructors for arrays are not allowed. + context->error((yyvsp[(1) - (1)].interm.type).line, "cannot construct this type", "array", ""); + context->recover(); + (yyvsp[(1) - (1)].interm.type).setArray(false); + } + + TOperator op = EOpNull; + if ((yyvsp[(1) - (1)].interm.type).userDef) { + op = EOpConstructStruct; + } else { + switch ((yyvsp[(1) - (1)].interm.type).type) { + case EbtFloat: + if ((yyvsp[(1) - (1)].interm.type).matrix) { + switch((yyvsp[(1) - (1)].interm.type).size) { + case 2: op = EOpConstructMat2; break; + case 3: op = EOpConstructMat3; break; + case 4: op = EOpConstructMat4; break; + } + } else { + switch((yyvsp[(1) - (1)].interm.type).size) { + case 1: op = EOpConstructFloat; break; + case 2: op = EOpConstructVec2; break; + case 3: op = EOpConstructVec3; break; + case 4: op = EOpConstructVec4; break; + } + } + break; + case EbtInt: + switch((yyvsp[(1) - (1)].interm.type).size) { + case 1: op = EOpConstructInt; break; + case 2: FRAG_VERT_ONLY("ivec2", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructIVec2; break; + case 3: FRAG_VERT_ONLY("ivec3", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructIVec3; break; + case 4: FRAG_VERT_ONLY("ivec4", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructIVec4; break; + } + break; + case EbtBool: + switch((yyvsp[(1) - (1)].interm.type).size) { + case 1: op = EOpConstructBool; break; + case 2: FRAG_VERT_ONLY("bvec2", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructBVec2; break; + case 3: FRAG_VERT_ONLY("bvec3", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructBVec3; break; + case 4: FRAG_VERT_ONLY("bvec4", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructBVec4; break; + } + break; + default: break; + } + if (op == EOpNull) { + context->error((yyvsp[(1) - (1)].interm.type).line, "cannot construct this type", getBasicString((yyvsp[(1) - (1)].interm.type).type), ""); + context->recover(); + (yyvsp[(1) - (1)].interm.type).type = EbtFloat; + op = EOpConstructFloat; + } + } + TString tempString; + TType type((yyvsp[(1) - (1)].interm.type)); + TFunction *function = new TFunction(&tempString, type, op); + (yyval.interm.function) = function; + ;} + break; + + case 26: + + { + if (context->reservedErrorCheck((yyvsp[(1) - (1)].lex).line, *(yyvsp[(1) - (1)].lex).string)) + context->recover(); + TType type(EbtVoid, EbpUndefined); + TFunction *function = new TFunction((yyvsp[(1) - (1)].lex).string, type); + (yyval.interm.function) = function; + ;} + break; + + case 27: + + { + if (context->reservedErrorCheck((yyvsp[(1) - (1)].lex).line, *(yyvsp[(1) - (1)].lex).string)) + context->recover(); + TType type(EbtVoid, EbpUndefined); + TFunction *function = new TFunction((yyvsp[(1) - (1)].lex).string, type); + (yyval.interm.function) = function; + ;} + break; + + case 28: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 29: + + { + if (context->lValueErrorCheck((yyvsp[(1) - (2)].lex).line, "++", (yyvsp[(2) - (2)].interm.intermTypedNode))) + context->recover(); + (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath(EOpPreIncrement, (yyvsp[(2) - (2)].interm.intermTypedNode), (yyvsp[(1) - (2)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->unaryOpError((yyvsp[(1) - (2)].lex).line, "++", (yyvsp[(2) - (2)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(2) - (2)].interm.intermTypedNode); + } + ;} + break; + + case 30: + + { + if (context->lValueErrorCheck((yyvsp[(1) - (2)].lex).line, "--", (yyvsp[(2) - (2)].interm.intermTypedNode))) + context->recover(); + (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath(EOpPreDecrement, (yyvsp[(2) - (2)].interm.intermTypedNode), (yyvsp[(1) - (2)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->unaryOpError((yyvsp[(1) - (2)].lex).line, "--", (yyvsp[(2) - (2)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(2) - (2)].interm.intermTypedNode); + } + ;} + break; + + case 31: + + { + if ((yyvsp[(1) - (2)].interm).op != EOpNull) { + (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath((yyvsp[(1) - (2)].interm).op, (yyvsp[(2) - (2)].interm.intermTypedNode), (yyvsp[(1) - (2)].interm).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + const char* errorOp = ""; + switch((yyvsp[(1) - (2)].interm).op) { + case EOpNegative: errorOp = "-"; break; + case EOpLogicalNot: errorOp = "!"; break; + default: break; + } + context->unaryOpError((yyvsp[(1) - (2)].interm).line, errorOp, (yyvsp[(2) - (2)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(2) - (2)].interm.intermTypedNode); + } + } else + (yyval.interm.intermTypedNode) = (yyvsp[(2) - (2)].interm.intermTypedNode); + ;} + break; + + case 32: + + { (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpNull; ;} + break; + + case 33: + + { (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpNegative; ;} + break; + + case 34: + + { (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpLogicalNot; ;} + break; + + case 35: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 36: + + { + FRAG_VERT_ONLY("*", (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpMul, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "*", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + ;} + break; + + case 37: + + { + FRAG_VERT_ONLY("/", (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpDiv, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "/", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + ;} + break; + + case 38: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 39: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpAdd, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "+", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + ;} + break; + + case 40: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpSub, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "-", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + ;} + break; + + case 41: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 42: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 43: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpLessThan, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "<", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 44: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpGreaterThan, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, ">", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 45: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpLessThanEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "<=", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 46: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpGreaterThanEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, ">=", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 47: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 48: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "==", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 49: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpNotEqual, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "!=", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 50: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 51: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 52: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 53: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 54: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpLogicalAnd, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "&&", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 55: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 56: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpLogicalXor, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "^^", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 57: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 58: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addBinaryMath(EOpLogicalOr, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, context->symbolTable); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, "||", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + ConstantUnion *unionArray = new ConstantUnion[1]; + unionArray->setBConst(false); + (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yyvsp[(2) - (3)].lex).line); + } + ;} + break; + + case 59: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 60: + + { + if (context->boolErrorCheck((yyvsp[(2) - (5)].lex).line, (yyvsp[(1) - (5)].interm.intermTypedNode))) + context->recover(); + + (yyval.interm.intermTypedNode) = context->intermediate.addSelection((yyvsp[(1) - (5)].interm.intermTypedNode), (yyvsp[(3) - (5)].interm.intermTypedNode), (yyvsp[(5) - (5)].interm.intermTypedNode), (yyvsp[(2) - (5)].lex).line); + if ((yyvsp[(3) - (5)].interm.intermTypedNode)->getType() != (yyvsp[(5) - (5)].interm.intermTypedNode)->getType()) + (yyval.interm.intermTypedNode) = 0; + + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (5)].lex).line, ":", (yyvsp[(3) - (5)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(5) - (5)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(5) - (5)].interm.intermTypedNode); + } + ;} + break; + + case 61: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 62: + + { + if (context->lValueErrorCheck((yyvsp[(2) - (3)].interm).line, "assign", (yyvsp[(1) - (3)].interm.intermTypedNode))) + context->recover(); + (yyval.interm.intermTypedNode) = context->intermediate.addAssign((yyvsp[(2) - (3)].interm).op, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].interm).line); + if ((yyval.interm.intermTypedNode) == 0) { + context->assignError((yyvsp[(2) - (3)].interm).line, "assign", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode); + } + ;} + break; + + case 63: + + { (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpAssign; ;} + break; + + case 64: + + { FRAG_VERT_ONLY("*=", (yyvsp[(1) - (1)].lex).line); (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpMulAssign; ;} + break; + + case 65: + + { FRAG_VERT_ONLY("/=", (yyvsp[(1) - (1)].lex).line); (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpDivAssign; ;} + break; + + case 66: + + { (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpAddAssign; ;} + break; + + case 67: + + { (yyval.interm).line = (yyvsp[(1) - (1)].lex).line; (yyval.interm).op = EOpSubAssign; ;} + break; + + case 68: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 69: + + { + (yyval.interm.intermTypedNode) = context->intermediate.addComma((yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line); + if ((yyval.interm.intermTypedNode) == 0) { + context->binaryOpError((yyvsp[(2) - (3)].lex).line, ",", (yyvsp[(1) - (3)].interm.intermTypedNode)->getCompleteString(), (yyvsp[(3) - (3)].interm.intermTypedNode)->getCompleteString()); + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(3) - (3)].interm.intermTypedNode); + } + ;} + break; + + case 70: + + { + if (context->constErrorCheck((yyvsp[(1) - (1)].interm.intermTypedNode))) + context->recover(); + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 71: + + { + TFunction &function = *((yyvsp[(1) - (2)].interm).function); + + TIntermAggregate *prototype = new TIntermAggregate; + prototype->setType(function.getReturnType()); + prototype->setName(function.getName()); + + for (int i = 0; i < function.getParamCount(); i++) + { + const TParameter ¶m = function.getParam(i); + if (param.name != 0) + { + TVariable *variable = new TVariable(param.name, *param.type); + + prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), (yyvsp[(1) - (2)].interm).line), (yyvsp[(1) - (2)].interm).line); + } + else + { + prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(0, "", *param.type, (yyvsp[(1) - (2)].interm).line), (yyvsp[(1) - (2)].interm).line); + } + } + + prototype->setOp(EOpPrototype); + (yyval.interm.intermNode) = prototype; + ;} + break; + + case 72: + + { + if ((yyvsp[(1) - (2)].interm).intermAggregate) + (yyvsp[(1) - (2)].interm).intermAggregate->setOp(EOpDeclaration); + (yyval.interm.intermNode) = (yyvsp[(1) - (2)].interm).intermAggregate; + ;} + break; + + case 73: + + { + context->symbolTable.setDefaultPrecision( (yyvsp[(3) - (4)].interm.type).type, (yyvsp[(2) - (4)].interm.precision) ); + (yyval.interm.intermNode) = 0; + ;} + break; + + case 74: + + { + // + // Multiple declarations of the same function are allowed. + // + // If this is a definition, the definition production code will check for redefinitions + // (we don't know at this point if it's a definition or not). + // + // Redeclarations are allowed. But, return types and parameter qualifiers must match. + // + TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find((yyvsp[(1) - (2)].interm.function)->getMangledName())); + if (prevDec) { + if (prevDec->getReturnType() != (yyvsp[(1) - (2)].interm.function)->getReturnType()) { + context->error((yyvsp[(2) - (2)].lex).line, "overloaded functions must have the same return type", (yyvsp[(1) - (2)].interm.function)->getReturnType().getBasicString(), ""); + context->recover(); + } + for (int i = 0; i < prevDec->getParamCount(); ++i) { + if (prevDec->getParam(i).type->getQualifier() != (yyvsp[(1) - (2)].interm.function)->getParam(i).type->getQualifier()) { + context->error((yyvsp[(2) - (2)].lex).line, "overloaded functions must have the same parameter qualifiers", (yyvsp[(1) - (2)].interm.function)->getParam(i).type->getQualifierString(), ""); + context->recover(); + } + } + } + + // + // If this is a redeclaration, it could also be a definition, + // in which case, we want to use the variable names from this one, and not the one that's + // being redeclared. So, pass back up this declaration, not the one in the symbol table. + // + (yyval.interm).function = (yyvsp[(1) - (2)].interm.function); + (yyval.interm).line = (yyvsp[(2) - (2)].lex).line; + + context->symbolTable.insert(*(yyval.interm).function); + ;} + break; + + case 75: + + { + (yyval.interm.function) = (yyvsp[(1) - (1)].interm.function); + ;} + break; + + case 76: + + { + (yyval.interm.function) = (yyvsp[(1) - (1)].interm.function); + ;} + break; + + case 77: + + { + // Add the parameter + (yyval.interm.function) = (yyvsp[(1) - (2)].interm.function); + if ((yyvsp[(2) - (2)].interm).param.type->getBasicType() != EbtVoid) + (yyvsp[(1) - (2)].interm.function)->addParameter((yyvsp[(2) - (2)].interm).param); + else + delete (yyvsp[(2) - (2)].interm).param.type; + ;} + break; + + case 78: + + { + // + // Only first parameter of one-parameter functions can be void + // The check for named parameters not being void is done in parameter_declarator + // + if ((yyvsp[(3) - (3)].interm).param.type->getBasicType() == EbtVoid) { + // + // This parameter > first is void + // + context->error((yyvsp[(2) - (3)].lex).line, "cannot be an argument type except for '(void)'", "void", ""); + context->recover(); + delete (yyvsp[(3) - (3)].interm).param.type; + } else { + // Add the parameter + (yyval.interm.function) = (yyvsp[(1) - (3)].interm.function); + (yyvsp[(1) - (3)].interm.function)->addParameter((yyvsp[(3) - (3)].interm).param); + } + ;} + break; + + case 79: + + { + if ((yyvsp[(1) - (3)].interm.type).qualifier != EvqGlobal && (yyvsp[(1) - (3)].interm.type).qualifier != EvqTemporary) { + context->error((yyvsp[(2) - (3)].lex).line, "no qualifiers allowed for function return", getQualifierString((yyvsp[(1) - (3)].interm.type).qualifier), ""); + context->recover(); + } + // make sure a sampler is not involved as well... + if (context->structQualifierErrorCheck((yyvsp[(2) - (3)].lex).line, (yyvsp[(1) - (3)].interm.type))) + context->recover(); + + // Add the function as a prototype after parsing it (we do not support recursion) + TFunction *function; + TType type((yyvsp[(1) - (3)].interm.type)); + function = new TFunction((yyvsp[(2) - (3)].lex).string, type); + (yyval.interm.function) = function; + ;} + break; + + case 80: + + { + if ((yyvsp[(1) - (2)].interm.type).type == EbtVoid) { + context->error((yyvsp[(2) - (2)].lex).line, "illegal use of type 'void'", (yyvsp[(2) - (2)].lex).string->c_str(), ""); + context->recover(); + } + if (context->reservedErrorCheck((yyvsp[(2) - (2)].lex).line, *(yyvsp[(2) - (2)].lex).string)) + context->recover(); + TParameter param = {(yyvsp[(2) - (2)].lex).string, new TType((yyvsp[(1) - (2)].interm.type))}; + (yyval.interm).line = (yyvsp[(2) - (2)].lex).line; + (yyval.interm).param = param; + ;} + break; + + case 81: + + { + // Check that we can make an array out of this type + if (context->arrayTypeErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(1) - (5)].interm.type))) + context->recover(); + + if (context->reservedErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string)) + context->recover(); + + int size; + if (context->arraySizeErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(4) - (5)].interm.intermTypedNode), size)) + context->recover(); + (yyvsp[(1) - (5)].interm.type).setArray(true, size); + + TType* type = new TType((yyvsp[(1) - (5)].interm.type)); + TParameter param = { (yyvsp[(2) - (5)].lex).string, type }; + (yyval.interm).line = (yyvsp[(2) - (5)].lex).line; + (yyval.interm).param = param; + ;} + break; + + case 82: + + { + (yyval.interm) = (yyvsp[(3) - (3)].interm); + if (context->paramErrorCheck((yyvsp[(3) - (3)].interm).line, (yyvsp[(1) - (3)].interm.type).qualifier, (yyvsp[(2) - (3)].interm.qualifier), (yyval.interm).param.type)) + context->recover(); + ;} + break; + + case 83: + + { + (yyval.interm) = (yyvsp[(2) - (2)].interm); + if (context->parameterSamplerErrorCheck((yyvsp[(2) - (2)].interm).line, (yyvsp[(1) - (2)].interm.qualifier), *(yyvsp[(2) - (2)].interm).param.type)) + context->recover(); + if (context->paramErrorCheck((yyvsp[(2) - (2)].interm).line, EvqTemporary, (yyvsp[(1) - (2)].interm.qualifier), (yyval.interm).param.type)) + context->recover(); + ;} + break; + + case 84: + + { + (yyval.interm) = (yyvsp[(3) - (3)].interm); + if (context->paramErrorCheck((yyvsp[(3) - (3)].interm).line, (yyvsp[(1) - (3)].interm.type).qualifier, (yyvsp[(2) - (3)].interm.qualifier), (yyval.interm).param.type)) + context->recover(); + ;} + break; + + case 85: + + { + (yyval.interm) = (yyvsp[(2) - (2)].interm); + if (context->parameterSamplerErrorCheck((yyvsp[(2) - (2)].interm).line, (yyvsp[(1) - (2)].interm.qualifier), *(yyvsp[(2) - (2)].interm).param.type)) + context->recover(); + if (context->paramErrorCheck((yyvsp[(2) - (2)].interm).line, EvqTemporary, (yyvsp[(1) - (2)].interm.qualifier), (yyval.interm).param.type)) + context->recover(); + ;} + break; + + case 86: + + { + (yyval.interm.qualifier) = EvqIn; + ;} + break; + + case 87: + + { + (yyval.interm.qualifier) = EvqIn; + ;} + break; + + case 88: + + { + (yyval.interm.qualifier) = EvqOut; + ;} + break; + + case 89: + + { + (yyval.interm.qualifier) = EvqInOut; + ;} + break; + + case 90: + + { + TParameter param = { 0, new TType((yyvsp[(1) - (1)].interm.type)) }; + (yyval.interm).param = param; + ;} + break; + + case 91: + + { + (yyval.interm) = (yyvsp[(1) - (1)].interm); + + if ((yyval.interm).type.precision == EbpUndefined) { + (yyval.interm).type.precision = context->symbolTable.getDefaultPrecision((yyvsp[(1) - (1)].interm).type.type); + if (context->precisionErrorCheck((yyvsp[(1) - (1)].interm).line, (yyval.interm).type.precision, (yyvsp[(1) - (1)].interm).type.type)) { + context->recover(); + } + } + ;} + break; + + case 92: + + { + (yyval.interm).intermAggregate = context->intermediate.growAggregate((yyvsp[(1) - (3)].interm).intermNode, context->intermediate.addSymbol(0, *(yyvsp[(3) - (3)].lex).string, TType((yyvsp[(1) - (3)].interm).type), (yyvsp[(3) - (3)].lex).line), (yyvsp[(3) - (3)].lex).line); + + if (context->structQualifierErrorCheck((yyvsp[(3) - (3)].lex).line, (yyval.interm).type)) + context->recover(); + + if (context->nonInitConstErrorCheck((yyvsp[(3) - (3)].lex).line, *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type)) + context->recover(); + + if (context->nonInitErrorCheck((yyvsp[(3) - (3)].lex).line, *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type)) + context->recover(); + ;} + break; + + case 93: + + { + if (context->structQualifierErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(1) - (5)].interm).type)) + context->recover(); + + if (context->nonInitConstErrorCheck((yyvsp[(3) - (5)].lex).line, *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type)) + context->recover(); + + (yyval.interm) = (yyvsp[(1) - (5)].interm); + + if (context->arrayTypeErrorCheck((yyvsp[(4) - (5)].lex).line, (yyvsp[(1) - (5)].interm).type) || context->arrayQualifierErrorCheck((yyvsp[(4) - (5)].lex).line, (yyvsp[(1) - (5)].interm).type)) + context->recover(); + else { + (yyvsp[(1) - (5)].interm).type.setArray(true); + TVariable* variable; + if (context->arrayErrorCheck((yyvsp[(4) - (5)].lex).line, *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type, variable)) + context->recover(); + } + ;} + break; + + case 94: + + { + if (context->structQualifierErrorCheck((yyvsp[(3) - (6)].lex).line, (yyvsp[(1) - (6)].interm).type)) + context->recover(); + + if (context->nonInitConstErrorCheck((yyvsp[(3) - (6)].lex).line, *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type)) + context->recover(); + + (yyval.interm) = (yyvsp[(1) - (6)].interm); + + if (context->arrayTypeErrorCheck((yyvsp[(4) - (6)].lex).line, (yyvsp[(1) - (6)].interm).type) || context->arrayQualifierErrorCheck((yyvsp[(4) - (6)].lex).line, (yyvsp[(1) - (6)].interm).type)) + context->recover(); + else { + int size; + if (context->arraySizeErrorCheck((yyvsp[(4) - (6)].lex).line, (yyvsp[(5) - (6)].interm.intermTypedNode), size)) + context->recover(); + (yyvsp[(1) - (6)].interm).type.setArray(true, size); + TVariable* variable; + if (context->arrayErrorCheck((yyvsp[(4) - (6)].lex).line, *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type, variable)) + context->recover(); + TType type = TType((yyvsp[(1) - (6)].interm).type); + type.setArraySize(size); + (yyval.interm).intermAggregate = context->intermediate.growAggregate((yyvsp[(1) - (6)].interm).intermNode, context->intermediate.addSymbol(0, *(yyvsp[(3) - (6)].lex).string, type, (yyvsp[(3) - (6)].lex).line), (yyvsp[(3) - (6)].lex).line); + } + ;} + break; + + case 95: + + { + if (context->structQualifierErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(1) - (5)].interm).type)) + context->recover(); + + (yyval.interm) = (yyvsp[(1) - (5)].interm); + + TIntermNode* intermNode; + if (!context->executeInitializer((yyvsp[(3) - (5)].lex).line, *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type, (yyvsp[(5) - (5)].interm.intermTypedNode), intermNode)) { + // + // build the intermediate representation + // + if (intermNode) + (yyval.interm).intermAggregate = context->intermediate.growAggregate((yyvsp[(1) - (5)].interm).intermNode, intermNode, (yyvsp[(4) - (5)].lex).line); + else + (yyval.interm).intermAggregate = (yyvsp[(1) - (5)].interm).intermAggregate; + } else { + context->recover(); + (yyval.interm).intermAggregate = 0; + } + ;} + break; + + case 96: + + { + (yyval.interm).type = (yyvsp[(1) - (1)].interm.type); + (yyval.interm).intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, "", TType((yyvsp[(1) - (1)].interm.type)), (yyvsp[(1) - (1)].interm.type).line), (yyvsp[(1) - (1)].interm.type).line); + ;} + break; + + case 97: + + { + (yyval.interm).intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *(yyvsp[(2) - (2)].lex).string, TType((yyvsp[(1) - (2)].interm.type)), (yyvsp[(2) - (2)].lex).line), (yyvsp[(2) - (2)].lex).line); + + if (context->structQualifierErrorCheck((yyvsp[(2) - (2)].lex).line, (yyval.interm).type)) + context->recover(); + + if (context->nonInitConstErrorCheck((yyvsp[(2) - (2)].lex).line, *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type)) + context->recover(); + + (yyval.interm).type = (yyvsp[(1) - (2)].interm.type); + + if (context->nonInitErrorCheck((yyvsp[(2) - (2)].lex).line, *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type)) + context->recover(); + ;} + break; + + case 98: + + { + (yyval.interm).intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *(yyvsp[(2) - (4)].lex).string, TType((yyvsp[(1) - (4)].interm.type)), (yyvsp[(2) - (4)].lex).line), (yyvsp[(2) - (4)].lex).line); + + if (context->structQualifierErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type))) + context->recover(); + + if (context->nonInitConstErrorCheck((yyvsp[(2) - (4)].lex).line, *(yyvsp[(2) - (4)].lex).string, (yyvsp[(1) - (4)].interm.type))) + context->recover(); + + (yyval.interm).type = (yyvsp[(1) - (4)].interm.type); + + if (context->arrayTypeErrorCheck((yyvsp[(3) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type)) || context->arrayQualifierErrorCheck((yyvsp[(3) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type))) + context->recover(); + else { + (yyvsp[(1) - (4)].interm.type).setArray(true); + TVariable* variable; + if (context->arrayErrorCheck((yyvsp[(3) - (4)].lex).line, *(yyvsp[(2) - (4)].lex).string, (yyvsp[(1) - (4)].interm.type), variable)) + context->recover(); + } + ;} + break; + + case 99: + + { + TType type = TType((yyvsp[(1) - (5)].interm.type)); + int size; + if (context->arraySizeErrorCheck((yyvsp[(2) - (5)].lex).line, (yyvsp[(4) - (5)].interm.intermTypedNode), size)) + context->recover(); + type.setArraySize(size); + (yyval.interm).intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *(yyvsp[(2) - (5)].lex).string, type, (yyvsp[(2) - (5)].lex).line), (yyvsp[(2) - (5)].lex).line); + + if (context->structQualifierErrorCheck((yyvsp[(2) - (5)].lex).line, (yyvsp[(1) - (5)].interm.type))) + context->recover(); + + if (context->nonInitConstErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type))) + context->recover(); + + (yyval.interm).type = (yyvsp[(1) - (5)].interm.type); + + if (context->arrayTypeErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(1) - (5)].interm.type)) || context->arrayQualifierErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(1) - (5)].interm.type))) + context->recover(); + else { + int size; + if (context->arraySizeErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(4) - (5)].interm.intermTypedNode), size)) + context->recover(); + + (yyvsp[(1) - (5)].interm.type).setArray(true, size); + TVariable* variable; + if (context->arrayErrorCheck((yyvsp[(3) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type), variable)) + context->recover(); + } + ;} + break; + + case 100: + + { + if (context->structQualifierErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type))) + context->recover(); + + (yyval.interm).type = (yyvsp[(1) - (4)].interm.type); + + TIntermNode* intermNode; + if (!context->executeInitializer((yyvsp[(2) - (4)].lex).line, *(yyvsp[(2) - (4)].lex).string, (yyvsp[(1) - (4)].interm.type), (yyvsp[(4) - (4)].interm.intermTypedNode), intermNode)) { + // + // Build intermediate representation + // + if(intermNode) + (yyval.interm).intermAggregate = context->intermediate.makeAggregate(intermNode, (yyvsp[(3) - (4)].lex).line); + else + (yyval.interm).intermAggregate = 0; + } else { + context->recover(); + (yyval.interm).intermAggregate = 0; + } + ;} + break; + + case 101: + + { + VERTEX_ONLY("invariant declaration", (yyvsp[(1) - (2)].lex).line); + (yyval.interm).qualifier = EvqInvariantVaryingOut; + (yyval.interm).intermAggregate = 0; + ;} + break; + + case 102: + + { + (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type); + + if ((yyvsp[(1) - (1)].interm.type).array) { + context->error((yyvsp[(1) - (1)].interm.type).line, "not supported", "first-class array", ""); + context->recover(); + (yyvsp[(1) - (1)].interm.type).setArray(false); + } + ;} + break; + + case 103: + + { + if ((yyvsp[(2) - (2)].interm.type).array) { + context->error((yyvsp[(2) - (2)].interm.type).line, "not supported", "first-class array", ""); + context->recover(); + (yyvsp[(2) - (2)].interm.type).setArray(false); + } + + if ((yyvsp[(1) - (2)].interm.type).qualifier == EvqAttribute && + ((yyvsp[(2) - (2)].interm.type).type == EbtBool || (yyvsp[(2) - (2)].interm.type).type == EbtInt)) { + context->error((yyvsp[(2) - (2)].interm.type).line, "cannot be bool or int", getQualifierString((yyvsp[(1) - (2)].interm.type).qualifier), ""); + context->recover(); + } + if (((yyvsp[(1) - (2)].interm.type).qualifier == EvqVaryingIn || (yyvsp[(1) - (2)].interm.type).qualifier == EvqVaryingOut) && + ((yyvsp[(2) - (2)].interm.type).type == EbtBool || (yyvsp[(2) - (2)].interm.type).type == EbtInt)) { + context->error((yyvsp[(2) - (2)].interm.type).line, "cannot be bool or int", getQualifierString((yyvsp[(1) - (2)].interm.type).qualifier), ""); + context->recover(); + } + (yyval.interm.type) = (yyvsp[(2) - (2)].interm.type); + (yyval.interm.type).qualifier = (yyvsp[(1) - (2)].interm.type).qualifier; + ;} + break; + + case 104: + + { + (yyval.interm.type).setBasic(EbtVoid, EvqConst, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 105: + + { + VERTEX_ONLY("attribute", (yyvsp[(1) - (1)].lex).line); + if (context->globalErrorCheck((yyvsp[(1) - (1)].lex).line, context->symbolTable.atGlobalLevel(), "attribute")) + context->recover(); + (yyval.interm.type).setBasic(EbtVoid, EvqAttribute, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 106: + + { + if (context->globalErrorCheck((yyvsp[(1) - (1)].lex).line, context->symbolTable.atGlobalLevel(), "varying")) + context->recover(); + if (context->shaderType == SH_VERTEX_SHADER) + (yyval.interm.type).setBasic(EbtVoid, EvqVaryingOut, (yyvsp[(1) - (1)].lex).line); + else + (yyval.interm.type).setBasic(EbtVoid, EvqVaryingIn, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 107: + + { + if (context->globalErrorCheck((yyvsp[(1) - (2)].lex).line, context->symbolTable.atGlobalLevel(), "invariant varying")) + context->recover(); + if (context->shaderType == SH_VERTEX_SHADER) + (yyval.interm.type).setBasic(EbtVoid, EvqInvariantVaryingOut, (yyvsp[(1) - (2)].lex).line); + else + (yyval.interm.type).setBasic(EbtVoid, EvqInvariantVaryingIn, (yyvsp[(1) - (2)].lex).line); + ;} + break; + + case 108: + + { + if (context->globalErrorCheck((yyvsp[(1) - (1)].lex).line, context->symbolTable.atGlobalLevel(), "uniform")) + context->recover(); + (yyval.interm.type).setBasic(EbtVoid, EvqUniform, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 109: + + { + (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type); + ;} + break; + + case 110: + + { + (yyval.interm.type) = (yyvsp[(2) - (2)].interm.type); + (yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision); + ;} + break; + + case 111: + + { + (yyval.interm.precision) = EbpHigh; + ;} + break; + + case 112: + + { + (yyval.interm.precision) = EbpMedium; + ;} + break; + + case 113: + + { + (yyval.interm.precision) = EbpLow; + ;} + break; + + case 114: + + { + (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type); + ;} + break; + + case 115: + + { + (yyval.interm.type) = (yyvsp[(1) - (4)].interm.type); + + if (context->arrayTypeErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type))) + context->recover(); + else { + int size; + if (context->arraySizeErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(3) - (4)].interm.intermTypedNode), size)) + context->recover(); + (yyval.interm.type).setArray(true, size); + } + ;} + break; + + case 116: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtVoid, qual, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 117: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 118: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtInt, qual, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 119: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtBool, qual, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 120: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(2); + ;} + break; + + case 121: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(3); + ;} + break; + + case 122: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(4); + ;} + break; + + case 123: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtBool, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(2); + ;} + break; + + case 124: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtBool, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(3); + ;} + break; + + case 125: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtBool, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(4); + ;} + break; + + case 126: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtInt, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(2); + ;} + break; + + case 127: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtInt, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(3); + ;} + break; + + case 128: + + { + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtInt, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(4); + ;} + break; + + case 129: + + { + FRAG_VERT_ONLY("mat2", (yyvsp[(1) - (1)].lex).line); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(2, true); + ;} + break; + + case 130: + + { + FRAG_VERT_ONLY("mat3", (yyvsp[(1) - (1)].lex).line); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(3, true); + ;} + break; + + case 131: + + { + FRAG_VERT_ONLY("mat4", (yyvsp[(1) - (1)].lex).line); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).setAggregate(4, true); + ;} + break; + + case 132: + + { + FRAG_VERT_ONLY("sampler2D", (yyvsp[(1) - (1)].lex).line); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtSampler2D, qual, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 133: + + { + FRAG_VERT_ONLY("samplerCube", (yyvsp[(1) - (1)].lex).line); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtSamplerCube, qual, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 134: + + { + FRAG_VERT_ONLY("struct", (yyvsp[(1) - (1)].interm.type).line); + (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type); + (yyval.interm.type).qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + ;} + break; + + case 135: + + { + // + // This is for user defined type names. The lexical phase looked up the + // type. + // + TType& structure = static_cast<TVariable*>((yyvsp[(1) - (1)].lex).symbol)->getType(); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtStruct, qual, (yyvsp[(1) - (1)].lex).line); + (yyval.interm.type).userDef = &structure; + ;} + break; + + case 136: + + { + if (context->reservedErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string)) + context->recover(); + + TType* structure = new TType((yyvsp[(4) - (5)].interm.typeList), *(yyvsp[(2) - (5)].lex).string); + TVariable* userTypeDef = new TVariable((yyvsp[(2) - (5)].lex).string, *structure, true); + if (! context->symbolTable.insert(*userTypeDef)) { + context->error((yyvsp[(2) - (5)].lex).line, "redefinition", (yyvsp[(2) - (5)].lex).string->c_str(), "struct"); + context->recover(); + } + (yyval.interm.type).setBasic(EbtStruct, EvqTemporary, (yyvsp[(1) - (5)].lex).line); + (yyval.interm.type).userDef = structure; + ;} + break; + + case 137: + + { + TType* structure = new TType((yyvsp[(3) - (4)].interm.typeList), TString("")); + (yyval.interm.type).setBasic(EbtStruct, EvqTemporary, (yyvsp[(1) - (4)].lex).line); + (yyval.interm.type).userDef = structure; + ;} + break; + + case 138: + + { + (yyval.interm.typeList) = (yyvsp[(1) - (1)].interm.typeList); + ;} + break; + + case 139: + + { + (yyval.interm.typeList) = (yyvsp[(1) - (2)].interm.typeList); + for (unsigned int i = 0; i < (yyvsp[(2) - (2)].interm.typeList)->size(); ++i) { + for (unsigned int j = 0; j < (yyval.interm.typeList)->size(); ++j) { + if ((*(yyval.interm.typeList))[j].type->getFieldName() == (*(yyvsp[(2) - (2)].interm.typeList))[i].type->getFieldName()) { + context->error((*(yyvsp[(2) - (2)].interm.typeList))[i].line, "duplicate field name in structure:", "struct", (*(yyvsp[(2) - (2)].interm.typeList))[i].type->getFieldName().c_str()); + context->recover(); + } + } + (yyval.interm.typeList)->push_back((*(yyvsp[(2) - (2)].interm.typeList))[i]); + } + ;} + break; + + case 140: + + { + (yyval.interm.typeList) = (yyvsp[(2) - (3)].interm.typeList); + + if (context->voidErrorCheck((yyvsp[(1) - (3)].interm.type).line, (*(yyvsp[(2) - (3)].interm.typeList))[0].type->getFieldName(), (yyvsp[(1) - (3)].interm.type))) { + context->recover(); + } + for (unsigned int i = 0; i < (yyval.interm.typeList)->size(); ++i) { + // + // Careful not to replace already known aspects of type, like array-ness + // + TType* type = (*(yyval.interm.typeList))[i].type; + type->setBasicType((yyvsp[(1) - (3)].interm.type).type); + type->setNominalSize((yyvsp[(1) - (3)].interm.type).size); + type->setMatrix((yyvsp[(1) - (3)].interm.type).matrix); + + // don't allow arrays of arrays + if (type->isArray()) { + if (context->arrayTypeErrorCheck((yyvsp[(1) - (3)].interm.type).line, (yyvsp[(1) - (3)].interm.type))) + context->recover(); + } + if ((yyvsp[(1) - (3)].interm.type).array) + type->setArraySize((yyvsp[(1) - (3)].interm.type).arraySize); + if ((yyvsp[(1) - (3)].interm.type).userDef) { + type->setStruct((yyvsp[(1) - (3)].interm.type).userDef->getStruct()); + type->setTypeName((yyvsp[(1) - (3)].interm.type).userDef->getTypeName()); + } + } + ;} + break; + + case 141: + + { + (yyval.interm.typeList) = NewPoolTTypeList(); + (yyval.interm.typeList)->push_back((yyvsp[(1) - (1)].interm.typeLine)); + ;} + break; + + case 142: + + { + (yyval.interm.typeList)->push_back((yyvsp[(3) - (3)].interm.typeLine)); + ;} + break; + + case 143: + + { + if (context->reservedErrorCheck((yyvsp[(1) - (1)].lex).line, *(yyvsp[(1) - (1)].lex).string)) + context->recover(); + + (yyval.interm.typeLine).type = new TType(EbtVoid, EbpUndefined); + (yyval.interm.typeLine).line = (yyvsp[(1) - (1)].lex).line; + (yyval.interm.typeLine).type->setFieldName(*(yyvsp[(1) - (1)].lex).string); + ;} + break; + + case 144: + + { + if (context->reservedErrorCheck((yyvsp[(1) - (4)].lex).line, *(yyvsp[(1) - (4)].lex).string)) + context->recover(); + + (yyval.interm.typeLine).type = new TType(EbtVoid, EbpUndefined); + (yyval.interm.typeLine).line = (yyvsp[(1) - (4)].lex).line; + (yyval.interm.typeLine).type->setFieldName(*(yyvsp[(1) - (4)].lex).string); + + int size; + if (context->arraySizeErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(3) - (4)].interm.intermTypedNode), size)) + context->recover(); + (yyval.interm.typeLine).type->setArraySize(size); + ;} + break; + + case 145: + + { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} + break; + + case 146: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 147: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermAggregate); ;} + break; + + case 148: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 149: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 150: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 151: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 152: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 153: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 154: + + { (yyval.interm.intermAggregate) = 0; ;} + break; + + case 155: + + { context->symbolTable.push(); ;} + break; + + case 156: + + { context->symbolTable.pop(); ;} + break; + + case 157: + + { + if ((yyvsp[(3) - (5)].interm.intermAggregate) != 0) + (yyvsp[(3) - (5)].interm.intermAggregate)->setOp(EOpSequence); + (yyval.interm.intermAggregate) = (yyvsp[(3) - (5)].interm.intermAggregate); + ;} + break; + + case 158: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 159: + + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 160: + + { + (yyval.interm.intermNode) = 0; + ;} + break; + + case 161: + + { + if ((yyvsp[(2) - (3)].interm.intermAggregate)) + (yyvsp[(2) - (3)].interm.intermAggregate)->setOp(EOpSequence); + (yyval.interm.intermNode) = (yyvsp[(2) - (3)].interm.intermAggregate); + ;} + break; + + case 162: + + { + (yyval.interm.intermAggregate) = context->intermediate.makeAggregate((yyvsp[(1) - (1)].interm.intermNode), 0); + ;} + break; + + case 163: + + { + (yyval.interm.intermAggregate) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermAggregate), (yyvsp[(2) - (2)].interm.intermNode), 0); + ;} + break; + + case 164: + + { (yyval.interm.intermNode) = 0; ;} + break; + + case 165: + + { (yyval.interm.intermNode) = static_cast<TIntermNode*>((yyvsp[(1) - (2)].interm.intermTypedNode)); ;} + break; + + case 166: + + { + if (context->boolErrorCheck((yyvsp[(1) - (5)].lex).line, (yyvsp[(3) - (5)].interm.intermTypedNode))) + context->recover(); + (yyval.interm.intermNode) = context->intermediate.addSelection((yyvsp[(3) - (5)].interm.intermTypedNode), (yyvsp[(5) - (5)].interm.nodePair), (yyvsp[(1) - (5)].lex).line); + ;} + break; + + case 167: + + { + (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermNode); + (yyval.interm.nodePair).node2 = (yyvsp[(3) - (3)].interm.intermNode); + ;} + break; + + case 168: + + { + (yyval.interm.nodePair).node1 = (yyvsp[(1) - (1)].interm.intermNode); + (yyval.interm.nodePair).node2 = 0; + ;} + break; + + case 169: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + if (context->boolErrorCheck((yyvsp[(1) - (1)].interm.intermTypedNode)->getLine(), (yyvsp[(1) - (1)].interm.intermTypedNode))) + context->recover(); + ;} + break; + + case 170: + + { + TIntermNode* intermNode; + if (context->structQualifierErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type))) + context->recover(); + if (context->boolErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type))) + context->recover(); + + if (!context->executeInitializer((yyvsp[(2) - (4)].lex).line, *(yyvsp[(2) - (4)].lex).string, (yyvsp[(1) - (4)].interm.type), (yyvsp[(4) - (4)].interm.intermTypedNode), intermNode)) + (yyval.interm.intermTypedNode) = (yyvsp[(4) - (4)].interm.intermTypedNode); + else { + context->recover(); + (yyval.interm.intermTypedNode) = 0; + } + ;} + break; + + case 171: + + { context->symbolTable.push(); ++context->loopNestingLevel; ;} + break; + + case 172: + + { + context->symbolTable.pop(); + (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopWhile, 0, (yyvsp[(4) - (6)].interm.intermTypedNode), 0, (yyvsp[(6) - (6)].interm.intermNode), (yyvsp[(1) - (6)].lex).line); + --context->loopNestingLevel; + ;} + break; + + case 173: + + { ++context->loopNestingLevel; ;} + break; + + case 174: + + { + if (context->boolErrorCheck((yyvsp[(8) - (8)].lex).line, (yyvsp[(6) - (8)].interm.intermTypedNode))) + context->recover(); + + (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopDoWhile, 0, (yyvsp[(6) - (8)].interm.intermTypedNode), 0, (yyvsp[(3) - (8)].interm.intermNode), (yyvsp[(4) - (8)].lex).line); + --context->loopNestingLevel; + ;} + break; + + case 175: + + { context->symbolTable.push(); ++context->loopNestingLevel; ;} + break; + + case 176: + + { + context->symbolTable.pop(); + (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[(4) - (7)].interm.intermNode), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node1), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node2), (yyvsp[(7) - (7)].interm.intermNode), (yyvsp[(1) - (7)].lex).line); + --context->loopNestingLevel; + ;} + break; + + case 177: + + { + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + ;} + break; + + case 178: + + { + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + ;} + break; + + case 179: + + { + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + ;} + break; + + case 180: + + { + (yyval.interm.intermTypedNode) = 0; + ;} + break; + + case 181: + + { + (yyval.interm.nodePair).node1 = (yyvsp[(1) - (2)].interm.intermTypedNode); + (yyval.interm.nodePair).node2 = 0; + ;} + break; + + case 182: + + { + (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermTypedNode); + (yyval.interm.nodePair).node2 = (yyvsp[(3) - (3)].interm.intermTypedNode); + ;} + break; + + case 183: + + { + if (context->loopNestingLevel <= 0) { + context->error((yyvsp[(1) - (2)].lex).line, "continue statement only allowed in loops", "", ""); + context->recover(); + } + (yyval.interm.intermNode) = context->intermediate.addBranch(EOpContinue, (yyvsp[(1) - (2)].lex).line); + ;} + break; + + case 184: + + { + if (context->loopNestingLevel <= 0) { + context->error((yyvsp[(1) - (2)].lex).line, "break statement only allowed in loops", "", ""); + context->recover(); + } + (yyval.interm.intermNode) = context->intermediate.addBranch(EOpBreak, (yyvsp[(1) - (2)].lex).line); + ;} + break; + + case 185: + + { + (yyval.interm.intermNode) = context->intermediate.addBranch(EOpReturn, (yyvsp[(1) - (2)].lex).line); + if (context->currentFunctionType->getBasicType() != EbtVoid) { + context->error((yyvsp[(1) - (2)].lex).line, "non-void function must return a value", "return", ""); + context->recover(); + } + ;} + break; + + case 186: + + { + (yyval.interm.intermNode) = context->intermediate.addBranch(EOpReturn, (yyvsp[(2) - (3)].interm.intermTypedNode), (yyvsp[(1) - (3)].lex).line); + context->functionReturnsValue = true; + if (context->currentFunctionType->getBasicType() == EbtVoid) { + context->error((yyvsp[(1) - (3)].lex).line, "void function cannot return a value", "return", ""); + context->recover(); + } else if (*(context->currentFunctionType) != (yyvsp[(2) - (3)].interm.intermTypedNode)->getType()) { + context->error((yyvsp[(1) - (3)].lex).line, "function return is not matching type:", "return", ""); + context->recover(); + } + ;} + break; + + case 187: + + { + FRAG_ONLY("discard", (yyvsp[(1) - (2)].lex).line); + (yyval.interm.intermNode) = context->intermediate.addBranch(EOpKill, (yyvsp[(1) - (2)].lex).line); + ;} + break; + + case 188: + + { + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + context->treeRoot = (yyval.interm.intermNode); + ;} + break; + + case 189: + + { + (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermNode), (yyvsp[(2) - (2)].interm.intermNode), 0); + context->treeRoot = (yyval.interm.intermNode); + ;} + break; + + case 190: + + { + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + ;} + break; + + case 191: + + { + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + ;} + break; + + case 192: + + { + TFunction* function = (yyvsp[(1) - (1)].interm).function; + TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName())); + // + // Note: 'prevDec' could be 'function' if this is the first time we've seen function + // as it would have just been put in the symbol table. Otherwise, we're looking up + // an earlier occurance. + // + if (prevDec->isDefined()) { + // + // Then this function already has a body. + // + context->error((yyvsp[(1) - (1)].interm).line, "function already has a body", function->getName().c_str(), ""); + context->recover(); + } + prevDec->setDefined(); + + // + // Raise error message if main function takes any parameters or return anything other than void + // + if (function->getName() == "main") { + if (function->getParamCount() > 0) { + context->error((yyvsp[(1) - (1)].interm).line, "function cannot take any parameter(s)", function->getName().c_str(), ""); + context->recover(); + } + if (function->getReturnType().getBasicType() != EbtVoid) { + context->error((yyvsp[(1) - (1)].interm).line, "", function->getReturnType().getBasicString(), "main function cannot return a value"); + context->recover(); + } + } + + // + // New symbol table scope for body of function plus its arguments + // + context->symbolTable.push(); + + // + // Remember the return type for later checking for RETURN statements. + // + context->currentFunctionType = &(prevDec->getReturnType()); + context->functionReturnsValue = false; + + // + // Insert parameters into the symbol table. + // If the parameter has no name, it's not an error, just don't insert it + // (could be used for unused args). + // + // Also, accumulate the list of parameters into the HIL, so lower level code + // knows where to find parameters. + // + TIntermAggregate* paramNodes = new TIntermAggregate; + for (int i = 0; i < function->getParamCount(); i++) { + const TParameter& param = function->getParam(i); + if (param.name != 0) { + TVariable *variable = new TVariable(param.name, *param.type); + // + // Insert the parameters with name in the symbol table. + // + if (! context->symbolTable.insert(*variable)) { + context->error((yyvsp[(1) - (1)].interm).line, "redefinition", variable->getName().c_str(), ""); + context->recover(); + delete variable; + } + + // + // Add the parameter to the HIL + // + paramNodes = context->intermediate.growAggregate( + paramNodes, + context->intermediate.addSymbol(variable->getUniqueId(), + variable->getName(), + variable->getType(), (yyvsp[(1) - (1)].interm).line), + (yyvsp[(1) - (1)].interm).line); + } else { + paramNodes = context->intermediate.growAggregate(paramNodes, context->intermediate.addSymbol(0, "", *param.type, (yyvsp[(1) - (1)].interm).line), (yyvsp[(1) - (1)].interm).line); + } + } + context->intermediate.setAggregateOperator(paramNodes, EOpParameters, (yyvsp[(1) - (1)].interm).line); + (yyvsp[(1) - (1)].interm).intermAggregate = paramNodes; + context->loopNestingLevel = 0; + ;} + break; + + case 193: + + { + //?? Check that all paths return a value if return type != void ? + // May be best done as post process phase on intermediate code + if (context->currentFunctionType->getBasicType() != EbtVoid && ! context->functionReturnsValue) { + context->error((yyvsp[(1) - (3)].interm).line, "function does not return a value:", "", (yyvsp[(1) - (3)].interm).function->getName().c_str()); + context->recover(); + } + context->symbolTable.pop(); + (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[(1) - (3)].interm).intermAggregate, (yyvsp[(3) - (3)].interm.intermNode), 0); + context->intermediate.setAggregateOperator((yyval.interm.intermNode), EOpFunction, (yyvsp[(1) - (3)].interm).line); + (yyval.interm.intermNode)->getAsAggregate()->setName((yyvsp[(1) - (3)].interm).function->getMangledName().c_str()); + (yyval.interm.intermNode)->getAsAggregate()->setType((yyvsp[(1) - (3)].interm).function->getReturnType()); + + // store the pragma information for debug and optimize and other vendor specific + // information. This information can be queried from the parse tree + (yyval.interm.intermNode)->getAsAggregate()->setOptimize(context->contextPragma.optimize); + (yyval.interm.intermNode)->getAsAggregate()->setDebug(context->contextPragma.debug); + (yyval.interm.intermNode)->getAsAggregate()->addToPragmaTable(context->contextPragma.pragmaTable); + ;} + break; + + +/* Line 1267 of yacc.c. */ + + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (context, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (context, yymsg); + } + else + { + yyerror (context, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, context); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, context); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (context, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, context); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, context); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + + + +int glslang_parse(TParseContext* context) { + return yyparse(context); +} + + diff --git a/Source/ThirdParty/ANGLE/src/compiler/glslang_tab.h b/Source/ThirdParty/ANGLE/src/compiler/glslang_tab.h new file mode 100644 index 0000000..05cbfd4 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/glslang_tab.h @@ -0,0 +1,274 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INVARIANT = 258, + HIGH_PRECISION = 259, + MEDIUM_PRECISION = 260, + LOW_PRECISION = 261, + PRECISION = 262, + ATTRIBUTE = 263, + CONST_QUAL = 264, + BOOL_TYPE = 265, + FLOAT_TYPE = 266, + INT_TYPE = 267, + BREAK = 268, + CONTINUE = 269, + DO = 270, + ELSE = 271, + FOR = 272, + IF = 273, + DISCARD = 274, + RETURN = 275, + BVEC2 = 276, + BVEC3 = 277, + BVEC4 = 278, + IVEC2 = 279, + IVEC3 = 280, + IVEC4 = 281, + VEC2 = 282, + VEC3 = 283, + VEC4 = 284, + MATRIX2 = 285, + MATRIX3 = 286, + MATRIX4 = 287, + IN_QUAL = 288, + OUT_QUAL = 289, + INOUT_QUAL = 290, + UNIFORM = 291, + VARYING = 292, + STRUCT = 293, + VOID_TYPE = 294, + WHILE = 295, + SAMPLER2D = 296, + SAMPLERCUBE = 297, + IDENTIFIER = 298, + TYPE_NAME = 299, + FLOATCONSTANT = 300, + INTCONSTANT = 301, + BOOLCONSTANT = 302, + FIELD_SELECTION = 303, + LEFT_OP = 304, + RIGHT_OP = 305, + INC_OP = 306, + DEC_OP = 307, + LE_OP = 308, + GE_OP = 309, + EQ_OP = 310, + NE_OP = 311, + AND_OP = 312, + OR_OP = 313, + XOR_OP = 314, + MUL_ASSIGN = 315, + DIV_ASSIGN = 316, + ADD_ASSIGN = 317, + MOD_ASSIGN = 318, + LEFT_ASSIGN = 319, + RIGHT_ASSIGN = 320, + AND_ASSIGN = 321, + XOR_ASSIGN = 322, + OR_ASSIGN = 323, + SUB_ASSIGN = 324, + LEFT_PAREN = 325, + RIGHT_PAREN = 326, + LEFT_BRACKET = 327, + RIGHT_BRACKET = 328, + LEFT_BRACE = 329, + RIGHT_BRACE = 330, + DOT = 331, + COMMA = 332, + COLON = 333, + EQUAL = 334, + SEMICOLON = 335, + BANG = 336, + DASH = 337, + TILDE = 338, + PLUS = 339, + STAR = 340, + SLASH = 341, + PERCENT = 342, + LEFT_ANGLE = 343, + RIGHT_ANGLE = 344, + VERTICAL_BAR = 345, + CARET = 346, + AMPERSAND = 347, + QUESTION = 348 + }; +#endif +/* Tokens. */ +#define INVARIANT 258 +#define HIGH_PRECISION 259 +#define MEDIUM_PRECISION 260 +#define LOW_PRECISION 261 +#define PRECISION 262 +#define ATTRIBUTE 263 +#define CONST_QUAL 264 +#define BOOL_TYPE 265 +#define FLOAT_TYPE 266 +#define INT_TYPE 267 +#define BREAK 268 +#define CONTINUE 269 +#define DO 270 +#define ELSE 271 +#define FOR 272 +#define IF 273 +#define DISCARD 274 +#define RETURN 275 +#define BVEC2 276 +#define BVEC3 277 +#define BVEC4 278 +#define IVEC2 279 +#define IVEC3 280 +#define IVEC4 281 +#define VEC2 282 +#define VEC3 283 +#define VEC4 284 +#define MATRIX2 285 +#define MATRIX3 286 +#define MATRIX4 287 +#define IN_QUAL 288 +#define OUT_QUAL 289 +#define INOUT_QUAL 290 +#define UNIFORM 291 +#define VARYING 292 +#define STRUCT 293 +#define VOID_TYPE 294 +#define WHILE 295 +#define SAMPLER2D 296 +#define SAMPLERCUBE 297 +#define IDENTIFIER 298 +#define TYPE_NAME 299 +#define FLOATCONSTANT 300 +#define INTCONSTANT 301 +#define BOOLCONSTANT 302 +#define FIELD_SELECTION 303 +#define LEFT_OP 304 +#define RIGHT_OP 305 +#define INC_OP 306 +#define DEC_OP 307 +#define LE_OP 308 +#define GE_OP 309 +#define EQ_OP 310 +#define NE_OP 311 +#define AND_OP 312 +#define OR_OP 313 +#define XOR_OP 314 +#define MUL_ASSIGN 315 +#define DIV_ASSIGN 316 +#define ADD_ASSIGN 317 +#define MOD_ASSIGN 318 +#define LEFT_ASSIGN 319 +#define RIGHT_ASSIGN 320 +#define AND_ASSIGN 321 +#define XOR_ASSIGN 322 +#define OR_ASSIGN 323 +#define SUB_ASSIGN 324 +#define LEFT_PAREN 325 +#define RIGHT_PAREN 326 +#define LEFT_BRACKET 327 +#define RIGHT_BRACKET 328 +#define LEFT_BRACE 329 +#define RIGHT_BRACE 330 +#define DOT 331 +#define COMMA 332 +#define COLON 333 +#define EQUAL 334 +#define SEMICOLON 335 +#define BANG 336 +#define DASH 337 +#define TILDE 338 +#define PLUS 339 +#define STAR 340 +#define SLASH 341 +#define PERCENT 342 +#define LEFT_ANGLE 343 +#define RIGHT_ANGLE 344 +#define VERTICAL_BAR 345 +#define CARET 346 +#define AMPERSAND 347 +#define QUESTION 348 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE + +{ + struct { + TSourceLoc line; + union { + TString *string; + float f; + int i; + bool b; + }; + TSymbol* symbol; + } lex; + struct { + TSourceLoc line; + TOperator op; + union { + TIntermNode* intermNode; + TIntermNodePair nodePair; + TIntermTyped* intermTypedNode; + TIntermAggregate* intermAggregate; + }; + union { + TPublicType type; + TPrecision precision; + TQualifier qualifier; + TFunction* function; + TParameter param; + TTypeLine typeLine; + TTypeList* typeList; + }; + } interm; +} +/* Line 1489 of yacc.c. */ + + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp b/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp index db042dd..798a69a 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp @@ -21,8 +21,8 @@ // class TOutputTraverser : public TIntermTraverser { public: - TOutputTraverser(TInfoSink& i) : infoSink(i) { } - TInfoSink& infoSink; + TOutputTraverser(TInfoSinkBase& i) : sink(i) { } + TInfoSinkBase& sink; protected: void visitSymbol(TIntermSymbol*); @@ -56,14 +56,14 @@ TString TType::getCompleteString() const // Helper functions for printing, not part of traversing. // -void OutputTreeText(TInfoSink& infoSink, TIntermNode* node, const int depth) +void OutputTreeText(TInfoSinkBase& sink, TIntermNode* node, const int depth) { int i; - infoSink.debug.location(node->getLine()); + sink.location(node->getLine()); for (i = 0; i < depth; ++i) - infoSink.debug << " "; + sink << " "; } // @@ -77,226 +77,226 @@ void OutputTreeText(TInfoSink& infoSink, TIntermNode* node, const int depth) void TOutputTraverser::visitSymbol(TIntermSymbol* node) { - OutputTreeText(infoSink, node, depth); + OutputTreeText(sink, node, depth); - infoSink.debug << "'" << node->getSymbol() << "' "; - infoSink.debug << "(" << node->getCompleteString() << ")\n"; + sink << "'" << node->getSymbol() << "' "; + sink << "(" << node->getCompleteString() << ")\n"; } bool TOutputTraverser::visitBinary(Visit visit, TIntermBinary* node) { - TInfoSink& out = infoSink; + TInfoSinkBase& out = sink; OutputTreeText(out, node, depth); switch (node->getOp()) { - case EOpAssign: out.debug << "move second child to first child"; break; - case EOpInitialize: out.debug << "initialize first child with second child"; break; - case EOpAddAssign: out.debug << "add second child into first child"; break; - case EOpSubAssign: out.debug << "subtract second child into first child"; break; - case EOpMulAssign: out.debug << "multiply second child into first child"; break; - case EOpVectorTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break; - case EOpVectorTimesScalarAssign: out.debug << "vector scale second child into first child"; break; - case EOpMatrixTimesScalarAssign: out.debug << "matrix scale second child into first child"; break; - case EOpMatrixTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break; - case EOpDivAssign: out.debug << "divide second child into first child"; break; - case EOpIndexDirect: out.debug << "direct index"; break; - case EOpIndexIndirect: out.debug << "indirect index"; break; - case EOpIndexDirectStruct: out.debug << "direct index for structure"; break; - case EOpVectorSwizzle: out.debug << "vector swizzle"; break; - - case EOpAdd: out.debug << "add"; break; - case EOpSub: out.debug << "subtract"; break; - case EOpMul: out.debug << "component-wise multiply"; break; - case EOpDiv: out.debug << "divide"; break; - case EOpEqual: out.debug << "Compare Equal"; break; - case EOpNotEqual: out.debug << "Compare Not Equal"; break; - case EOpLessThan: out.debug << "Compare Less Than"; break; - case EOpGreaterThan: out.debug << "Compare Greater Than"; break; - case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break; - case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break; - - case EOpVectorTimesScalar: out.debug << "vector-scale"; break; - case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break; - case EOpMatrixTimesVector: out.debug << "matrix-times-vector"; break; - case EOpMatrixTimesScalar: out.debug << "matrix-scale"; break; - case EOpMatrixTimesMatrix: out.debug << "matrix-multiply"; break; - - case EOpLogicalOr: out.debug << "logical-or"; break; - case EOpLogicalXor: out.debug << "logical-xor"; break; - case EOpLogicalAnd: out.debug << "logical-and"; break; - default: out.debug << "<unknown op>"; + case EOpAssign: out << "move second child to first child"; break; + case EOpInitialize: out << "initialize first child with second child"; break; + case EOpAddAssign: out << "add second child into first child"; break; + case EOpSubAssign: out << "subtract second child into first child"; break; + case EOpMulAssign: out << "multiply second child into first child"; break; + case EOpVectorTimesMatrixAssign: out << "matrix mult second child into first child"; break; + case EOpVectorTimesScalarAssign: out << "vector scale second child into first child"; break; + case EOpMatrixTimesScalarAssign: out << "matrix scale second child into first child"; break; + case EOpMatrixTimesMatrixAssign: out << "matrix mult second child into first child"; break; + case EOpDivAssign: out << "divide second child into first child"; break; + case EOpIndexDirect: out << "direct index"; break; + case EOpIndexIndirect: out << "indirect index"; break; + case EOpIndexDirectStruct: out << "direct index for structure"; break; + case EOpVectorSwizzle: out << "vector swizzle"; break; + + case EOpAdd: out << "add"; break; + case EOpSub: out << "subtract"; break; + case EOpMul: out << "component-wise multiply"; break; + case EOpDiv: out << "divide"; break; + case EOpEqual: out << "Compare Equal"; break; + case EOpNotEqual: out << "Compare Not Equal"; break; + case EOpLessThan: out << "Compare Less Than"; break; + case EOpGreaterThan: out << "Compare Greater Than"; break; + case EOpLessThanEqual: out << "Compare Less Than or Equal"; break; + case EOpGreaterThanEqual: out << "Compare Greater Than or Equal"; break; + + case EOpVectorTimesScalar: out << "vector-scale"; break; + case EOpVectorTimesMatrix: out << "vector-times-matrix"; break; + case EOpMatrixTimesVector: out << "matrix-times-vector"; break; + case EOpMatrixTimesScalar: out << "matrix-scale"; break; + case EOpMatrixTimesMatrix: out << "matrix-multiply"; break; + + case EOpLogicalOr: out << "logical-or"; break; + case EOpLogicalXor: out << "logical-xor"; break; + case EOpLogicalAnd: out << "logical-and"; break; + default: out << "<unknown op>"; } - out.debug << " (" << node->getCompleteString() << ")"; + out << " (" << node->getCompleteString() << ")"; - out.debug << "\n"; + out << "\n"; return true; } bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node) { - TInfoSink& out = infoSink; + TInfoSinkBase& out = sink; OutputTreeText(out, node, depth); switch (node->getOp()) { - case EOpNegative: out.debug << "Negate value"; break; + case EOpNegative: out << "Negate value"; break; case EOpVectorLogicalNot: - case EOpLogicalNot: out.debug << "Negate conditional"; break; - - case EOpPostIncrement: out.debug << "Post-Increment"; break; - case EOpPostDecrement: out.debug << "Post-Decrement"; break; - case EOpPreIncrement: out.debug << "Pre-Increment"; break; - case EOpPreDecrement: out.debug << "Pre-Decrement"; break; - - case EOpConvIntToBool: out.debug << "Convert int to bool"; break; - case EOpConvFloatToBool:out.debug << "Convert float to bool";break; - case EOpConvBoolToFloat:out.debug << "Convert bool to float";break; - case EOpConvIntToFloat: out.debug << "Convert int to float"; break; - case EOpConvFloatToInt: out.debug << "Convert float to int"; break; - case EOpConvBoolToInt: out.debug << "Convert bool to int"; break; - - case EOpRadians: out.debug << "radians"; break; - case EOpDegrees: out.debug << "degrees"; break; - case EOpSin: out.debug << "sine"; break; - case EOpCos: out.debug << "cosine"; break; - case EOpTan: out.debug << "tangent"; break; - case EOpAsin: out.debug << "arc sine"; break; - case EOpAcos: out.debug << "arc cosine"; break; - case EOpAtan: out.debug << "arc tangent"; break; - - case EOpExp: out.debug << "exp"; break; - case EOpLog: out.debug << "log"; break; - case EOpExp2: out.debug << "exp2"; break; - case EOpLog2: out.debug << "log2"; break; - case EOpSqrt: out.debug << "sqrt"; break; - case EOpInverseSqrt: out.debug << "inverse sqrt"; break; - - case EOpAbs: out.debug << "Absolute value"; break; - case EOpSign: out.debug << "Sign"; break; - case EOpFloor: out.debug << "Floor"; break; - case EOpCeil: out.debug << "Ceiling"; break; - case EOpFract: out.debug << "Fraction"; break; - - case EOpLength: out.debug << "length"; break; - case EOpNormalize: out.debug << "normalize"; break; - // case EOpDPdx: out.debug << "dPdx"; break; - // case EOpDPdy: out.debug << "dPdy"; break; - // case EOpFwidth: out.debug << "fwidth"; break; - - case EOpAny: out.debug << "any"; break; - case EOpAll: out.debug << "all"; break; - - default: out.debug.message(EPrefixError, "Bad unary op"); + case EOpLogicalNot: out << "Negate conditional"; break; + + case EOpPostIncrement: out << "Post-Increment"; break; + case EOpPostDecrement: out << "Post-Decrement"; break; + case EOpPreIncrement: out << "Pre-Increment"; break; + case EOpPreDecrement: out << "Pre-Decrement"; break; + + case EOpConvIntToBool: out << "Convert int to bool"; break; + case EOpConvFloatToBool:out << "Convert float to bool";break; + case EOpConvBoolToFloat:out << "Convert bool to float";break; + case EOpConvIntToFloat: out << "Convert int to float"; break; + case EOpConvFloatToInt: out << "Convert float to int"; break; + case EOpConvBoolToInt: out << "Convert bool to int"; break; + + case EOpRadians: out << "radians"; break; + case EOpDegrees: out << "degrees"; break; + case EOpSin: out << "sine"; break; + case EOpCos: out << "cosine"; break; + case EOpTan: out << "tangent"; break; + case EOpAsin: out << "arc sine"; break; + case EOpAcos: out << "arc cosine"; break; + case EOpAtan: out << "arc tangent"; break; + + case EOpExp: out << "exp"; break; + case EOpLog: out << "log"; break; + case EOpExp2: out << "exp2"; break; + case EOpLog2: out << "log2"; break; + case EOpSqrt: out << "sqrt"; break; + case EOpInverseSqrt: out << "inverse sqrt"; break; + + case EOpAbs: out << "Absolute value"; break; + case EOpSign: out << "Sign"; break; + case EOpFloor: out << "Floor"; break; + case EOpCeil: out << "Ceiling"; break; + case EOpFract: out << "Fraction"; break; + + case EOpLength: out << "length"; break; + case EOpNormalize: out << "normalize"; break; + // case EOpDPdx: out << "dPdx"; break; + // case EOpDPdy: out << "dPdy"; break; + // case EOpFwidth: out << "fwidth"; break; + + case EOpAny: out << "any"; break; + case EOpAll: out << "all"; break; + + default: out.message(EPrefixError, "Bad unary op"); } - out.debug << " (" << node->getCompleteString() << ")"; + out << " (" << node->getCompleteString() << ")"; - out.debug << "\n"; + out << "\n"; return true; } bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate* node) { - TInfoSink& out = infoSink; + TInfoSinkBase& out = sink; if (node->getOp() == EOpNull) { - out.debug.message(EPrefixError, "node is still EOpNull!"); + out.message(EPrefixError, "node is still EOpNull!"); return true; } OutputTreeText(out, node, depth); switch (node->getOp()) { - case EOpSequence: out.debug << "Sequence\n"; return true; - case EOpComma: out.debug << "Comma\n"; return true; - case EOpFunction: out.debug << "Function Definition: " << node->getName(); break; - case EOpFunctionCall: out.debug << "Function Call: " << node->getName(); break; - case EOpParameters: out.debug << "Function Parameters: "; break; - - case EOpConstructFloat: out.debug << "Construct float"; break; - case EOpConstructVec2: out.debug << "Construct vec2"; break; - case EOpConstructVec3: out.debug << "Construct vec3"; break; - case EOpConstructVec4: out.debug << "Construct vec4"; break; - case EOpConstructBool: out.debug << "Construct bool"; break; - case EOpConstructBVec2: out.debug << "Construct bvec2"; break; - case EOpConstructBVec3: out.debug << "Construct bvec3"; break; - case EOpConstructBVec4: out.debug << "Construct bvec4"; break; - case EOpConstructInt: out.debug << "Construct int"; break; - case EOpConstructIVec2: out.debug << "Construct ivec2"; break; - case EOpConstructIVec3: out.debug << "Construct ivec3"; break; - case EOpConstructIVec4: out.debug << "Construct ivec4"; break; - case EOpConstructMat2: out.debug << "Construct mat2"; break; - case EOpConstructMat3: out.debug << "Construct mat3"; break; - case EOpConstructMat4: out.debug << "Construct mat4"; break; - case EOpConstructStruct: out.debug << "Construct structure"; break; - - case EOpLessThan: out.debug << "Compare Less Than"; break; - case EOpGreaterThan: out.debug << "Compare Greater Than"; break; - case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break; - case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break; - case EOpVectorEqual: out.debug << "Equal"; break; - case EOpVectorNotEqual: out.debug << "NotEqual"; break; - - case EOpMod: out.debug << "mod"; break; - case EOpPow: out.debug << "pow"; break; - - case EOpAtan: out.debug << "arc tangent"; break; - - case EOpMin: out.debug << "min"; break; - case EOpMax: out.debug << "max"; break; - case EOpClamp: out.debug << "clamp"; break; - case EOpMix: out.debug << "mix"; break; - case EOpStep: out.debug << "step"; break; - case EOpSmoothStep: out.debug << "smoothstep"; break; - - case EOpDistance: out.debug << "distance"; break; - case EOpDot: out.debug << "dot-product"; break; - case EOpCross: out.debug << "cross-product"; break; - case EOpFaceForward: out.debug << "face-forward"; break; - case EOpReflect: out.debug << "reflect"; break; - case EOpRefract: out.debug << "refract"; break; - case EOpMul: out.debug << "component-wise multiply"; break; - - default: out.debug.message(EPrefixError, "Bad aggregation op"); + case EOpSequence: out << "Sequence\n"; return true; + case EOpComma: out << "Comma\n"; return true; + case EOpFunction: out << "Function Definition: " << node->getName(); break; + case EOpFunctionCall: out << "Function Call: " << node->getName(); break; + case EOpParameters: out << "Function Parameters: "; break; + + case EOpConstructFloat: out << "Construct float"; break; + case EOpConstructVec2: out << "Construct vec2"; break; + case EOpConstructVec3: out << "Construct vec3"; break; + case EOpConstructVec4: out << "Construct vec4"; break; + case EOpConstructBool: out << "Construct bool"; break; + case EOpConstructBVec2: out << "Construct bvec2"; break; + case EOpConstructBVec3: out << "Construct bvec3"; break; + case EOpConstructBVec4: out << "Construct bvec4"; break; + case EOpConstructInt: out << "Construct int"; break; + case EOpConstructIVec2: out << "Construct ivec2"; break; + case EOpConstructIVec3: out << "Construct ivec3"; break; + case EOpConstructIVec4: out << "Construct ivec4"; break; + case EOpConstructMat2: out << "Construct mat2"; break; + case EOpConstructMat3: out << "Construct mat3"; break; + case EOpConstructMat4: out << "Construct mat4"; break; + case EOpConstructStruct: out << "Construct structure"; break; + + case EOpLessThan: out << "Compare Less Than"; break; + case EOpGreaterThan: out << "Compare Greater Than"; break; + case EOpLessThanEqual: out << "Compare Less Than or Equal"; break; + case EOpGreaterThanEqual: out << "Compare Greater Than or Equal"; break; + case EOpVectorEqual: out << "Equal"; break; + case EOpVectorNotEqual: out << "NotEqual"; break; + + case EOpMod: out << "mod"; break; + case EOpPow: out << "pow"; break; + + case EOpAtan: out << "arc tangent"; break; + + case EOpMin: out << "min"; break; + case EOpMax: out << "max"; break; + case EOpClamp: out << "clamp"; break; + case EOpMix: out << "mix"; break; + case EOpStep: out << "step"; break; + case EOpSmoothStep: out << "smoothstep"; break; + + case EOpDistance: out << "distance"; break; + case EOpDot: out << "dot-product"; break; + case EOpCross: out << "cross-product"; break; + case EOpFaceForward: out << "face-forward"; break; + case EOpReflect: out << "reflect"; break; + case EOpRefract: out << "refract"; break; + case EOpMul: out << "component-wise multiply"; break; + + default: out.message(EPrefixError, "Bad aggregation op"); } if (node->getOp() != EOpSequence && node->getOp() != EOpParameters) - out.debug << " (" << node->getCompleteString() << ")"; + out << " (" << node->getCompleteString() << ")"; - out.debug << "\n"; + out << "\n"; return true; } bool TOutputTraverser::visitSelection(Visit visit, TIntermSelection* node) { - TInfoSink& out = infoSink; + TInfoSinkBase& out = sink; OutputTreeText(out, node, depth); - out.debug << "Test condition and select"; - out.debug << " (" << node->getCompleteString() << ")\n"; + out << "Test condition and select"; + out << " (" << node->getCompleteString() << ")\n"; ++depth; - OutputTreeText(infoSink, node, depth); - out.debug << "Condition\n"; + OutputTreeText(sink, node, depth); + out << "Condition\n"; node->getCondition()->traverse(this); - OutputTreeText(infoSink, node, depth); + OutputTreeText(sink, node, depth); if (node->getTrueBlock()) { - out.debug << "true case\n"; + out << "true case\n"; node->getTrueBlock()->traverse(this); } else - out.debug << "true case is null\n"; + out << "true case is null\n"; if (node->getFalseBlock()) { - OutputTreeText(infoSink, node, depth); - out.debug << "false case\n"; + OutputTreeText(sink, node, depth); + out << "false case\n"; node->getFalseBlock()->traverse(this); } @@ -307,7 +307,7 @@ bool TOutputTraverser::visitSelection(Visit visit, TIntermSelection* node) void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node) { - TInfoSink& out = infoSink; + TInfoSinkBase& out = sink; int size = node->getType().getObjectSize(); @@ -316,23 +316,23 @@ void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node) switch (node->getUnionArrayPointer()[i].getType()) { case EbtBool: if (node->getUnionArrayPointer()[i].getBConst()) - out.debug << "true"; + out << "true"; else - out.debug << "false"; + out << "false"; - out.debug << " (" << "const bool" << ")"; - out.debug << "\n"; + out << " (" << "const bool" << ")"; + out << "\n"; break; case EbtFloat: - out.debug << node->getUnionArrayPointer()[i].getFConst(); - out.debug << " (const float)\n"; + out << node->getUnionArrayPointer()[i].getFConst(); + out << " (const float)\n"; break; case EbtInt: - out.debug << node->getUnionArrayPointer()[i].getIConst(); - out.debug << " (const int)\n"; + out << node->getUnionArrayPointer()[i].getIConst(); + out << " (const int)\n"; break; default: - out.info.message(EPrefixInternalError, "Unknown constant", node->getLine()); + out.message(EPrefixInternalError, "Unknown constant", node->getLine()); break; } } @@ -340,35 +340,35 @@ void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node) bool TOutputTraverser::visitLoop(Visit visit, TIntermLoop* node) { - TInfoSink& out = infoSink; + TInfoSinkBase& out = sink; OutputTreeText(out, node, depth); - out.debug << "Loop with condition "; - if (! node->testFirst()) - out.debug << "not "; - out.debug << "tested first\n"; + out << "Loop with condition "; + if (node->getType() == ELoopDoWhile) + out << "not "; + out << "tested first\n"; ++depth; - OutputTreeText(infoSink, node, depth); - if (node->getTest()) { - out.debug << "Loop Condition\n"; - node->getTest()->traverse(this); + OutputTreeText(sink, node, depth); + if (node->getCondition()) { + out << "Loop Condition\n"; + node->getCondition()->traverse(this); } else - out.debug << "No loop condition\n"; + out << "No loop condition\n"; - OutputTreeText(infoSink, node, depth); + OutputTreeText(sink, node, depth); if (node->getBody()) { - out.debug << "Loop Body\n"; + out << "Loop Body\n"; node->getBody()->traverse(this); } else - out.debug << "No loop body\n"; + out << "No loop body\n"; - if (node->getTerminal()) { - OutputTreeText(infoSink, node, depth); - out.debug << "Loop Terminal Expression\n"; - node->getTerminal()->traverse(this); + if (node->getExpression()) { + OutputTreeText(sink, node, depth); + out << "Loop Terminal Expression\n"; + node->getExpression()->traverse(this); } --depth; @@ -378,25 +378,25 @@ bool TOutputTraverser::visitLoop(Visit visit, TIntermLoop* node) bool TOutputTraverser::visitBranch(Visit visit, TIntermBranch* node) { - TInfoSink& out = infoSink; + TInfoSinkBase& out = sink; OutputTreeText(out, node, depth); switch (node->getFlowOp()) { - case EOpKill: out.debug << "Branch: Kill"; break; - case EOpBreak: out.debug << "Branch: Break"; break; - case EOpContinue: out.debug << "Branch: Continue"; break; - case EOpReturn: out.debug << "Branch: Return"; break; - default: out.debug << "Branch: Unknown Branch"; break; + case EOpKill: out << "Branch: Kill"; break; + case EOpBreak: out << "Branch: Break"; break; + case EOpContinue: out << "Branch: Continue"; break; + case EOpReturn: out << "Branch: Return"; break; + default: out << "Branch: Unknown Branch"; break; } if (node->getExpression()) { - out.debug << " with expression\n"; + out << " with expression\n"; ++depth; node->getExpression()->traverse(this); --depth; } else - out.debug << "\n"; + out << "\n"; return false; } @@ -411,7 +411,7 @@ void TIntermediate::outputTree(TIntermNode* root) if (root == 0) return; - TOutputTraverser it(infoSink); + TOutputTraverser it(infoSink.info); root->traverse(&it); } diff --git a/Source/ThirdParty/ANGLE/src/compiler/intermediate.h b/Source/ThirdParty/ANGLE/src/compiler/intermediate.h index d262905..f9fa1de 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/intermediate.h +++ b/Source/ThirdParty/ANGLE/src/compiler/intermediate.h @@ -129,9 +129,9 @@ enum TOperator { EOpReflect, EOpRefract, - //EOpDPdx, // Fragment only, OES_standard_derivatives extension - //EOpDPdy, // Fragment only, OES_standard_derivatives extension - //EOpFwidth, // Fragment only, OES_standard_derivatives extension + EOpDFdx, // Fragment only, OES_standard_derivatives extension + EOpDFdy, // Fragment only, OES_standard_derivatives extension + EOpFwidth, // Fragment only, OES_standard_derivatives extension EOpMatrixTimesMatrix, @@ -184,6 +184,8 @@ enum TOperator { EOpDivAssign, }; +extern const char* getOperatorString(TOperator op); + class TIntermTraverser; class TIntermAggregate; class TIntermBinary; @@ -262,30 +264,38 @@ protected: // // Handle for, do-while, and while loops. // +enum TLoopType { + ELoopFor, + ELoopWhile, + ELoopDoWhile, +}; + class TIntermLoop : public TIntermNode { public: - TIntermLoop(TIntermNode *init, TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) : - init(init), - body(aBody), - test(aTest), - terminal(aTerminal), - first(testFirst) { } + TIntermLoop(TLoopType aType, + TIntermNode *aInit, TIntermTyped* aCond, TIntermTyped* aExpr, + TIntermNode* aBody) : + type(aType), + init(aInit), + cond(aCond), + expr(aExpr), + body(aBody) { } virtual TIntermLoop* getAsLoopNode() { return this; } virtual void traverse(TIntermTraverser*); - TIntermNode *getInit() { return init; } - TIntermNode *getBody() { return body; } - TIntermTyped *getTest() { return test; } - TIntermTyped *getTerminal() { return terminal; } - bool testFirst() { return first; } + TLoopType getType() const { return type; } + TIntermNode* getInit() { return init; } + TIntermTyped* getCondition() { return cond; } + TIntermTyped* getExpression() { return expr; } + TIntermNode* getBody() { return body; } protected: - TIntermNode *init; - TIntermNode *body; // code to loop over - TIntermTyped *test; // exit condition associated with loop, could be 0 for 'for' loops - TIntermTyped *terminal; // exists for for-loops - bool first; // true for while and for, not for do-while + TLoopType type; + TIntermNode* init; // for-loop initialization + TIntermTyped* cond; // loop exit condition + TIntermTyped* expr; // for-loop expression + TIntermNode* body; // loop body }; // @@ -404,6 +414,7 @@ protected: typedef TVector<TIntermNode*> TIntermSequence; typedef TVector<int> TQualifierList; +typedef TMap<TString, TString> TPragmaTable; // // Nodes that operate on an arbitrary sized set of children. // @@ -417,12 +428,13 @@ public: virtual void traverse(TIntermTraverser*); TIntermSequence& getSequence() { return sequence; } + void setName(const TString& n) { name = n; } const TString& getName() const { return name; } void setUserDefined() { userDefined = true; } bool isUserDefined() { return userDefined; } - TQualifierList& getQualifier() { return qualifier; } + void setOptimize(bool o) { optimize = o; } bool getOptimize() { return optimize; } void setDebug(bool d) { debug = d; } @@ -434,9 +446,9 @@ protected: TIntermAggregate(const TIntermAggregate&); // disallow copy constructor TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator TIntermSequence sequence; - TQualifierList qualifier; TString name; bool userDefined; // used for user defined function names + bool optimize; bool debug; TPragmaTable *pragmaTable; diff --git a/Source/ThirdParty/ANGLE/src/compiler/localintermediate.h b/Source/ThirdParty/ANGLE/src/compiler/localintermediate.h index 5fd4c69..56890bd 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/localintermediate.h +++ b/Source/ThirdParty/ANGLE/src/compiler/localintermediate.h @@ -40,11 +40,11 @@ public: TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, TSourceLoc); TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ; bool parseConstTree(TSourceLoc, TIntermNode*, ConstantUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false); - TIntermNode* addLoop(TIntermNode*, TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc); + TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, TSourceLoc); TIntermBranch* addBranch(TOperator, TSourceLoc); TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc); TIntermTyped* addSwizzle(TVectorFields&, TSourceLoc); - bool postProcess(TIntermNode*, EShLanguage); + bool postProcess(TIntermNode*); void remove(TIntermNode*); void outputTree(TIntermNode*); diff --git a/Source/ThirdParty/ANGLE/src/compiler/osinclude.h b/Source/ThirdParty/ANGLE/src/compiler/osinclude.h index d887914..1af5064 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/osinclude.h +++ b/Source/ThirdParty/ANGLE/src/compiler/osinclude.h @@ -8,8 +8,8 @@ #define __OSINCLUDE_H // -// This file contains contains the window's specific datatypes and -// declares any windows specific functions. +// This file contains contains os-specific datatypes and +// declares any os-specific functions. // #if defined(_WIN32) || defined(_WIN64) @@ -22,7 +22,9 @@ #error Unsupported platform. #endif -#if defined(ANGLE_OS_WIN) +#if defined(ANGLE_USE_NSPR) +#include "prthread.h" +#elif defined(ANGLE_OS_WIN) #define STRICT #define VC_EXTRALEAN 1 #include <windows.h> @@ -30,20 +32,24 @@ #include <pthread.h> #include <semaphore.h> #include <errno.h> -#endif // ANGLE_OS_WIN +#endif // ANGLE_USE_NSPR + #include "compiler/debug.h" // // Thread Local Storage Operations // -#if defined(ANGLE_OS_WIN) +#if defined(ANGLE_USE_NSPR) +typedef PRUintn OS_TLSIndex; +#define OS_INVALID_TLS_INDEX 0xFFFFFFFF +#elif defined(ANGLE_OS_WIN) typedef DWORD OS_TLSIndex; #define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES) #elif defined(ANGLE_OS_POSIX) typedef unsigned int OS_TLSIndex; #define OS_INVALID_TLS_INDEX 0xFFFFFFFF -#endif // ANGLE_OS_WIN +#endif // ANGLE_USE_NSPR OS_TLSIndex OS_AllocTLSIndex(); bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue); @@ -51,8 +57,10 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex); inline void* OS_GetTLSValue(OS_TLSIndex nIndex) { - assert(nIndex != OS_INVALID_TLS_INDEX); -#if defined(ANGLE_OS_WIN) + ASSERT(nIndex != OS_INVALID_TLS_INDEX); +#if defined(ANGLE_USE_NSPR) + return PR_GetThreadPrivate(nIndex); +#elif defined(ANGLE_OS_WIN) return TlsGetValue(nIndex); #elif defined(ANGLE_OS_POSIX) return pthread_getspecific(nIndex); diff --git a/Source/ThirdParty/ANGLE/src/compiler/ossource_nspr.cpp b/Source/ThirdParty/ANGLE/src/compiler/ossource_nspr.cpp new file mode 100644 index 0000000..f63d81e --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/ossource_nspr.cpp @@ -0,0 +1,43 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// +// This file contains the nspr specific functions +// +#include "compiler/osinclude.h" + +// +// Thread Local Storage Operations +// +OS_TLSIndex OS_AllocTLSIndex() +{ + PRUintn index; + PRStatus status = PR_NewThreadPrivateIndex(&index, NULL); + + if (status) { + assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage"); + return OS_INVALID_TLS_INDEX; + } + + return index; +} + +bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue) +{ + if (nIndex == OS_INVALID_TLS_INDEX) { + assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); + return false; + } + + return PR_SetThreadPrivate(nIndex, lpvValue) == 0; +} + +bool OS_FreeTLSIndex(OS_TLSIndex nIndex) +{ + // Can't delete TLS keys with nspr + return true; +} + diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/compile.h b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/compile.h index 5bfa902..69e3425 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/compile.h +++ b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/compile.h @@ -89,10 +89,10 @@ struct CPPStruct_Rec { // Globals used to communicate between PaParseStrings() and yy_input()and // also across the files.(gen_glslang.cpp and scanner.c) // - int PaWhichStr; // which string we're parsing - int* PaStrLen; // array of lengths of the PaArgv strings - int PaArgc; // count of strings in the array - char** PaArgv; // our array of strings to parse + int PaWhichStr; // which string we're parsing + const int* PaStrLen; // array of lengths of the PaArgv strings + int PaArgc; // count of strings in the array + const char* const* PaArgv; // our array of strings to parse unsigned int tokensBeforeEOF : 1; }; diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/cpp.c b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/cpp.c index f15c56d..204a213 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/cpp.c +++ b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/cpp.c @@ -191,6 +191,9 @@ static int CPPdefine(yystypepp * yylvalpp) if (token == '\\') { CPPErrorToInfoLog("The line continuation character (\\) is not part of the OpenGL ES Shading Language"); return token; + } else if (token <= 0) { // EOF or error + CPPErrorToInfoLog("unexpected end of input in #define preprocessor directive - expected a newline"); + return 0; } RecordToken(mac.body, token, yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); @@ -267,9 +270,13 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp) while (token > 0) { if (token != '#') { - while (token != '\n') + while (token != '\n') { token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - + if (token <= 0) { // EOF or error + CPPErrorToInfoLog("unexpected end of input in #else preprocessor directive - expected a newline"); + return 0; + } + } token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); continue; } @@ -295,8 +302,13 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp) token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if (token != '\n') { CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline"); - while (token != '\n') + while (token != '\n') { token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); + if (token <= 0) { // EOF or error + CPPErrorToInfoLog("unexpected end of input following #else preprocessor directive - expected a newline"); + return 0; + } + } } break; } @@ -467,9 +479,14 @@ static int CPPif(yystypepp * yylvalpp) { } token = eval(token, MIN_PREC, &res, &err, yylvalpp); if (token != '\n') { - CPPWarningToInfoLog("unexpected tokens following the preprocessor directive - expected a newline"); - while (token != '\n') + CPPWarningToInfoLog("unexpected tokens following #if preprocessor directive - expected a newline"); + while (token != '\n') { token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); + if (token <= 0) { // EOF or error + CPPErrorToInfoLog("unexpected end of input in #if preprocessor directive - expected a newline"); + return 0; + } + } } if (!res && !err) { token = CPPelse(1, yylvalpp); @@ -495,8 +512,13 @@ static int CPPifdef(int defined, yystypepp * yylvalpp) token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if (token != '\n') { CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline"); - while (token != '\n') + while (token != '\n') { token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); + if (token <= 0) { // EOF or error + CPPErrorToInfoLog("unexpected end of input in #ifdef preprocessor directive - expected a newline"); + return 0; + } + } } if (((s && !s->details.mac.undef) ? 1 : 0) != defined) token = CPPelse(1, yylvalpp); @@ -544,7 +566,10 @@ static int CPPerror(yystypepp * yylvalpp) { const char *message; while (token != '\n') { - if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){ + if (token <= 0){ + CPPErrorToInfoLog("unexpected end of input in #error preprocessor directive - expected a newline"); + return 0; + }else if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){ StoreStr(yylvalpp->symbol_name); }else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){ StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident)); @@ -670,7 +695,7 @@ static int CPPextension(yystypepp * yylvalpp) { int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - char extensionName[80]; + char extensionName[MAX_SYMBOL_NAME_LEN + 1]; if(token=='\n'){ DecLineNumber(); @@ -682,7 +707,8 @@ static int CPPextension(yystypepp * yylvalpp) if (token != CPP_IDENTIFIER) CPPErrorToInfoLog("#extension"); - strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident)); + strncpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident), MAX_SYMBOL_NAME_LEN); + extensionName[MAX_SYMBOL_NAME_LEN] = '\0'; token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if (token != ':') { @@ -726,8 +752,13 @@ int readCPPline(yystypepp * yylvalpp) token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if (token != '\n') { CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline"); - while (token != '\n') + while (token != '\n') { token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); + if (token <= 0) { // EOF or error + CPPErrorToInfoLog("unexpected end of input in #ifdef preprocessor directive - expected a newline"); + return 0; + } + } } token = CPPelse(0, yylvalpp); }else{ @@ -743,8 +774,14 @@ int readCPPline(yystypepp * yylvalpp) } // this token is really a dont care, but we still need to eat the tokens token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); - while (token != '\n') + while (token != '\n') { token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); + if (token <= 0) { // EOF or error + CPPErrorToInfoLog("unexpect tokens following #elif preprocessor directive - expected a newline"); + cpp->CompileError = 1; + break; + } + } token = CPPelse(0, yylvalpp); } else if (yylvalpp->sc_ident == endifAtom) { --cpp->elsetracker; diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/preprocess.h b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/preprocess.h index 0602c91..88d196f 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/preprocess.h +++ b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/preprocess.h @@ -42,10 +42,10 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \****************************************************************************/ -# include "compiler/preprocessor/slglobals.h" +#include "compiler/preprocessor/slglobals.h" extern CPPStruct *cpp; int InitCPPStruct(void); int InitScanner(CPPStruct *cpp); int InitAtomTable(AtomTable *atable, int htsize); -int ScanFromString(char *s); +int ScanFromString(const char *s); char* GetStringOfAtom(AtomTable *atable, int atom); diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.c b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.c index c77d271..7b399a0 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.c +++ b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.c @@ -45,6 +45,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // scanner.c // +#include <assert.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -52,13 +53,13 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if 0 #include <ieeefp.h> - #else +#else #define isinff(x) (((*(int *)&(x) & 0x7f800000L)==0x7f800000L) && \ ((*(int *)&(x) & 0x007fffffL)==0000000000L)) #endif #include "compiler/preprocessor/slglobals.h" - +#include "compiler/util.h" typedef struct StringInputSrc { InputSrc base; @@ -133,49 +134,49 @@ int FreeScanner(void) */ static int str_getch(StringInputSrc *in) { - for(;;){ - if (*in->p){ - if (*in->p == '\n') { + for(;;){ + if (*in->p){ + if (*in->p == '\n') { in->base.line++; IncLineNumber(); } return *in->p++; - } - if(++(cpp->PaWhichStr) < cpp->PaArgc){ - free(in); - SetStringNumber(cpp->PaWhichStr); - SetLineNumber(1); - ScanFromString(cpp->PaArgv[cpp->PaWhichStr]); - in=(StringInputSrc*)cpp->currentInput; - continue; - } - else{ - cpp->currentInput = in->base.prev; - cpp->PaWhichStr=0; + } + if(++(cpp->PaWhichStr) < cpp->PaArgc){ + free(in); + SetStringNumber(cpp->PaWhichStr); + SetLineNumber(1); + ScanFromString(cpp->PaArgv[cpp->PaWhichStr]); + in=(StringInputSrc*)cpp->currentInput; + continue; + } + else{ + cpp->currentInput = in->base.prev; + cpp->PaWhichStr=0; free(in); return EOF; } - } + } } // str_getch static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) { if (in->p[-1] == ch)in->p--; - else { - *(in->p)='\0'; //this would take care of shifting to the previous string. - cpp->PaWhichStr--; - } - if (ch == '\n') { + else { + *(in->p)='\0'; //this would take care of shifting to the previous string. + cpp->PaWhichStr--; + } + if (ch == '\n') { in->base.line--; DecLineNumber(); } } // str_ungetch -int ScanFromString(char *s) +int ScanFromString(const char *s) { - StringInputSrc *in = malloc(sizeof(StringInputSrc)); + StringInputSrc *in = malloc(sizeof(StringInputSrc)); memset(in, 0, sizeof(StringInputSrc)); - in->p = s; + in->p = (char*) s; in->base.line = 1; in->base.scan = byte_scan; in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch; @@ -190,119 +191,63 @@ int ScanFromString(char *s) /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////// Floating point constants: ///////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// -/* - * lBuildFloatValue() - Quick and dirty conversion to floating point. Since all - * we need is single precision this should be quite precise. - */ - -static float lBuildFloatValue(const char *str, int len, int exp) -{ - double val, expval, ten; - int ii, llen, absexp; - float rv; - - val = 0.0; - llen = len; - for (ii = 0; ii < len; ii++) - val = val*10.0 + (str[ii] - '0'); - if (exp != 0) { - absexp = exp > 0 ? exp : -exp; - expval = 1.0f; - ten = 10.0; - while (absexp) { - if (absexp & 1) - expval *= ten; - ten *= ten; - absexp >>= 1; - } - if (exp >= 0) { - val *= expval; - } else { - val /= expval; - } - } - rv = (float)val; - if (isinff(rv)) { - CPPErrorToInfoLog(" ERROR___FP_CONST_OVERFLOW"); - } - return rv; -} // lBuildFloatValue +#define APPEND_CHAR_S(ch, str, len, max_len) \ + if (len < max_len) { \ + str[len++] = ch; \ + } else if (!alreadyComplained) { \ + CPPErrorToInfoLog("BUFFER OVERFLOW"); \ + alreadyComplained = 1; \ + } /* * lFloatConst() - Scan a floating point constant. Assumes that the scanner * has seen at least one digit, followed by either a decimal '.' or the * letter 'e'. + * ch - '.' or 'e' + * len - length of string already copied into yylvalpp->symbol_name. */ -static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) +static int lFloatConst(int ch, int len, yystypepp * yylvalpp) { - int HasDecimal, declen, exp, ExpSign; - int str_len; - float lval; - - HasDecimal = 0; - declen = 0; - exp = 0; - - str_len=len; + int alreadyComplained = 0; + assert((ch == '.') || (ch == 'e') || (ch == 'E')); + if (ch == '.') { - str[len++]=ch; - HasDecimal = 1; - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - while (ch >= '0' && ch <= '9') { - if (len < MAX_SYMBOL_NAME_LEN) { - declen++; - if (len > 0 || ch != '0') { - str[len] = ch; - len++;str_len++; - } - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } else { - CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG"); - len = 1,str_len=1; - } - } + do { + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); + ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); + } while (ch >= '0' && ch <= '9'); } // Exponent: - if (ch == 'e' || ch == 'E') { - ExpSign = 1; - str[len++]=ch; + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); if (ch == '+') { - str[len++]=ch; - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); + ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } else if (ch == '-') { - ExpSign = -1; - str[len++]=ch; + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } if (ch >= '0' && ch <= '9') { while (ch >= '0' && ch <= '9') { - exp = exp*10 + ch - '0'; - str[len++]=ch; + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } } else { - CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT"); + CPPErrorToInfoLog("EXPONENT INVALID"); } - exp *= ExpSign; } - - if (len == 0) { - lval = 0.0f; - strcpy(str,"0.0"); - } else { - str[len]='\0'; - lval = lBuildFloatValue(str, str_len, exp - declen); + cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); + + assert(len <= MAX_SYMBOL_NAME_LEN); + yylvalpp->symbol_name[len] = '\0'; + yylvalpp->sc_fval = (float) atof_dot(yylvalpp->symbol_name); + if (isinff(yylvalpp->sc_fval)) { + CPPErrorToInfoLog("FLOAT CONSTANT OVERFLOW"); } - // Suffix: - - yylvalpp->sc_fval = lval; - strcpy(yylvalpp->symbol_name,str); - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); return CPP_FLOATCONSTANT; } // lFloatConst @@ -312,29 +257,29 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) static int byte_scan(InputSrc *in, yystypepp * yylvalpp) { - char symbol_name[MAX_SYMBOL_NAME_LEN + 1]; char string_val[MAX_STRING_LEN + 1]; - int AlreadyComplained; + int alreadyComplained = 0; int len, ch, ii, ival = 0; for (;;) { yylvalpp->sc_int = 0; ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - + while (ch == ' ' || ch == '\t' || ch == '\r') { yylvalpp->sc_int = 1; ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } - + cpp->ltokenLoc.file = cpp->currentInput->name; cpp->ltokenLoc.line = cpp->currentInput->line; + alreadyComplained = 0; len = 0; switch (ch) { default: - return ch; // Single character token + return ch; // Single character token case EOF: return -1; - case 'A': case 'B': case 'C': case 'D': case 'E': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': @@ -347,39 +292,32 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': do { - if (len < MAX_SYMBOL_NAME_LEN) { - symbol_name[len] = ch; - len++; - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } else { - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); + ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } while ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '_'); - if (len >= MAX_SYMBOL_NAME_LEN) - len = MAX_SYMBOL_NAME_LEN - 1; - symbol_name[len] = '\0'; + assert(len <= MAX_SYMBOL_NAME_LEN); + yylvalpp->symbol_name[len] = '\0'; cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - yylvalpp->sc_ident = LookUpAddString(atable, symbol_name); + yylvalpp->sc_ident = LookUpAddString(atable, yylvalpp->symbol_name); return CPP_IDENTIFIER; break; case '0': - yylvalpp->symbol_name[len++] = ch; + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - if (ch == 'x' || ch == 'X') { - yylvalpp->symbol_name[len++] = ch; + if (ch == 'x' || ch == 'X') { // hexadecimal integer constants + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) { - AlreadyComplained = 0; ival = 0; do { - yylvalpp->symbol_name[len++] = ch; - if (ival <= 0x0fffffff) { + if ((ival <= 0x0fffffff) && (len < MAX_SYMBOL_NAME_LEN)) { + yylvalpp->symbol_name[len++] = ch; if (ch >= '0' && ch <= '9') { ii = ch - '0'; } else if (ch >= 'A' && ch <= 'F') { @@ -388,74 +326,67 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ii = ch - 'a' + 10; } ival = (ival << 4) | ii; - } else { - if (!AlreadyComplained) - CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW"); - AlreadyComplained = 1; + } else if (!alreadyComplained) { + CPPErrorToInfoLog("HEX CONSTANT OVERFLOW"); + alreadyComplained = 1; } ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } while ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')); } else { - CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT"); + CPPErrorToInfoLog("HEX CONSTANT INVALID"); } + assert(len <= MAX_SYMBOL_NAME_LEN); yylvalpp->symbol_name[len] = '\0'; - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - yylvalpp->sc_int = ival; + cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); + yylvalpp->sc_int = ival; return CPP_INTCONSTANT; } else if (ch >= '0' && ch <= '7') { // octal integer constants - AlreadyComplained = 0; ival = 0; do { - yylvalpp->symbol_name[len++] = ch; - if (ival <= 0x1fffffff) { + if ((ival <= 0x1fffffff) && (len < MAX_SYMBOL_NAME_LEN)) { + yylvalpp->symbol_name[len++] = ch; ii = ch - '0'; ival = (ival << 3) | ii; - } else { - if (!AlreadyComplained) - CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW"); - AlreadyComplained = 1; + } else if (!alreadyComplained) { + CPPErrorToInfoLog("OCT CONSTANT OVERFLOW"); + alreadyComplained = 1; } ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } while (ch >= '0' && ch <= '7'); if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') - return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp); + return lFloatConst(ch, len, yylvalpp); + assert(len <= MAX_SYMBOL_NAME_LEN); yylvalpp->symbol_name[len] = '\0'; - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - yylvalpp->sc_int = ival; + cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); + yylvalpp->sc_int = ival; return CPP_INTCONSTANT; } else { - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - ch = '0'; + cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); + ch = '0'; } // Fall through... case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': do { - if (len < MAX_SYMBOL_NAME_LEN) { - if (len > 0 || ch != '0') { - yylvalpp->symbol_name[len] = ch; - len++; - } - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } + APPEND_CHAR_S(ch, yylvalpp->symbol_name, len, MAX_SYMBOL_NAME_LEN); + ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } while (ch >= '0' && ch <= '9'); if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') { - return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp); + return lFloatConst(ch, len, yylvalpp); } else { + assert(len <= MAX_SYMBOL_NAME_LEN); yylvalpp->symbol_name[len] = '\0'; - cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); + cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); ival = 0; - AlreadyComplained = 0; for (ii = 0; ii < len; ii++) { ch = yylvalpp->symbol_name[ii] - '0'; + ival = ival*10 + ch; if ((ival > 214748364) || (ival == 214748364 && ch >= 8)) { - if (!AlreadyComplained) - CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW"); - AlreadyComplained = 1; + CPPErrorToInfoLog("INTEGER CONSTANT OVERFLOW"); + break; } - ival = ival*10 + ch; } yylvalpp->sc_int = ival; if(ival==0) @@ -608,7 +539,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); if (ch >= '0' && ch <= '9') { cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp); - return lFloatConst(yylvalpp->symbol_name, 0, '.', yylvalpp); + return lFloatConst('.', 0, yylvalpp); } else { if (ch == '.') { return -1; // Special EOF hack @@ -633,14 +564,14 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) while (ch != '*') { if (ch == '\n') nlcount++; if (ch == EOF) { - CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT"); + CPPErrorToInfoLog("EOF IN COMMENT"); return -1; } ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); } ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); if (ch == EOF) { - CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT"); + CPPErrorToInfoLog("EOF IN COMMENT"); return -1; } } while (ch != '/'); @@ -662,41 +593,40 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) CPPErrorToInfoLog("The line continuation character (\\) is not part of the OpenGL ES Shading Language"); return -1; } - if (len < MAX_STRING_LEN) { - string_val[len] = ch; - len++; - ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); - } + APPEND_CHAR_S(ch, string_val, len, MAX_STRING_LEN); + ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); }; + assert(len <= MAX_STRING_LEN); string_val[len] = '\0'; if (ch == '"') { yylvalpp->sc_ident = LookUpAddString(atable, string_val); return CPP_STRCONSTANT; } else { - CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING"); + CPPErrorToInfoLog("EOL IN STRING"); return ERROR_SY; } + break; } } } // byte_scan int yylex_CPP(char* buf, int maxSize) { - yystypepp yylvalpp; + yystypepp yylvalpp; int token = '\n'; for(;;) { char* tokenString = 0; token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp); - if(check_EOF(token)) - return 0; + if(check_EOF(token)) + return 0; if (token == '#') { if (cpp->previous_token == '\n'|| cpp->previous_token == 0) { - token = readCPPline(&yylvalpp); + token = readCPPline(&yylvalpp); if(check_EOF(token)) return 0; - continue; + continue; } else { CPPErrorToInfoLog("preprocessor command must not be preceded by any other statement in that line"); return 0; @@ -708,30 +638,28 @@ int yylex_CPP(char* buf, int maxSize) cpp->pastFirstStatement = 1; continue; } - + if (token == '\n') continue; - - if (token == CPP_IDENTIFIER) { - cpp->pastFirstStatement = 1; + cpp->pastFirstStatement = 1; + + if (token == CPP_IDENTIFIER) { tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident); - } else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){ - cpp->pastFirstStatement = 1; + } else if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){ tokenString = yylvalpp.symbol_name; - } else { - cpp->pastFirstStatement = 1; + } else { tokenString = GetStringOfAtom(atable,token); - } + } if (tokenString) { - if ((signed)strlen(tokenString) >= maxSize) { - cpp->tokensBeforeEOF = 1; - return maxSize; - } else if (strlen(tokenString) > 0) { - strcpy(buf, tokenString); - cpp->tokensBeforeEOF = 1; - return (int)strlen(tokenString); - } + int len = strlen(tokenString); + cpp->tokensBeforeEOF = 1; + if (len >= maxSize) { + return maxSize; + } else if (len > 0) { + strcpy(buf, tokenString); + return len; + } return 0; } @@ -745,7 +673,7 @@ int check_EOF(int token) { if(token==-1){ if(cpp->ifdepth >0){ - CPPErrorToInfoLog("#endif missing!! Compilation stopped"); + CPPErrorToInfoLog("#endif missing!! Compilation stopped"); cpp->CompileError=1; } return 1; diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.h b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.h index 571fe57..0fee20d 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.h +++ b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.h @@ -48,8 +48,9 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if !defined(__SCANNER_H) #define __SCANNER_H 1 -#define MAX_SYMBOL_NAME_LEN 128 -#define MAX_STRING_LEN 512 +// These lengths do not include the NULL terminator. +#define MAX_SYMBOL_NAME_LEN 127 +#define MAX_STRING_LEN 511 #include "compiler/preprocessor/parser.h" @@ -59,8 +60,6 @@ typedef struct SourceLoc_Rec { unsigned short file, line; } SourceLoc; -int yyparse (void); - int yylex_CPP(char* buf, int maxSize); typedef struct InputSrc { @@ -73,7 +72,7 @@ typedef struct InputSrc { } InputSrc; int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner. -int ScanFromString(char *); // Start scanning the input from the string mentioned. +int ScanFromString(const char *); // Start scanning the input from the string mentioned. int check_EOF(int); // check if we hit a EOF abruptly void CPPErrorToInfoLog(char *); // sticking the msg,line into the Shader's.Info.log void SetLineNumber(int); diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/tokens.c b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/tokens.c index 057cce8..aa83d2f 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/tokens.c +++ b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/tokens.c @@ -52,6 +52,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "compiler/debug.h" #include "compiler/preprocessor/slglobals.h" +#include "compiler/util.h" /////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// @@ -224,8 +225,7 @@ void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp) case CPP_INTCONSTANT: str=yylvalpp->symbol_name; while (*str){ - lAddByte(pTok,(unsigned char) *str); - *str++; + lAddByte(pTok, (unsigned char) *str++); } lAddByte(pTok, 0); break; @@ -276,8 +276,7 @@ int ReadToken(TokenStream *pTok, yystypepp * yylvalpp) ch == '_') { if (len < MAX_SYMBOL_NAME_LEN) { - symbol_name[len] = ch; - len++; + symbol_name[len++] = ch; ch = lReadByte(pTok); } } @@ -291,7 +290,7 @@ int ReadToken(TokenStream *pTok, yystypepp * yylvalpp) while ((ch = lReadByte(pTok)) != 0) if (len < MAX_STRING_LEN) string_val[len++] = ch; - string_val[len] = 0; + string_val[len] = '\0'; yylvalpp->sc_ident = LookUpAddString(atable, string_val); break; case CPP_FLOATCONSTANT: @@ -300,15 +299,14 @@ int ReadToken(TokenStream *pTok, yystypepp * yylvalpp) while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-')) { if (len < MAX_SYMBOL_NAME_LEN) { - symbol_name[len] = ch; - len++; + symbol_name[len++] = ch; ch = lReadByte(pTok); } } symbol_name[len] = '\0'; assert(ch == '\0'); strcpy(yylvalpp->symbol_name,symbol_name); - yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name); + yylvalpp->sc_fval=(float)atof_dot(yylvalpp->symbol_name); break; case CPP_INTCONSTANT: len = 0; @@ -316,8 +314,7 @@ int ReadToken(TokenStream *pTok, yystypepp * yylvalpp) while ((ch >= '0' && ch <= '9')) { if (len < MAX_SYMBOL_NAME_LEN) { - symbol_name[len] = ch; - len++; + symbol_name[len++] = ch; ch = lReadByte(pTok); } } diff --git a/Source/ThirdParty/ANGLE/src/compiler/unistd.h b/Source/ThirdParty/ANGLE/src/compiler/unistd.h deleted file mode 100644 index c7c9147..0000000 --- a/Source/ThirdParty/ANGLE/src/compiler/unistd.h +++ /dev/null @@ -1 +0,0 @@ -// This is a NULL file and is meant to be empty diff --git a/Source/ThirdParty/ANGLE/src/compiler/util.cpp b/Source/ThirdParty/ANGLE/src/compiler/util.cpp new file mode 100644 index 0000000..b46e4d0 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/util.cpp @@ -0,0 +1,33 @@ +// +// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include <math.h> +#include <stdlib.h> + +#include "util.h" + +#ifdef _MSC_VER + #include <locale.h> +#else + #include <sstream> +#endif + +double atof_dot(const char *str) +{ +#ifdef _MSC_VER + _locale_t l = _create_locale(LC_NUMERIC, "C"); + double result = _atof_l(str, l); + _free_locale(l); + return result; +#else + double result; + std::istringstream s(str); + std::locale l("C"); + s.imbue(l); + s >> result; + return result; +#endif +} diff --git a/Source/ThirdParty/ANGLE/src/compiler/util.h b/Source/ThirdParty/ANGLE/src/compiler/util.h new file mode 100644 index 0000000..35288b7 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/compiler/util.h @@ -0,0 +1,21 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_UTIL_H +#define COMPILER_UTIL_H + +#ifdef __cplusplus +extern "C" { +#endif + +// atof_dot is like atof but forcing C locale, i.e. forcing '.' as decimal point. +double atof_dot(const char *str); + +#ifdef __cplusplus +} // end extern "C" +#endif + +#endif // COMPILER_UTIL_H diff --git a/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp b/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp index 21d4661..284f61d 100644 --- a/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp +++ b/Source/ThirdParty/ANGLE/src/libEGL/Config.cpp @@ -94,13 +94,6 @@ void Config::set(D3DDISPLAYMODE displayMode, EGLint minInterval, EGLint maxInter mBlueSize = 5; mAlphaSize = 0; break; - case D3DFMT_X1R5G5B5: - mBufferSize = 16; - mRedSize = 5; - mGreenSize = 5; - mBlueSize = 5; - mAlphaSize = 0; - break; case D3DFMT_X8R8G8B8: mBufferSize = 32; mRedSize = 8; diff --git a/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp b/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp index e2802da..6f1a335 100644 --- a/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp +++ b/Source/ThirdParty/ANGLE/src/libEGL/Display.cpp @@ -17,7 +17,8 @@ #include "libEGL/main.h" -#define REF_RAST 0 // Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros +#define REF_RAST 0 // Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros +#define ENABLE_D3D9EX 1 // Enables use of the IDirect3D9Ex interface, when available namespace egl { @@ -40,7 +41,6 @@ Display::Display(HDC deviceContext) : mDc(deviceContext) mMinSwapInterval = 1; mMaxSwapInterval = 1; - setSwapInterval(1); } Display::~Display() @@ -77,7 +77,7 @@ bool Display::initialize() // Use Direct3D9Ex if available. Among other things, this version is less // inclined to report a lost context, for example when the user switches // desktop. Direct3D9Ex is available in Windows Vista and later if suitable drivers are available. - if (Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9ex))) + if (ENABLE_D3D9EX && Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9ex))) { ASSERT(mD3d9ex); mD3d9ex->QueryInterface(IID_IDirect3D9, reinterpret_cast<void**>(&mD3d9)); @@ -95,11 +95,26 @@ bool Display::initialize() // UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to } - HRESULT result = mD3d9->GetDeviceCaps(mAdapter, mDeviceType, &mDeviceCaps); - - if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) + HRESULT result; + + // Give up on getting device caps after about one second. + for (int i = 0; i < 10; ++i) { - return error(EGL_BAD_ALLOC, false); + result = mD3d9->GetDeviceCaps(mAdapter, mDeviceType, &mDeviceCaps); + + if (SUCCEEDED(result)) + { + break; + } + else if (result == D3DERR_NOTAVAILABLE) + { + Sleep(100); // Give the driver some time to initialize/recover + } + else if (FAILED(result)) // D3DERR_OUTOFVIDEOMEMORY, E_OUTOFMEMORY, D3DERR_INVALIDDEVICE, or another error we can't recover from + { + terminate(); + return error(EGL_BAD_ALLOC, false); + } } if (mDeviceCaps.PixelShaderVersion < D3DPS_VERSION(2, 0)) @@ -108,6 +123,14 @@ bool Display::initialize() return error(EGL_NOT_INITIALIZED, false); } + // When DirectX9 is running with an older DirectX8 driver, a StretchRect from a regular texture to a render target texture is not supported. + // This is required by Texture2D::convertToRenderTarget. + if ((mDeviceCaps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES) == 0) + { + terminate(); + return error(EGL_NOT_INITIALIZED, false); + } + mMinSwapInterval = 4; mMaxSwapInterval = 0; @@ -123,7 +146,7 @@ bool Display::initialize() // D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value. D3DFMT_A8R8G8B8, D3DFMT_R5G6B5, - D3DFMT_X1R5G5B5, + // D3DFMT_X1R5G5B5, // Has no compatible OpenGL ES renderbuffer format D3DFMT_X8R8G8B8 }; @@ -183,13 +206,6 @@ bool Display::initialize() mConfigSet.mSet.insert(configuration); } - - if (!createDevice()) - { - terminate(); - - return false; - } } if (!isInitialized()) @@ -199,23 +215,34 @@ bool Display::initialize() return false; } + static const TCHAR windowName[] = TEXT("AngleHiddenWindow"); + static const TCHAR className[] = TEXT("STATIC"); + + mDeviceWindow = CreateWindowEx(WS_EX_NOACTIVATE, className, windowName, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, HWND_MESSAGE, NULL, GetModuleHandle(NULL), NULL); + return true; } void Display::terminate() { - for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++) + while (!mSurfaceSet.empty()) { - delete *surface; + destroySurface(*mSurfaceSet.begin()); } - for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++) + while (!mContextSet.empty()) { - glDestroyContext(*context); + destroyContext(*mContextSet.begin()); } if (mDevice) { + // If the device is lost, reset it first to prevent leaving the driver in an unstable state + if (FAILED(mDevice->TestCooperativeLevel())) + { + resetDevice(); + } + mDevice->Release(); mDevice = NULL; } @@ -314,33 +341,12 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) bool Display::createDevice() { - static const TCHAR windowName[] = TEXT("AngleHiddenWindow"); - static const TCHAR className[] = TEXT("STATIC"); - - mDeviceWindow = CreateWindowEx(WS_EX_NOACTIVATE, className, windowName, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, HWND_MESSAGE, NULL, GetModuleHandle(NULL), NULL); - - D3DPRESENT_PARAMETERS presentParameters = {0}; - - // The default swap chain is never actually used. Surface will create a new swap chain with the proper parameters. - presentParameters.AutoDepthStencilFormat = D3DFMT_UNKNOWN; - presentParameters.BackBufferCount = 1; - presentParameters.BackBufferFormat = D3DFMT_UNKNOWN; - presentParameters.BackBufferWidth = 1; - presentParameters.BackBufferHeight = 1; - presentParameters.EnableAutoDepthStencil = FALSE; - presentParameters.Flags = 0; - presentParameters.hDeviceWindow = mDeviceWindow; - presentParameters.MultiSampleQuality = 0; - presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; - presentParameters.PresentationInterval = convertInterval(mMinSwapInterval); - presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; - presentParameters.Windowed = TRUE; - + D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters(); DWORD behaviorFlags = D3DCREATE_FPU_PRESERVE | D3DCREATE_NOWINDOWCHANGES; HRESULT result = mD3d9->CreateDevice(mAdapter, mDeviceType, mDeviceWindow, behaviorFlags | D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, &presentParameters, &mDevice); - if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) + if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DEVICELOST) { return error(EGL_BAD_ALLOC, false); } @@ -349,14 +355,13 @@ bool Display::createDevice() { result = mD3d9->CreateDevice(mAdapter, mDeviceType, mDeviceWindow, behaviorFlags | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParameters, &mDevice); - if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) + if (FAILED(result)) { + ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_NOTAVAILABLE || result == D3DERR_DEVICELOST); return error(EGL_BAD_ALLOC, false); } } - ASSERT(SUCCEEDED(result)); - // Permanent non-default states mDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE); @@ -365,6 +370,29 @@ bool Display::createDevice() return true; } +bool Display::resetDevice() +{ + D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters(); + HRESULT result; + + do + { + Sleep(0); // Give the graphics driver some CPU time + + result = mDevice->Reset(&presentParameters); + } + while (result == D3DERR_DEVICELOST); + + if (FAILED(result)) + { + return error(EGL_BAD_ALLOC, false); + } + + ASSERT(SUCCEEDED(result)); + + return true; +} + Surface *Display::createWindowSurface(HWND window, EGLConfig config) { const Config *configuration = mConfigSet.get(config); @@ -377,6 +405,27 @@ Surface *Display::createWindowSurface(HWND window, EGLConfig config) EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext) { + if (!mDevice) + { + if (!createDevice()) + { + return NULL; + } + } + else if (FAILED(mDevice->TestCooperativeLevel())) // Lost device + { + if (!resetDevice()) + { + return NULL; + } + + // Restore any surfaces that may have been lost + for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++) + { + (*surface)->resetSwapChain(); + } + } + const egl::Config *config = mConfigSet.get(configHandle); gl::Context *context = glCreateContext(config, shareContext); @@ -395,6 +444,14 @@ void Display::destroyContext(gl::Context *context) { glDestroyContext(context); mContextSet.erase(context); + + if (mContextSet.empty() && mDevice && FAILED(mDevice->TestCooperativeLevel())) // Last context of a lost device + { + for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++) + { + (*surface)->release(); + } + } } bool Display::isInitialized() @@ -430,37 +487,26 @@ bool Display::hasExistingWindowSurface(HWND window) return false; } -void Display::setSwapInterval(GLint interval) +EGLint Display::getMinSwapInterval() { - mSwapInterval = interval; - mSwapInterval = std::max(mSwapInterval, mMinSwapInterval); - mSwapInterval = std::min(mSwapInterval, mMaxSwapInterval); - - mPresentInterval = convertInterval(mSwapInterval); + return mMinSwapInterval; } -DWORD Display::getPresentInterval() +EGLint Display::getMaxSwapInterval() { - return mPresentInterval; + return mMaxSwapInterval; } -DWORD Display::convertInterval(GLint interval) +IDirect3DDevice9 *Display::getDevice() { - switch(interval) + if (!mDevice) { - case 0: return D3DPRESENT_INTERVAL_IMMEDIATE; - case 1: return D3DPRESENT_INTERVAL_ONE; - case 2: return D3DPRESENT_INTERVAL_TWO; - case 3: return D3DPRESENT_INTERVAL_THREE; - case 4: return D3DPRESENT_INTERVAL_FOUR; - default: UNREACHABLE(); + if (!createDevice()) + { + return NULL; + } } - return D3DPRESENT_INTERVAL_DEFAULT; -} - -IDirect3DDevice9 *Display::getDevice() -{ return mDevice; } @@ -487,4 +533,127 @@ bool Display::getCompressedTextureSupport() return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1)); } + +bool Display::getFloatTextureSupport(bool *filtering, bool *renderable) +{ + D3DDISPLAYMODE currentDisplayMode; + mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); + + *filtering = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F)); + + *renderable = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F))&& + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F)); + + if (!filtering && !renderable) + { + return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F)); + } + else + { + return true; + } +} + +bool Display::getHalfFloatTextureSupport(bool *filtering, bool *renderable) +{ + D3DDISPLAYMODE currentDisplayMode; + mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); + + *filtering = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER, + D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F)); + + *renderable = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, + D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F)); + + if (!filtering && !renderable) + { + return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) && + SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, + D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F)); + } + else + { + return true; + } +} + +bool Display::getLuminanceTextureSupport() +{ + D3DDISPLAYMODE currentDisplayMode; + mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); + + return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_L8)); +} + +bool Display::getLuminanceAlphaTextureSupport() +{ + D3DDISPLAYMODE currentDisplayMode; + mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); + + return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8L8)); +} + +D3DPOOL Display::getBufferPool(DWORD usage) const +{ + if (mD3d9ex != NULL) + { + return D3DPOOL_DEFAULT; + } + else + { + if (!(usage & D3DUSAGE_DYNAMIC)) + { + return D3DPOOL_MANAGED; + } + } + + return D3DPOOL_DEFAULT; +} + +bool Display::getEventQuerySupport() +{ + IDirect3DQuery9 *query; + HRESULT result = mDevice->CreateQuery(D3DQUERYTYPE_EVENT, &query); + if (SUCCEEDED(result)) + { + query->Release(); + } + + return result != D3DERR_NOTAVAILABLE; +} + +D3DPRESENT_PARAMETERS Display::getDefaultPresentParameters() +{ + D3DPRESENT_PARAMETERS presentParameters = {0}; + + // The default swap chain is never actually used. Surface will create a new swap chain with the proper parameters. + presentParameters.AutoDepthStencilFormat = D3DFMT_UNKNOWN; + presentParameters.BackBufferCount = 1; + presentParameters.BackBufferFormat = D3DFMT_UNKNOWN; + presentParameters.BackBufferWidth = 1; + presentParameters.BackBufferHeight = 1; + presentParameters.EnableAutoDepthStencil = FALSE; + presentParameters.Flags = 0; + presentParameters.hDeviceWindow = mDeviceWindow; + presentParameters.MultiSampleQuality = 0; + presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; + presentParameters.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; + presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + presentParameters.Windowed = TRUE; + + return presentParameters; } +}
\ No newline at end of file diff --git a/Source/ThirdParty/ANGLE/src/libEGL/Display.h b/Source/ThirdParty/ANGLE/src/libEGL/Display.h index bd33012..4b74e1e 100644 --- a/Source/ThirdParty/ANGLE/src/libEGL/Display.h +++ b/Source/ThirdParty/ANGLE/src/libEGL/Display.h @@ -54,17 +54,25 @@ class Display bool isValidSurface(egl::Surface *surface); bool hasExistingWindowSurface(HWND window); - void setSwapInterval(GLint interval); - DWORD getPresentInterval(); - static DWORD convertInterval(GLint interval); + EGLint getMinSwapInterval(); + EGLint getMaxSwapInterval(); virtual IDirect3DDevice9 *getDevice(); virtual D3DCAPS9 getDeviceCaps(); virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); virtual bool getCompressedTextureSupport(); + virtual bool getEventQuerySupport(); + virtual bool getFloatTextureSupport(bool *filtering, bool *renderable); + virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable); + virtual bool getLuminanceTextureSupport(); + virtual bool getLuminanceAlphaTextureSupport(); + virtual D3DPOOL getBufferPool(DWORD usage) const; private: DISALLOW_COPY_AND_ASSIGN(Display); + + D3DPRESENT_PARAMETERS getDefaultPresentParameters(); + const HDC mDc; HMODULE mD3d9Module; @@ -78,11 +86,9 @@ class Display HWND mDeviceWindow; bool mSceneStarted; - GLint mSwapInterval; EGLint mMaxSwapInterval; EGLint mMinSwapInterval; - DWORD mPresentInterval; - + typedef std::set<Surface*> SurfaceSet; SurfaceSet mSurfaceSet; @@ -92,6 +98,7 @@ class Display ContextSet mContextSet; bool createDevice(); + bool resetDevice(); }; } diff --git a/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp b/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp index a5638d4..2736a7f 100644 --- a/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp +++ b/Source/ThirdParty/ANGLE/src/libEGL/Surface.cpp @@ -8,6 +8,8 @@ // such as the client area of a window, including any back buffers. // Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3. +#include <tchar.h> + #include "libEGL/Surface.h" #include "common/debug.h" @@ -23,7 +25,6 @@ Surface::Surface(Display *display, const Config *config, HWND window) mSwapChain = NULL; mDepthStencil = NULL; mBackBuffer = NULL; - mRenderTarget = NULL; mFlipTexture = NULL; mFlipState = NULL; mPreFlipState = NULL; @@ -31,52 +32,86 @@ Surface::Surface(Display *display, const Config *config, HWND window) mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING); // FIXME: Determine actual pixel aspect ratio mRenderBuffer = EGL_BACK_BUFFER; mSwapBehavior = EGL_BUFFER_PRESERVED; + mSwapInterval = -1; + setSwapInterval(1); + subclassWindow(); resetSwapChain(); } Surface::~Surface() { + unsubclassWindow(); + release(); +} + +void Surface::release() +{ if (mSwapChain) { mSwapChain->Release(); + mSwapChain = NULL; } if (mBackBuffer) { mBackBuffer->Release(); - } - - if (mRenderTarget) - { - mRenderTarget->Release(); + mBackBuffer = NULL; } if (mDepthStencil) { mDepthStencil->Release(); + mDepthStencil = NULL; } if (mFlipTexture) { mFlipTexture->Release(); + mFlipTexture = NULL; } if (mFlipState) { mFlipState->Release(); + mFlipState = NULL; } if (mPreFlipState) { mPreFlipState->Release(); + mPreFlipState = NULL; } } void Surface::resetSwapChain() { + RECT windowRect; + if (!GetClientRect(getWindowHandle(), &windowRect)) + { + ASSERT(false); + + ERR("Could not retrieve the window dimensions"); + return; + } + + resetSwapChain(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); +} + +void Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) +{ IDirect3DDevice9 *device = mDisplay->getDevice(); + if (device == NULL) + { + return; + } + + // Evict all non-render target textures to system memory and release all resources + // before reallocating them to free up as much video memory as possible. + device->EvictManagedResources(); + release(); + D3DPRESENT_PARAMETERS presentParameters = {0}; presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat; @@ -87,96 +122,57 @@ void Surface::resetSwapChain() presentParameters.hDeviceWindow = getWindowHandle(); presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented - presentParameters.PresentationInterval = Display::convertInterval(mConfig->mMinSwapInterval); + presentParameters.PresentationInterval = mPresentInterval; presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; presentParameters.Windowed = TRUE; + presentParameters.BackBufferWidth = backbufferWidth; + presentParameters.BackBufferHeight = backbufferHeight; - RECT windowRect; - if (!GetClientRect(getWindowHandle(), &windowRect)) - { - ASSERT(false); - return; - } - - presentParameters.BackBufferWidth = windowRect.right - windowRect.left; - presentParameters.BackBufferHeight = windowRect.bottom - windowRect.top; - - IDirect3DSwapChain9 *swapChain = NULL; - HRESULT result = device->CreateAdditionalSwapChain(&presentParameters, &swapChain); + HRESULT result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain); if (FAILED(result)) { ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); ERR("Could not create additional swap chains: %08lX", result); + release(); return error(EGL_BAD_ALLOC); } - IDirect3DSurface9 *depthStencilSurface = NULL; result = device->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType, - presentParameters.MultiSampleQuality, FALSE, &depthStencilSurface, NULL); + presentParameters.MultiSampleQuality, FALSE, &mDepthStencil, NULL); if (FAILED(result)) { ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); - swapChain->Release(); - ERR("Could not create depthstencil surface for new swap chain: %08lX", result); - return error(EGL_BAD_ALLOC); - } - - IDirect3DSurface9 *renderTarget = NULL; - result = device->CreateRenderTarget(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, presentParameters.BackBufferFormat, - presentParameters.MultiSampleType, presentParameters.MultiSampleQuality, FALSE, &renderTarget, NULL); - - if (FAILED(result)) - { - ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); - - swapChain->Release(); - depthStencilSurface->Release(); - - ERR("Could not create render target surface for new swap chain: %08lX", result); + release(); return error(EGL_BAD_ALLOC); } ASSERT(SUCCEEDED(result)); - IDirect3DTexture9 *flipTexture = NULL; result = device->CreateTexture(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, 1, D3DUSAGE_RENDERTARGET, - presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &flipTexture, NULL); + presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &mFlipTexture, NULL); if (FAILED(result)) { ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); - swapChain->Release(); - depthStencilSurface->Release(); - renderTarget->Release(); - ERR("Could not create flip texture for new swap chain: %08lX", result); + release(); return error(EGL_BAD_ALLOC); } - IDirect3DSurface9 *backBuffer = NULL; - swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &backBuffer); - - if (mSwapChain) mSwapChain->Release(); - if (mDepthStencil) mDepthStencil->Release(); - if (mBackBuffer) mBackBuffer->Release(); - if (mRenderTarget) mRenderTarget->Release(); - if (mFlipTexture) mFlipTexture->Release(); - + mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackBuffer); mWidth = presentParameters.BackBufferWidth; mHeight = presentParameters.BackBufferHeight; - mSwapChain = swapChain; - mDepthStencil = depthStencilSurface; - mBackBuffer = backBuffer; - mRenderTarget = renderTarget; - mFlipTexture = flipTexture; + mPresentIntervalDirty = false; + + InvalidateRect(mWindow, NULL, FALSE); // The flip state block recorded mFlipTexture so it is now invalid. releaseRecordedState(device); @@ -199,6 +195,7 @@ void Surface::writeRecordableFlipState(IDirect3DDevice9 *device) device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED); device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE); + device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); device->SetPixelShader(NULL); device->SetVertexShader(NULL); @@ -206,7 +203,7 @@ void Surface::writeRecordableFlipState(IDirect3DDevice9 *device) device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - device->SetTexture(0, NULL); // The actual texture will change after resizing. But the pre-flip state block must save/restore the texture. + device->SetTexture(0, NULL); // The actual texture will change after resizing. But the pre-flip state block must save/restore the texture. device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); device->SetSamplerState(0, D3DSAMP_SRGBTEXTURE, FALSE); @@ -214,7 +211,10 @@ void Surface::writeRecordableFlipState(IDirect3DDevice9 *device) device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1); - device->SetStreamSourceFreq(0, 1); // DrawPrimitiveUP only cares about stream 0, not the rest. + RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle + device->SetScissorRect(&scissorRect); + D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f}; + device->SetViewport(&viewport); } void Surface::applyFlipState(IDirect3DDevice9 *device) @@ -275,8 +275,6 @@ void Surface::applyFlipState(IDirect3DDevice9 *device) void Surface::restoreState(IDirect3DDevice9 *device) { - mPreFlipState->Apply(); - device->SetRenderTarget(0, mPreFlipBackBuffer); device->SetDepthStencilSurface(mPreFlipDepthStencil); @@ -291,6 +289,8 @@ void Surface::restoreState(IDirect3DDevice9 *device) mPreFlipDepthStencil->Release(); mPreFlipDepthStencil = NULL; } + + mPreFlipState->Apply(); } // On the next flip, this will cause the state to be recorded from scratch. @@ -309,8 +309,58 @@ void Surface::releaseRecordedState(IDirect3DDevice9 *device) mPreFlipState = NULL; } } +#define kSurfaceProperty _TEXT("Egl::SurfaceOwner") +#define kParentWndProc _TEXT("Egl::SurfaceParentWndProc") + +static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { + if (message == WM_SIZE) { + Surface* surf = reinterpret_cast<Surface*>(GetProp(hwnd, kSurfaceProperty)); + if(surf) { + surf->checkForOutOfDateSwapChain(); + } + } + WNDPROC prevWndFunc = reinterpret_cast<WNDPROC >(GetProp(hwnd, kParentWndProc)); + return CallWindowProc(prevWndFunc, hwnd, message, wparam, lparam); +} -bool Surface::checkForWindowResize() +void Surface::subclassWindow() +{ + SetLastError(0); + LONG oldWndProc = SetWindowLong(mWindow, GWL_WNDPROC, reinterpret_cast<LONG>(SurfaceWindowProc)); + if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS) { + mWindowSubclassed = false; + return; + } + + SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this)); + SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc)); + mWindowSubclassed = true; +} + +void Surface::unsubclassWindow() +{ + if(!mWindowSubclassed) + return; + + // un-subclass + LONG parentWndFunc = reinterpret_cast<LONG>(GetProp(mWindow, kParentWndProc)); + + // Check the windowproc is still SurfaceWindowProc. + // If this assert fails, then it is likely the application has subclassed the + // hwnd as well and did not unsubclass before destroying its EGL context. The + // application should be modified to either subclass before initializing the + // EGL context, or to unsubclass before destroying the EGL context. + if(parentWndFunc) { + LONG prevWndFunc = SetWindowLong(mWindow, GWL_WNDPROC, parentWndFunc); + ASSERT(prevWndFunc == reinterpret_cast<LONG>(SurfaceWindowProc)); + } + + RemoveProp(mWindow, kSurfaceProperty); + RemoveProp(mWindow, kParentWndProc); + mWindowSubclassed = false; +} + +bool Surface::checkForOutOfDateSwapChain() { RECT client; if (!GetClientRect(getWindowHandle(), &client)) @@ -319,10 +369,14 @@ bool Surface::checkForWindowResize() return false; } - if (getWidth() != client.right - client.left || getHeight() != client.bottom - client.top) - { - resetSwapChain(); + // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information. + int clientWidth = client.right - client.left; + int clientHeight = client.bottom - client.top; + bool sizeDirty = clientWidth != getWidth() || clientHeight != getHeight(); + if (sizeDirty || mPresentIntervalDirty) + { + resetSwapChain(clientWidth, clientHeight); if (static_cast<egl::Surface*>(getCurrentDrawSurface()) == this) { glMakeCurrent(glGetCurrentContext(), static_cast<egl::Display*>(getCurrentDisplay()), this); @@ -330,57 +384,51 @@ bool Surface::checkForWindowResize() return true; } - return false; } -bool Surface::swap() +DWORD Surface::convertInterval(EGLint interval) { - if (mSwapChain) + switch(interval) { - IDirect3DTexture9 *flipTexture = mFlipTexture; - flipTexture->AddRef(); - - IDirect3DSurface9 *renderTarget = mRenderTarget; - renderTarget->AddRef(); + case 0: return D3DPRESENT_INTERVAL_IMMEDIATE; + case 1: return D3DPRESENT_INTERVAL_ONE; + case 2: return D3DPRESENT_INTERVAL_TWO; + case 3: return D3DPRESENT_INTERVAL_THREE; + case 4: return D3DPRESENT_INTERVAL_FOUR; + default: UNREACHABLE(); + } - EGLint oldWidth = mWidth; - EGLint oldHeight = mHeight; + return D3DPRESENT_INTERVAL_DEFAULT; +} - checkForWindowResize(); +bool Surface::swap() +{ + if (mSwapChain) + { IDirect3DDevice9 *device = mDisplay->getDevice(); - IDirect3DSurface9 *textureSurface; - flipTexture->GetSurfaceLevel(0, &textureSurface); - - mDisplay->endScene(); - device->StretchRect(renderTarget, NULL, textureSurface, NULL, D3DTEXF_NONE); - renderTarget->Release(); - applyFlipState(device); - device->SetTexture(0, flipTexture); - - float xscale = (float)mWidth / oldWidth; - float yscale = (float)mHeight / oldHeight; + device->SetTexture(0, mFlipTexture); // Render the texture upside down into the back buffer - // Texcoords are chosen to pin a potentially resized image into the upper-left corner without scaling. - float quad[4][6] = {{ 0 - 0.5f, 0 - 0.5f, 0.0f, 1.0f, 0.0f, 1.0f }, - {mWidth - 0.5f, 0 - 0.5f, 0.0f, 1.0f, xscale, 1.0f }, - {mWidth - 0.5f, mHeight - 0.5f, 0.0f, 1.0f, xscale, 1.0f-yscale}, - { 0 - 0.5f, mHeight - 0.5f, 0.0f, 1.0f, 0.0f, 1.0f-yscale}}; // x, y, z, rhw, u, v + // Texcoords are chosen to flip the renderTarget about its Y axis. + float w = static_cast<float>(getWidth()); + float h = static_cast<float>(getHeight()); + float quad[4][6] = {{0 - 0.5f, 0 - 0.5f, 0.0f, 1.0f, 0.0f, 1.0f}, + {w - 0.5f, 0 - 0.5f, 0.0f, 1.0f, 1.0f, 1.0f}, + {w - 0.5f, h - 0.5f, 0.0f, 1.0f, 1.0f, 0.0f}, + {0 - 0.5f, h - 0.5f, 0.0f, 1.0f, 0.0f, 0.0f}}; // x, y, z, rhw, u, v mDisplay->startScene(); device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float)); - flipTexture->Release(); - textureSurface->Release(); - restoreState(device); mDisplay->endScene(); - HRESULT result = mSwapChain->Present(NULL, NULL, NULL, NULL, mDisplay->getPresentInterval()); + + HRESULT result = mSwapChain->Present(NULL, NULL, NULL, NULL, 0); if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR) { @@ -394,6 +442,7 @@ bool Surface::swap() ASSERT(SUCCEEDED(result)); + checkForOutOfDateSwapChain(); } return true; @@ -411,12 +460,14 @@ EGLint Surface::getHeight() const IDirect3DSurface9 *Surface::getRenderTarget() { - if (mRenderTarget) + IDirect3DSurface9 *textureSurface = NULL; + + if (mFlipTexture) { - mRenderTarget->AddRef(); + mFlipTexture->GetSurfaceLevel(0, &textureSurface); } - return mRenderTarget; + return textureSurface; } IDirect3DSurface9 *Surface::getDepthStencil() @@ -428,4 +479,19 @@ IDirect3DSurface9 *Surface::getDepthStencil() return mDepthStencil; } + +void Surface::setSwapInterval(EGLint interval) +{ + if (mSwapInterval == interval) + { + return; + } + + mSwapInterval = interval; + mSwapInterval = std::max(mSwapInterval, mDisplay->getMinSwapInterval()); + mSwapInterval = std::min(mSwapInterval, mDisplay->getMaxSwapInterval()); + + mPresentInterval = convertInterval(mSwapInterval); + mPresentIntervalDirty = true; +} } diff --git a/Source/ThirdParty/ANGLE/src/libEGL/Surface.h b/Source/ThirdParty/ANGLE/src/libEGL/Surface.h index 5bc912c..422d3d5 100644 --- a/Source/ThirdParty/ANGLE/src/libEGL/Surface.h +++ b/Source/ThirdParty/ANGLE/src/libEGL/Surface.h @@ -29,6 +29,9 @@ class Surface ~Surface(); + void release(); + void resetSwapChain(); + HWND getWindowHandle(); bool swap(); @@ -38,18 +41,22 @@ class Surface virtual IDirect3DSurface9 *getRenderTarget(); virtual IDirect3DSurface9 *getDepthStencil(); - private: + void setSwapInterval(EGLint interval); + bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update + +private: DISALLOW_COPY_AND_ASSIGN(Surface); Display *const mDisplay; IDirect3DSwapChain9 *mSwapChain; IDirect3DSurface9 *mBackBuffer; - IDirect3DSurface9 *mRenderTarget; IDirect3DSurface9 *mDepthStencil; IDirect3DTexture9 *mFlipTexture; - void resetSwapChain(); - bool checkForWindowResize(); + void subclassWindow(); + void unsubclassWindow(); + void resetSwapChain(int backbufferWidth, int backbufferHeight); + static DWORD convertInterval(EGLint interval); void applyFlipState(IDirect3DDevice9 *device); void restoreState(IDirect3DDevice9 *device); @@ -61,6 +68,7 @@ class Surface IDirect3DSurface9 *mPreFlipDepthStencil; const HWND mWindow; // Window that the surface is created for. + bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking const egl::Config *mConfig; // EGL config surface was created with EGLint mHeight; // Height of surface EGLint mWidth; // Width of surface @@ -77,6 +85,9 @@ class Surface // EGLenum textureTarget; // Type of texture: 2D or no texture // EGLenum vgAlphaFormat; // Alpha format for OpenVG // EGLenum vgColorSpace; // Color space for OpenVG + EGLint mSwapInterval; + DWORD mPresentInterval; + bool mPresentIntervalDirty; }; } diff --git a/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp b/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp index 5ceb6ef..8dfe6e5 100644 --- a/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp +++ b/Source/ThirdParty/ANGLE/src/libEGL/libEGL.cpp @@ -360,6 +360,8 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG default: return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); } + + attrib_list += 2; } } @@ -746,7 +748,14 @@ EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval) return EGL_FALSE; } - display->setSwapInterval(interval); + egl::Surface *draw_surface = static_cast<egl::Surface*>(egl::getCurrentDrawSurface()); + + if (draw_surface == NULL) + { + return error(EGL_BAD_SURFACE, EGL_FALSE); + } + + draw_surface->setSwapInterval(interval); return success(EGL_TRUE); } @@ -765,6 +774,28 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte try { + // Get the requested client version (default is 1) and check it is two. + EGLint client_version = 1; + if (attrib_list) + { + for (const EGLint* attribute = attrib_list; attribute[0] != EGL_NONE; attribute += 2) + { + if (attribute[0] == EGL_CONTEXT_CLIENT_VERSION) + { + client_version = attribute[1]; + } + else + { + return error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT); + } + } + } + + if (client_version != 2) + { + return error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); + } + egl::Display *display = static_cast<egl::Display*>(dpy); if (!validate(display, config)) @@ -825,7 +856,7 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface gl::Context *context = static_cast<gl::Context*>(ctx); IDirect3DDevice9 *device = display->getDevice(); - if (!device || device->TestCooperativeLevel() != D3D_OK) + if (!device || FAILED(device->TestCooperativeLevel())) { return error(EGL_CONTEXT_LOST, EGL_FALSE); } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Blit.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Blit.cpp index 00c878f..43ed8a0 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Blit.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Blit.cpp @@ -382,6 +382,11 @@ bool Blit::setFormatConvertShaders(GLenum destFormat) IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect) { + if (!surface) + { + return NULL; + } + egl::Display *display = getDisplay(); IDirect3DDevice9 *device = getDevice(); @@ -408,14 +413,8 @@ IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const return error(GL_OUT_OF_MEMORY, (IDirect3DTexture9*)NULL); } - RECT d3dSourceRect; - d3dSourceRect.left = sourceRect.left; - d3dSourceRect.right = sourceRect.right; - d3dSourceRect.top = sourceRect.top; - d3dSourceRect.bottom = sourceRect.bottom; - display->endScene(); - result = device->StretchRect(surface, &d3dSourceRect, textureSurface, NULL, D3DTEXF_NONE); + result = device->StretchRect(surface, &sourceRect, textureSurface, NULL, D3DTEXF_NONE); textureSurface->Release(); @@ -467,10 +466,8 @@ void Blit::setCommonBlitState() device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); - for (int i = 0; i < MAX_VERTEX_ATTRIBS+1; i++) - { - device->SetStreamSourceFreq(i, 1); - } + RECT scissorRect = {0}; // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle + device->SetScissorRect(&scissorRect); } void Blit::render() diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp index 43993e7..17cea6c 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.cpp @@ -10,6 +10,10 @@ #include "libGLESv2/Buffer.h" +#include "libGLESv2/main.h" +#include "libGLESv2/geometry/VertexDataManager.h" +#include "libGLESv2/geometry/IndexDataManager.h" + namespace gl { @@ -18,11 +22,16 @@ Buffer::Buffer(GLuint id) : RefCountObject(id) mContents = NULL; mSize = 0; mUsage = GL_DYNAMIC_DRAW; + + mVertexBuffer = NULL; + mIndexBuffer = NULL; } Buffer::~Buffer() { delete[] mContents; + delete mVertexBuffer; + delete mIndexBuffer; } void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) @@ -46,11 +55,52 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) mSize = size; mUsage = usage; + + invalidateStaticData(); + + if (usage == GL_STATIC_DRAW) + { + mVertexBuffer = new StaticVertexBuffer(getDevice()); + mIndexBuffer = new StaticIndexBuffer(getDevice()); + } } void Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset) { memcpy(mContents + offset, data, size); + + if ((mVertexBuffer && mVertexBuffer->size() != 0) || (mIndexBuffer && mIndexBuffer->size() != 0)) + { + invalidateStaticData(); + + if (mUsage == GL_STATIC_DRAW) + { + // If applications update the buffer data after it has already been used in a draw call, + // it most likely isn't used as a static buffer so we should fall back to streaming usage + // for best performance. So ignore the usage hint and don't create new static buffers. + // mVertexBuffer = new StaticVertexBuffer(getDevice()); + // mIndexBuffer = new StaticIndexBuffer(getDevice()); + } + } +} + +StaticVertexBuffer *Buffer::getVertexBuffer() +{ + return mVertexBuffer; +} + +StaticIndexBuffer *Buffer::getIndexBuffer() +{ + return mIndexBuffer; +} + +void Buffer::invalidateStaticData() +{ + delete mVertexBuffer; + mVertexBuffer = NULL; + + delete mIndexBuffer; + mIndexBuffer = NULL; } } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h index 5611cc9..c2ed60f 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Buffer.h @@ -22,6 +22,8 @@ namespace gl { +class StaticVertexBuffer; +class StaticIndexBuffer; class Buffer : public RefCountObject { @@ -37,12 +39,19 @@ class Buffer : public RefCountObject size_t size() const { return mSize; } GLenum usage() const { return mUsage; } + StaticVertexBuffer *getVertexBuffer(); + StaticIndexBuffer *getIndexBuffer(); + void invalidateStaticData(); + private: DISALLOW_COPY_AND_ASSIGN(Buffer); GLubyte *mContents; size_t mSize; GLenum mUsage; + + StaticVertexBuffer *mVertexBuffer; + StaticIndexBuffer *mIndexBuffer; }; } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp index 48ef8fc..9be59c4 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.cpp @@ -19,15 +19,14 @@ #include "libGLESv2/Blit.h" #include "libGLESv2/ResourceManager.h" #include "libGLESv2/Buffer.h" +#include "libGLESv2/Fence.h" #include "libGLESv2/FrameBuffer.h" #include "libGLESv2/Program.h" #include "libGLESv2/RenderBuffer.h" #include "libGLESv2/Shader.h" #include "libGLESv2/Texture.h" -#include "libGLESv2/geometry/backend.h" #include "libGLESv2/geometry/VertexDataManager.h" #include "libGLESv2/geometry/IndexDataManager.h" -#include "libGLESv2/geometry/dx9.h" #undef near #undef far @@ -83,6 +82,7 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) mState.scissorTest = false; mState.dither = true; mState.generateMipmapHint = GL_DONT_CARE; + mState.fragmentShaderDerivativeHint = GL_DONT_CARE; mState.lineWidth = 1.0f; @@ -120,11 +120,8 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) // In order that access to these initial textures not be lost, they are treated as texture // objects all of whose names are 0. - mTexture2DZero = new Texture2D(0); - mTextureCubeMapZero = new TextureCubeMap(0); - - mColorbufferZero = NULL; - mDepthStencilbufferZero = NULL; + mTexture2DZero.set(new Texture2D(0)); + mTextureCubeMapZero.set(new TextureCubeMap(0)); mState.activeSampler = 0; bindArrayBuffer(0); @@ -135,17 +132,11 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) bindDrawFramebuffer(0); bindRenderbuffer(0); - for (int type = 0; type < SAMPLER_TYPE_COUNT; type++) - { - mIncompleteTextures[type] = NULL; - } - mState.currentProgram = 0; mState.packAlignment = 4; mState.unpackAlignment = 4; - mBufferBackEnd = NULL; mVertexDataManager = NULL; mIndexDataManager = NULL; mBlit = NULL; @@ -158,6 +149,8 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) mHasBeenCurrent = false; + mSupportsCompressedTextures = false; + mSupportsEventQueries = false; mMaxSupportedSamples = 0; mMaskedClearSavedState = NULL; markAllStateDirty(); @@ -180,6 +173,11 @@ Context::~Context() deleteFramebuffer(mFramebufferMap.begin()->first); } + while (!mFenceMap.empty()) + { + deleteFence(mFenceMap.begin()->first); + } + while (!mMultiSampleSupport.empty()) { delete [] mMultiSampleSupport.begin()->second; @@ -196,7 +194,7 @@ Context::~Context() for (int type = 0; type < SAMPLER_TYPE_COUNT; type++) { - delete mIncompleteTextures[type]; + mIncompleteTextures[type].set(NULL); } for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) @@ -206,14 +204,11 @@ Context::~Context() mState.arrayBuffer.set(NULL); mState.elementArrayBuffer.set(NULL); - mState.texture2D.set(NULL); - mState.textureCubeMap.set(NULL); mState.renderbuffer.set(NULL); - delete mTexture2DZero; - delete mTextureCubeMapZero; + mTexture2DZero.set(NULL); + mTextureCubeMapZero.set(NULL); - delete mBufferBackEnd; delete mVertexDataManager; delete mIndexDataManager; delete mBlit; @@ -234,11 +229,20 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) { mDeviceCaps = display->getDeviceCaps(); - mBufferBackEnd = new Dx9BackEnd(this, device); - mVertexDataManager = new VertexDataManager(this, mBufferBackEnd); - mIndexDataManager = new IndexDataManager(this, mBufferBackEnd); + mVertexDataManager = new VertexDataManager(this, device); + mIndexDataManager = new IndexDataManager(this, device); mBlit = new Blit(this); + mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(3, 0); + + mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidth, (int)mDeviceCaps.MaxTextureHeight), + (int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE); + mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE); + mMaxRenderbufferDimension = mMaxTextureDimension; + mMaxTextureLevel = log2(mMaxTextureDimension) + 1; + TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbufferDimension=%d, MaxTextureLevel=%d", + mMaxTextureDimension, mMaxCubeTextureDimension, mMaxRenderbufferDimension, mMaxTextureLevel); + const D3DFORMAT renderBufferFormats[] = { D3DFMT_A8R8G8B8, @@ -265,7 +269,14 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) mMaxSupportedSamples = max; + mSupportsEventQueries = display->getEventQuerySupport(); mSupportsCompressedTextures = display->getCompressedTextureSupport(); + mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloatLinearFilter, &mSupportsFloatRenderableTextures); + mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSupportsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures); + mSupportsLuminanceTextures = display->getLuminanceTextureSupport(); + mSupportsLuminanceAlphaTextures = display->getLuminanceAlphaTextureSupport(); + + mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16); initExtensionString(); @@ -292,15 +303,16 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) setFramebufferZero(framebufferZero); - defaultRenderTarget->Release(); + if (defaultRenderTarget) + { + defaultRenderTarget->Release(); + } if (depthStencil) { depthStencil->Release(); } - mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(3, 0); - markAllStateDirty(); } @@ -309,6 +321,8 @@ void Context::markAllStateDirty() { mAppliedRenderTargetSerial = 0; mAppliedDepthbufferSerial = 0; + mAppliedStencilbufferSerial = 0; + mDepthStencilInitialized = false; mAppliedProgram = 0; mClearStateDirty = true; @@ -322,11 +336,6 @@ void Context::markAllStateDirty() mSampleStateDirty = true; mDitherStateDirty = true; mFrontFaceDirty = true; - - if (mBufferBackEnd != NULL) - { - mBufferBackEnd->invalidate(); - } } void Context::setClearColor(float red, float green, float blue, float alpha) @@ -650,6 +659,14 @@ void Context::setGenerateMipmapHint(GLenum hint) mState.generateMipmapHint = hint; } +void Context::setFragmentShaderDerivativeHint(GLenum hint) +{ + mState.fragmentShaderDerivativeHint = hint; + // TODO: Propagate the hint to shader translator so we can write + // ddx, ddx_coarse, or ddx_fine depending on the hint. + // Ignore for now. It is valid for implementations to ignore hint. +} + void Context::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height) { mState.viewportX = x; @@ -718,12 +735,12 @@ GLuint Context::getArrayBufferHandle() const return mState.arrayBuffer.id(); } -void Context::setVertexAttribEnabled(unsigned int attribNum, bool enabled) +void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled) { - mState.vertexAttribute[attribNum].mEnabled = enabled; + mState.vertexAttribute[attribNum].mArrayEnabled = enabled; } -const AttributeState &Context::getVertexAttribState(unsigned int attribNum) +const VertexAttribute &Context::getVertexAttribState(unsigned int attribNum) { return mState.vertexAttribute[attribNum]; } @@ -744,8 +761,7 @@ const void *Context::getVertexAttribPointer(unsigned int attribNum) const return mState.vertexAttribute[attribNum].mPointer; } -// returns entire set of attributes as a block -const AttributeState *Context::getVertexAttribBlock() +const VertexAttributeArray &Context::getVertexAttributes() { return mState.vertexAttribute; } @@ -810,6 +826,20 @@ GLuint Context::createFramebuffer() return handle; } +GLuint Context::createFence() +{ + unsigned int handle = 0; + + while (mFenceMap.find(handle) != mFenceMap.end()) + { + handle++; + } + + mFenceMap[handle] = new Fence; + + return handle; +} + void Context::deleteBuffer(GLuint buffer) { if (mResourceManager->getBuffer(buffer)) @@ -863,6 +893,17 @@ void Context::deleteFramebuffer(GLuint framebuffer) } } +void Context::deleteFence(GLuint fence) +{ + FenceMap::iterator fenceObject = mFenceMap.find(fence); + + if (fenceObject != mFenceMap.end()) + { + delete fenceObject->second; + mFenceMap.erase(fenceObject); + } +} + Buffer *Context::getBuffer(GLuint handle) { return mResourceManager->getBuffer(handle); @@ -916,18 +957,14 @@ void Context::bindTexture2D(GLuint texture) { mResourceManager->checkTextureAllocation(texture, SAMPLER_2D); - mState.texture2D.set(getTexture(texture)); - - mState.samplerTexture[SAMPLER_2D][mState.activeSampler].set(mState.texture2D.get()); + mState.samplerTexture[SAMPLER_2D][mState.activeSampler].set(getTexture(texture)); } void Context::bindTextureCubeMap(GLuint texture) { mResourceManager->checkTextureAllocation(texture, SAMPLER_CUBE); - mState.textureCubeMap.set(getTexture(texture)); - - mState.samplerTexture[SAMPLER_CUBE][mState.activeSampler].set(mState.textureCubeMap.get()); + mState.samplerTexture[SAMPLER_CUBE][mState.activeSampler].set(getTexture(texture)); } void Context::bindReadFramebuffer(GLuint framebuffer) @@ -1005,6 +1042,20 @@ Framebuffer *Context::getFramebuffer(unsigned int handle) } } +Fence *Context::getFence(unsigned int handle) +{ + FenceMap::iterator fence = mFenceMap.find(handle); + + if (fence == mFenceMap.end()) + { + return NULL; + } + else + { + return fence->second; + } +} + Buffer *Context::getArrayBuffer() { return mState.arrayBuffer.get(); @@ -1022,35 +1073,25 @@ Program *Context::getCurrentProgram() Texture2D *Context::getTexture2D() { - if (mState.texture2D.id() == 0) // Special case: 0 refers to different initial textures based on the target - { - return mTexture2DZero; - } - - return static_cast<Texture2D*>(mState.texture2D.get()); + return static_cast<Texture2D*>(getSamplerTexture(mState.activeSampler, SAMPLER_2D)); } TextureCubeMap *Context::getTextureCubeMap() { - if (mState.textureCubeMap.id() == 0) // Special case: 0 refers to different initial textures based on the target - { - return mTextureCubeMapZero; - } - - return static_cast<TextureCubeMap*>(mState.textureCubeMap.get()); + return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, SAMPLER_CUBE)); } Texture *Context::getSamplerTexture(unsigned int sampler, SamplerType type) { GLuint texid = mState.samplerTexture[type][sampler].id(); - if (texid == 0) + if (texid == 0) // Special case: 0 refers to different initial textures based on the target { switch (type) { default: UNREACHABLE(); - case SAMPLER_2D: return mTexture2DZero; - case SAMPLER_CUBE: return mTextureCubeMapZero; + case SAMPLER_2D: return mTexture2DZero.get(); + case SAMPLER_CUBE: return mTextureCubeMapZero.get(); } } @@ -1070,15 +1111,15 @@ bool Context::getBooleanv(GLenum pname, GLboolean *params) params[2] = mState.colorMaskBlue; params[3] = mState.colorMaskAlpha; break; - case GL_CULL_FACE: *params = mState.cullFace; - case GL_POLYGON_OFFSET_FILL: *params = mState.polygonOffsetFill; - case GL_SAMPLE_ALPHA_TO_COVERAGE: *params = mState.sampleAlphaToCoverage; - case GL_SAMPLE_COVERAGE: *params = mState.sampleCoverage; - case GL_SCISSOR_TEST: *params = mState.scissorTest; - case GL_STENCIL_TEST: *params = mState.stencilTest; - case GL_DEPTH_TEST: *params = mState.depthTest; - case GL_BLEND: *params = mState.blend; - case GL_DITHER: *params = mState.dither; + case GL_CULL_FACE: *params = mState.cullFace; break; + case GL_POLYGON_OFFSET_FILL: *params = mState.polygonOffsetFill; break; + case GL_SAMPLE_ALPHA_TO_COVERAGE: *params = mState.sampleAlphaToCoverage; break; + case GL_SAMPLE_COVERAGE: *params = mState.sampleCoverage; break; + case GL_SCISSOR_TEST: *params = mState.scissorTest; break; + case GL_STENCIL_TEST: *params = mState.stencilTest; break; + case GL_DEPTH_TEST: *params = mState.depthTest; break; + case GL_BLEND: *params = mState.blend; break; + case GL_DITHER: *params = mState.dither; break; default: return false; } @@ -1141,24 +1182,25 @@ bool Context::getIntegerv(GLenum pname, GLint *params) { case GL_MAX_VERTEX_ATTRIBS: *params = gl::MAX_VERTEX_ATTRIBS; break; case GL_MAX_VERTEX_UNIFORM_VECTORS: *params = gl::MAX_VERTEX_UNIFORM_VECTORS; break; - case GL_MAX_VARYING_VECTORS: *params = gl::MAX_VARYING_VECTORS; break; + case GL_MAX_VARYING_VECTORS: *params = getMaximumVaryingVectors(); break; case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS; break; case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS; break; case GL_MAX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_TEXTURE_IMAGE_UNITS; break; - case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = gl::MAX_FRAGMENT_UNIFORM_VECTORS; break; - case GL_MAX_RENDERBUFFER_SIZE: *params = gl::MAX_RENDERBUFFER_SIZE; break; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = getMaximumFragmentUniformVectors(); break; + case GL_MAX_RENDERBUFFER_SIZE: *params = getMaximumRenderbufferDimension(); break; case GL_NUM_SHADER_BINARY_FORMATS: *params = 0; break; case GL_SHADER_BINARY_FORMATS: /* no shader binary formats are supported */ break; case GL_ARRAY_BUFFER_BINDING: *params = mState.arrayBuffer.id(); break; case GL_ELEMENT_ARRAY_BUFFER_BINDING: *params = mState.elementArrayBuffer.id(); break; - //case GL_FRAMEBUFFER_BINDING: // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE - case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE: *params = mState.drawFramebuffer; break; - case GL_READ_FRAMEBUFFER_BINDING_ANGLE: *params = mState.readFramebuffer; break; + //case GL_FRAMEBUFFER_BINDING: // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE + case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE: *params = mState.drawFramebuffer; break; + case GL_READ_FRAMEBUFFER_BINDING_ANGLE: *params = mState.readFramebuffer; break; case GL_RENDERBUFFER_BINDING: *params = mState.renderbuffer.id(); break; case GL_CURRENT_PROGRAM: *params = mState.currentProgram; break; case GL_PACK_ALIGNMENT: *params = mState.packAlignment; break; case GL_UNPACK_ALIGNMENT: *params = mState.unpackAlignment; break; case GL_GENERATE_MIPMAP_HINT: *params = mState.generateMipmapHint; break; + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: *params = mState.fragmentShaderDerivativeHint; break; case GL_ACTIVE_TEXTURE: *params = (mState.activeSampler + GL_TEXTURE0); break; case GL_STENCIL_FUNC: *params = mState.stencilFunc; break; case GL_STENCIL_REF: *params = mState.stencilRef; break; @@ -1183,8 +1225,8 @@ bool Context::getIntegerv(GLenum pname, GLint *params) case GL_STENCIL_BACK_WRITEMASK: *params = mState.stencilBackWritemask; break; case GL_STENCIL_CLEAR_VALUE: *params = mState.stencilClearValue; break; case GL_SUBPIXEL_BITS: *params = 4; break; - case GL_MAX_TEXTURE_SIZE: *params = gl::MAX_TEXTURE_SIZE; break; - case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = gl::MAX_CUBE_MAP_TEXTURE_SIZE; break; + case GL_MAX_TEXTURE_SIZE: *params = getMaximumTextureDimension(); break; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break; case GL_NUM_COMPRESSED_TEXTURE_FORMATS: { if (supportsCompressedTextures()) @@ -1246,7 +1288,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) case GL_IMPLEMENTATION_COLOR_READ_FORMAT: *params = gl::IMPLEMENTATION_COLOR_READ_FORMAT; break; case GL_MAX_VIEWPORT_DIMS: { - int maxDimension = std::max((int)gl::MAX_RENDERBUFFER_SIZE, (int)gl::MAX_TEXTURE_SIZE); + int maxDimension = std::max(getMaximumRenderbufferDimension(), getMaximumTextureDimension()); params[0] = maxDimension; params[1] = maxDimension; } @@ -1392,6 +1434,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu case GL_PACK_ALIGNMENT: case GL_UNPACK_ALIGNMENT: case GL_GENERATE_MIPMAP_HINT: + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: case GL_RED_BITS: case GL_GREEN_BITS: case GL_BLUE_BITS: @@ -1535,6 +1578,12 @@ bool Context::applyRenderTarget(bool ignoreViewport) } IDirect3DSurface9 *renderTarget = framebufferObject->getRenderTarget(); + + if (!renderTarget) + { + return false; // Context must be lost + } + IDirect3DSurface9 *depthStencil = NULL; unsigned int renderTargetSerial = framebufferObject->getRenderTargetSerial(); @@ -1550,26 +1599,43 @@ bool Context::applyRenderTarget(bool ignoreViewport) if (framebufferObject->getDepthbufferType() != GL_NONE) { depthStencil = framebufferObject->getDepthbuffer()->getDepthStencil(); + if (!depthStencil) + { + ERR("Depth stencil pointer unexpectedly null."); + return false; + } + depthbufferSerial = framebufferObject->getDepthbuffer()->getSerial(); } else if (framebufferObject->getStencilbufferType() != GL_NONE) { depthStencil = framebufferObject->getStencilbuffer()->getDepthStencil(); + if (!depthStencil) + { + ERR("Depth stencil pointer unexpectedly null."); + return false; + } + stencilbufferSerial = framebufferObject->getStencilbuffer()->getSerial(); } if (depthbufferSerial != mAppliedDepthbufferSerial || - stencilbufferSerial != mAppliedStencilbufferSerial) + stencilbufferSerial != mAppliedStencilbufferSerial || + !mDepthStencilInitialized) { device->SetDepthStencilSurface(depthStencil); mAppliedDepthbufferSerial = depthbufferSerial; mAppliedStencilbufferSerial = stencilbufferSerial; + mDepthStencilInitialized = true; } D3DVIEWPORT9 viewport; D3DSURFACE_DESC desc; renderTarget->GetDesc(&desc); + float zNear = clamp01(mState.zNear); + float zFar = clamp01(mState.zFar); + if (ignoreViewport) { viewport.X = 0; @@ -1585,8 +1651,8 @@ bool Context::applyRenderTarget(bool ignoreViewport) viewport.Y = std::max(mState.viewportY, 0); viewport.Width = std::min(mState.viewportWidth, (int)desc.Width - (int)viewport.X); viewport.Height = std::min(mState.viewportHeight, (int)desc.Height - (int)viewport.Y); - viewport.MinZ = clamp01(mState.zNear); - viewport.MaxZ = clamp01(mState.zFar); + viewport.MinZ = zNear; + viewport.MaxZ = zFar; } if (viewport.Width <= 0 || viewport.Height <= 0) @@ -1623,27 +1689,21 @@ bool Context::applyRenderTarget(bool ignoreViewport) GLint halfPixelSize = programObject->getDxHalfPixelSizeLocation(); GLfloat xy[2] = {1.0f / viewport.Width, 1.0f / viewport.Height}; - programObject->setUniform2fv(halfPixelSize, 1, (GLfloat*)&xy); + programObject->setUniform2fv(halfPixelSize, 1, xy); - GLint window = programObject->getDxViewportLocation(); + GLint viewport = programObject->getDxViewportLocation(); GLfloat whxy[4] = {mState.viewportWidth / 2.0f, mState.viewportHeight / 2.0f, (float)mState.viewportX + mState.viewportWidth / 2.0f, (float)mState.viewportY + mState.viewportHeight / 2.0f}; - programObject->setUniform4fv(window, 1, (GLfloat*)&whxy); + programObject->setUniform4fv(viewport, 1, whxy); GLint depth = programObject->getDxDepthLocation(); - GLfloat dz[2] = {(mState.zFar - mState.zNear) / 2.0f, (mState.zNear + mState.zFar) / 2.0f}; - programObject->setUniform2fv(depth, 1, (GLfloat*)&dz); + GLfloat dz[2] = {(zFar - zNear) / 2.0f, (zNear + zFar) / 2.0f}; + programObject->setUniform2fv(depth, 1, dz); - GLint near = programObject->getDepthRangeNearLocation(); - programObject->setUniform1fv(near, 1, &mState.zNear); - - GLint far = programObject->getDepthRangeFarLocation(); - programObject->setUniform1fv(far, 1, &mState.zFar); - - GLint diff = programObject->getDepthRangeDiffLocation(); - GLfloat zDiff = mState.zFar - mState.zNear; - programObject->setUniform1fv(diff, 1, &zDiff); + GLint depthRange = programObject->getDxDepthRangeLocation(); + GLfloat nearFarDiff[3] = {zNear, zFar, zFar - zNear}; + programObject->setUniform3fv(depthRange, 1, nearFarDiff); } return true; @@ -1830,39 +1890,46 @@ void Context::applyState(GLenum drawMode) mPolygonOffsetStateDirty = false; } - if (framebufferObject->isMultisample() && mSampleStateDirty) + if (mSampleStateDirty) { - if (mState.sampleAlphaToCoverage) + if (framebufferObject->isMultisample()) { - FIXME("Sample alpha to coverage is unimplemented."); - } + if (mState.sampleAlphaToCoverage) + { + FIXME("Sample alpha to coverage is unimplemented."); + } - if (mState.sampleCoverage) - { device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); - unsigned int mask = 0; - if (mState.sampleCoverageValue != 0) + if (mState.sampleCoverage) { - float threshold = 0.5f; - - for (int i = 0; i < framebufferObject->getSamples(); ++i) + unsigned int mask = 0; + if (mState.sampleCoverageValue != 0) { - mask <<= 1; + float threshold = 0.5f; - if ((i + 1) * mState.sampleCoverageValue >= threshold) + for (int i = 0; i < framebufferObject->getSamples(); ++i) { - threshold += 1.0f; - mask |= 1; + mask <<= 1; + + if ((i + 1) * mState.sampleCoverageValue >= threshold) + { + threshold += 1.0f; + mask |= 1; + } } } + + if (mState.sampleCoverageInvert) + { + mask = ~mask; + } + + device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask); } - - if (mState.sampleCoverageInvert) + else { - mask = ~mask; + device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF); } - - device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask); } else { @@ -1887,18 +1954,18 @@ void Context::lookupAttributeMapping(TranslatedAttribute *attributes) { for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - if (attributes[i].enabled) + if (attributes[i].active) { attributes[i].semanticIndex = getCurrentProgram()->getSemanticIndex(i); } } } -GLenum Context::applyVertexBuffer(GLenum mode, GLint first, GLsizei count, bool *useIndexing, TranslatedIndexData *indexInfo) +GLenum Context::applyVertexBuffer(GLint first, GLsizei count) { TranslatedAttribute translated[MAX_VERTEX_ATTRIBS]; - GLenum err = mVertexDataManager->preRenderValidate(first, count, translated); + GLenum err = mVertexDataManager->prepareVertexData(first, count, translated); if (err != GL_NO_ERROR) { return err; @@ -1906,53 +1973,20 @@ GLenum Context::applyVertexBuffer(GLenum mode, GLint first, GLsizei count, bool lookupAttributeMapping(translated); - mBufferBackEnd->setupAttributesPreDraw(translated); - - for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) - { - if (translated[i].enabled && translated[i].nonArray) - { - err = mIndexDataManager->preRenderValidateUnindexed(mode, count, indexInfo); - if (err != GL_NO_ERROR) - { - return err; - } + mVertexDataManager->setupAttributes(translated); - mBufferBackEnd->setupIndicesPreDraw(*indexInfo); - - *useIndexing = true; - return GL_NO_ERROR; - } - } - - *useIndexing = false; return GL_NO_ERROR; } -GLenum Context::applyVertexBuffer(const TranslatedIndexData &indexInfo) -{ - TranslatedAttribute translated[MAX_VERTEX_ATTRIBS]; - - GLenum err = mVertexDataManager->preRenderValidate(indexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, translated); - - if (err == GL_NO_ERROR) - { - lookupAttributeMapping(translated); - - mBufferBackEnd->setupAttributesPreDraw(translated); - } - - return err; -} - // Applies the indices and element array bindings to the Direct3D 9 device GLenum Context::applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) { - GLenum err = mIndexDataManager->preRenderValidate(mode, type, count, mState.elementArrayBuffer.get(), indices, indexInfo); + IDirect3DDevice9 *device = getDevice(); + GLenum err = mIndexDataManager->prepareIndexData(type, count, mState.elementArrayBuffer.get(), indices, indexInfo); if (err == GL_NO_ERROR) { - mBufferBackEnd->setupIndicesPreDraw(*indexInfo); + device->SetIndices(indexInfo->indexBuffer); } return err; @@ -2048,6 +2082,12 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum } IDirect3DSurface9 *renderTarget = framebuffer->getRenderTarget(); + + if (!renderTarget) + { + return; // Context must be lost, return silently + } + IDirect3DDevice9 *device = getDevice(); D3DSURFACE_DESC desc; @@ -2141,16 +2181,6 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum r = (rgb & 0xF800) * (1.0f / 0xF800); } break; - case D3DFMT_X1R5G5B5: - { - unsigned short xrgb = *(unsigned short*)(source + 2 * i + j * lock.Pitch); - - a = 1.0f; - b = (xrgb & 0x001F) * (1.0f / 0x001F); - g = (xrgb & 0x03E0) * (1.0f / 0x03E0); - r = (xrgb & 0x7C00) * (1.0f / 0x7C00); - } - break; case D3DFMT_A1R5G5B5: { unsigned short argb = *(unsigned short*)(source + 2 * i + j * lock.Pitch); @@ -2191,6 +2221,28 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum r = (argb & 0x3FF00000) * (1.0f / 0x3FF00000); } break; + case D3DFMT_A32B32G32R32F: + { + // float formats in D3D are stored rgba, rather than the other way round + r = *((float*)(source + 16 * i + j * lock.Pitch) + 0); + g = *((float*)(source + 16 * i + j * lock.Pitch) + 1); + b = *((float*)(source + 16 * i + j * lock.Pitch) + 2); + a = *((float*)(source + 16 * i + j * lock.Pitch) + 3); + } + break; + case D3DFMT_A16B16G16R16F: + { + // float formats in D3D are stored rgba, rather than the other way round + float abgr[4]; + + D3DXFloat16To32Array(abgr, (D3DXFLOAT16*)(source + 8 * i + j * lock.Pitch), 4); + + a = abgr[3]; + b = abgr[2]; + g = abgr[1]; + r = abgr[0]; + } + break; default: UNIMPLEMENTED(); // FIXME UNREACHABLE(); @@ -2314,6 +2366,12 @@ void Context::clear(GLbitfield mask) if (framebufferObject->getStencilbufferType() != GL_NONE) { IDirect3DSurface9 *depthStencil = framebufferObject->getStencilbuffer()->getDepthStencil(); + if (!depthStencil) + { + ERR("Depth stencil pointer unexpectedly null."); + return; + } + D3DSURFACE_DESC desc; depthStencil->GetDesc(&desc); @@ -2346,6 +2404,11 @@ void Context::clear(GLbitfield mask) IDirect3DSurface9 *renderTarget = framebufferObject->getRenderTarget(); + if (!renderTarget) + { + return; // Context must be lost, return silently + } + D3DSURFACE_DESC desc; renderTarget->GetDesc(&desc); @@ -2381,7 +2444,7 @@ void Context::clear(GLbitfield mask) device->SetPixelShader(NULL); device->SetVertexShader(NULL); device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); - device->SetStreamSourceFreq(0, 1); + device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); hr = device->EndStateBlock(&mMaskedClearSavedState); ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY); @@ -2436,7 +2499,7 @@ void Context::clear(GLbitfield mask) device->SetPixelShader(NULL); device->SetVertexShader(NULL); device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); - device->SetStreamSourceFreq(0, 1); + device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); struct Vertex { @@ -2517,9 +2580,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count) applyState(mode); - TranslatedIndexData indexInfo; - bool useIndexing; - GLenum err = applyVertexBuffer(mode, first, count, &useIndexing, &indexInfo); + GLenum err = applyVertexBuffer(first, count); if (err != GL_NO_ERROR) { return error(err); @@ -2536,18 +2597,17 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count) if (!cullSkipsDraw(mode)) { display->startScene(); - if (useIndexing) - { - device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, indexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, indexInfo.offset/indexInfo.indexSize, primitiveCount); - } - else + + device->DrawPrimitive(primitiveType, 0, primitiveCount); + + if (mode == GL_LINE_LOOP) // Draw the last segment separately { - device->DrawPrimitive(primitiveType, 0, primitiveCount); + drawClosingLine(first, first + count - 1); } } } -void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) +void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices) { if (!mState.currentProgram) { @@ -2586,7 +2646,8 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void* return error(err); } - err = applyVertexBuffer(indexInfo); + GLsizei vertexCount = indexInfo.maxIndex - indexInfo.minIndex + 1; + err = applyVertexBuffer(indexInfo.minIndex, vertexCount); if (err != GL_NO_ERROR) { return error(err); @@ -2603,7 +2664,13 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void* if (!cullSkipsDraw(mode)) { display->startScene(); - device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, indexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, indexInfo.offset/indexInfo.indexSize, primitiveCount); + + device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, indexInfo.minIndex, vertexCount, indexInfo.startIndex, primitiveCount); + + if (mode == GL_LINE_LOOP) // Draw the last segment separately + { + drawClosingLine(count, type, indices); + } } } @@ -2631,7 +2698,6 @@ void Context::finish() ASSERT(SUCCEEDED(result)); // Render something outside the render target - device->SetStreamSourceFreq(0, 1); device->SetPixelShader(NULL); device->SetVertexShader(NULL); device->SetFVF(D3DFVF_XYZRHW); @@ -2687,6 +2753,93 @@ void Context::flush() } } +void Context::drawClosingLine(unsigned int first, unsigned int last) +{ + IDirect3DDevice9 *device = getDevice(); + IDirect3DIndexBuffer9 *indexBuffer = NULL; + HRESULT result = D3DERR_INVALIDCALL; + + if (supports32bitIndices()) + { + result = device->CreateIndexBuffer(8, D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &indexBuffer, 0); + + if (SUCCEEDED(result)) + { + unsigned int *data; + result = indexBuffer->Lock(0, 0, (void**)&data, 0); + + if (SUCCEEDED(result)) + { + data[0] = last; + data[1] = first; + } + } + } + else + { + result = device->CreateIndexBuffer(4, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &indexBuffer, 0); + + if (SUCCEEDED(result)) + { + unsigned short *data; + result = indexBuffer->Lock(0, 0, (void**)&data, 0); + + if (SUCCEEDED(result)) + { + data[0] = last; + data[1] = first; + } + } + } + + if (SUCCEEDED(result)) + { + indexBuffer->Unlock(); + device->SetIndices(indexBuffer); + + device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, 2, 0, 1); + + indexBuffer->Release(); + } + else + { + ERR("Could not create an index buffer for closing a line loop."); + error(GL_OUT_OF_MEMORY); + } +} + +void Context::drawClosingLine(GLsizei count, GLenum type, const void *indices) +{ + unsigned int first = 0; + unsigned int last = 0; + + if (mState.elementArrayBuffer.get()) + { + Buffer *indexBuffer = mState.elementArrayBuffer.get(); + intptr_t offset = reinterpret_cast<intptr_t>(indices); + indices = static_cast<const GLubyte*>(indexBuffer->data()) + offset; + } + + switch (type) + { + case GL_UNSIGNED_BYTE: + first = static_cast<const GLubyte*>(indices)[0]; + last = static_cast<const GLubyte*>(indices)[count - 1]; + break; + case GL_UNSIGNED_SHORT: + first = static_cast<const GLushort*>(indices)[0]; + last = static_cast<const GLushort*>(indices)[count - 1]; + break; + case GL_UNSIGNED_INT: + first = static_cast<const GLuint*>(indices)[0]; + last = static_cast<const GLuint*>(indices)[count - 1]; + break; + default: UNREACHABLE(); + } + + drawClosingLine(first, last); +} + void Context::recordInvalidEnum() { mInvalidEnum = true; @@ -2759,6 +2912,16 @@ bool Context::supportsShaderModel3() const return mSupportsShaderModel3; } +int Context::getMaximumVaryingVectors() const +{ + return mSupportsShaderModel3 ? MAX_VARYING_VECTORS_SM3 : MAX_VARYING_VECTORS_SM2; +} + +int Context::getMaximumFragmentUniformVectors() const +{ + return mSupportsShaderModel3 ? MAX_FRAGMENT_UNIFORM_VECTORS_SM3 : MAX_FRAGMENT_UNIFORM_VECTORS_SM2; +} + int Context::getMaxSupportedSamples() const { return mMaxSupportedSamples; @@ -2788,11 +2951,81 @@ int Context::getNearestSupportedSamples(D3DFORMAT format, int requested) const return -1; } +bool Context::supportsEventQueries() const +{ + return mSupportsEventQueries; +} + bool Context::supportsCompressedTextures() const { return mSupportsCompressedTextures; } +bool Context::supportsFloatTextures() const +{ + return mSupportsFloatTextures; +} + +bool Context::supportsFloatLinearFilter() const +{ + return mSupportsFloatLinearFilter; +} + +bool Context::supportsFloatRenderableTextures() const +{ + return mSupportsFloatRenderableTextures; +} + +bool Context::supportsHalfFloatTextures() const +{ + return mSupportsHalfFloatTextures; +} + +bool Context::supportsHalfFloatLinearFilter() const +{ + return mSupportsHalfFloatLinearFilter; +} + +bool Context::supportsHalfFloatRenderableTextures() const +{ + return mSupportsHalfFloatRenderableTextures; +} + +int Context::getMaximumRenderbufferDimension() const +{ + return mMaxRenderbufferDimension; +} + +int Context::getMaximumTextureDimension() const +{ + return mMaxTextureDimension; +} + +int Context::getMaximumCubeTextureDimension() const +{ + return mMaxCubeTextureDimension; +} + +int Context::getMaximumTextureLevel() const +{ + return mMaxTextureLevel; +} + +bool Context::supportsLuminanceTextures() const +{ + return mSupportsLuminanceTextures; +} + +bool Context::supportsLuminanceAlphaTextures() const +{ + return mSupportsLuminanceAlphaTextures; +} + +bool Context::supports32bitIndices() const +{ + return mSupports32bitIndices; +} + void Context::detachBuffer(GLuint buffer) { // [OpenGL ES 2.0.24] section 2.9 page 22: @@ -2903,7 +3136,7 @@ void Context::detachRenderbuffer(GLuint renderbuffer) Texture *Context::getIncompleteTexture(SamplerType type) { - Texture *t = mIncompleteTextures[type]; + Texture *t = mIncompleteTextures[type].get(); if (t == NULL) { @@ -2939,7 +3172,7 @@ Texture *Context::getIncompleteTexture(SamplerType type) break; } - mIncompleteTextures[type] = t; + mIncompleteTextures[type].set(t); } return t; @@ -2978,7 +3211,7 @@ void Context::setVertexAttrib(GLuint index, const GLfloat *values) mState.vertexAttribute[index].mCurrentValue[2] = values[2]; mState.vertexAttribute[index].mCurrentValue[3] = values[3]; - mVertexDataManager->dirtyCurrentValues(); + mVertexDataManager->dirtyCurrentValue(index); } void Context::initExtensionString() @@ -2988,18 +3221,44 @@ void Context::initExtensionString() mExtensionString += "GL_EXT_read_format_bgra "; mExtensionString += "GL_ANGLE_framebuffer_blit "; mExtensionString += "GL_OES_rgb8_rgba8 "; + mExtensionString += "GL_OES_standard_derivatives "; + + if (supportsEventQueries()) + { + mExtensionString += "GL_NV_fence "; + } if (supportsCompressedTextures()) { mExtensionString += "GL_EXT_texture_compression_dxt1 "; } + if (supportsFloatTextures()) + { + mExtensionString += "GL_OES_texture_float "; + } + + if (supportsHalfFloatTextures()) + { + mExtensionString += "GL_OES_texture_half_float "; + } + + if (supportsFloatLinearFilter()) + { + mExtensionString += "GL_OES_texture_float_linear "; + } + + if (supportsHalfFloatLinearFilter()) + { + mExtensionString += "GL_OES_texture_half_float_linear "; + } + if (getMaxSupportedSamples() != 0) { mExtensionString += "GL_ANGLE_framebuffer_multisample "; } - if (mBufferBackEnd->supportIntIndices()) + if (supports32bitIndices()) { mExtensionString += "GL_OES_element_index_uint "; } @@ -3178,10 +3437,10 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 } bool partialBufferCopy = false; - if (sourceTrimmedRect.bottom - sourceTrimmedRect.top < readFramebuffer->getColorbuffer()->getHeight() || - sourceTrimmedRect.right - sourceTrimmedRect.left < readFramebuffer->getColorbuffer()->getWidth() || - destTrimmedRect.bottom - destTrimmedRect.top < drawFramebuffer->getColorbuffer()->getHeight() || - destTrimmedRect.right - destTrimmedRect.left < drawFramebuffer->getColorbuffer()->getWidth() || + if (sourceTrimmedRect.bottom - sourceTrimmedRect.top < readBufferHeight || + sourceTrimmedRect.right - sourceTrimmedRect.left < readBufferWidth || + destTrimmedRect.bottom - destTrimmedRect.top < drawBufferHeight || + destTrimmedRect.right - destTrimmedRect.left < drawBufferWidth || sourceTrimmedRect.top != 0 || destTrimmedRect.top != 0 || sourceTrimmedRect.left != 0 || destTrimmedRect.left != 0) { partialBufferCopy = true; @@ -3189,7 +3448,11 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 if (mask & GL_COLOR_BUFFER_BIT) { - if (readFramebuffer->getColorbufferType() != drawFramebuffer->getColorbufferType() || + const bool validReadType = readFramebuffer->getColorbufferType() == GL_TEXTURE_2D || + readFramebuffer->getColorbufferType() == GL_RENDERBUFFER; + const bool validDrawType = drawFramebuffer->getColorbufferType() == GL_TEXTURE_2D || + drawFramebuffer->getColorbufferType() == GL_RENDERBUFFER; + if (!validReadType || !validDrawType || readFramebuffer->getColorbuffer()->getD3DFormat() != drawFramebuffer->getColorbuffer()->getD3DFormat()) { ERR("Color buffer format conversion in BlitFramebufferANGLE not supported by this implementation"); diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h index 6bca756..2906664 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h @@ -12,6 +12,7 @@ #define GL_APICALL #include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> #define EGLAPI #include <EGL/egl.h> #include <d3d9.h> @@ -49,19 +50,20 @@ class Stencilbuffer; class DepthStencilbuffer; class VertexDataManager; class IndexDataManager; -class BufferBackEnd; class Blit; +class Fence; enum { - MAX_VERTEX_ATTRIBS = 12, - MAX_VERTEX_UNIFORM_VECTORS = 128, - MAX_VARYING_VECTORS = 8, + MAX_VERTEX_ATTRIBS = 16, + MAX_VERTEX_UNIFORM_VECTORS = 256 - 2, // 256 is the minimum for SM2, and in practice the maximum for DX9. Reserve space for dx_HalfPixelSize and dx_DepthRange. + MAX_VARYING_VECTORS_SM2 = 8, + MAX_VARYING_VECTORS_SM3 = 10, MAX_COMBINED_TEXTURE_IMAGE_UNITS = 16, MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0, MAX_TEXTURE_IMAGE_UNITS = 16, - MAX_FRAGMENT_UNIFORM_VECTORS = 16, - MAX_RENDERBUFFER_SIZE = 4096, // FIXME: Verify + MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Viewport, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers. + MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3, MAX_DRAW_BUFFERS = 1, IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB, @@ -83,32 +85,56 @@ struct Color }; // Helper structure describing a single vertex attribute -class AttributeState +class VertexAttribute { public: - AttributeState() - : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mEnabled(false) + VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false) { - mCurrentValue[0] = 0; - mCurrentValue[1] = 0; - mCurrentValue[2] = 0; - mCurrentValue[3] = 1; + mCurrentValue[0] = 0.0f; + mCurrentValue[1] = 0.0f; + mCurrentValue[2] = 0.0f; + mCurrentValue[3] = 1.0f; } - // From VertexArrayPointer + int typeSize() const + { + switch (mType) + { + case GL_BYTE: return mSize * sizeof(GLbyte); + case GL_UNSIGNED_BYTE: return mSize * sizeof(GLubyte); + case GL_SHORT: return mSize * sizeof(GLshort); + case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort); + case GL_FIXED: return mSize * sizeof(GLfixed); + case GL_FLOAT: return mSize * sizeof(GLfloat); + default: UNREACHABLE(); return mSize * sizeof(GLfloat); + } + } + + GLsizei stride() const + { + return mStride ? mStride : typeSize(); + } + + // From glVertexAttribPointer GLenum mType; GLint mSize; bool mNormalized; - GLsizei mStride; // 0 means natural stride - const void *mPointer; + GLsizei mStride; // 0 means natural stride - BindingPointer<Buffer> mBoundBuffer; // Captured when VertexArrayPointer is called. + union + { + const void *mPointer; + intptr_t mOffset; + }; - bool mEnabled; // From Enable/DisableVertexAttribArray + BindingPointer<Buffer> mBoundBuffer; // Captured when glVertexAttribPointer is called. - float mCurrentValue[4]; // From VertexAttrib4f + bool mArrayEnabled; // From glEnable/DisableVertexAttribArray + float mCurrentValue[4]; // From glVertexAttrib }; +typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS]; + // Helper structure to store all raw state struct State { @@ -157,6 +183,7 @@ struct State GLfloat lineWidth; GLenum generateMipmapHint; + GLenum fragmentShaderDerivativeHint; GLint viewportX; GLint viewportY; @@ -179,14 +206,12 @@ struct State int activeSampler; // Active texture unit selector - GL_TEXTURE0 BindingPointer<Buffer> arrayBuffer; BindingPointer<Buffer> elementArrayBuffer; - BindingPointer<Texture> texture2D; - BindingPointer<Texture> textureCubeMap; GLuint readFramebuffer; GLuint drawFramebuffer; BindingPointer<Renderbuffer> renderbuffer; GLuint currentProgram; - AttributeState vertexAttribute[MAX_VERTEX_ATTRIBS]; + VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS]; BindingPointer<Texture> samplerTexture[SAMPLER_TYPE_COUNT][MAX_TEXTURE_IMAGE_UNITS]; GLint unpackAlignment; @@ -264,6 +289,7 @@ class Context void setLineWidth(GLfloat width); void setGenerateMipmapHint(GLenum hint); + void setFragmentShaderDerivativeHint(GLenum hint); void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height); @@ -280,13 +306,13 @@ class Context GLuint getArrayBufferHandle() const; - void setVertexAttribEnabled(unsigned int attribNum, bool enabled); - const AttributeState &getVertexAttribState(unsigned int attribNum); + void setEnableVertexAttribArray(unsigned int attribNum, bool enabled); + const VertexAttribute &getVertexAttribState(unsigned int attribNum); void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, bool normalized, GLsizei stride, const void *pointer); const void *getVertexAttribPointer(unsigned int attribNum) const; - const AttributeState *getVertexAttribBlock(); + const VertexAttributeArray &getVertexAttributes(); void setUnpackAlignment(GLint alignment); GLint getUnpackAlignment() const; @@ -312,6 +338,10 @@ class Context GLuint createFramebuffer(); void deleteFramebuffer(GLuint framebuffer); + // Fences are owned by the Context. + GLuint createFence(); + void deleteFence(GLuint fence); + void bindArrayBuffer(GLuint buffer); void bindElementArrayBuffer(GLuint buffer); void bindTexture2D(GLuint texture); @@ -328,6 +358,7 @@ class Context void setVertexAttrib(GLuint index, const GLfloat *values); Buffer *getBuffer(GLuint handle); + Fence *getFence(GLuint handle); Shader *getShader(GLuint handle); Program *getProgram(GLuint handle); Texture *getTexture(GLuint handle); @@ -351,20 +382,22 @@ class Context bool applyRenderTarget(bool ignoreViewport); void applyState(GLenum drawMode); - GLenum applyVertexBuffer(GLenum mode, GLint first, GLsizei count, bool *useIndexing, TranslatedIndexData *indexInfo); - GLenum applyVertexBuffer(const TranslatedIndexData &indexInfo); + GLenum applyVertexBuffer(GLint first, GLsizei count); GLenum applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); - GLenum applyCountingIndexBuffer(GLenum mode, GLenum count, TranslatedIndexData *indexInfo); void applyShaders(); void applyTextures(); void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); void clear(GLbitfield mask); void drawArrays(GLenum mode, GLint first, GLsizei count); - void drawElements(GLenum mode, GLsizei count, GLenum type, const void* indices); + void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices); void finish(); void flush(); + // Draw the last segment of a line loop + void drawClosingLine(unsigned int first, unsigned int last); + void drawClosingLine(GLsizei count, GLenum type, const void *indices); + void recordInvalidEnum(); void recordInvalidValue(); void recordInvalidOperation(); @@ -374,10 +407,26 @@ class Context GLenum getError(); bool supportsShaderModel3() const; + int getMaximumVaryingVectors() const; + int getMaximumFragmentUniformVectors() const; + int getMaximumRenderbufferDimension() const; + int getMaximumTextureDimension() const; + int getMaximumCubeTextureDimension() const; + int getMaximumTextureLevel() const; GLsizei getMaxSupportedSamples() const; int getNearestSupportedSamples(D3DFORMAT format, int requested) const; const char *getExtensionString() const; + bool supportsEventQueries() const; bool supportsCompressedTextures() const; + bool supportsFloatTextures() const; + bool supportsFloatLinearFilter() const; + bool supportsFloatRenderableTextures() const; + bool supportsHalfFloatTextures() const; + bool supportsHalfFloatLinearFilter() const; + bool supportsHalfFloatRenderableTextures() const; + bool supportsLuminanceTextures() const; + bool supportsLuminanceAlphaTextures() const; + bool supports32bitIndices() const; void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, @@ -406,25 +455,24 @@ class Context State mState; - Texture2D *mTexture2DZero; - TextureCubeMap *mTextureCubeMapZero; - - Colorbuffer *mColorbufferZero; - DepthStencilbuffer *mDepthStencilbufferZero; + BindingPointer<Texture2D> mTexture2DZero; + BindingPointer<TextureCubeMap> mTextureCubeMapZero; typedef std::map<GLuint, Framebuffer*> FramebufferMap; FramebufferMap mFramebufferMap; + typedef std::map<GLuint, Fence*> FenceMap; + FenceMap mFenceMap; + void initExtensionString(); std::string mExtensionString; - BufferBackEnd *mBufferBackEnd; VertexDataManager *mVertexDataManager; IndexDataManager *mIndexDataManager; Blit *mBlit; - Texture *mIncompleteTextures[SAMPLER_TYPE_COUNT]; + BindingPointer<Texture> mIncompleteTextures[SAMPLER_TYPE_COUNT]; // Recorded errors bool mInvalidEnum; @@ -439,11 +487,26 @@ class Context unsigned int mAppliedRenderTargetSerial; unsigned int mAppliedDepthbufferSerial; unsigned int mAppliedStencilbufferSerial; + bool mDepthStencilInitialized; bool mSupportsShaderModel3; + int mMaxRenderbufferDimension; + int mMaxTextureDimension; + int mMaxCubeTextureDimension; + int mMaxTextureLevel; std::map<D3DFORMAT, bool *> mMultiSampleSupport; GLsizei mMaxSupportedSamples; + bool mSupportsEventQueries; bool mSupportsCompressedTextures; + bool mSupportsFloatTextures; + bool mSupportsFloatLinearFilter; + bool mSupportsFloatRenderableTextures; + bool mSupportsHalfFloatTextures; + bool mSupportsHalfFloatLinearFilter; + bool mSupportsHalfFloatRenderableTextures; + bool mSupportsLuminanceTextures; + bool mSupportsLuminanceAlphaTextures; + bool mSupports32bitIndices; // state caching flags bool mClearStateDirty; diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp new file mode 100644 index 0000000..7fbcb6a --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.cpp @@ -0,0 +1,134 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// Fence.cpp: Implements the gl::Fence class, which supports the GL_NV_fence extension. + +#include "libGLESv2/Fence.h" + +#include "libGLESv2/main.h" + +namespace gl +{ + +Fence::Fence() +{ + mQuery = NULL; + mCondition = GL_NONE; + mStatus = GL_FALSE; +} + +Fence::~Fence() +{ + if (mQuery != NULL) + { + mQuery->Release(); + mQuery = NULL; + } +} + +GLboolean Fence::isFence() +{ + // GL_NV_fence spec: + // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence. + return mQuery != NULL; +} + +void Fence::setFence(GLenum condition) +{ + if (mQuery != NULL) + { + mQuery->Release(); + mQuery = NULL; + } + + if (FAILED(getDevice()->CreateQuery(D3DQUERYTYPE_EVENT, &mQuery))) + { + return error(GL_OUT_OF_MEMORY); + } + + HRESULT result = mQuery->Issue(D3DISSUE_END); + ASSERT(SUCCEEDED(result)); + + mCondition = condition; + mStatus = GL_FALSE; +} + +GLboolean Fence::testFence() +{ + if (mQuery == NULL) + { + return error(GL_INVALID_OPERATION, GL_TRUE); + } + + HRESULT result = mQuery->GetData(NULL, 0, D3DGETDATA_FLUSH); + + if (result == D3DERR_DEVICELOST) + { + return error(GL_OUT_OF_MEMORY, GL_TRUE); + } + + ASSERT(result == S_OK || result == S_FALSE); + mStatus = result == S_OK; + return mStatus; +} + +void Fence::finishFence() +{ + if (mQuery == NULL) + { + return error(GL_INVALID_OPERATION); + } + + while (!testFence()) + { + Sleep(0); + } +} + +void Fence::getFenceiv(GLenum pname, GLint *params) +{ + if (mQuery == NULL) + { + return error(GL_INVALID_OPERATION); + } + + switch (pname) + { + case GL_FENCE_STATUS_NV: + { + // GL_NV_fence spec: + // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV + // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. + if (mStatus) + { + params[0] = GL_TRUE; + return; + } + + HRESULT result = mQuery->GetData(NULL, 0, 0); + + if (result == D3DERR_DEVICELOST) + { + params[0] = GL_TRUE; + return error(GL_OUT_OF_MEMORY); + } + + ASSERT(result == S_OK || result == S_FALSE); + mStatus = result == S_OK; + params[0] = mStatus; + + break; + } + case GL_FENCE_CONDITION_NV: + params[0] = mCondition; + break; + default: + return error(GL_INVALID_ENUM); + break; + } +} + +} diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h new file mode 100644 index 0000000..17bad78 --- /dev/null +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Fence.h @@ -0,0 +1,43 @@ +// +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// Fence.h: Defines the gl::Fence class, which supports the GL_NV_fence extension. + +#ifndef LIBGLESV2_FENCE_H_ +#define LIBGLESV2_FENCE_H_ + +#define GL_APICALL +#include <GLES2/gl2.h> +#include <d3d9.h> + +#include "common/angleutils.h" + +namespace gl +{ + +class Fence +{ + public: + Fence(); + virtual ~Fence(); + + GLboolean isFence(); + void setFence(GLenum condition); + GLboolean testFence(); + void finishFence(); + void getFenceiv(GLenum pname, GLint *params); + + private: + DISALLOW_COPY_AND_ASSIGN(Fence); + + IDirect3DQuery9* mQuery; + GLenum mCondition; + GLboolean mStatus; +}; + +} + +#endif // LIBGLESV2_FENCE_H_ diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp index 5c4bc99..5fe01e0 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Framebuffer.cpp @@ -305,13 +305,32 @@ GLenum Framebuffer::completeness() return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } - if (IsTextureTarget(mColorbufferType)) + if (mColorbufferType == GL_RENDERBUFFER) + { + if (!gl::IsColorRenderable(colorbuffer->getFormat())) + { + return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + } + } + else if (IsTextureTarget(mColorbufferType)) { if (IsCompressed(colorbuffer->getFormat())) { return GL_FRAMEBUFFER_UNSUPPORTED; } + + if (colorbuffer->isFloatingPoint() && (!getContext()->supportsFloatRenderableTextures() || + !getContext()->supportsHalfFloatRenderableTextures())) + { + return GL_FRAMEBUFFER_UNSUPPORTED; + } + + if (colorbuffer->getFormat() == GL_LUMINANCE || colorbuffer->getFormat() == GL_LUMINANCE_ALPHA) + { + return GL_FRAMEBUFFER_UNSUPPORTED; + } } + else UNREACHABLE(); width = colorbuffer->getWidth(); height = colorbuffer->getHeight(); @@ -327,6 +346,11 @@ GLenum Framebuffer::completeness() if (mDepthbufferType != GL_NONE) { + if (mDepthbufferType != GL_RENDERBUFFER) + { + return GL_FRAMEBUFFER_UNSUPPORTED; // Requires GL_OES_depth_texture + } + depthbuffer = getDepthbuffer(); if (!depthbuffer) @@ -357,18 +381,15 @@ GLenum Framebuffer::completeness() { return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; } - - if (IsTextureTarget(mDepthbufferType)) - { - if (IsCompressed(depthbuffer->getFormat())) - { - return GL_FRAMEBUFFER_UNSUPPORTED; - } - } } if (mStencilbufferType != GL_NONE) { + if (mStencilbufferType != GL_RENDERBUFFER) + { + return GL_FRAMEBUFFER_UNSUPPORTED; + } + stencilbuffer = getStencilbuffer(); if (!stencilbuffer) @@ -399,14 +420,6 @@ GLenum Framebuffer::completeness() { return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; } - - if (IsTextureTarget(mStencilbufferType)) - { - if (IsCompressed(stencilbuffer->getFormat())) - { - return GL_FRAMEBUFFER_UNSUPPORTED; - } - } } if (mDepthbufferType == GL_RENDERBUFFER && mStencilbufferType == GL_RENDERBUFFER) @@ -425,8 +438,8 @@ GLenum Framebuffer::completeness() DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *color, DepthStencilbuffer *depthStencil) { mColorbufferType = GL_RENDERBUFFER; - mDepthbufferType = GL_RENDERBUFFER; - mStencilbufferType = GL_RENDERBUFFER; + mDepthbufferType = (depthStencil->getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE; + mStencilbufferType = (depthStencil->getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE; mColorbufferPointer.set(new Renderbuffer(0, color)); @@ -449,6 +462,9 @@ int Framebuffer::getSamples() GLenum DefaultFramebuffer::completeness() { + // The default framebuffer should always be complete + ASSERT(Framebuffer::completeness() == GL_FRAMEBUFFER_COMPLETE); + return GL_FRAMEBUFFER_COMPLETE; } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp index a32bc9f..780c3e3 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp @@ -45,7 +45,7 @@ UniformLocation::UniformLocation(const std::string &name, unsigned int element, { } -Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(manager), mHandle(handle) +Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(manager), mHandle(handle), mSerial(issueSerial()) { mFragmentShader = NULL; mVertexShader = NULL; @@ -63,8 +63,6 @@ Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(man mDeleteStatus = false; mRefCount = 0; - - mSerial = issueSerial(); } Program::~Program() @@ -205,7 +203,7 @@ GLint Program::getSamplerMapping(unsigned int samplerIndex) logicalTextureUnit = mSamplers[samplerIndex].logicalTextureUnit; } - if (logicalTextureUnit < MAX_TEXTURE_IMAGE_UNITS) + if (logicalTextureUnit >= 0 && logicalTextureUnit < MAX_TEXTURE_IMAGE_UNITS) { return logicalTextureUnit; } @@ -243,26 +241,22 @@ void Program::setSamplerDirty(unsigned int samplerIndex, bool dirty) GLint Program::getUniformLocation(const char *name, bool decorated) { - std::string nameStr(name); + std::string _name = decorated ? name : decorate(name); int subscript = 0; - size_t beginB = nameStr.find('['); - size_t endB = nameStr.find(']'); - if (beginB != std::string::npos && endB != std::string::npos) - { - std::string subscrStr = nameStr.substr(beginB + 1, beginB - endB - 1); - nameStr.erase(beginB); - subscript = atoi(subscrStr.c_str()); - } - if (!decorated) + // Strip any trailing array operator and retrieve the subscript + size_t open = _name.find_last_of('['); + size_t close = _name.find_last_of(']'); + if (open != std::string::npos && close == _name.length() - 1) { - nameStr = decorate(nameStr); + subscript = atoi(_name.substr(open + 1).c_str()); + _name.erase(open); } unsigned int numUniforms = mUniformIndex.size(); for (unsigned int location = 0; location < numUniforms; location++) { - if (mUniformIndex[location].name == nameStr && + if (mUniformIndex[location].name == _name && mUniformIndex[location].element == subscript) { return location; @@ -595,7 +589,9 @@ bool Program::setUniform1iv(GLint location, GLsizei count, const GLint *v) Uniform *targetUniform = mUniforms[mUniformIndex[location].index]; targetUniform->dirty = true; - if (targetUniform->type == GL_INT) + if (targetUniform->type == GL_INT || + targetUniform->type == GL_SAMPLER_2D || + targetUniform->type == GL_SAMPLER_CUBE) { int arraySize = targetUniform->arraySize; @@ -949,6 +945,8 @@ void Program::applyUniforms() case GL_FLOAT_MAT2: applyUniformMatrix2fv(location, arraySize, f); break; case GL_FLOAT_MAT3: applyUniformMatrix3fv(location, arraySize, f); break; case GL_FLOAT_MAT4: applyUniformMatrix4fv(location, arraySize, f); break; + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: case GL_INT: applyUniform1iv(location, arraySize, i); break; case GL_INT_VEC2: applyUniform2iv(location, arraySize, i); break; case GL_INT_VEC3: applyUniform3iv(location, arraySize, i); break; @@ -1001,6 +999,9 @@ ID3DXBuffer *Program::compileToBinary(const char *hlsl, const char *profile, ID3 // Returns the number of used varying registers, or -1 if unsuccesful int Program::packVaryings(const Varying *packing[][4]) { + Context *context = getContext(); + const int maxVaryingVectors = context->getMaximumVaryingVectors(); + for (VaryingList::iterator varying = mFragmentShader->varyings.begin(); varying != mFragmentShader->varyings.end(); varying++) { int n = VariableRowCount(varying->type) * varying->size; @@ -1009,7 +1010,7 @@ int Program::packVaryings(const Varying *packing[][4]) if (m == 2 || m == 3 || m == 4) { - for (int r = 0; r <= MAX_VARYING_VECTORS - n && !success; r++) + for (int r = 0; r <= maxVaryingVectors - n && !success; r++) { bool available = true; @@ -1043,7 +1044,7 @@ int Program::packVaryings(const Varying *packing[][4]) if (!success && m == 2) { - for (int r = MAX_VARYING_VECTORS - n; r >= 0 && !success; r--) + for (int r = maxVaryingVectors - n; r >= 0 && !success; r--) { bool available = true; @@ -1080,7 +1081,7 @@ int Program::packVaryings(const Varying *packing[][4]) { int space[4] = {0}; - for (int y = 0; y < MAX_VARYING_VECTORS; y++) + for (int y = 0; y < maxVaryingVectors; y++) { for (int x = 0; x < 4; x++) { @@ -1100,7 +1101,7 @@ int Program::packVaryings(const Varying *packing[][4]) if (space[column] > n) { - for (int r = 0; r < MAX_VARYING_VECTORS; r++) + for (int r = 0; r < maxVaryingVectors; r++) { if (!packing[r][column]) { @@ -1133,7 +1134,7 @@ int Program::packVaryings(const Varying *packing[][4]) // Return the number of used registers int registers = 0; - for (int r = 0; r < MAX_VARYING_VECTORS; r++) + for (int r = 0; r < maxVaryingVectors; r++) { if (packing[r][0] || packing[r][1] || packing[r][2] || packing[r][3]) { @@ -1151,7 +1152,7 @@ bool Program::linkVaryings() return false; } - const Varying *packing[MAX_VARYING_VECTORS][4] = {NULL}; + const Varying *packing[MAX_VARYING_VECTORS_SM3][4] = {NULL}; int registers = packVaryings(packing); if (registers < 0) @@ -1159,7 +1160,11 @@ bool Program::linkVaryings() return false; } - if (registers == MAX_VARYING_VECTORS && mFragmentShader->mUsesFragCoord) + Context *context = getContext(); + const bool sm3 = context->supportsShaderModel3(); + const int maxVaryingVectors = context->getMaximumVaryingVectors(); + + if (registers == maxVaryingVectors && mFragmentShader->mUsesFragCoord) { appendToInfoLog("No varying registers left to support gl_FragCoord"); @@ -1197,8 +1202,6 @@ bool Program::linkVaryings() } } - Context *context = getContext(); - bool sm3 = context->supportsShaderModel3(); std::string varyingSemantic = (sm3 ? "COLOR" : "TEXCOORD"); mVertexHLSL += "struct VS_INPUT\n" @@ -1371,6 +1374,9 @@ bool Program::linkVaryings() if (mFragmentShader->mUsesFragCoord) { mPixelHLSL += " float4 gl_FragCoord : " + varyingSemantic + str(registers) + ";\n"; + if (sm3) { + mPixelHLSL += " float2 dx_VPos : VPOS;\n"; + } } if (mFragmentShader->mUsesPointCoord && sm3) @@ -1395,10 +1401,15 @@ bool Program::linkVaryings() if (mFragmentShader->mUsesFragCoord) { - mPixelHLSL += " float rhw = 1.0 / input.gl_FragCoord.w;\n" - " gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_Viewport.x + dx_Viewport.z;\n" - " gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_Viewport.y + dx_Viewport.w;\n" - " gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * dx_Depth.x + dx_Depth.y;\n" + mPixelHLSL += " float rhw = 1.0 / input.gl_FragCoord.w;\n"; + if (sm3) { + mPixelHLSL += " gl_FragCoord.x = input.dx_VPos.x;\n" + " gl_FragCoord.y = input.dx_VPos.y;\n"; + } else { + mPixelHLSL += " gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_Viewport.x + dx_Viewport.z;\n" + " gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_Viewport.y + dx_Viewport.w;\n"; + } + mPixelHLSL += " gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * dx_Depth.x + dx_Depth.y;\n" " gl_FragCoord.w = rhw;\n"; } @@ -1525,9 +1536,7 @@ void Program::link() // these uniforms are searched as already-decorated because gl_ and dx_ // are reserved prefixes, and do not receive additional decoration - mDepthRangeNearLocation = getUniformLocation("gl_DepthRange.near", true); - mDepthRangeFarLocation = getUniformLocation("gl_DepthRange.far", true); - mDepthRangeDiffLocation = getUniformLocation("gl_DepthRange.diff", true); + mDxDepthRangeLocation = getUniformLocation("dx_DepthRange", true); mDxDepthLocation = getUniformLocation("dx_Depth", true); mDxViewportLocation = getUniformLocation("dx_Viewport", true); mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize", true); @@ -1650,32 +1659,38 @@ bool Program::defineUniform(const D3DXHANDLE &constantHandle, const D3DXCONSTANT { if (constantDescription.RegisterSet == D3DXRS_SAMPLER) { - unsigned int samplerIndex = constantDescription.RegisterIndex; - - assert(samplerIndex < sizeof(mSamplers)/sizeof(mSamplers[0])); + for (unsigned int samplerIndex = constantDescription.RegisterIndex; samplerIndex < constantDescription.RegisterIndex + constantDescription.RegisterCount; samplerIndex++) + { + ASSERT(samplerIndex < sizeof(mSamplers)/sizeof(mSamplers[0])); - mSamplers[samplerIndex].active = true; - mSamplers[samplerIndex].type = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? SAMPLER_CUBE : SAMPLER_2D; - mSamplers[samplerIndex].logicalTextureUnit = 0; - mSamplers[samplerIndex].dirty = true; + mSamplers[samplerIndex].active = true; + mSamplers[samplerIndex].type = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? SAMPLER_CUBE : SAMPLER_2D; + mSamplers[samplerIndex].logicalTextureUnit = 0; + mSamplers[samplerIndex].dirty = true; + } } switch(constantDescription.Class) { case D3DXPC_STRUCT: { - for (unsigned int field = 0; field < constantDescription.StructMembers; field++) + for (unsigned int arrayIndex = 0; arrayIndex < constantDescription.Elements; arrayIndex++) { - D3DXHANDLE fieldHandle = mConstantTablePS->GetConstant(constantHandle, field); + for (unsigned int field = 0; field < constantDescription.StructMembers; field++) + { + D3DXHANDLE fieldHandle = mConstantTablePS->GetConstant(constantHandle, field); - D3DXCONSTANT_DESC fieldDescription; - UINT descriptionCount = 1; + D3DXCONSTANT_DESC fieldDescription; + UINT descriptionCount = 1; - mConstantTablePS->GetConstantDesc(fieldHandle, &fieldDescription, &descriptionCount); + mConstantTablePS->GetConstantDesc(fieldHandle, &fieldDescription, &descriptionCount); - if (!defineUniform(fieldHandle, fieldDescription, name + constantDescription.Name + ".")) - { - return false; + std::string structIndex = (constantDescription.Elements > 1) ? ("[" + str(arrayIndex) + "]") : ""; + + if (!defineUniform(fieldHandle, fieldDescription, name + constantDescription.Name + structIndex + ".")) + { + return false; + } } } @@ -1737,10 +1752,16 @@ Uniform *Program::createUniform(const D3DXCONSTANT_DESC &constantDescription, st switch (constantDescription.Type) { case D3DXPT_SAMPLER2D: + switch (constantDescription.Columns) + { + case 1: return new Uniform(GL_SAMPLER_2D, name, constantDescription.Elements); + default: UNREACHABLE(); + } + break; case D3DXPT_SAMPLERCUBE: switch (constantDescription.Columns) { - case 1: return new Uniform(GL_INT, name, constantDescription.Elements); + case 1: return new Uniform(GL_SAMPLER_CUBE, name, constantDescription.Elements); default: UNREACHABLE(); } break; @@ -2205,14 +2226,14 @@ bool Program::applyUniform1iv(GLint location, GLsizei count, const GLint *v) { unsigned int firstIndex = mConstantTablePS->GetSamplerIndex(constantPS); - for (unsigned int samplerIndex = firstIndex; samplerIndex < firstIndex + count; samplerIndex++) + for (int i = 0; i < count; i++) { - GLint mappedSampler = v[0]; + unsigned int samplerIndex = firstIndex + i; - if (samplerIndex >= 0 && samplerIndex < MAX_TEXTURE_IMAGE_UNITS) + if (samplerIndex < MAX_TEXTURE_IMAGE_UNITS) { ASSERT(mSamplers[samplerIndex].active); - mSamplers[samplerIndex].logicalTextureUnit = mappedSampler; + mSamplers[samplerIndex].logicalTextureUnit = v[i]; mSamplers[samplerIndex].dirty = true; } } @@ -2371,6 +2392,7 @@ void Program::resetInfoLog() if (mInfoLog) { delete [] mInfoLog; + mInfoLog = NULL; } } @@ -2434,9 +2456,7 @@ void Program::unlink(bool destroy) mUniforms.pop_back(); } - mDepthRangeDiffLocation = -1; - mDepthRangeNearLocation = -1; - mDepthRangeFarLocation = -1; + mDxDepthRangeLocation = -1; mDxDepthLocation = -1; mDxViewportLocation = -1; mDxHalfPixelSizeLocation = -1; @@ -2562,16 +2582,22 @@ void Program::getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shade void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) { - unsigned int attribute = 0; - for (unsigned int i = 0; i < index; i++) + // Skip over inactive attributes + unsigned int activeAttribute = 0; + unsigned int attribute; + for (attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++) { - do + if (mLinkedAttribute[attribute].name.empty()) { - attribute++; + continue; + } - ASSERT(attribute < MAX_VERTEX_ATTRIBS); // index must be smaller than getActiveAttributeCount() + if (activeAttribute == index) + { + break; } - while (mLinkedAttribute[attribute].name.empty()); + + activeAttribute++; } if (bufsize > 0) @@ -2624,18 +2650,26 @@ GLint Program::getActiveAttributeMaxLength() void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) { - unsigned int uniform = 0; - for (unsigned int i = 0; i < index; i++) + // Skip over internal uniforms + unsigned int activeUniform = 0; + unsigned int uniform; + for (uniform = 0; uniform < mUniforms.size(); uniform++) { - do + if (mUniforms[uniform]->name.substr(0, 3) == "dx_") { - uniform++; + continue; + } - ASSERT(uniform < mUniforms.size()); // index must be smaller than getActiveUniformCount() + if (activeUniform == index) + { + break; } - while (mUniforms[uniform]->name.substr(0, 3) == "dx_"); + + activeUniform++; } + ASSERT(uniform < mUniforms.size()); // index must be smaller than getActiveUniformCount() + if (bufsize > 0) { std::string string = undecorate(mUniforms[uniform]->name); @@ -2763,19 +2797,9 @@ void Program::getConstantHandles(Uniform *targetUniform, D3DXHANDLE *constantPS, *constantVS = targetUniform->vsHandle; } -GLint Program::getDepthRangeDiffLocation() const -{ - return mDepthRangeDiffLocation; -} - -GLint Program::getDepthRangeNearLocation() const -{ - return mDepthRangeNearLocation; -} - -GLint Program::getDepthRangeFarLocation() const +GLint Program::getDxDepthRangeLocation() const { - return mDepthRangeFarLocation; + return mDxDepthRangeLocation; } GLint Program::getDxDepthLocation() const diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h index 3021b7a..e9c149e 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Program.h @@ -94,9 +94,7 @@ class Program bool getUniformfv(GLint location, GLfloat *params); bool getUniformiv(GLint location, GLint *params); - GLint getDepthRangeDiffLocation() const; - GLint getDepthRangeNearLocation() const; - GLint getDepthRangeFarLocation() const; + GLint getDxDepthRangeLocation() const; GLint getDxDepthLocation() const; GLint getDxViewportLocation() const; GLint getDxHalfPixelSizeLocation() const; @@ -204,9 +202,7 @@ class Program typedef std::vector<UniformLocation> UniformIndex; UniformIndex mUniformIndex; - GLint mDepthRangeDiffLocation; - GLint mDepthRangeNearLocation; - GLint mDepthRangeFarLocation; + GLint mDxDepthRangeLocation; GLint mDxDepthLocation; GLint mDxViewportLocation; GLint mDxHalfPixelSizeLocation; @@ -220,7 +216,7 @@ class Program unsigned int mRefCount; - unsigned int mSerial; + const unsigned int mSerial; static unsigned int mCurrentSerial; diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/RefCountObject.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/RefCountObject.cpp index e3fd36e..2de1e71 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/RefCountObject.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/RefCountObject.cpp @@ -22,6 +22,7 @@ RefCountObject::RefCountObject(GLuint id) RefCountObject::~RefCountObject() { + ASSERT(mRefCount == 0); } void RefCountObject::addRef() const diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp index 0eb4637..6e4494b 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.cpp @@ -11,6 +11,7 @@ #include "libGLESv2/Renderbuffer.h" #include "libGLESv2/main.h" +#include "libGLESv2/Texture.h" #include "libGLESv2/utilities.h" namespace gl @@ -86,9 +87,13 @@ void Renderbuffer::setStorage(RenderbufferStorage *newStorage) mStorage = newStorage; } -RenderbufferStorage::RenderbufferStorage() +RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerial()) { - mSerial = issueSerial(); + mWidth = 0; + mHeight = 0; + mFormat = GL_RGBA4; + mD3DFormat = D3DFMT_A8R8G8B8; + mSamples = 0; } RenderbufferStorage::~RenderbufferStorage() @@ -141,6 +146,11 @@ GLenum RenderbufferStorage::getFormat() const return mFormat; } +bool RenderbufferStorage::isFloatingPoint() const +{ + return false; // no floating point renderbuffers +} + D3DFORMAT RenderbufferStorage::getD3DFormat() const { return mD3DFormat; @@ -171,14 +181,17 @@ Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(render renderTarget->GetDesc(&description); setSize(description.Width, description.Height); + mFormat = dx2es::ConvertBackBufferFormat(description.Format); mD3DFormat = description.Format; mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType); } - else - { - mD3DFormat = D3DFMT_UNKNOWN; - mSamples = 0; - } +} + +Colorbuffer::Colorbuffer(const Texture* texture) : mRenderTarget(NULL) +{ + setSize(texture->getWidth(), texture->getHeight()); + mD3DFormat = texture->getD3DFormat(); + mSamples = 0; } Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) @@ -218,13 +231,6 @@ Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) mD3DFormat = requestedFormat; mSamples = supportedSamples; } - else - { - setSize(0, 0); - mFormat = GL_RGBA4; - mD3DFormat = D3DFMT_UNKNOWN; - mSamples = 0; - } } Colorbuffer::~Colorbuffer() @@ -307,15 +313,10 @@ DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepth depthStencil->GetDesc(&description); setSize(description.Width, description.Height); - mFormat = (description.Format == D3DFMT_D16 ? GL_DEPTH_COMPONENT16 : GL_DEPTH24_STENCIL8_OES); + mFormat = dx2es::ConvertDepthStencilFormat(description.Format); mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType); mD3DFormat = description.Format; } - else - { - mD3DFormat = D3DFMT_UNKNOWN; - mSamples = 0; - } } DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) @@ -352,13 +353,6 @@ DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) mD3DFormat = D3DFMT_D24S8; mSamples = supportedSamples; } - else - { - setSize(0, 0); - mFormat = GL_RGBA4; //default format - mD3DFormat = D3DFMT_UNKNOWN; - mSamples = 0; - } } DepthStencilbuffer::~DepthStencilbuffer() diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h index cb8c06a..98510c2 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Renderbuffer.h @@ -21,6 +21,7 @@ namespace gl { + class Texture; // A class derived from RenderbufferStorage is created whenever glRenderbufferStorage // is called. The specific concrete type depends on whether the internal format is @@ -42,6 +43,7 @@ class RenderbufferStorage virtual int getWidth() const; virtual int getHeight() const; virtual GLenum getFormat() const; + virtual bool isFloatingPoint() const; D3DFORMAT getD3DFormat() const; GLsizei getSamples() const; unsigned int getSerial() const; @@ -53,7 +55,7 @@ class RenderbufferStorage GLenum mFormat; D3DFORMAT mD3DFormat; GLsizei mSamples; - unsigned int mSerial; + const unsigned int mSerial; private: DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage); @@ -100,6 +102,7 @@ class Colorbuffer : public RenderbufferStorage { public: explicit Colorbuffer(IDirect3DSurface9 *renderTarget); + explicit Colorbuffer(const Texture* texture); Colorbuffer(int width, int height, GLenum format, GLsizei samples); ~Colorbuffer(); diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp index b73ef2a..4c969d6 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Shader.cpp @@ -34,19 +34,22 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso if (result) { - TBuiltInResource resources; - ShInitBuiltInResource(&resources); + ShBuiltInResources resources; + ShInitBuiltInResources(&resources); + Context *context = getContext(); + resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS; resources.MaxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS; - resources.MaxVaryingVectors = MAX_VARYING_VECTORS; + resources.MaxVaryingVectors = context->getMaximumVaryingVectors(); resources.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; resources.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; - resources.MaxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS; + resources.MaxFragmentUniformVectors = context->getMaximumFragmentUniformVectors(); resources.MaxDrawBuffers = MAX_DRAW_BUFFERS; + resources.OES_standard_derivatives = 1; - mFragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecGLES2, &resources); - mVertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecGLES2, &resources); + mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources); + mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, &resources); } } @@ -240,7 +243,7 @@ void Shader::parseVaryings() char varyingType[256]; char varyingName[256]; - int matches = sscanf(input, "static %s %s", varyingType, varyingName); + int matches = sscanf(input, "static %255s %255s", varyingType, varyingName); if (matches != 2) { @@ -280,21 +283,23 @@ void Shader::compileToHLSL(void *compiler) delete[] mInfoLog; mInfoLog = NULL; - int result = ShCompile(compiler, &mSource, 1, EShOptNone, EDebugOpNone); - const char *obj = ShGetObjectCode(compiler); - const char *info = ShGetInfoLog(compiler); + int result = ShCompile(compiler, &mSource, 1, SH_OBJECT_CODE); if (result) { - mHlsl = new char[strlen(obj) + 1]; - strcpy(mHlsl, obj); + int objCodeLen = 0; + ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &objCodeLen); + mHlsl = new char[objCodeLen]; + ShGetObjectCode(compiler, mHlsl); TRACE("\n%s", mHlsl); } else { - mInfoLog = new char[strlen(info) + 1]; - strcpy(mInfoLog, info); + int infoLogLen = 0; + ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &infoLogLen); + mInfoLog = new char[infoLogLen]; + ShGetInfoLog(compiler, mInfoLog); TRACE("\n%s", mInfoLog); } @@ -468,7 +473,7 @@ void VertexShader::parseAttributes() char attributeType[256]; char attributeName[256]; - int matches = sscanf(input, "static %s _%s", attributeType, attributeName); + int matches = sscanf(input, "static %255s _%255s", attributeType, attributeName); if (matches != 2) { diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp index 2e0b1e3..7c040f8 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp @@ -10,6 +10,8 @@ #include "libGLESv2/Texture.h" +#include <d3dx9tex.h> + #include <algorithm> #include "common/debug.h" @@ -45,6 +47,7 @@ Texture::Texture(GLuint id) : RefCountObject(id) mDirtyMetaData = true; mDirty = true; mIsRenderable = false; + mType = GL_UNSIGNED_BYTE; mBaseTexture = NULL; } @@ -174,86 +177,171 @@ GLuint Texture::getHeight() const return mHeight; } +bool Texture::isFloatingPoint() const +{ + return (mType == GL_FLOAT || mType == GL_HALF_FLOAT_OES); +} + +bool Texture::isRenderableFormat() const +{ + D3DFORMAT format = getD3DFormat(); + + switch(format) + { + case D3DFMT_L8: + case D3DFMT_A8L8: + case D3DFMT_DXT1: + return false; + case D3DFMT_A8R8G8B8: + case D3DFMT_X8R8G8B8: + case D3DFMT_A16B16G16R16F: + case D3DFMT_A32B32G32R32F: + return true; + default: + UNREACHABLE(); + } + + return false; +} + // Selects an internal Direct3D 9 format for storing an Image -D3DFORMAT Texture::selectFormat(GLenum format) +D3DFORMAT Texture::selectFormat(GLenum format, GLenum type) { if (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { return D3DFMT_DXT1; } - else + else if (type == GL_FLOAT) + { + return D3DFMT_A32B32G32R32F; + } + else if (type == GL_HALF_FLOAT_OES) { + return D3DFMT_A16B16G16R16F; + } + else if (type == GL_UNSIGNED_BYTE) + { + if (format == GL_LUMINANCE && getContext()->supportsLuminanceTextures()) + { + return D3DFMT_L8; + } + else if (format == GL_LUMINANCE_ALPHA && getContext()->supportsLuminanceAlphaTextures()) + { + return D3DFMT_A8L8; + } + else if (format == GL_RGB) + { + return D3DFMT_X8R8G8B8; + } + return D3DFMT_A8R8G8B8; } -} -int Texture::imagePitch(const Image &img) const -{ - return img.width * 4; + return D3DFMT_A8R8G8B8; } // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input -// into the BGRA8 pixel rectangle at output with outputPitch bytes in between each line. +// into the target pixel rectangle at output with outputPitch bytes in between each line. void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, - GLint unpackAlignment, const void *input, size_t outputPitch, void *output) const + GLint unpackAlignment, const void *input, size_t outputPitch, void *output, D3DSURFACE_DESC *description) const { GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment); - switch (format) + switch (type) { - case GL_ALPHA: - loadAlphaImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); - break; - - case GL_LUMINANCE: - loadLuminanceImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); - break; - - case GL_LUMINANCE_ALPHA: - loadLuminanceAlphaImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); - break; - - case GL_RGB: - switch (type) + case GL_UNSIGNED_BYTE: + switch (format) { - case GL_UNSIGNED_BYTE: + case GL_ALPHA: + loadAlphaImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_LUMINANCE: + loadLuminanceImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output, description->Format == D3DFMT_L8); + break; + case GL_LUMINANCE_ALPHA: + loadLuminanceAlphaImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output, description->Format == D3DFMT_A8L8); + break; + case GL_RGB: loadRGBUByteImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); break; - - case GL_UNSIGNED_SHORT_5_6_5: - loadRGB565ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + case GL_RGBA: + loadRGBAUByteImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_BGRA_EXT: + loadBGRAImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); break; - default: UNREACHABLE(); } break; - - case GL_RGBA: - switch (type) + case GL_UNSIGNED_SHORT_5_6_5: + switch (format) { - case GL_UNSIGNED_BYTE: - loadRGBAUByteImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + case GL_RGB: + loadRGB565ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); break; - - case GL_UNSIGNED_SHORT_4_4_4_4: + default: UNREACHABLE(); + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + switch (format) + { + case GL_RGBA: loadRGBA4444ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); break; - - case GL_UNSIGNED_SHORT_5_5_5_1: + default: UNREACHABLE(); + } + break; + case GL_UNSIGNED_SHORT_5_5_5_1: + switch (format) + { + case GL_RGBA: loadRGBA5551ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); break; - default: UNREACHABLE(); } break; - case GL_BGRA_EXT: - switch (type) + case GL_FLOAT: + switch (format) { - case GL_UNSIGNED_BYTE: - loadBGRAImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D + case GL_ALPHA: + loadAlphaFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_LUMINANCE: + loadLuminanceFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_LUMINANCE_ALPHA: + loadLuminanceAlphaFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_RGB: + loadRGBFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_RGBA: + loadRGBAFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + default: UNREACHABLE(); + } + break; + case GL_HALF_FLOAT_OES: + switch (format) + { + // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D + case GL_ALPHA: + loadAlphaHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_LUMINANCE: + loadLuminanceHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_LUMINANCE_ALPHA: + loadLuminanceAlphaHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_RGB: + loadRGBHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case GL_RGBA: + loadRGBAHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); break; - default: UNREACHABLE(); } break; @@ -281,36 +369,174 @@ void Texture::loadAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GL } } +void Texture::loadAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const float *source = NULL; + float *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16); + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = 0; + dest[4 * x + 1] = 0; + dest[4 * x + 2] = 0; + dest[4 * x + 3] = source[x]; + } + } +} + +void Texture::loadAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const unsigned short *source = NULL; + unsigned short *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 8); + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = 0; + dest[4 * x + 1] = 0; + dest[4 * x + 2] = 0; + dest[4 * x + 3] = source[x]; + } + } +} + void Texture::loadLuminanceImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, - size_t inputPitch, const void *input, size_t outputPitch, void *output) const + size_t inputPitch, const void *input, size_t outputPitch, void *output, bool native) const { + const int destBytesPerPixel = native? 1: 4; const unsigned char *source = NULL; unsigned char *dest = NULL; for (int y = 0; y < height; y++) { source = static_cast<const unsigned char*>(input) + y * inputPitch; - dest = static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 4; + dest = static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * destBytesPerPixel; + + if (!native) // BGRA8 destination format + { + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = source[x]; + dest[4 * x + 1] = source[x]; + dest[4 * x + 2] = source[x]; + dest[4 * x + 3] = 0xFF; + } + } + else // L8 destination format + { + memcpy(dest, source, width); + } + } +} + +void Texture::loadLuminanceFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const float *source = NULL; + float *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16); for (int x = 0; x < width; x++) { dest[4 * x + 0] = source[x]; dest[4 * x + 1] = source[x]; dest[4 * x + 2] = source[x]; - dest[4 * x + 3] = 0xFF; + dest[4 * x + 3] = 1.0f; + } + } +} + +void Texture::loadLuminanceHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const unsigned short *source = NULL; + unsigned short *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 8); + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = source[x]; + dest[4 * x + 1] = source[x]; + dest[4 * x + 2] = source[x]; + dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1 } } } void Texture::loadLuminanceAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, - size_t inputPitch, const void *input, size_t outputPitch, void *output) const + size_t inputPitch, const void *input, size_t outputPitch, void *output, bool native) const { + const int destBytesPerPixel = native? 2: 4; const unsigned char *source = NULL; unsigned char *dest = NULL; for (int y = 0; y < height; y++) { source = static_cast<const unsigned char*>(input) + y * inputPitch; - dest = static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 4; + dest = static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * destBytesPerPixel; + + if (!native) // BGRA8 destination format + { + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = source[2*x+0]; + dest[4 * x + 1] = source[2*x+0]; + dest[4 * x + 2] = source[2*x+0]; + dest[4 * x + 3] = source[2*x+1]; + } + } + else + { + memcpy(dest, source, width * 2); + } + } +} + +void Texture::loadLuminanceAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const float *source = NULL; + float *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16); + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = source[2*x+0]; + dest[4 * x + 1] = source[2*x+0]; + dest[4 * x + 2] = source[2*x+0]; + dest[4 * x + 3] = source[2*x+1]; + } + } +} + +void Texture::loadLuminanceAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const unsigned short *source = NULL; + unsigned short *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 8); for (int x = 0; x < width; x++) { dest[4 * x + 0] = source[2*x+0]; @@ -362,6 +588,46 @@ void Texture::loadRGB565ImageData(GLint xoffset, GLint yoffset, GLsizei width, G } } +void Texture::loadRGBFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const float *source = NULL; + float *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16); + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = source[x * 3 + 0]; + dest[4 * x + 1] = source[x * 3 + 1]; + dest[4 * x + 2] = source[x * 3 + 2]; + dest[4 * x + 3] = 1.0f; + } + } +} + +void Texture::loadRGBHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const unsigned short *source = NULL; + unsigned short *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 8); + for (int x = 0; x < width; x++) + { + dest[4 * x + 0] = source[x * 3 + 0]; + dest[4 * x + 1] = source[x * 3 + 1]; + dest[4 * x + 2] = source[x * 3 + 2]; + dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1 + } + } +} + void Texture::loadRGBAUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const { @@ -424,6 +690,34 @@ void Texture::loadRGBA5551ImageData(GLint xoffset, GLint yoffset, GLsizei width, } } +void Texture::loadRGBAFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const float *source = NULL; + float *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); + dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16); + memcpy(dest, source, width * 16); + } +} + +void Texture::loadRGBAHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const unsigned char *source = NULL; + unsigned char *dest = NULL; + + for (int y = 0; y < height; y++) + { + source = static_cast<const unsigned char*>(input) + y * inputPitch; + dest = static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 8; + memcpy(dest, source, width * 8); + } +} + void Texture::loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const { @@ -438,7 +732,7 @@ void Texture::loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs } } -void Texture::createSurface(GLsizei width, GLsizei height, GLenum format, Image *img) +void Texture::createSurface(GLsizei width, GLsizei height, GLenum format, GLenum type, Image *img) { IDirect3DTexture9 *newTexture = NULL; IDirect3DSurface9 *newSurface = NULL; @@ -465,7 +759,7 @@ void Texture::createSurface(GLsizei width, GLsizei height, GLenum format, Image levelToFetch = upsampleCount; } - HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, selectFormat(format), + HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, selectFormat(format, type), D3DPOOL_SYSTEMMEM, &newTexture, NULL); if (FAILED(result)) @@ -488,10 +782,13 @@ void Texture::createSurface(GLsizei width, GLsizei height, GLenum format, Image void Texture::setImage(GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img) { - createSurface(width, height, format, img); + createSurface(width, height, format, type, img); if (pixels != NULL && img->surface != NULL) { + D3DSURFACE_DESC description; + img->surface->GetDesc(&description); + D3DLOCKED_RECT locked; HRESULT result = img->surface->LockRect(&locked, NULL, 0); @@ -499,7 +796,7 @@ void Texture::setImage(GLsizei width, GLsizei height, GLenum format, GLenum type if (SUCCEEDED(result)) { - loadImageData(0, 0, width, height, format, type, unpackAlignment, pixels, locked.Pitch, locked.pBits); + loadImageData(0, 0, width, height, format, type, unpackAlignment, pixels, locked.Pitch, locked.pBits, &description); img->surface->UnlockRect(); } @@ -511,7 +808,7 @@ void Texture::setImage(GLsizei width, GLsizei height, GLenum format, GLenum type void Texture::setCompressedImage(GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, Image *img) { - createSurface(width, height, format, img); + createSurface(width, height, format, GL_UNSIGNED_BYTE, img); if (pixels != NULL && img->surface != NULL) { @@ -540,18 +837,30 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig return false; } - D3DLOCKED_RECT locked; - HRESULT result = img->surface->LockRect(&locked, NULL, 0); - - ASSERT(SUCCEEDED(result)); + if (!img->surface) + { + createSurface(img->width, img->height, format, type, img); + } - if (SUCCEEDED(result)) + if (pixels != NULL && img->surface != NULL) { - loadImageData(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, locked.Pitch, locked.pBits); - img->surface->UnlockRect(); + D3DSURFACE_DESC description; + img->surface->GetDesc(&description); + + D3DLOCKED_RECT locked; + HRESULT result = img->surface->LockRect(&locked, NULL, 0); + + ASSERT(SUCCEEDED(result)); + + if (SUCCEEDED(result)) + { + loadImageData(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, locked.Pitch, locked.pBits, &description); + img->surface->UnlockRect(); + } + + img->dirty = true; } - img->dirty = true; return true; } @@ -569,32 +878,215 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL return false; } - RECT updateRegion; - updateRegion.left = xoffset; - updateRegion.right = xoffset + width; - updateRegion.bottom = yoffset + height; - updateRegion.top = yoffset; + if (!img->surface) + { + createSurface(img->width, img->height, format, GL_UNSIGNED_BYTE, img); + } + + if (pixels != NULL && img->surface != NULL) + { + RECT updateRegion; + updateRegion.left = xoffset; + updateRegion.right = xoffset + width; + updateRegion.bottom = yoffset + height; + updateRegion.top = yoffset; - D3DLOCKED_RECT locked; - HRESULT result = img->surface->LockRect(&locked, &updateRegion, 0); + D3DLOCKED_RECT locked; + HRESULT result = img->surface->LockRect(&locked, &updateRegion, 0); - ASSERT(SUCCEEDED(result)); + ASSERT(SUCCEEDED(result)); - if (SUCCEEDED(result)) - { - GLsizei inputPitch = ComputeCompressedPitch(width, format); - int rows = imageSize / inputPitch; - for (int i = 0; i < rows; ++i) + if (SUCCEEDED(result)) { - memcpy((void*)((BYTE*)locked.pBits + i * locked.Pitch), (void*)((BYTE*)pixels + i * inputPitch), inputPitch); + GLsizei inputPitch = ComputeCompressedPitch(width, format); + int rows = imageSize / inputPitch; + for (int i = 0; i < rows; ++i) + { + memcpy((void*)((BYTE*)locked.pBits + i * locked.Pitch), (void*)((BYTE*)pixels + i * inputPitch), inputPitch); + } + img->surface->UnlockRect(); } - img->surface->UnlockRect(); + + img->dirty = true; } - img->dirty = true; return true; } +// This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats +void Texture::copyNonRenderable(Image *image, GLenum internalFormat, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget) +{ + IDirect3DDevice9 *device = getDevice(); + IDirect3DSurface9 *surface = NULL; + D3DSURFACE_DESC description; + renderTarget->GetDesc(&description); + + HRESULT result = device->CreateOffscreenPlainSurface(description.Width, description.Height, description.Format, D3DPOOL_SYSTEMMEM, &surface, NULL); + + if (!SUCCEEDED(result)) + { + ERR("Could not create matching destination surface."); + return error(GL_OUT_OF_MEMORY); + } + + result = device->GetRenderTargetData(renderTarget, surface); + + if (!SUCCEEDED(result)) + { + ERR("GetRenderTargetData unexpectedly failed."); + surface->Release(); + return error(GL_OUT_OF_MEMORY); + } + + D3DLOCKED_RECT sourceLock = {0}; + RECT sourceRect = {x, y, x + width, y + height}; + result = surface->LockRect(&sourceLock, &sourceRect, 0); + + if (FAILED(result)) + { + ERR("Failed to lock the source surface (rectangle might be invalid)."); + surface->UnlockRect(); + surface->Release(); + return error(GL_OUT_OF_MEMORY); + } + + if (!image->surface) + { + createSurface(width, height, internalFormat, mType, image); + } + + if (image->surface == NULL) + { + ERR("Failed to create an image surface."); + surface->UnlockRect(); + surface->Release(); + return error(GL_OUT_OF_MEMORY); + } + + D3DLOCKED_RECT destLock = {0}; + RECT destRect = {xoffset, yoffset, xoffset + width, yoffset + height}; + result = image->surface->LockRect(&destLock, &destRect, 0); + + if (FAILED(result)) + { + ERR("Failed to lock the destination surface (rectangle might be invalid)."); + surface->UnlockRect(); + surface->Release(); + return error(GL_OUT_OF_MEMORY); + } + + if (destLock.pBits && sourceLock.pBits) + { + unsigned char *source = (unsigned char*)sourceLock.pBits; + unsigned char *dest = (unsigned char*)destLock.pBits; + + switch (description.Format) + { + case D3DFMT_X8R8G8B8: + case D3DFMT_A8R8G8B8: + switch(getD3DFormat()) + { + case D3DFMT_L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + dest[x] = source[x * 4 + 2]; + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + case D3DFMT_A8L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + dest[x * 2 + 0] = source[x * 4 + 2]; + dest[x * 2 + 1] = source[x * 4 + 3]; + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + default: + UNREACHABLE(); + } + break; + case D3DFMT_R5G6B5: + switch(getD3DFormat()) + { + case D3DFMT_L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned char red = source[x * 2 + 1] & 0xF8; + dest[x] = red | (red >> 5); + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + default: + UNREACHABLE(); + } + break; + case D3DFMT_A1R5G5B5: + switch(getD3DFormat()) + { + case D3DFMT_L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned char red = source[x * 2 + 1] & 0x7C; + dest[x] = (red << 1) | (red >> 4); + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + case D3DFMT_A8L8: + for(int y = 0; y < height; y++) + { + for(int x = 0; x < width; x++) + { + unsigned char red = source[x * 2 + 1] & 0x7C; + dest[x * 2 + 0] = (red << 1) | (red >> 4); + dest[x * 2 + 1] = (signed char)source[x * 2 + 1] >> 7; + } + + source += sourceLock.Pitch; + dest += destLock.Pitch; + } + break; + default: + UNREACHABLE(); + } + break; + default: + UNREACHABLE(); + } + + image->dirty = true; + mDirtyMetaData = true; + } + + image->surface->UnlockRect(); + surface->UnlockRect(); + surface->Release(); +} + +D3DFORMAT Texture::getD3DFormat() const +{ + return selectFormat(getFormat(), mType); +} + IDirect3DBaseTexture9 *Texture::getTexture() { if (!isComplete()) @@ -683,15 +1175,19 @@ int Texture::levelCount() const return mBaseTexture ? mBaseTexture->GetLevelCount() : 0; } +bool Texture::isRenderable() const +{ + return mIsRenderable; +} + Texture2D::Texture2D(GLuint id) : Texture(id) { mTexture = NULL; - mColorbufferProxy = NULL; } Texture2D::~Texture2D() { - delete mColorbufferProxy; + mColorbufferProxy.set(NULL); if (mTexture) { @@ -714,9 +1210,9 @@ GLenum Texture2D::getFormat() const // for render-to-texture (such as CopyTexImage). We have no way of keeping individual inconsistent levels. // Call this when a particular level of the texture must be defined with a specific format, width and height. // -// Returns true if the existing texture was unsuitable had to be destroyed. If so, it will also set +// Returns true if the existing texture was unsuitable and had to be destroyed. If so, it will also set // a new height and width for the texture by working backwards from the given width and height. -bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height) +bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum type) { bool widthOkay = (mWidth >> level == width); bool heightOkay = (mHeight >> level == height); @@ -725,7 +1221,9 @@ bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei widt || (widthOkay && mHeight >> level == 0 && height == 1) || (heightOkay && mWidth >> level == 0 && width == 1)); - bool textureOkay = (sizeOkay && internalFormat == mImageArray[0].format); + bool typeOkay = (type == mType); + + bool textureOkay = (sizeOkay && typeOkay && internalFormat == mImageArray[0].format); if (!textureOkay) { @@ -735,7 +1233,7 @@ bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei widt // Purge all the levels and the texture. - for (int i = 0; i < MAX_TEXTURE_LEVELS; i++) + for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) { if (mImageArray[i].surface != NULL) { @@ -756,6 +1254,7 @@ bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei widt mWidth = width << level; mHeight = height << level; mImageArray[0].format = internalFormat; + mType = type; } return !textureOkay; @@ -763,14 +1262,14 @@ bool Texture2D::redefineTexture(GLint level, GLenum internalFormat, GLsizei widt void Texture2D::setImage(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) { - redefineTexture(level, internalFormat, width, height); + redefineTexture(level, internalFormat, width, height, type); Texture::setImage(width, height, format, type, unpackAlignment, pixels, &mImageArray[level]); } void Texture2D::setCompressedImage(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) { - redefineTexture(level, internalFormat, width, height); + redefineTexture(level, internalFormat, width, height, GL_UNSIGNED_BYTE); Texture::setCompressedImage(width, height, internalFormat, imageSize, pixels, &mImageArray[level]); } @@ -828,29 +1327,46 @@ void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GL void Texture2D::copyImage(GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) { - if (redefineTexture(level, internalFormat, width, height)) + IDirect3DSurface9 *renderTarget = source->getRenderTarget(); + + if (!renderTarget) { - convertToRenderTarget(); - pushTexture(mTexture, true); + ERR("Failed to retrieve the render target."); + return error(GL_OUT_OF_MEMORY); } - else + + bool redefined = redefineTexture(level, internalFormat, width, height, mType); + + if (!isRenderableFormat()) { - needRenderTarget(); + copyNonRenderable(&mImageArray[level], internalFormat, 0, 0, x, y, width, height, renderTarget); } - - if (width != 0 && height != 0 && level < levelCount()) + else { - RECT sourceRect; - sourceRect.left = x; - sourceRect.right = x + width; - sourceRect.top = y; - sourceRect.bottom = y + height; + if (redefined) + { + convertToRenderTarget(); + pushTexture(mTexture, true); + } + else + { + needRenderTarget(); + } + + if (width != 0 && height != 0 && level < levelCount()) + { + RECT sourceRect; + sourceRect.left = x; + sourceRect.right = x + width; + sourceRect.top = y; + sourceRect.bottom = y + height; - IDirect3DSurface9 *dest; - HRESULT hr = mTexture->GetSurfaceLevel(level, &dest); + IDirect3DSurface9 *dest; + HRESULT hr = mTexture->GetSurfaceLevel(level, &dest); - getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, internalFormat, 0, 0, dest); - dest->Release(); + getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, internalFormat, 0, 0, dest); + dest->Release(); + } } mImageArray[level].width = width; @@ -858,36 +1374,53 @@ void Texture2D::copyImage(GLint level, GLenum internalFormat, GLint x, GLint y, mImageArray[level].format = internalFormat; } -void Texture2D::copySubImage(GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) +void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) { if (xoffset + width > mImageArray[level].width || yoffset + height > mImageArray[level].height) { return error(GL_INVALID_VALUE); } - if (redefineTexture(0, mImageArray[0].format, mImageArray[0].width, mImageArray[0].height)) + IDirect3DSurface9 *renderTarget = source->getRenderTarget(); + + if (!renderTarget) { - convertToRenderTarget(); - pushTexture(mTexture, true); + ERR("Failed to retrieve the render target."); + return error(GL_OUT_OF_MEMORY); } - else + + bool redefined = redefineTexture(0, mImageArray[0].format, mImageArray[0].width, mImageArray[0].height, mType); + + if (!isRenderableFormat()) { - needRenderTarget(); + copyNonRenderable(&mImageArray[level], getFormat(), xoffset, yoffset, x, y, width, height, renderTarget); } - - if (level < levelCount()) + else { - RECT sourceRect; - sourceRect.left = x; - sourceRect.right = x + width; - sourceRect.top = y; - sourceRect.bottom = y + height; + if (redefined) + { + convertToRenderTarget(); + pushTexture(mTexture, true); + } + else + { + needRenderTarget(); + } + + if (level < levelCount()) + { + RECT sourceRect; + sourceRect.left = x; + sourceRect.right = x + width; + sourceRect.top = y; + sourceRect.bottom = y + height; - IDirect3DSurface9 *dest; - HRESULT hr = mTexture->GetSurfaceLevel(level, &dest); + IDirect3DSurface9 *dest; + HRESULT hr = mTexture->GetSurfaceLevel(level, &dest); - getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, mImageArray[0].format, xoffset, yoffset, dest); - dest->Release(); + getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, mImageArray[0].format, xoffset, yoffset, dest); + dest->Release(); + } } } @@ -919,6 +1452,16 @@ bool Texture2D::isComplete() const default: UNREACHABLE(); } + if ((getFormat() == GL_FLOAT && !getContext()->supportsFloatLinearFilter()) || + (getFormat() == GL_HALF_FLOAT_OES && !getContext()->supportsHalfFloatLinearFilter())) + { + if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST)) + { + return false; + } + } + + if ((getWrapS() != GL_CLAMP_TO_EDGE && !isPow2(width)) || (getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(height))) { @@ -967,7 +1510,7 @@ IDirect3DBaseTexture9 *Texture2D::createTexture() IDirect3DTexture9 *texture; IDirect3DDevice9 *device = getDevice(); - D3DFORMAT format = selectFormat(mImageArray[0].format); + D3DFORMAT format = selectFormat(mImageArray[0].format, mType); HRESULT result = device->CreateTexture(mWidth, mHeight, creationLevels(mWidth, mHeight, 0), 0, format, D3DPOOL_DEFAULT, &texture, NULL); @@ -1018,7 +1561,7 @@ IDirect3DBaseTexture9 *Texture2D::convertToRenderTarget() { egl::Display *display = getDisplay(); IDirect3DDevice9 *device = getDevice(); - D3DFORMAT format = selectFormat(mImageArray[0].format); + D3DFORMAT format = selectFormat(mImageArray[0].format, mType); HRESULT result = device->CreateTexture(mWidth, mHeight, creationLevels(mWidth, mHeight, 0), D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture, NULL); @@ -1123,23 +1666,50 @@ void Texture2D::generateMipmaps() mImageArray[i].height = std::max(mImageArray[0].height >> i, 1); } - needRenderTarget(); - - for (unsigned int i = 1; i <= q; i++) + if (isRenderable()) { - IDirect3DSurface9 *upper = NULL; - IDirect3DSurface9 *lower = NULL; + if (mTexture == NULL) + { + ERR(" failed because mTexture was null."); + return; + } - mTexture->GetSurfaceLevel(i-1, &upper); - mTexture->GetSurfaceLevel(i, &lower); + for (unsigned int i = 1; i <= q; i++) + { + IDirect3DSurface9 *upper = NULL; + IDirect3DSurface9 *lower = NULL; + + mTexture->GetSurfaceLevel(i-1, &upper); + mTexture->GetSurfaceLevel(i, &lower); + + if (upper != NULL && lower != NULL) + { + getBlitter()->boxFilter(upper, lower); + } - if (upper != NULL && lower != NULL) + if (upper != NULL) upper->Release(); + if (lower != NULL) lower->Release(); + } + } + else + { + for (unsigned int i = 1; i <= q; i++) { - getBlitter()->boxFilter(upper, lower); + createSurface(mImageArray[i].width, mImageArray[i].height, mImageArray[i].format, mType, &mImageArray[i]); + if (mImageArray[i].surface == NULL) + { + return error(GL_OUT_OF_MEMORY); + } + + if (FAILED(D3DXLoadSurfaceFromSurface(mImageArray[i].surface, NULL, NULL, mImageArray[i - 1].surface, NULL, NULL, D3DX_FILTER_BOX, 0))) + { + ERR(" failed to load filter %d to %d.", i - 1, i); + } + + mImageArray[i].dirty = true; } - if (upper != NULL) upper->Release(); - if (lower != NULL) lower->Release(); + mDirtyMetaData = true; } } @@ -1150,13 +1720,12 @@ Renderbuffer *Texture2D::getColorbuffer(GLenum target) return error(GL_INVALID_OPERATION, (Renderbuffer *)NULL); } - if (mColorbufferProxy == NULL) + if (mColorbufferProxy.get() == NULL) { - mColorbufferProxy = new Renderbuffer(id(), new TextureColorbufferProxy(this, target)); - mColorbufferProxy->addRef(); + mColorbufferProxy.set(new Renderbuffer(id(), new TextureColorbufferProxy(this, target))); } - return mColorbufferProxy; + return mColorbufferProxy.get(); } IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target) @@ -1165,6 +1734,11 @@ IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target) needRenderTarget(); + if (mTexture == NULL) + { + return NULL; + } + IDirect3DSurface9 *renderTarget = NULL; mTexture->GetSurfaceLevel(0, &renderTarget); @@ -1174,18 +1748,13 @@ IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target) TextureCubeMap::TextureCubeMap(GLuint id) : Texture(id) { mTexture = NULL; - - for (int i = 0; i < 6; i++) - { - mFaceProxies[i] = NULL; - } } TextureCubeMap::~TextureCubeMap() { for (int i = 0; i < 6; i++) { - delete mFaceProxies[i]; + mFaceProxies[i].set(NULL); } if (mTexture) @@ -1277,19 +1846,19 @@ void TextureCubeMap::commitRect(GLenum faceTarget, GLint level, GLint xoffset, G } } -void TextureCubeMap::subImage(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) +void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) { - if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, &mImageArray[faceIndex(face)][level])) + if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, &mImageArray[faceIndex(target)][level])) { - commitRect(face, level, xoffset, yoffset, width, height); + commitRect(target, level, xoffset, yoffset, width, height); } } -void TextureCubeMap::subImageCompressed(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels) +void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels) { - if (Texture::subImageCompressed(xoffset, yoffset, width, height, format, imageSize, pixels, &mImageArray[faceIndex(face)][level])) + if (Texture::subImageCompressed(xoffset, yoffset, width, height, format, imageSize, pixels, &mImageArray[faceIndex(target)][level])) { - commitRect(face, level, xoffset, yoffset, width, height); + commitRect(target, level, xoffset, yoffset, width, height); } } @@ -1328,6 +1897,15 @@ bool TextureCubeMap::isComplete() const } } + if ((getFormat() == GL_FLOAT && !getContext()->supportsFloatLinearFilter()) || + (getFormat() == GL_HALF_FLOAT_OES && !getContext()->supportsHalfFloatLinearFilter())) + { + if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST)) + { + return false; + } + } + if (mipmapping) { if (!isPow2(size) && (getWrapS() != GL_CLAMP_TO_EDGE || getWrapT() != GL_CLAMP_TO_EDGE)) @@ -1368,7 +1946,7 @@ bool TextureCubeMap::isCompressed() const IDirect3DBaseTexture9 *TextureCubeMap::createTexture() { IDirect3DDevice9 *device = getDevice(); - D3DFORMAT format = selectFormat(mImageArray[0][0].format); + D3DFORMAT format = selectFormat(mImageArray[0][0].format, mType); IDirect3DCubeTexture9 *texture; @@ -1424,7 +2002,7 @@ IDirect3DBaseTexture9 *TextureCubeMap::convertToRenderTarget() { egl::Display *display = getDisplay(); IDirect3DDevice9 *device = getDevice(); - D3DFORMAT format = selectFormat(mImageArray[0][0].format); + D3DFORMAT format = selectFormat(mImageArray[0][0].format, mType); HRESULT result = device->CreateCubeTexture(mWidth, creationLevels(mWidth, 0), D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture, NULL); @@ -1546,7 +2124,7 @@ bool TextureCubeMap::redefineTexture(GLint level, GLenum internalFormat, GLsizei internalFormat, width); // Purge all the levels and the texture. - for (int i = 0; i < MAX_TEXTURE_LEVELS; i++) + for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) { for (int f = 0; f < 6; f++) { @@ -1578,34 +2156,50 @@ bool TextureCubeMap::redefineTexture(GLint level, GLenum internalFormat, GLsizei return !textureOkay; } -void TextureCubeMap::copyImage(GLenum face, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) +void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) { - unsigned int faceindex = faceIndex(face); + IDirect3DSurface9 *renderTarget = source->getRenderTarget(); - if (redefineTexture(level, internalFormat, width)) + if (!renderTarget) { - convertToRenderTarget(); - pushTexture(mTexture, true); + ERR("Failed to retrieve the render target."); + return error(GL_OUT_OF_MEMORY); } - else + + unsigned int faceindex = faceIndex(target); + bool redefined = redefineTexture(level, internalFormat, width); + + if (!isRenderableFormat()) { - needRenderTarget(); + copyNonRenderable(&mImageArray[faceindex][level], internalFormat, 0, 0, x, y, width, height, renderTarget); } + else + { + if (redefined) + { + convertToRenderTarget(); + pushTexture(mTexture, true); + } + else + { + needRenderTarget(); + } - ASSERT(width == height); + ASSERT(width == height); - if (width > 0 && level < levelCount()) - { - RECT sourceRect; - sourceRect.left = x; - sourceRect.right = x + width; - sourceRect.top = y; - sourceRect.bottom = y + height; + if (width > 0 && level < levelCount()) + { + RECT sourceRect; + sourceRect.left = x; + sourceRect.right = x + width; + sourceRect.top = y; + sourceRect.bottom = y + height; - IDirect3DSurface9 *dest = getCubeMapSurface(face, level); + IDirect3DSurface9 *dest = getCubeMapSurface(target, level); - getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, internalFormat, 0, 0, dest); - dest->Release(); + getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, internalFormat, 0, 0, dest); + dest->Release(); + } } mImageArray[faceindex][level].width = width; @@ -1644,37 +2238,55 @@ IDirect3DSurface9 *TextureCubeMap::getCubeMapSurface(unsigned int faceIdentifier return (SUCCEEDED(hr)) ? surface : NULL; } -void TextureCubeMap::copySubImage(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) +void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) { - GLsizei size = mImageArray[faceIndex(face)][level].width; + GLsizei size = mImageArray[faceIndex(target)][level].width; if (xoffset + width > size || yoffset + height > size) { return error(GL_INVALID_VALUE); } - if (redefineTexture(0, mImageArray[0][0].format, mImageArray[0][0].width)) + IDirect3DSurface9 *renderTarget = source->getRenderTarget(); + + if (!renderTarget) { - convertToRenderTarget(); - pushTexture(mTexture, true); + ERR("Failed to retrieve the render target."); + return error(GL_OUT_OF_MEMORY); } - else + + unsigned int faceindex = faceIndex(target); + bool redefined = redefineTexture(0, mImageArray[0][0].format, mImageArray[0][0].width); + + if (!isRenderableFormat()) { - needRenderTarget(); + copyNonRenderable(&mImageArray[faceindex][level], getFormat(), 0, 0, x, y, width, height, renderTarget); } - - if (level < levelCount()) + else { - RECT sourceRect; - sourceRect.left = x; - sourceRect.right = x + width; - sourceRect.top = y; - sourceRect.bottom = y + height; + if (redefined) + { + convertToRenderTarget(); + pushTexture(mTexture, true); + } + else + { + needRenderTarget(); + } + + if (level < levelCount()) + { + RECT sourceRect; + sourceRect.left = x; + sourceRect.right = x + width; + sourceRect.top = y; + sourceRect.bottom = y + height; - IDirect3DSurface9 *dest = getCubeMapSurface(face, level); + IDirect3DSurface9 *dest = getCubeMapSurface(target, level); - getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, mImageArray[0][0].format, xoffset, yoffset, dest); - dest->Release(); + getBlitter()->formatConvert(source->getRenderTarget(), sourceRect, mImageArray[0][0].format, xoffset, yoffset, dest); + dest->Release(); + } } } @@ -1724,23 +2336,52 @@ void TextureCubeMap::generateMipmaps() } } - needRenderTarget(); - - for (unsigned int f = 0; f < 6; f++) + if (isRenderable()) { - for (unsigned int i = 1; i <= q; i++) + if (mTexture == NULL) { - IDirect3DSurface9 *upper = getCubeMapSurface(f, i-1); - IDirect3DSurface9 *lower = getCubeMapSurface(f, i); + return; + } - if (upper != NULL && lower != NULL) + for (unsigned int f = 0; f < 6; f++) + { + for (unsigned int i = 1; i <= q; i++) { - getBlitter()->boxFilter(upper, lower); + IDirect3DSurface9 *upper = getCubeMapSurface(f, i-1); + IDirect3DSurface9 *lower = getCubeMapSurface(f, i); + + if (upper != NULL && lower != NULL) + { + getBlitter()->boxFilter(upper, lower); + } + + if (upper != NULL) upper->Release(); + if (lower != NULL) lower->Release(); } + } + } + else + { + for (unsigned int f = 0; f < 6; f++) + { + for (unsigned int i = 1; i <= q; i++) + { + createSurface(mImageArray[f][i].width, mImageArray[f][i].height, mImageArray[f][i].format, mType, &mImageArray[f][i]); + if (mImageArray[f][i].surface == NULL) + { + return error(GL_OUT_OF_MEMORY); + } - if (upper != NULL) upper->Release(); - if (lower != NULL) lower->Release(); + if (FAILED(D3DXLoadSurfaceFromSurface(mImageArray[f][i].surface, NULL, NULL, mImageArray[f][i - 1].surface, NULL, NULL, D3DX_FILTER_BOX, 0))) + { + ERR(" failed to load filter %d to %d.", i - 1, i); + } + + mImageArray[f][i].dirty = true; + } } + + mDirtyMetaData = true; } } @@ -1753,13 +2394,12 @@ Renderbuffer *TextureCubeMap::getColorbuffer(GLenum target) unsigned int face = faceIndex(target); - if (mFaceProxies[face] == NULL) + if (mFaceProxies[face].get() == NULL) { - mFaceProxies[face] = new Renderbuffer(id(), new TextureColorbufferProxy(this, target)); - mFaceProxies[face]->addRef(); + mFaceProxies[face].set(new Renderbuffer(id(), new TextureColorbufferProxy(this, target))); } - return mFaceProxies[face]; + return mFaceProxies[face].get(); } IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target) @@ -1767,7 +2407,12 @@ IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target) ASSERT(IsCubemapTextureTarget(target)); needRenderTarget(); - + + if (mTexture == NULL) + { + return NULL; + } + IDirect3DSurface9 *renderTarget = NULL; mTexture->GetCubeMapSurface(static_cast<D3DCUBEMAP_FACES>(faceIndex(target)), 0, &renderTarget); @@ -1775,9 +2420,9 @@ IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target) } Texture::TextureColorbufferProxy::TextureColorbufferProxy(Texture *texture, GLenum target) - : Colorbuffer(NULL), mTexture(texture), mTarget(target) + : Colorbuffer(texture), mTexture(texture), mTarget(target) { - ASSERT(target == GL_TEXTURE_2D || IsCubemapTextureTarget(target)); + ASSERT(IsTextureTarget(target)); } void Texture::TextureColorbufferProxy::addRef() const @@ -1814,4 +2459,9 @@ GLenum Texture::TextureColorbufferProxy::getFormat() const return mTexture->getFormat(); } +bool Texture::TextureColorbufferProxy::isFloatingPoint() const +{ + return mTexture->isFloatingPoint(); +} + } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h index efa882c..ca7aec7 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Texture.h @@ -18,6 +18,7 @@ #include <d3d9.h> #include "libGLESv2/Renderbuffer.h" +#include "libGLESv2/RefCountObject.h" #include "libGLESv2/utilities.h" #include "common/debug.h" @@ -27,10 +28,13 @@ class Blit; enum { - MAX_TEXTURE_SIZE = 2048, - MAX_CUBE_MAP_TEXTURE_SIZE = 2048, + // These are the maximums the implementation can support + // The actual GL caps are limited by the device caps + // and should be queried from the Context + IMPLEMENTATION_MAX_TEXTURE_SIZE = 16384, + IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384, - MAX_TEXTURE_LEVELS = 12 // 1+log2 of MAX_TEXTURE_SIZE + IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE }; class Texture : public RefCountObject @@ -58,11 +62,15 @@ class Texture : public RefCountObject virtual GLenum getFormat() const = 0; virtual bool isComplete() const = 0; virtual bool isCompressed() const = 0; + bool isFloatingPoint() const; + bool isRenderableFormat() const; + D3DFORMAT getD3DFormat() const; IDirect3DBaseTexture9 *getTexture(); virtual Renderbuffer *getColorbuffer(GLenum target) = 0; virtual void generateMipmaps() = 0; + virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) = 0; bool isDirty() const; @@ -85,6 +93,7 @@ class Texture : public RefCountObject virtual int getWidth() const; virtual int getHeight() const; virtual GLenum getFormat() const; + virtual bool isFloatingPoint() const; private: Texture *mTexture; @@ -106,13 +115,13 @@ class Texture : public RefCountObject IDirect3DSurface9 *surface; }; - static D3DFORMAT selectFormat(GLenum format); - int imagePitch(const Image& img) const; + static D3DFORMAT selectFormat(GLenum format, GLenum type); void setImage(GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img); bool subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img); void setCompressedImage(GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, Image *img); bool subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, Image *img); + void copyNonRenderable(Image *image, GLenum internalFormat, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget); void needRenderTarget(); @@ -129,50 +138,73 @@ class Texture : public RefCountObject void dropTexture(); void pushTexture(IDirect3DBaseTexture9 *newTexture, bool renderable); + void createSurface(GLsizei width, GLsizei height, GLenum format, GLenum type, Image *img); Blit *getBlitter(); int levelCount() const; + bool isRenderable() const; + unsigned int mWidth; unsigned int mHeight; GLenum mMinFilter; GLenum mMagFilter; GLenum mWrapS; GLenum mWrapT; + GLenum mType; + + bool mDirtyMetaData; private: DISALLOW_COPY_AND_ASSIGN(Texture); void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, - GLint unpackAlignment, const void *input, std::size_t outputPitch, void *output) const; + GLint unpackAlignment, const void *input, std::size_t outputPitch, void *output, D3DSURFACE_DESC *description) const; void loadAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; void loadLuminanceImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, - size_t inputPitch, const void *input, size_t outputPitch, void *output) const; - void loadLuminanceAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output, bool native) const; + void loadLuminanceFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadLuminanceHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadLuminanceAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output, bool native) const; + void loadLuminanceAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadLuminanceAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; void loadRGBUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; void loadRGB565ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadRGBFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadRGBHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; void loadRGBAUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; void loadRGBA4444ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; void loadRGBA5551ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadRGBAFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadRGBAHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + size_t inputPitch, const void *input, size_t outputPitch, void *output) const; void loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, size_t inputPitch, const void *input, size_t outputPitch, void *output) const; IDirect3DBaseTexture9 *mBaseTexture; // This is a weak pointer. The derived class is assumed to own a strong pointer. bool mDirty; - bool mDirtyMetaData; bool mIsRenderable; - - void createSurface(GLsizei width, GLsizei height, GLenum format, Image *img); }; class Texture2D : public Texture @@ -190,7 +222,7 @@ class Texture2D : public Texture void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void copyImage(GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source); - void copySubImage(GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source); + void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source); bool isComplete() const; bool isCompressed() const; @@ -209,14 +241,14 @@ class Texture2D : public Texture virtual bool dirtyImageData() const; - bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height); + bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum type); void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); - Image mImageArray[MAX_TEXTURE_LEVELS]; + Image mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS]; IDirect3DTexture9 *mTexture; - Renderbuffer *mColorbufferProxy; + BindingPointer<Renderbuffer> mColorbufferProxy; }; class TextureCubeMap : public Texture @@ -238,10 +270,10 @@ class TextureCubeMap : public Texture void setCompressedImage(GLenum face, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); - void subImage(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); - void subImageCompressed(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); - void copyImage(GLenum face, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source); - void copySubImage(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source); + void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels); + void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); + void copyImage(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source); + void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source); bool isComplete() const; bool isCompressed() const; @@ -272,11 +304,11 @@ class TextureCubeMap : public Texture void commitRect(GLenum faceTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width); - Image mImageArray[6][MAX_TEXTURE_LEVELS]; + Image mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS]; IDirect3DCubeTexture9 *mTexture; - Renderbuffer *mFaceProxies[6]; + BindingPointer<Renderbuffer> mFaceProxies[6]; }; } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.cpp index d573579..f79d606 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.cpp @@ -13,7 +13,7 @@ #include "libGLESv2/Buffer.h" #include "libGLESv2/mathutil.h" -#include "libGLESv2/geometry/backend.h" +#include "libGLESv2/main.h" namespace { @@ -23,239 +23,360 @@ namespace namespace gl { -IndexDataManager::IndexDataManager(Context *context, BufferBackEnd *backend) - : mContext(context), mBackend(backend), mIntIndicesSupported(backend->supportIntIndices()) +IndexDataManager::IndexDataManager(Context *context, IDirect3DDevice9 *device) : mDevice(device) { - mCountingBuffer = NULL; - mCountingBufferSize = 0; + mStreamingBufferShort = new StreamingIndexBuffer(mDevice, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16); - mLineLoopBuffer = NULL; - - mStreamBufferShort = mBackend->createIndexBuffer(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT); - - if (mIntIndicesSupported) + if (context->supports32bitIndices()) { - mStreamBufferInt = mBackend->createIndexBuffer(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT); + mStreamingBufferInt = new StreamingIndexBuffer(mDevice, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX32); } else { - mStreamBufferInt = NULL; + mStreamingBufferInt = NULL; } } IndexDataManager::~IndexDataManager() { - delete mStreamBufferShort; - delete mStreamBufferInt; - delete mCountingBuffer; - delete mLineLoopBuffer; + delete mStreamingBufferShort; + delete mStreamingBufferInt; } -namespace +void convertIndices(GLenum type, const void *input, GLsizei count, void *output) { + if (type == GL_UNSIGNED_BYTE) + { + const GLubyte *in = static_cast<const GLubyte*>(input); + GLushort *out = static_cast<GLushort*>(output); + + for (GLsizei i = 0; i < count; i++) + { + out[i] = in[i]; + } + } + else if (type == GL_UNSIGNED_INT) + { + memcpy(output, input, count * sizeof(GLuint)); + } + else if (type == GL_UNSIGNED_SHORT) + { + memcpy(output, input, count * sizeof(GLushort)); + } + else UNREACHABLE(); +} -template <class InputIndexType, class OutputIndexType> -void copyIndices(const InputIndexType *in, GLsizei count, OutputIndexType *out, GLuint *minIndex, GLuint *maxIndex) +template <class IndexType> +void computeRange(const IndexType *indices, GLsizei count, GLuint *minIndex, GLuint *maxIndex) { - InputIndexType first = *in; - GLuint minIndexSoFar = first; - GLuint maxIndexSoFar = first; + *minIndex = indices[0]; + *maxIndex = indices[0]; for (GLsizei i = 0; i < count; i++) { - if (minIndexSoFar > *in) minIndexSoFar = *in; - if (maxIndexSoFar < *in) maxIndexSoFar = *in; - - *out++ = *in++; + if (*minIndex > indices[i]) *minIndex = indices[i]; + if (*maxIndex < indices[i]) *maxIndex = indices[i]; } - - // It might be a line loop, so copy the loop index. - *out = first; - - *minIndex = minIndexSoFar; - *maxIndex = maxIndexSoFar; } +void computeRange(GLenum type, const void *indices, GLsizei count, GLuint *minIndex, GLuint *maxIndex) +{ + if (type == GL_UNSIGNED_BYTE) + { + computeRange(static_cast<const GLubyte*>(indices), count, minIndex, maxIndex); + } + else if (type == GL_UNSIGNED_INT) + { + computeRange(static_cast<const GLuint*>(indices), count, minIndex, maxIndex); + } + else if (type == GL_UNSIGNED_SHORT) + { + computeRange(static_cast<const GLushort*>(indices), count, minIndex, maxIndex); + } + else UNREACHABLE(); } -GLenum IndexDataManager::preRenderValidate(GLenum mode, GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices, TranslatedIndexData *translated) +GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, Buffer *buffer, const void *indices, TranslatedIndexData *translated) { - ASSERT(type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT); - ASSERT(count > 0); + D3DFORMAT format = (type == GL_UNSIGNED_INT) ? D3DFMT_INDEX32 : D3DFMT_INDEX16; + intptr_t offset = reinterpret_cast<intptr_t>(indices); + bool alignedOffset = false; - if (arrayElementBuffer != NULL) + if (buffer != NULL) { - GLsizei offset = reinterpret_cast<GLsizei>(indices); + switch (type) + { + case GL_UNSIGNED_BYTE: alignedOffset = (offset % sizeof(GLubyte) == 0); break; + case GL_UNSIGNED_SHORT: alignedOffset = (offset % sizeof(GLushort) == 0); break; + case GL_UNSIGNED_INT: alignedOffset = (offset % sizeof(GLuint) == 0); break; + default: UNREACHABLE(); alignedOffset = false; + } - if (typeSize(type) * count + offset > static_cast<std::size_t>(arrayElementBuffer->size())) + if (typeSize(type) * count + offset > static_cast<std::size_t>(buffer->size())) { return GL_INVALID_OPERATION; } - indices = static_cast<const GLubyte*>(arrayElementBuffer->data()) + offset; + indices = static_cast<const GLubyte*>(buffer->data()) + offset; } - translated->count = count; - - std::size_t requiredSpace = spaceRequired(type, count); - - TranslatedIndexBuffer *streamIb = prepareIndexBuffer(type, requiredSpace); + StreamingIndexBuffer *streamingBuffer = (type == GL_UNSIGNED_INT) ? mStreamingBufferInt : mStreamingBufferShort; - size_t offset; - void *output = streamIb->map(requiredSpace, &offset); + StaticIndexBuffer *staticBuffer = buffer ? buffer->getIndexBuffer() : NULL; + IndexBuffer *indexBuffer = streamingBuffer; + UINT streamOffset = 0; - translated->buffer = streamIb; - translated->offset = offset; - translated->indexSize = indexSize(type); - - if (type == GL_UNSIGNED_BYTE) + if (staticBuffer && staticBuffer->lookupType(type) && alignedOffset) { - const GLubyte *in = static_cast<const GLubyte*>(indices); - GLushort *out = static_cast<GLushort*>(output); + indexBuffer = staticBuffer; + streamOffset = staticBuffer->lookupRange(offset, count, &translated->minIndex, &translated->maxIndex); - copyIndices(in, count, out, &translated->minIndex, &translated->maxIndex); + if (streamOffset == -1) + { + streamOffset = (offset / typeSize(type)) * indexSize(format); + computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); + staticBuffer->addRange(offset, count, translated->minIndex, translated->maxIndex, streamOffset); + } } - else if (type == GL_UNSIGNED_INT) + else { - const GLuint *in = static_cast<const GLuint*>(indices); + int convertCount = count; - if (mIntIndicesSupported) + if (staticBuffer) { - GLuint *out = static_cast<GLuint*>(output); + if (staticBuffer->size() == 0 && alignedOffset) + { + indexBuffer = staticBuffer; + convertCount = buffer->size() / typeSize(type); + } + else + { + buffer->invalidateStaticData(); + staticBuffer = NULL; + } + } - copyIndices(in, count, out, &translated->minIndex, &translated->maxIndex); + void *output = NULL; + + if (indexBuffer) + { + indexBuffer->reserveSpace(convertCount * indexSize(format), type); + output = indexBuffer->map(indexSize(format) * convertCount, &streamOffset); } - else + + if (output == NULL) { - // When 32-bit indices are unsupported, fake them by truncating to 16-bit. + ERR("Failed to map index buffer."); + return GL_OUT_OF_MEMORY; + } - GLushort *out = static_cast<GLushort*>(output); + convertIndices(type, staticBuffer ? buffer->data() : indices, convertCount, output); + indexBuffer->unmap(); - copyIndices(in, count, out, &translated->minIndex, &translated->maxIndex); - } - } - else - { - const GLushort *in = static_cast<const GLushort*>(indices); - GLushort *out = static_cast<GLushort*>(output); + computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); - copyIndices(in, count, out, &translated->minIndex, &translated->maxIndex); + if (staticBuffer) + { + streamOffset = (offset / typeSize(type)) * indexSize(format); + staticBuffer->addRange(offset, count, translated->minIndex, translated->maxIndex, streamOffset); + } } - streamIb->unmap(); + translated->indexBuffer = indexBuffer->getBuffer(); + translated->startIndex = streamOffset / indexSize(format); return GL_NO_ERROR; } -std::size_t IndexDataManager::indexSize(GLenum type) const +std::size_t IndexDataManager::indexSize(D3DFORMAT format) const { - return (type == GL_UNSIGNED_INT && mIntIndicesSupported) ? sizeof(GLuint) : sizeof(GLushort); + return (format == D3DFMT_INDEX32) ? sizeof(unsigned int) : sizeof(unsigned short); } std::size_t IndexDataManager::typeSize(GLenum type) const { switch (type) { - case GL_UNSIGNED_INT: return sizeof(GLuint); + case GL_UNSIGNED_INT: return sizeof(GLuint); case GL_UNSIGNED_SHORT: return sizeof(GLushort); - default: UNREACHABLE(); - case GL_UNSIGNED_BYTE: return sizeof(GLubyte); + case GL_UNSIGNED_BYTE: return sizeof(GLubyte); + default: UNREACHABLE(); return sizeof(GLushort); } } -std::size_t IndexDataManager::spaceRequired(GLenum type, GLsizei count) const +IndexBuffer::IndexBuffer(IDirect3DDevice9 *device, UINT size, D3DFORMAT format) : mDevice(device), mBufferSize(size), mIndexBuffer(NULL) { - return (count + 1) * indexSize(type); // +1 because we always leave an extra for line loops + if (size > 0) + { + D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY); + HRESULT result = device->CreateIndexBuffer(size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, format, pool, &mIndexBuffer, NULL); + + if (FAILED(result)) + { + ERR("Out of memory allocating an index buffer of size %lu.", size); + } + } } -TranslatedIndexBuffer *IndexDataManager::prepareIndexBuffer(GLenum type, std::size_t requiredSpace) +IndexBuffer::~IndexBuffer() { - bool use32 = (type == GL_UNSIGNED_INT && mIntIndicesSupported); + if (mIndexBuffer) + { + mIndexBuffer->Release(); + } +} - TranslatedIndexBuffer *streamIb = use32 ? mStreamBufferInt : mStreamBufferShort; +IDirect3DIndexBuffer9 *IndexBuffer::getBuffer() const +{ + return mIndexBuffer; +} - if (requiredSpace > streamIb->size()) +void IndexBuffer::unmap() +{ + if (mIndexBuffer) { - std::size_t newSize = std::max(requiredSpace, 2 * streamIb->size()); + mIndexBuffer->Unlock(); + } +} - TranslatedIndexBuffer *newStreamBuffer = mBackend->createIndexBuffer(newSize, use32 ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT); +StreamingIndexBuffer::StreamingIndexBuffer(IDirect3DDevice9 *device, UINT initialSize, D3DFORMAT format) : IndexBuffer(device, initialSize, format) +{ + mWritePosition = 0; +} - delete streamIb; +StreamingIndexBuffer::~StreamingIndexBuffer() +{ +} - streamIb = newStreamBuffer; +void *StreamingIndexBuffer::map(UINT requiredSpace, UINT *offset) +{ + void *mapPtr = NULL; - if (use32) - { - mStreamBufferInt = streamIb; - } - else + if (mIndexBuffer) + { + HRESULT result = mIndexBuffer->Lock(mWritePosition, requiredSpace, &mapPtr, D3DLOCK_NOOVERWRITE); + + if (FAILED(result)) { - mStreamBufferShort = streamIb; + ERR(" Lock failed with error 0x%08x", result); + return NULL; } - } - streamIb->reserveSpace(requiredSpace); + *offset = mWritePosition; + mWritePosition += requiredSpace; + } - return streamIb; + return mapPtr; } -GLenum IndexDataManager::preRenderValidateUnindexed(GLenum mode, GLsizei count, TranslatedIndexData *indexInfo) +void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) { - if (count >= 65535) return GL_OUT_OF_MEMORY; - - if (mode == GL_LINE_LOOP) + if (requiredSpace > mBufferSize) { - // For line loops, create a single-use buffer that runs 0 - count-1, 0. - delete mLineLoopBuffer; - mLineLoopBuffer = mBackend->createIndexBuffer((count+1) * sizeof(unsigned short), GL_UNSIGNED_SHORT); - - unsigned short *indices = static_cast<unsigned short *>(mLineLoopBuffer->map()); - - for (int i = 0; i < count; i++) + if (mIndexBuffer) { - indices[i] = i; + mIndexBuffer->Release(); + mIndexBuffer = NULL; } - indices[count] = 0; + mBufferSize = std::max(requiredSpace, 2 * mBufferSize); - mLineLoopBuffer->unmap(); + D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY); + HRESULT result = mDevice->CreateIndexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL); + + if (FAILED(result)) + { + ERR("Out of memory allocating a vertex buffer of size %lu.", mBufferSize); + } - indexInfo->buffer = mLineLoopBuffer; - indexInfo->count = count + 1; - indexInfo->maxIndex = count - 1; + mWritePosition = 0; } - else if (mCountingBufferSize < count) + else if (mWritePosition + requiredSpace > mBufferSize) // Recycle { - mCountingBufferSize = std::max(static_cast<GLsizei>(ceilPow2(count)), mCountingBufferSize*2); + void *dummy; + mIndexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD); + mIndexBuffer->Unlock(); - delete mCountingBuffer; - mCountingBuffer = mBackend->createIndexBuffer(count * sizeof(unsigned short), GL_UNSIGNED_SHORT); + mWritePosition = 0; + } +} - unsigned short *indices = static_cast<unsigned short *>(mCountingBuffer->map()); +StaticIndexBuffer::StaticIndexBuffer(IDirect3DDevice9 *device) : IndexBuffer(device, 0, D3DFMT_UNKNOWN) +{ + mCacheType = GL_NONE; +} - for (int i = 0; i < count; i++) +StaticIndexBuffer::~StaticIndexBuffer() +{ +} + +void *StaticIndexBuffer::map(UINT requiredSpace, UINT *offset) +{ + void *mapPtr = NULL; + + if (mIndexBuffer) + { + HRESULT result = mIndexBuffer->Lock(0, requiredSpace, &mapPtr, 0); + + if (FAILED(result)) { - indices[i] = i; + ERR(" Lock failed with error 0x%08x", result); + return NULL; } - mCountingBuffer->unmap(); + *offset = 0; + } + + return mapPtr; +} + +void StaticIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) +{ + if (!mIndexBuffer && mBufferSize == 0) + { + D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_WRITEONLY); + HRESULT result = mDevice->CreateIndexBuffer(requiredSpace, D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL); + + if (FAILED(result)) + { + ERR("Out of memory allocating a vertex buffer of size %lu.", mBufferSize); + } - indexInfo->buffer = mCountingBuffer; - indexInfo->count = count; - indexInfo->maxIndex = count - 1; + mBufferSize = requiredSpace; + mCacheType = type; } - else + else if (mIndexBuffer && mBufferSize >= requiredSpace && mCacheType == type) { - indexInfo->buffer = mCountingBuffer; - indexInfo->count = count; - indexInfo->maxIndex = count - 1; + // Already allocated } + else UNREACHABLE(); // Static index buffers can't be resized +} - indexInfo->indexSize = sizeof(unsigned short); - indexInfo->minIndex = 0; - indexInfo->offset = 0; +bool StaticIndexBuffer::lookupType(GLenum type) +{ + return mCacheType == type; +} - return GL_NO_ERROR; +UINT StaticIndexBuffer::lookupRange(intptr_t offset, GLsizei count, UINT *minIndex, UINT *maxIndex) +{ + for (unsigned int range = 0; range < mCache.size(); range++) + { + if (mCache[range].offset == offset && mCache[range].count == count) + { + *minIndex = mCache[range].minIndex; + *maxIndex = mCache[range].maxIndex; + + return mCache[range].streamOffset; + } + } + + return -1; +} + +void StaticIndexBuffer::addRange(intptr_t offset, GLsizei count, UINT minIndex, UINT maxIndex, UINT streamOffset) +{ + IndexRange indexRange = {offset, count, minIndex, maxIndex, streamOffset}; + mCache.push_back(indexRange); } } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.h b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.h index 00ebed2..d48249c 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/IndexDataManager.h @@ -10,7 +10,7 @@ #ifndef LIBGLESV2_GEOMETRY_INDEXDATAMANAGER_H_ #define LIBGLESV2_GEOMETRY_INDEXDATAMANAGER_H_ -#include <bitset> +#include <vector> #include <cstddef> #define GL_APICALL @@ -21,49 +21,98 @@ namespace gl { -class Buffer; -class BufferBackEnd; -class TranslatedIndexBuffer; -struct FormatConverter; - struct TranslatedIndexData { - GLuint minIndex; - GLuint maxIndex; - GLuint count; - GLuint indexSize; + UINT minIndex; + UINT maxIndex; + UINT startIndex; - TranslatedIndexBuffer *buffer; - GLsizei offset; + IDirect3DIndexBuffer9 *indexBuffer; }; -class IndexDataManager +class IndexBuffer +{ + public: + IndexBuffer(IDirect3DDevice9 *device, UINT size, D3DFORMAT format); + virtual ~IndexBuffer(); + + UINT size() const { return mBufferSize; } + virtual void *map(UINT requiredSpace, UINT *offset) = 0; + void unmap(); + virtual void reserveSpace(UINT requiredSpace, GLenum type) = 0; + + IDirect3DIndexBuffer9 *getBuffer() const; + + protected: + IDirect3DDevice9 *const mDevice; + + IDirect3DIndexBuffer9 *mIndexBuffer; + UINT mBufferSize; + + private: + DISALLOW_COPY_AND_ASSIGN(IndexBuffer); +}; + +class StreamingIndexBuffer : public IndexBuffer +{ + public: + StreamingIndexBuffer(IDirect3DDevice9 *device, UINT initialSize, D3DFORMAT format); + ~StreamingIndexBuffer(); + + void *map(UINT requiredSpace, UINT *offset); + void reserveSpace(UINT requiredSpace, GLenum type); + + private: + UINT mWritePosition; +}; + +class StaticIndexBuffer : public IndexBuffer { public: - IndexDataManager(Context *context, BufferBackEnd *backend); - ~IndexDataManager(); + explicit StaticIndexBuffer(IDirect3DDevice9 *device); + ~StaticIndexBuffer(); + + void *map(UINT requiredSpace, UINT *offset); + void reserveSpace(UINT requiredSpace, GLenum type); - GLenum preRenderValidate(GLenum mode, GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices, TranslatedIndexData *translated); - GLenum preRenderValidateUnindexed(GLenum mode, GLsizei count, TranslatedIndexData *indexInfo); + bool lookupType(GLenum type); + UINT lookupRange(intptr_t offset, GLsizei count, UINT *minIndex, UINT *maxIndex); // Returns the offset into the index buffer, or -1 if not found + void addRange(intptr_t offset, GLsizei count, UINT minIndex, UINT maxIndex, UINT streamOffset); private: - std::size_t IndexDataManager::typeSize(GLenum type) const; - std::size_t IndexDataManager::indexSize(GLenum type) const; - std::size_t spaceRequired(GLenum type, GLsizei count) const; - TranslatedIndexBuffer *prepareIndexBuffer(GLenum type, std::size_t requiredSpace); + GLenum mCacheType; + + struct IndexRange + { + intptr_t offset; + GLsizei count; + + UINT minIndex; + UINT maxIndex; + UINT streamOffset; + }; + + std::vector<IndexRange> mCache; +}; + +class IndexDataManager +{ + public: + IndexDataManager(Context *context, IDirect3DDevice9 *evice); + virtual ~IndexDataManager(); - Context *mContext; - BufferBackEnd *mBackend; + GLenum prepareIndexData(GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices, TranslatedIndexData *translated); - bool mIntIndicesSupported; + private: + DISALLOW_COPY_AND_ASSIGN(IndexDataManager); - TranslatedIndexBuffer *mStreamBufferShort; - TranslatedIndexBuffer *mStreamBufferInt; + std::size_t typeSize(GLenum type) const; + std::size_t indexSize(D3DFORMAT format) const; - TranslatedIndexBuffer *mCountingBuffer; - GLsizei mCountingBufferSize; + IDirect3DDevice9 *const mDevice; - TranslatedIndexBuffer *mLineLoopBuffer; + StreamingIndexBuffer *mStreamingBufferShort; + StreamingIndexBuffer *mStreamingBufferInt; }; } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.cpp index 7762e07..99ece17 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.cpp @@ -9,14 +9,13 @@ #include "libGLESv2/geometry/VertexDataManager.h" -#include <limits> - #include "common/debug.h" #include "libGLESv2/Buffer.h" #include "libGLESv2/Program.h" +#include "libGLESv2/main.h" -#include "libGLESv2/geometry/backend.h" +#include "libGLESv2/geometry/vertexconversion.h" #include "libGLESv2/geometry/IndexDataManager.h" namespace @@ -27,245 +26,744 @@ namespace namespace gl { -VertexDataManager::VertexDataManager(Context *context, BufferBackEnd *backend) - : mContext(context), mBackend(backend), mDirtyCurrentValues(true), mCurrentValueOffset(0) +VertexDataManager::VertexDataManager(Context *context, IDirect3DDevice9 *device) : mContext(context), mDevice(device) { - mStreamBuffer = mBackend->createVertexBuffer(INITIAL_STREAM_BUFFER_SIZE); - try - { - mCurrentValueBuffer = mBackend->createVertexBufferForStrideZero(4 * sizeof(float) * MAX_VERTEX_ATTRIBS); - } - catch (...) + for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - delete mStreamBuffer; - throw; + mDirtyCurrentValue[i] = true; + mCurrentValueBuffer[i] = NULL; } + + const D3DCAPS9 &caps = context->getDeviceCaps(); + checkVertexCaps(caps.DeclTypes); + + mStreamingBuffer = new StreamingVertexBuffer(mDevice, INITIAL_STREAM_BUFFER_SIZE); } VertexDataManager::~VertexDataManager() { - delete mStreamBuffer; - delete mCurrentValueBuffer; + delete mStreamingBuffer; + + for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) + { + delete mCurrentValueBuffer[i]; + } } -std::bitset<MAX_VERTEX_ATTRIBS> VertexDataManager::getActiveAttribs() const +UINT VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute) { - std::bitset<MAX_VERTEX_ATTRIBS> active; + Buffer *buffer = attribute.mBoundBuffer.get(); - Program *program = mContext->getCurrentProgram(); + int inputStride = attribute.stride(); + int elementSize = attribute.typeSize(); + const FormatConverter &converter = formatConverter(attribute); + UINT streamOffset = 0; - for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) + void *output = NULL; + + if (vertexBuffer) { - active[attributeIndex] = (program->getSemanticIndex(attributeIndex) != -1); + output = vertexBuffer->map(attribute, spaceRequired(attribute, count), &streamOffset); } - return active; -} + if (output == NULL) + { + ERR("Failed to map vertex buffer."); + return -1; + } -GLenum VertexDataManager::preRenderValidate(GLint start, GLsizei count, - TranslatedAttribute *translated) -{ - const AttributeState *attribs = mContext->getVertexAttribBlock(); - const std::bitset<MAX_VERTEX_ATTRIBS> activeAttribs = getActiveAttribs(); + const char *input = NULL; - for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) + if (buffer) + { + int offset = attribute.mOffset; + + input = static_cast<const char*>(buffer->data()) + offset; + } + else { - if (!activeAttribs[i] && attribs[i].mEnabled && attribs[i].mBoundBuffer != 0 && !mContext->getBuffer(attribs[i].mBoundBuffer)) - return GL_INVALID_OPERATION; + input = static_cast<const char*>(attribute.mPointer); } - for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) + input += inputStride * start; + + if (converter.identity && inputStride == elementSize) { - translated[i].enabled = activeAttribs[i]; + memcpy(output, input, count * inputStride); } + else + { + converter.convertArray(input, inputStride, count, output); + } + + vertexBuffer->unmap(); - bool usesCurrentValues = false; + return streamOffset; +} +GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, TranslatedAttribute *translated) +{ + GLenum error = GL_NO_ERROR; + const VertexAttributeArray &attribs = mContext->getVertexAttributes(); + Program *program = mContext->getCurrentProgram(); + + for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) + { + translated[attributeIndex].active = (program->getSemanticIndex(attributeIndex) != -1); + } + + // Determine the required storage size per used buffer for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - if (activeAttribs[i] && !attribs[i].mEnabled) + Buffer *buffer = attribs[i].mBoundBuffer.get(); + + if (translated[i].active && attribs[i].mArrayEnabled && (buffer || attribs[i].mPointer)) { - usesCurrentValues = true; - break; + StaticVertexBuffer *staticBuffer = buffer ? buffer->getVertexBuffer() : NULL; + + if (staticBuffer && staticBuffer->size() == 0) + { + int totalCount = buffer->size() / attribs[i].stride(); + staticBuffer->addRequiredSpace(spaceRequired(attribs[i], totalCount)); + } + else if (!staticBuffer || staticBuffer->lookupAttribute(attribs[i]) == -1) + { + if (mStreamingBuffer) + { + mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count)); + } + } } } - // Handle the identity-mapped attributes. - // Process array attributes. - - std::size_t requiredSpace = 0; - + // Invalidate static buffers if the attribute formats no longer match for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - if (activeAttribs[i] && attribs[i].mEnabled) + Buffer *buffer = attribs[i].mBoundBuffer.get(); + + if (translated[i].active && attribs[i].mArrayEnabled && buffer) { - requiredSpace += spaceRequired(attribs[i], count); + StaticVertexBuffer *staticBuffer = buffer->getVertexBuffer(); + + if (staticBuffer && staticBuffer->size() != 0) + { + bool matchingAttributes = true; + + for (int j = 0; j < MAX_VERTEX_ATTRIBS; j++) + { + if (translated[j].active && attribs[j].mArrayEnabled && attribs[j].mBoundBuffer.get() == buffer) + { + if (staticBuffer->lookupAttribute(attribs[j]) == -1) + { + matchingAttributes = false; + break; + } + } + } + + if (!matchingAttributes && mStreamingBuffer) + { + mStreamingBuffer->addRequiredSpaceFor(staticBuffer); + buffer->invalidateStaticData(); + } + } } } - if (requiredSpace > mStreamBuffer->size()) + // Reserve the required space per used buffer + for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - std::size_t newSize = std::max(requiredSpace, 3 * mStreamBuffer->size() / 2); // 1.5 x mStreamBuffer->size() is arbitrary and should be checked to see we don't have too many reallocations. + Buffer *buffer = attribs[i].mBoundBuffer.get(); - TranslatedVertexBuffer *newStreamBuffer = mBackend->createVertexBuffer(newSize); + if (translated[i].active && attribs[i].mArrayEnabled && (buffer || attribs[i].mPointer)) + { + ArrayVertexBuffer *staticBuffer = buffer ? buffer->getVertexBuffer() : NULL; + ArrayVertexBuffer *vertexBuffer = staticBuffer ? staticBuffer : mStreamingBuffer; - delete mStreamBuffer; - mStreamBuffer = newStreamBuffer; + if (vertexBuffer) + { + vertexBuffer->reserveRequiredSpace(); + } + } } - mStreamBuffer->reserveSpace(requiredSpace); - - for (size_t i = 0; i < MAX_VERTEX_ATTRIBS; i++) + // Perform the vertex data translations + for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - if (activeAttribs[i] && attribs[i].mEnabled) + if (translated[i].active) { - FormatConverter formatConverter = mBackend->getFormatConverter(attribs[i].mType, attribs[i].mSize, attribs[i].mNormalized); + Buffer *buffer = attribs[i].mBoundBuffer.get(); - translated[i].nonArray = false; - translated[i].type = attribs[i].mType; - translated[i].size = attribs[i].mSize; - translated[i].normalized = attribs[i].mNormalized; - translated[i].stride = formatConverter.outputVertexSize; - translated[i].buffer = mStreamBuffer; + if (attribs[i].mArrayEnabled) + { + if (!buffer && attribs[i].mPointer == NULL) + { + // This is an application error that would normally result in a crash, but we catch it and return an error + ERR("An enabled vertex array has no buffer and no pointer."); + return GL_INVALID_OPERATION; + } - size_t inputStride = interpretGlStride(attribs[i]); - size_t elementSize = typeSize(attribs[i].mType) * attribs[i].mSize; + const FormatConverter &converter = formatConverter(attribs[i]); - void *output = mStreamBuffer->map(spaceRequired(attribs[i], count), &translated[i].offset); + StaticVertexBuffer *staticBuffer = buffer ? buffer->getVertexBuffer() : NULL; + ArrayVertexBuffer *vertexBuffer = staticBuffer ? staticBuffer : static_cast<ArrayVertexBuffer*>(mStreamingBuffer); - const void *input; - if (attribs[i].mBoundBuffer) - { - Buffer *buffer = mContext->getBuffer(attribs[i].mBoundBuffer); + UINT streamOffset = -1; + + if (staticBuffer) + { + streamOffset = staticBuffer->lookupAttribute(attribs[i]); - size_t offset = reinterpret_cast<size_t>(attribs[i].mPointer); + if (streamOffset == -1) + { + // Convert the entire buffer + int totalCount = buffer->size() / attribs[i].stride(); + int startIndex = attribs[i].mOffset / attribs[i].stride(); - // Before we calculate the required size below, make sure it can be computed without integer overflow. - if (std::numeric_limits<std::size_t>::max() - start < static_cast<std::size_t>(count) - || std::numeric_limits<std::size_t>::max() / inputStride < static_cast<std::size_t>(start + count - 1) // it's a prerequisite that count >= 1, so start+count-1 >= 0. - || std::numeric_limits<std::size_t>::max() - offset < inputStride * (start + count - 1) - || std::numeric_limits<std::size_t>::max() - elementSize < offset + inputStride * (start + count - 1) + elementSize) + streamOffset = writeAttributeData(staticBuffer, -startIndex, totalCount, attribs[i]); + } + + if (streamOffset != -1) + { + streamOffset += (start + attribs[i].mOffset / attribs[i].stride()) * converter.outputElementSize; + } + } + else { - mStreamBuffer->unmap(); - return GL_INVALID_OPERATION; + streamOffset = writeAttributeData(mStreamingBuffer, start, count, attribs[i]); } - if (offset + inputStride * (start + count - 1) + elementSize > buffer->size()) + if (streamOffset == -1) { - mStreamBuffer->unmap(); - return GL_INVALID_OPERATION; + return GL_OUT_OF_MEMORY; } - input = static_cast<const char*>(buffer->data()) + offset; + translated[i].vertexBuffer = vertexBuffer->getBuffer(); + translated[i].type = converter.d3dDeclType; + translated[i].stride = converter.outputElementSize; + translated[i].offset = streamOffset; } else { - input = attribs[i].mPointer; - } + if (mDirtyCurrentValue[i]) + { + delete mCurrentValueBuffer[i]; + mCurrentValueBuffer[i] = new ConstantVertexBuffer(mDevice, attribs[i].mCurrentValue[0], attribs[i].mCurrentValue[1], attribs[i].mCurrentValue[2], attribs[i].mCurrentValue[3]); + mDirtyCurrentValue[i] = false; + } - input = static_cast<const char*>(input) + inputStride * start; + translated[i].vertexBuffer = mCurrentValueBuffer[i]->getBuffer(); - if (formatConverter.identity && inputStride == elementSize) - { - memcpy(output, input, count * inputStride); + translated[i].type = D3DDECLTYPE_FLOAT4; + translated[i].stride = 0; + translated[i].offset = 0; } - else + } + } + + return GL_NO_ERROR; +} + +std::size_t VertexDataManager::spaceRequired(const VertexAttribute &attrib, std::size_t count) const +{ + return formatConverter(attrib).outputElementSize * count; +} + +// Mapping from OpenGL-ES vertex attrib type to D3D decl type: +// +// BYTE SHORT (Cast) +// BYTE-norm FLOAT (Normalize) (can't be exactly represented as SHORT-norm) +// UNSIGNED_BYTE UBYTE4 (Identity) or SHORT (Cast) +// UNSIGNED_BYTE-norm UBYTE4N (Identity) or FLOAT (Normalize) +// SHORT SHORT (Identity) +// SHORT-norm SHORT-norm (Identity) or FLOAT (Normalize) +// UNSIGNED_SHORT FLOAT (Cast) +// UNSIGNED_SHORT-norm USHORT-norm (Identity) or FLOAT (Normalize) +// FIXED (not in WebGL) FLOAT (FixedToFloat) +// FLOAT FLOAT (Identity) + +// GLToCType maps from GL type (as GLenum) to the C typedef. +template <GLenum GLType> struct GLToCType { }; + +template <> struct GLToCType<GL_BYTE> { typedef GLbyte type; }; +template <> struct GLToCType<GL_UNSIGNED_BYTE> { typedef GLubyte type; }; +template <> struct GLToCType<GL_SHORT> { typedef GLshort type; }; +template <> struct GLToCType<GL_UNSIGNED_SHORT> { typedef GLushort type; }; +template <> struct GLToCType<GL_FIXED> { typedef GLuint type; }; +template <> struct GLToCType<GL_FLOAT> { typedef GLfloat type; }; + +// This differs from D3DDECLTYPE in that it is unsized. (Size expansion is applied last.) +enum D3DVertexType +{ + D3DVT_FLOAT, + D3DVT_SHORT, + D3DVT_SHORT_NORM, + D3DVT_UBYTE, + D3DVT_UBYTE_NORM, + D3DVT_USHORT_NORM +}; + +// D3DToCType maps from D3D vertex type (as enum D3DVertexType) to the corresponding C type. +template <unsigned int D3DType> struct D3DToCType { }; + +template <> struct D3DToCType<D3DVT_FLOAT> { typedef float type; }; +template <> struct D3DToCType<D3DVT_SHORT> { typedef short type; }; +template <> struct D3DToCType<D3DVT_SHORT_NORM> { typedef short type; }; +template <> struct D3DToCType<D3DVT_UBYTE> { typedef unsigned char type; }; +template <> struct D3DToCType<D3DVT_UBYTE_NORM> { typedef unsigned char type; }; +template <> struct D3DToCType<D3DVT_USHORT_NORM> { typedef unsigned short type; }; + +// Encode the type/size combinations that D3D permits. For each type/size it expands to a widener that will provide the appropriate final size. +template <unsigned int type, int size> +struct WidenRule +{ +}; + +template <int size> struct WidenRule<D3DVT_FLOAT, size> : gl::NoWiden<size> { }; +template <int size> struct WidenRule<D3DVT_SHORT, size> : gl::WidenToEven<size> { }; +template <int size> struct WidenRule<D3DVT_SHORT_NORM, size> : gl::WidenToEven<size> { }; +template <int size> struct WidenRule<D3DVT_UBYTE, size> : gl::WidenToFour<size> { }; +template <int size> struct WidenRule<D3DVT_UBYTE_NORM, size> : gl::WidenToFour<size> { }; +template <int size> struct WidenRule<D3DVT_USHORT_NORM, size> : gl::WidenToEven<size> { }; + +// VertexTypeFlags encodes the D3DCAPS9::DeclType flag and vertex declaration flag for each D3D vertex type & size combination. +template <unsigned int d3dtype, int size> +struct VertexTypeFlags +{ +}; + +template <unsigned int capflag, unsigned int declflag> +struct VertexTypeFlagsHelper +{ + enum { capflag = capflag }; + enum { declflag = declflag }; +}; + +template <> struct VertexTypeFlags<D3DVT_FLOAT, 1> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT1> { }; +template <> struct VertexTypeFlags<D3DVT_FLOAT, 2> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT2> { }; +template <> struct VertexTypeFlags<D3DVT_FLOAT, 3> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT3> { }; +template <> struct VertexTypeFlags<D3DVT_FLOAT, 4> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT4> { }; +template <> struct VertexTypeFlags<D3DVT_SHORT, 2> : VertexTypeFlagsHelper<0, D3DDECLTYPE_SHORT2> { }; +template <> struct VertexTypeFlags<D3DVT_SHORT, 4> : VertexTypeFlagsHelper<0, D3DDECLTYPE_SHORT4> { }; +template <> struct VertexTypeFlags<D3DVT_SHORT_NORM, 2> : VertexTypeFlagsHelper<D3DDTCAPS_SHORT2N, D3DDECLTYPE_SHORT2N> { }; +template <> struct VertexTypeFlags<D3DVT_SHORT_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_SHORT4N, D3DDECLTYPE_SHORT4N> { }; +template <> struct VertexTypeFlags<D3DVT_UBYTE, 4> : VertexTypeFlagsHelper<D3DDTCAPS_UBYTE4, D3DDECLTYPE_UBYTE4> { }; +template <> struct VertexTypeFlags<D3DVT_UBYTE_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_UBYTE4N, D3DDECLTYPE_UBYTE4N> { }; +template <> struct VertexTypeFlags<D3DVT_USHORT_NORM, 2> : VertexTypeFlagsHelper<D3DDTCAPS_USHORT2N, D3DDECLTYPE_USHORT2N> { }; +template <> struct VertexTypeFlags<D3DVT_USHORT_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_USHORT4N, D3DDECLTYPE_USHORT4N> { }; + + +// VertexTypeMapping maps GL type & normalized flag to preferred and fallback D3D vertex types (as D3DVertexType enums). +template <GLenum GLtype, bool normalized> +struct VertexTypeMapping +{ +}; + +template <D3DVertexType Preferred, D3DVertexType Fallback = Preferred> +struct VertexTypeMappingBase +{ + enum { preferred = Preferred }; + enum { fallback = Fallback }; +}; + +template <> struct VertexTypeMapping<GL_BYTE, false> : VertexTypeMappingBase<D3DVT_SHORT> { }; // Cast +template <> struct VertexTypeMapping<GL_BYTE, true> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Normalize +template <> struct VertexTypeMapping<GL_UNSIGNED_BYTE, false> : VertexTypeMappingBase<D3DVT_UBYTE, D3DVT_FLOAT> { }; // Identity, Cast +template <> struct VertexTypeMapping<GL_UNSIGNED_BYTE, true> : VertexTypeMappingBase<D3DVT_UBYTE_NORM, D3DVT_FLOAT> { }; // Identity, Normalize +template <> struct VertexTypeMapping<GL_SHORT, false> : VertexTypeMappingBase<D3DVT_SHORT> { }; // Identity +template <> struct VertexTypeMapping<GL_SHORT, true> : VertexTypeMappingBase<D3DVT_SHORT_NORM, D3DVT_FLOAT> { }; // Cast, Normalize +template <> struct VertexTypeMapping<GL_UNSIGNED_SHORT, false> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Cast +template <> struct VertexTypeMapping<GL_UNSIGNED_SHORT, true> : VertexTypeMappingBase<D3DVT_USHORT_NORM, D3DVT_FLOAT> { }; // Cast, Normalize +template <bool normalized> struct VertexTypeMapping<GL_FIXED, normalized> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // FixedToFloat +template <bool normalized> struct VertexTypeMapping<GL_FLOAT, normalized> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Identity + + +// Given a GL type & norm flag and a D3D type, ConversionRule provides the type conversion rule (Cast, Normalize, Identity, FixedToFloat). +// The conversion rules themselves are defined in vertexconversion.h. + +// Almost all cases are covered by Cast (including those that are actually Identity since Cast<T,T> knows it's an identity mapping). +template <GLenum fromType, bool normalized, unsigned int toType> +struct ConversionRule : gl::Cast<typename GLToCType<fromType>::type, typename D3DToCType<toType>::type> +{ +}; + +// All conversions from normalized types to float use the Normalize operator. +template <GLenum fromType> struct ConversionRule<fromType, true, D3DVT_FLOAT> : gl::Normalize<typename GLToCType<fromType>::type> { }; + +// Use a full specialisation for this so that it preferentially matches ahead of the generic normalize-to-float rules. +template <> struct ConversionRule<GL_FIXED, true, D3DVT_FLOAT> : gl::FixedToFloat<GLuint, 16> { }; +template <> struct ConversionRule<GL_FIXED, false, D3DVT_FLOAT> : gl::FixedToFloat<GLuint, 16> { }; + +// A 2-stage construction is used for DefaultVertexValues because float must use SimpleDefaultValues (i.e. 0/1) +// whether it is normalized or not. +template <class T, bool normalized> +struct DefaultVertexValuesStage2 +{ +}; + +template <class T> struct DefaultVertexValuesStage2<T, true> : gl::NormalizedDefaultValues<T> { }; +template <class T> struct DefaultVertexValuesStage2<T, false> : gl::SimpleDefaultValues<T> { }; + +// Work out the default value rule for a D3D type (expressed as the C type) and +template <class T, bool normalized> +struct DefaultVertexValues : DefaultVertexValuesStage2<T, normalized> +{ +}; + +template <bool normalized> struct DefaultVertexValues<float, normalized> : gl::SimpleDefaultValues<float> { }; + +// Policy rules for use with Converter, to choose whether to use the preferred or fallback conversion. +// The fallback conversion produces an output that all D3D9 devices must support. +template <class T> struct UsePreferred { enum { type = T::preferred }; }; +template <class T> struct UseFallback { enum { type = T::fallback }; }; + +// Converter ties it all together. Given an OpenGL type/norm/size and choice of preferred/fallback conversion, +// it provides all the members of the appropriate VertexDataConverter, the D3DCAPS9::DeclTypes flag in cap flag +// and the D3DDECLTYPE member needed for the vertex declaration in declflag. +template <GLenum fromType, bool normalized, int size, template <class T> class PreferenceRule> +struct Converter + : gl::VertexDataConverter<typename GLToCType<fromType>::type, + WidenRule<PreferenceRule< VertexTypeMapping<fromType, normalized> >::type, size>, + ConversionRule<fromType, + normalized, + PreferenceRule< VertexTypeMapping<fromType, normalized> >::type>, + DefaultVertexValues<typename D3DToCType<PreferenceRule< VertexTypeMapping<fromType, normalized> >::type>::type, normalized > > +{ +private: + enum { d3dtype = PreferenceRule< VertexTypeMapping<fromType, normalized> >::type }; + enum { d3dsize = WidenRule<d3dtype, size>::finalWidth }; + +public: + enum { capflag = VertexTypeFlags<d3dtype, d3dsize>::capflag }; + enum { declflag = VertexTypeFlags<d3dtype, d3dsize>::declflag }; +}; + +// Initialise a TranslationInfo +#define TRANSLATION(type, norm, size, preferred) \ + { \ + Converter<type, norm, size, preferred>::identity, \ + Converter<type, norm, size, preferred>::finalSize, \ + Converter<type, norm, size, preferred>::convertArray, \ + static_cast<D3DDECLTYPE>(Converter<type, norm, size, preferred>::declflag) \ + } + +#define TRANSLATION_FOR_TYPE_NORM_SIZE(type, norm, size) \ + { \ + Converter<type, norm, size, UsePreferred>::capflag, \ + TRANSLATION(type, norm, size, UsePreferred), \ + TRANSLATION(type, norm, size, UseFallback) \ + } + +#define TRANSLATIONS_FOR_TYPE(type) \ + { \ + { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \ + { TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 4) }, \ + } + +const VertexDataManager::TranslationDescription VertexDataManager::mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4] = // [GL types as enumerated by typeIndex()][normalized][size-1] +{ + TRANSLATIONS_FOR_TYPE(GL_BYTE), + TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_BYTE), + TRANSLATIONS_FOR_TYPE(GL_SHORT), + TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_SHORT), + TRANSLATIONS_FOR_TYPE(GL_FIXED), + TRANSLATIONS_FOR_TYPE(GL_FLOAT) +}; + +void VertexDataManager::checkVertexCaps(DWORD declTypes) +{ + for (unsigned int i = 0; i < NUM_GL_VERTEX_ATTRIB_TYPES; i++) + { + for (unsigned int j = 0; j < 2; j++) + { + for (unsigned int k = 0; k < 4; k++) { - formatConverter.convertArray(input, inputStride, count, output); + if (mPossibleTranslations[i][j][k].capsFlag == 0 || (declTypes & mPossibleTranslations[i][j][k].capsFlag) != 0) + { + mAttributeTypes[i][j][k] = mPossibleTranslations[i][j][k].preferredConversion; + } + else + { + mAttributeTypes[i][j][k] = mPossibleTranslations[i][j][k].fallbackConversion; + } } + } + } +} + +// This is used to index mAttributeTypes and mPossibleTranslations. +unsigned int VertexDataManager::typeIndex(GLenum type) const +{ + switch (type) + { + case GL_BYTE: return 0; + case GL_UNSIGNED_BYTE: return 1; + case GL_SHORT: return 2; + case GL_UNSIGNED_SHORT: return 3; + case GL_FIXED: return 4; + case GL_FLOAT: return 5; + + default: UNREACHABLE(); return 5; + } +} + +void VertexDataManager::setupAttributes(const TranslatedAttribute *attributes) +{ + D3DVERTEXELEMENT9 elements[MAX_VERTEX_ATTRIBS]; + D3DVERTEXELEMENT9 *element = &elements[0]; - mStreamBuffer->unmap(); + for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) + { + if (attributes[i].active) + { + mDevice->SetStreamSource(i, attributes[i].vertexBuffer, attributes[i].offset, attributes[i].stride); + + element->Stream = i; + element->Offset = 0; + element->Type = attributes[i].type; + element->Method = D3DDECLMETHOD_DEFAULT; + element->Usage = D3DDECLUSAGE_TEXCOORD; + element->UsageIndex = attributes[i].semanticIndex; + element++; } } - if (usesCurrentValues) + static const D3DVERTEXELEMENT9 end = D3DDECL_END(); + *element = end; + + IDirect3DVertexDeclaration9 *vertexDeclaration; + mDevice->CreateVertexDeclaration(elements, &vertexDeclaration); + mDevice->SetVertexDeclaration(vertexDeclaration); + vertexDeclaration->Release(); +} + +VertexBuffer::VertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags) : mDevice(device), mVertexBuffer(NULL) +{ + if (size > 0) { - processNonArrayAttributes(attribs, activeAttribs, translated, count); + D3DPOOL pool = getDisplay()->getBufferPool(usageFlags); + HRESULT result = device->CreateVertexBuffer(size, usageFlags, 0, pool, &mVertexBuffer, NULL); + + if (FAILED(result)) + { + ERR("Out of memory allocating a vertex buffer of size %lu.", size); + } } +} - return GL_NO_ERROR; +VertexBuffer::~VertexBuffer() +{ + if (mVertexBuffer) + { + mVertexBuffer->Release(); + } } -std::size_t VertexDataManager::typeSize(GLenum type) const +void VertexBuffer::unmap() { - switch (type) + if (mVertexBuffer) { - case GL_BYTE: case GL_UNSIGNED_BYTE: return sizeof(GLbyte); - case GL_SHORT: case GL_UNSIGNED_SHORT: return sizeof(GLshort); - case GL_FIXED: return sizeof(GLfixed); - case GL_FLOAT: return sizeof(GLfloat); - default: UNREACHABLE(); return sizeof(GLfloat); + mVertexBuffer->Unlock(); } } -std::size_t VertexDataManager::interpretGlStride(const AttributeState &attrib) const +IDirect3DVertexBuffer9 *VertexBuffer::getBuffer() const { - return attrib.mStride ? attrib.mStride : typeSize(attrib.mType) * attrib.mSize; + return mVertexBuffer; } -// Round up x (>=0) to the next multiple of multiple (>0). -// 0 rounds up to 0. -std::size_t VertexDataManager::roundUp(std::size_t x, std::size_t multiple) const +ConstantVertexBuffer::ConstantVertexBuffer(IDirect3DDevice9 *device, float x, float y, float z, float w) : VertexBuffer(device, 4 * sizeof(float), D3DUSAGE_WRITEONLY) { - ASSERT(x >= 0); - ASSERT(multiple > 0); + void *buffer = NULL; - std::size_t remainder = x % multiple; - if (remainder != 0) + if (mVertexBuffer) { - return x + multiple - remainder; + HRESULT result = mVertexBuffer->Lock(0, 0, &buffer, 0); + + if (FAILED(result)) + { + ERR("Lock failed with error 0x%08x", result); + } } - else + + if (buffer) { - return x; + float *vector = (float*)buffer; + + vector[0] = x; + vector[1] = y; + vector[2] = z; + vector[3] = w; + + mVertexBuffer->Unlock(); } } -std::size_t VertexDataManager::spaceRequired(const AttributeState &attrib, std::size_t maxVertex) const +ConstantVertexBuffer::~ConstantVertexBuffer() { - std::size_t size = mBackend->getFormatConverter(attrib.mType, attrib.mSize, attrib.mNormalized).outputVertexSize; - size *= maxVertex; +} - return roundUp(size, 4 * sizeof(GLfloat)); +ArrayVertexBuffer::ArrayVertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags) : VertexBuffer(device, size, usageFlags) +{ + mBufferSize = size; + mWritePosition = 0; + mRequiredSpace = 0; } -void VertexDataManager::processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count) +ArrayVertexBuffer::~ArrayVertexBuffer() { - if (mDirtyCurrentValues) +} + +void ArrayVertexBuffer::addRequiredSpace(UINT requiredSpace) +{ + mRequiredSpace += requiredSpace; +} + +void ArrayVertexBuffer::addRequiredSpaceFor(ArrayVertexBuffer *buffer) +{ + mRequiredSpace += buffer->mRequiredSpace; +} + +StreamingVertexBuffer::StreamingVertexBuffer(IDirect3DDevice9 *device, std::size_t initialSize) : ArrayVertexBuffer(device, initialSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY) +{ +} + +StreamingVertexBuffer::~StreamingVertexBuffer() +{ +} + +void *StreamingVertexBuffer::map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *offset) +{ + void *mapPtr = NULL; + + if (mVertexBuffer) + { + HRESULT result = mVertexBuffer->Lock(mWritePosition, requiredSpace, &mapPtr, D3DLOCK_NOOVERWRITE); + + if (FAILED(result)) + { + ERR("Lock failed with error 0x%08x", result); + return NULL; + } + + *offset = mWritePosition; + mWritePosition += requiredSpace; + } + + return mapPtr; +} + +void StreamingVertexBuffer::reserveRequiredSpace() +{ + if (mRequiredSpace > mBufferSize) { - std::size_t totalSize = 4 * sizeof(float) * MAX_VERTEX_ATTRIBS; + if (mVertexBuffer) + { + mVertexBuffer->Release(); + mVertexBuffer = NULL; + } + + mBufferSize = std::max(mRequiredSpace, 3 * mBufferSize / 2); // 1.5 x mBufferSize is arbitrary and should be checked to see we don't have too many reallocations. + + D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY); + HRESULT result = mDevice->CreateVertexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, pool, &mVertexBuffer, NULL); + + if (FAILED(result)) + { + ERR("Out of memory allocating a vertex buffer of size %lu.", mBufferSize); + } + + mWritePosition = 0; + } + else if (mWritePosition + mRequiredSpace > mBufferSize) // Recycle + { + if (mVertexBuffer) + { + void *dummy; + mVertexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD); + mVertexBuffer->Unlock(); + } + + mWritePosition = 0; + } - mCurrentValueBuffer->reserveSpace(totalSize); + mRequiredSpace = 0; +} + +StaticVertexBuffer::StaticVertexBuffer(IDirect3DDevice9 *device) : ArrayVertexBuffer(device, 0, D3DUSAGE_WRITEONLY) +{ +} + +StaticVertexBuffer::~StaticVertexBuffer() +{ +} - float* currentValues = static_cast<float*>(mCurrentValueBuffer->map(totalSize, &mCurrentValueOffset)); +void *StaticVertexBuffer::map(const VertexAttribute &attribute, std::size_t requiredSpace, UINT *streamOffset) +{ + void *mapPtr = NULL; - for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) + if (mVertexBuffer) + { + HRESULT result = mVertexBuffer->Lock(mWritePosition, requiredSpace, &mapPtr, 0); + + if (FAILED(result)) { - // This assumes that the GL_FLOATx4 is supported by the back-end. (For D3D9, it is a mandatory format.) - currentValues[i*4+0] = attribs[i].mCurrentValue[0]; - currentValues[i*4+1] = attribs[i].mCurrentValue[1]; - currentValues[i*4+2] = attribs[i].mCurrentValue[2]; - currentValues[i*4+3] = attribs[i].mCurrentValue[3]; + ERR("Lock failed with error 0x%08x", result); + return NULL; } - mCurrentValueBuffer->unmap(); + int attributeOffset = attribute.mOffset % attribute.stride(); + VertexElement element = {attribute.mType, attribute.mSize, attribute.mNormalized, attributeOffset, mWritePosition}; + mCache.push_back(element); + + *streamOffset = mWritePosition; + mWritePosition += requiredSpace; } - for (std::size_t i = 0; i < MAX_VERTEX_ATTRIBS; i++) + return mapPtr; +} + +void StaticVertexBuffer::reserveRequiredSpace() +{ + if (!mVertexBuffer && mBufferSize == 0) { - if (activeAttribs[i] && !attribs[i].mEnabled) + D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_WRITEONLY); + HRESULT result = mDevice->CreateVertexBuffer(mRequiredSpace, D3DUSAGE_WRITEONLY, 0, pool, &mVertexBuffer, NULL); + + if (FAILED(result)) { - translated[i].nonArray = true; + ERR("Out of memory allocating a vertex buffer of size %lu.", mRequiredSpace); + } - translated[i].buffer = mCurrentValueBuffer; + mBufferSize = mRequiredSpace; + } + else if (mVertexBuffer && mBufferSize >= mRequiredSpace) + { + // Already allocated + } + else UNREACHABLE(); // Static vertex buffers can't be resized - translated[i].type = GL_FLOAT; - translated[i].size = 4; - translated[i].normalized = false; - translated[i].stride = 0; - translated[i].offset = mCurrentValueOffset + 4 * sizeof(float) * i; + mRequiredSpace = 0; +} + +UINT StaticVertexBuffer::lookupAttribute(const VertexAttribute &attribute) +{ + for (unsigned int element = 0; element < mCache.size(); element++) + { + if (mCache[element].type == attribute.mType && mCache[element].size == attribute.mSize && mCache[element].normalized == attribute.mNormalized) + { + if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride()) + { + return mCache[element].streamOffset; + } } } + + return -1; } +const VertexDataManager::FormatConverter &VertexDataManager::formatConverter(const VertexAttribute &attribute) const +{ + return mAttributeTypes[typeIndex(attribute.mType)][attribute.mNormalized][attribute.mSize - 1]; +} } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.h b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.h index 04900b8..257f2c3 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/VertexDataManager.h @@ -10,7 +10,7 @@ #ifndef LIBGLESV2_GEOMETRY_VERTEXDATAMANAGER_H_ #define LIBGLESV2_GEOMETRY_VERTEXDATAMANAGER_H_ -#include <bitset> +#include <vector> #include <cstddef> #define GL_APICALL @@ -21,44 +21,148 @@ namespace gl { -class Buffer; -class BufferBackEnd; -class TranslatedVertexBuffer; -struct TranslatedAttribute; -struct FormatConverter; -struct TranslatedIndexData; +struct TranslatedAttribute +{ + bool active; + + D3DDECLTYPE type; + UINT offset; + UINT stride; // 0 means not to advance the read pointer at all + UINT semanticIndex; + + IDirect3DVertexBuffer9 *vertexBuffer; +}; + +class VertexBuffer +{ + public: + VertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags); + virtual ~VertexBuffer(); + + void unmap(); + + IDirect3DVertexBuffer9 *getBuffer() const; + + protected: + IDirect3DDevice9 *const mDevice; + IDirect3DVertexBuffer9 *mVertexBuffer; + + private: + DISALLOW_COPY_AND_ASSIGN(VertexBuffer); +}; + +class ConstantVertexBuffer : public VertexBuffer +{ + public: + ConstantVertexBuffer(IDirect3DDevice9 *device, float x, float y, float z, float w); + ~ConstantVertexBuffer(); +}; + +class ArrayVertexBuffer : public VertexBuffer +{ + public: + ArrayVertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags); + ~ArrayVertexBuffer(); + + UINT size() const { return mBufferSize; } + virtual void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset) = 0; + virtual void reserveRequiredSpace() = 0; + void addRequiredSpace(UINT requiredSpace); + void addRequiredSpaceFor(ArrayVertexBuffer *buffer); + + protected: + UINT mBufferSize; + UINT mWritePosition; + UINT mRequiredSpace; +}; + +class StreamingVertexBuffer : public ArrayVertexBuffer +{ + public: + StreamingVertexBuffer(IDirect3DDevice9 *device, UINT initialSize); + ~StreamingVertexBuffer(); + + void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset); + void reserveRequiredSpace(); +}; + +class StaticVertexBuffer : public ArrayVertexBuffer +{ + public: + explicit StaticVertexBuffer(IDirect3DDevice9 *device); + ~StaticVertexBuffer(); + + void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset); + void reserveRequiredSpace(); + + UINT lookupAttribute(const VertexAttribute &attribute); // Returns the offset into the vertex buffer, or -1 if not found + + private: + struct VertexElement + { + GLenum type; + GLint size; + bool normalized; + int attributeOffset; + + UINT streamOffset; + }; + + std::vector<VertexElement> mCache; +}; class VertexDataManager { public: - VertexDataManager(Context *context, BufferBackEnd *backend); - ~VertexDataManager(); + VertexDataManager(Context *context, IDirect3DDevice9 *backend); + virtual ~VertexDataManager(); - void dirtyCurrentValues() { mDirtyCurrentValues = true; } + void dirtyCurrentValue(int index) { mDirtyCurrentValue[index] = true; } - GLenum preRenderValidate(GLint start, - GLsizei count, - TranslatedAttribute *outAttribs); + void setupAttributes(const TranslatedAttribute *attributes); + GLenum prepareVertexData(GLint start, GLsizei count, TranslatedAttribute *outAttribs); private: - std::bitset<MAX_VERTEX_ATTRIBS> getActiveAttribs() const; + DISALLOW_COPY_AND_ASSIGN(VertexDataManager); + + UINT spaceRequired(const VertexAttribute &attrib, std::size_t count) const; + UINT writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute); + + Context *const mContext; + IDirect3DDevice9 *const mDevice; + + StreamingVertexBuffer *mStreamingBuffer; + + bool mDirtyCurrentValue[MAX_VERTEX_ATTRIBS]; + ConstantVertexBuffer *mCurrentValueBuffer[MAX_VERTEX_ATTRIBS]; + + // Attribute format conversion + struct FormatConverter + { + bool identity; + std::size_t outputElementSize; + void (*convertArray)(const void *in, std::size_t stride, std::size_t n, void *out); + D3DDECLTYPE d3dDeclType; + }; - void processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count); + enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 }; - std::size_t typeSize(GLenum type) const; - std::size_t interpretGlStride(const AttributeState &attrib) const; + FormatConverter mAttributeTypes[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1] - std::size_t roundUp(std::size_t x, std::size_t multiple) const; - std::size_t spaceRequired(const AttributeState &attrib, std::size_t maxVertex) const; + struct TranslationDescription + { + DWORD capsFlag; + FormatConverter preferredConversion; + FormatConverter fallbackConversion; + }; - Context *mContext; - BufferBackEnd *mBackend; + // This table is used to generate mAttributeTypes. + static const TranslationDescription mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1] - TranslatedVertexBuffer *mStreamBuffer; + void checkVertexCaps(DWORD declTypes); - bool mDirtyCurrentValues; - std::size_t mCurrentValueOffset; // Offset within mCurrentValueBuffer that the current attribute values were last loaded at. - TranslatedVertexBuffer *mCurrentValueBuffer; + unsigned int typeIndex(GLenum type) const; + const FormatConverter &formatConverter(const VertexAttribute &attribute) const; }; } diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.cpp deleted file mode 100644 index 3f5e283..0000000 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// geometry/backend.h: Abstract classes BufferBackEnd, TranslatedVertexBuffer and TranslatedIndexBuffer -// that must be implemented by any API-specific implementation of ANGLE. - -#include "libGLESv2/geometry/backend.h" - -#include "common/debug.h" - -namespace gl -{ - -void *TranslatedBuffer::map(std::size_t requiredSpace, std::size_t *offset) -{ - ASSERT(requiredSpace <= mBufferSize); - - reserveSpace(requiredSpace); - - *offset = mCurrentPoint; - mCurrentPoint += requiredSpace; - - return streamingMap(*offset, requiredSpace); -} - -void TranslatedBuffer::reserveSpace(std::size_t requiredSpace) -{ - if (mCurrentPoint + requiredSpace > mBufferSize) - { - recycle(); - mCurrentPoint = 0; - } -} - -} diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.h b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.h deleted file mode 100644 index d18a908..0000000 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/backend.h +++ /dev/null @@ -1,110 +0,0 @@ -// -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// geometry/backend.h: Abstract classes BufferBackEnd, TranslatedVertexBuffer and TranslatedIndexBuffer -// that must be implemented by any API-specific implementation of ANGLE. - -#ifndef LIBGLESV2_GEOMETRY_BACKEND_H_ -#define LIBGLESV2_GEOMETRY_BACKEND_H_ - -#include <cstddef> - -#define GL_APICALL -#include <GLES2/gl2.h> - -#include "libGLESv2/Context.h" - -namespace gl -{ -class TranslatedVertexBuffer; -class TranslatedIndexBuffer; - -struct FormatConverter -{ - bool identity; - std::size_t outputVertexSize; - void (*convertArray)(const void *in, std::size_t stride, std::size_t n, void *out); -}; - -struct TranslatedAttribute -{ - bool enabled; - bool nonArray; - - // These are the original untranslated values. (Or just have some sort of BufferBackEnd::TranslatedTypeKey.) - GLenum type; - std::size_t size; - bool normalized; - - std::size_t offset; - - std::size_t stride; // 0 means not to advance the read pointer at all - - std::size_t semanticIndex; - - TranslatedVertexBuffer *buffer; -}; - -class BufferBackEnd -{ - public: - virtual ~BufferBackEnd() { } - - virtual bool supportIntIndices() = 0; - - virtual TranslatedVertexBuffer *createVertexBuffer(std::size_t size) = 0; - virtual TranslatedVertexBuffer *createVertexBufferForStrideZero(std::size_t size) = 0; - virtual TranslatedIndexBuffer *createIndexBuffer(std::size_t size, GLenum type) = 0; - virtual FormatConverter getFormatConverter(GLenum type, std::size_t size, bool normalize) = 0; - - // For an identity-mappable stream, verify that the stride and offset are okay. - virtual bool validateStream(GLenum type, std::size_t size, std::size_t stride, std::size_t offset) const = 0; - - virtual GLenum setupIndicesPreDraw(const TranslatedIndexData &indexInfo) = 0; - virtual GLenum setupAttributesPreDraw(const TranslatedAttribute *attributes) = 0; -}; - -class TranslatedBuffer -{ - public: - explicit TranslatedBuffer(std::size_t size) : mBufferSize(size), mCurrentPoint(0) { } - virtual ~TranslatedBuffer() { } - - std::size_t size() const { return mBufferSize; } - - virtual void *map() = 0; - virtual void unmap() = 0; - - void reserveSpace(std::size_t requiredSpace); - - void *map(std::size_t requiredSpace, std::size_t *offset); - - protected: - virtual void recycle() = 0; - virtual void *streamingMap(std::size_t offset, std::size_t size) = 0; - - private: - std::size_t mBufferSize; - std::size_t mCurrentPoint; - - DISALLOW_COPY_AND_ASSIGN(TranslatedBuffer); -}; - -class TranslatedVertexBuffer : public TranslatedBuffer -{ - public: - explicit TranslatedVertexBuffer(std::size_t size) : TranslatedBuffer(size) { } -}; - -class TranslatedIndexBuffer : public TranslatedBuffer -{ - public: - explicit TranslatedIndexBuffer(std::size_t size) : TranslatedBuffer(size) { } -}; - -} - -#endif // LIBGLESV2_GEOMETRY_BACKEND_H_ diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.cpp deleted file mode 100644 index e51befb..0000000 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.cpp +++ /dev/null @@ -1,613 +0,0 @@ -// -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// geometry/dx9.h: Direct3D 9-based implementation of BufferBackEnd, TranslatedVertexBuffer and TranslatedIndexBuffer. - -#include "libGLESv2/geometry/dx9.h" - -#include <cstddef> - -#define GL_APICALL -#include <GLES2/gl2.h> - -#include "common/debug.h" - -#include "libGLESv2/Context.h" -#include "libGLESv2/main.h" -#include "libGLESv2/geometry/vertexconversion.h" -#include "libGLESv2/geometry/IndexDataManager.h" - -namespace -{ -// Mapping from OpenGL-ES vertex attrib type to D3D decl type: -// -// BYTE SHORT (Cast) -// BYTE-norm FLOAT (Normalize) (can't be exactly represented as SHORT-norm) -// UNSIGNED_BYTE UBYTE4 (Identity) or SHORT (Cast) -// UNSIGNED_BYTE-norm UBYTE4N (Identity) or FLOAT (Normalize) -// SHORT SHORT (Identity) -// SHORT-norm SHORT-norm (Identity) or FLOAT (Normalize) -// UNSIGNED_SHORT FLOAT (Cast) -// UNSIGNED_SHORT-norm USHORT-norm (Identity) or FLOAT (Normalize) -// FIXED (not in WebGL) FLOAT (FixedToFloat) -// FLOAT FLOAT (Identity) - -// GLToCType maps from GL type (as GLenum) to the C typedef. -template <GLenum GLType> struct GLToCType { }; - -template <> struct GLToCType<GL_BYTE> { typedef GLbyte type; }; -template <> struct GLToCType<GL_UNSIGNED_BYTE> { typedef GLubyte type; }; -template <> struct GLToCType<GL_SHORT> { typedef GLshort type; }; -template <> struct GLToCType<GL_UNSIGNED_SHORT> { typedef GLushort type; }; -template <> struct GLToCType<GL_FIXED> { typedef GLuint type; }; -template <> struct GLToCType<GL_FLOAT> { typedef GLfloat type; }; - -// This differs from D3DDECLTYPE in that it is unsized. (Size expansion is applied last.) -enum D3DVertexType -{ - D3DVT_FLOAT, - D3DVT_SHORT, - D3DVT_SHORT_NORM, - D3DVT_UBYTE, - D3DVT_UBYTE_NORM, - D3DVT_USHORT_NORM -}; - -// D3DToCType maps from D3D vertex type (as enum D3DVertexType) to the corresponding C type. -template <unsigned int D3DType> struct D3DToCType { }; - -template <> struct D3DToCType<D3DVT_FLOAT> { typedef float type; }; -template <> struct D3DToCType<D3DVT_SHORT> { typedef short type; }; -template <> struct D3DToCType<D3DVT_SHORT_NORM> { typedef short type; }; -template <> struct D3DToCType<D3DVT_UBYTE> { typedef unsigned char type; }; -template <> struct D3DToCType<D3DVT_UBYTE_NORM> { typedef unsigned char type; }; -template <> struct D3DToCType<D3DVT_USHORT_NORM> { typedef unsigned short type; }; - -// Encode the type/size combinations that D3D permits. For each type/size it expands to a widener that will provide the appropriate final size. -template <unsigned int type, int size> -struct WidenRule -{ -}; - -template <int size> struct WidenRule<D3DVT_FLOAT, size> : gl::NoWiden<size> { }; -template <int size> struct WidenRule<D3DVT_SHORT, size> : gl::WidenToEven<size> { }; -template <int size> struct WidenRule<D3DVT_SHORT_NORM, size> : gl::WidenToEven<size> { }; -template <int size> struct WidenRule<D3DVT_UBYTE, size> : gl::WidenToFour<size> { }; -template <int size> struct WidenRule<D3DVT_UBYTE_NORM, size> : gl::WidenToFour<size> { }; -template <int size> struct WidenRule<D3DVT_USHORT_NORM, size> : gl::WidenToEven<size> { }; - -// VertexTypeFlags encodes the D3DCAPS9::DeclType flag and vertex declaration flag for each D3D vertex type & size combination. -template <unsigned int d3dtype, int size> -struct VertexTypeFlags -{ -}; - -template <unsigned int capflag, unsigned int declflag> -struct VertexTypeFlagsHelper -{ - enum { capflag = capflag }; - enum { declflag = declflag }; -}; - -template <> struct VertexTypeFlags<D3DVT_FLOAT, 1> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT1> { }; -template <> struct VertexTypeFlags<D3DVT_FLOAT, 2> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT2> { }; -template <> struct VertexTypeFlags<D3DVT_FLOAT, 3> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT3> { }; -template <> struct VertexTypeFlags<D3DVT_FLOAT, 4> : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT4> { }; -template <> struct VertexTypeFlags<D3DVT_SHORT, 2> : VertexTypeFlagsHelper<0, D3DDECLTYPE_SHORT2> { }; -template <> struct VertexTypeFlags<D3DVT_SHORT, 4> : VertexTypeFlagsHelper<0, D3DDECLTYPE_SHORT4> { }; -template <> struct VertexTypeFlags<D3DVT_SHORT_NORM, 2> : VertexTypeFlagsHelper<D3DDTCAPS_SHORT2N, D3DDECLTYPE_SHORT2N> { }; -template <> struct VertexTypeFlags<D3DVT_SHORT_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_SHORT4N, D3DDECLTYPE_SHORT4N> { }; -template <> struct VertexTypeFlags<D3DVT_UBYTE, 4> : VertexTypeFlagsHelper<D3DDTCAPS_UBYTE4, D3DDECLTYPE_UBYTE4> { }; -template <> struct VertexTypeFlags<D3DVT_UBYTE_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_UBYTE4N, D3DDECLTYPE_UBYTE4N> { }; -template <> struct VertexTypeFlags<D3DVT_USHORT_NORM, 2> : VertexTypeFlagsHelper<D3DDTCAPS_USHORT2N, D3DDECLTYPE_USHORT2N> { }; -template <> struct VertexTypeFlags<D3DVT_USHORT_NORM, 4> : VertexTypeFlagsHelper<D3DDTCAPS_USHORT4N, D3DDECLTYPE_USHORT4N> { }; - - -// VertexTypeMapping maps GL type & normalized flag to preferred and fallback D3D vertex types (as D3DVertexType enums). -template <GLenum GLtype, bool normalized> -struct VertexTypeMapping -{ -}; - -template <D3DVertexType Preferred, D3DVertexType Fallback = Preferred> -struct VertexTypeMappingBase -{ - enum { preferred = Preferred }; - enum { fallback = Fallback }; -}; - -template <> struct VertexTypeMapping<GL_BYTE, false> : VertexTypeMappingBase<D3DVT_SHORT> { }; // Cast -template <> struct VertexTypeMapping<GL_BYTE, true> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Normalize -template <> struct VertexTypeMapping<GL_UNSIGNED_BYTE, false> : VertexTypeMappingBase<D3DVT_UBYTE, D3DVT_FLOAT> { }; // Identity, Cast -template <> struct VertexTypeMapping<GL_UNSIGNED_BYTE, true> : VertexTypeMappingBase<D3DVT_UBYTE_NORM, D3DVT_FLOAT> { }; // Identity, Normalize -template <> struct VertexTypeMapping<GL_SHORT, false> : VertexTypeMappingBase<D3DVT_SHORT> { }; // Identity -template <> struct VertexTypeMapping<GL_SHORT, true> : VertexTypeMappingBase<D3DVT_SHORT_NORM, D3DVT_FLOAT> { }; // Cast, Normalize -template <> struct VertexTypeMapping<GL_UNSIGNED_SHORT, false> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Cast -template <> struct VertexTypeMapping<GL_UNSIGNED_SHORT, true> : VertexTypeMappingBase<D3DVT_USHORT_NORM, D3DVT_FLOAT> { }; // Cast, Normalize -template <bool normalized> struct VertexTypeMapping<GL_FIXED, normalized> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // FixedToFloat -template <bool normalized> struct VertexTypeMapping<GL_FLOAT, normalized> : VertexTypeMappingBase<D3DVT_FLOAT> { }; // Identity - - -// Given a GL type & norm flag and a D3D type, ConversionRule provides the type conversion rule (Cast, Normalize, Identity, FixedToFloat). -// The conversion rules themselves are defined in vertexconversion.h. - -// Almost all cases are covered by Cast (including those that are actually Identity since Cast<T,T> knows it's an identity mapping). -template <GLenum fromType, bool normalized, unsigned int toType> -struct ConversionRule : gl::Cast<typename GLToCType<fromType>::type, typename D3DToCType<toType>::type> -{ -}; - -// All conversions from normalized types to float use the Normalize operator. -template <GLenum fromType> struct ConversionRule<fromType, true, D3DVT_FLOAT> : gl::Normalize<typename GLToCType<fromType>::type> { }; - -// Use a full specialisation for this so that it preferentially matches ahead of the generic normalize-to-float rules. -template <> struct ConversionRule<GL_FIXED, true, D3DVT_FLOAT> : gl::FixedToFloat<GLuint, 16> { }; -template <> struct ConversionRule<GL_FIXED, false, D3DVT_FLOAT> : gl::FixedToFloat<GLuint, 16> { }; - -// A 2-stage construction is used for DefaultVertexValues because float must use SimpleDefaultValues (i.e. 0/1) -// whether it is normalized or not. -template <class T, bool normalized> -struct DefaultVertexValuesStage2 -{ -}; - -template <class T> struct DefaultVertexValuesStage2<T, true> : gl::NormalizedDefaultValues<T> { }; -template <class T> struct DefaultVertexValuesStage2<T, false> : gl::SimpleDefaultValues<T> { }; - -// Work out the default value rule for a D3D type (expressed as the C type) and -template <class T, bool normalized> -struct DefaultVertexValues : DefaultVertexValuesStage2<T, normalized> -{ -}; - -template <bool normalized> struct DefaultVertexValues<float, normalized> : gl::SimpleDefaultValues<float> { }; - -// Policy rules for use with Converter, to choose whether to use the preferred or fallback conversion. -// The fallback conversion produces an output that all D3D9 devices must support. -template <class T> struct UsePreferred { enum { type = T::preferred }; }; -template <class T> struct UseFallback { enum { type = T::fallback }; }; - -// Converter ties it all together. Given an OpenGL type/norm/size and choice of preferred/fallback conversion, -// it provides all the members of the appropriate VertexDataConverter, the D3DCAPS9::DeclTypes flag in cap flag -// and the D3DDECLTYPE member needed for the vertex declaration in declflag. -template <GLenum fromType, bool normalized, int size, template <class T> class PreferenceRule> -struct Converter - : gl::VertexDataConverter<typename GLToCType<fromType>::type, - WidenRule<PreferenceRule< VertexTypeMapping<fromType, normalized> >::type, size>, - ConversionRule<fromType, - normalized, - PreferenceRule< VertexTypeMapping<fromType, normalized> >::type>, - DefaultVertexValues<typename D3DToCType<PreferenceRule< VertexTypeMapping<fromType, normalized> >::type>::type, normalized > > -{ -private: - enum { d3dtype = PreferenceRule< VertexTypeMapping<fromType, normalized> >::type }; - enum { d3dsize = WidenRule<d3dtype, size>::finalWidth }; - -public: - enum { capflag = VertexTypeFlags<d3dtype, d3dsize>::capflag }; - enum { declflag = VertexTypeFlags<d3dtype, d3dsize>::declflag }; -}; - -} - -namespace gl -{ -Dx9BackEnd::Dx9BackEnd(Context *context, IDirect3DDevice9 *d3ddevice) - : mDevice(d3ddevice) -{ - mDevice->AddRef(); - - for (int i = 0; i < MAX_VERTEX_ATTRIBS; ++i) - { - mAppliedAttribEnabled[i] = true; - mStreamFrequency[i] = STREAM_FREQUENCY_UNINSTANCED; - } - - mStreamFrequency[MAX_VERTEX_ATTRIBS] = STREAM_FREQUENCY_UNINSTANCED; - - D3DCAPS9 caps = context->getDeviceCaps(); - - IDirect3D9 *d3dObject; - mDevice->GetDirect3D(&d3dObject); - - D3DADAPTER_IDENTIFIER9 ident; - d3dObject->GetAdapterIdentifier(caps.AdapterOrdinal, 0, &ident); - d3dObject->Release(); - - // Instancing is mandatory for all HW with SM3 vertex shaders, but avoid hardware where it does not work. - mUseInstancingForStrideZero = (caps.VertexShaderVersion >= D3DVS_VERSION(3, 0) && ident.VendorId != 0x8086); - mSupportIntIndices = (caps.MaxVertexIndex >= (1 << 16)); - - checkVertexCaps(caps.DeclTypes); -} - -Dx9BackEnd::~Dx9BackEnd() -{ - mDevice->Release(); -} - -bool Dx9BackEnd::supportIntIndices() -{ - return mSupportIntIndices; -} - -// Initialise a TranslationInfo -#define TRANSLATION(type, norm, size, preferred) \ - { \ - { \ - Converter<type, norm, size, preferred>::identity, \ - Converter<type, norm, size, preferred>::finalSize, \ - Converter<type, norm, size, preferred>::convertArray, \ - }, \ - static_cast<D3DDECLTYPE>(Converter<type, norm, size, preferred>::declflag) \ - } - -#define TRANSLATION_FOR_TYPE_NORM_SIZE(type, norm, size) \ - { \ - Converter<type, norm, size, UsePreferred>::capflag, \ - TRANSLATION(type, norm, size, UsePreferred), \ - TRANSLATION(type, norm, size, UseFallback) \ - } - -#define TRANSLATIONS_FOR_TYPE(type) \ - { \ - { TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, false, 4) }, \ - { TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 1), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 2), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 3), TRANSLATION_FOR_TYPE_NORM_SIZE(type, true, 4) }, \ - } - -const Dx9BackEnd::TranslationDescription Dx9BackEnd::mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4] = // [GL types as enumerated by typeIndex()][normalized][size-1] -{ - TRANSLATIONS_FOR_TYPE(GL_BYTE), - TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_BYTE), - TRANSLATIONS_FOR_TYPE(GL_SHORT), - TRANSLATIONS_FOR_TYPE(GL_UNSIGNED_SHORT), - TRANSLATIONS_FOR_TYPE(GL_FIXED), - TRANSLATIONS_FOR_TYPE(GL_FLOAT) -}; - -void Dx9BackEnd::checkVertexCaps(DWORD declTypes) -{ - for (unsigned int i = 0; i < NUM_GL_VERTEX_ATTRIB_TYPES; i++) - { - for (unsigned int j = 0; j < 2; j++) - { - for (unsigned int k = 0; k < 4; k++) - { - if (mPossibleTranslations[i][j][k].capsFlag == 0 || (declTypes & mPossibleTranslations[i][j][k].capsFlag) != 0) - { - mAttributeTypes[i][j][k] = mPossibleTranslations[i][j][k].preferredConversion; - } - else - { - mAttributeTypes[i][j][k] = mPossibleTranslations[i][j][k].fallbackConversion; - } - } - } - } -} - -TranslatedVertexBuffer *Dx9BackEnd::createVertexBuffer(std::size_t size) -{ - return new Dx9VertexBuffer(mDevice, size); -} - -TranslatedVertexBuffer *Dx9BackEnd::createVertexBufferForStrideZero(std::size_t size) -{ - if (mUseInstancingForStrideZero) - { - return new Dx9VertexBuffer(mDevice, size); - } - else - { - return new Dx9VertexBufferZeroStrideWorkaround(mDevice, size); - } -} - -TranslatedIndexBuffer *Dx9BackEnd::createIndexBuffer(std::size_t size, GLenum type) -{ - return new Dx9IndexBuffer(mDevice, size, type); -} - -// This is used to index mAttributeTypes and mPossibleTranslations. -unsigned int Dx9BackEnd::typeIndex(GLenum type) const -{ - switch (type) - { - case GL_BYTE: return 0; - case GL_UNSIGNED_BYTE: return 1; - case GL_SHORT: return 2; - case GL_UNSIGNED_SHORT: return 3; - case GL_FIXED: return 4; - case GL_FLOAT: return 5; - - default: UNREACHABLE(); return 5; - } -} - -FormatConverter Dx9BackEnd::getFormatConverter(GLenum type, std::size_t size, bool normalize) -{ - return mAttributeTypes[typeIndex(type)][normalize][size-1].formatConverter; -} - -D3DDECLTYPE Dx9BackEnd::mapAttributeType(GLenum type, std::size_t size, bool normalize) const -{ - return mAttributeTypes[typeIndex(type)][normalize][size-1].d3dDeclType; -} - -bool Dx9BackEnd::validateStream(GLenum type, std::size_t size, std::size_t stride, std::size_t offset) const -{ - // D3D9 requires the stream offset and stride to be a multiple of DWORD. - return (stride % sizeof(DWORD) == 0 && offset % sizeof(DWORD) == 0); -} - -IDirect3DVertexBuffer9 *Dx9BackEnd::getDxBuffer(TranslatedVertexBuffer *vb) const -{ - return vb ? static_cast<Dx9VertexBuffer*>(vb)->getBuffer() : NULL; -} - -IDirect3DIndexBuffer9 *Dx9BackEnd::getDxBuffer(TranslatedIndexBuffer *ib) const -{ - return ib ? static_cast<Dx9IndexBuffer*>(ib)->getBuffer() : NULL; -} - -GLenum Dx9BackEnd::setupIndicesPreDraw(const TranslatedIndexData &indexInfo) -{ - mDevice->SetIndices(getDxBuffer(indexInfo.buffer)); - return GL_NO_ERROR; -} - -GLenum Dx9BackEnd::setupAttributesPreDraw(const TranslatedAttribute *attributes) -{ - HRESULT hr; - - D3DVERTEXELEMENT9 elements[MAX_VERTEX_ATTRIBS+1]; - - D3DVERTEXELEMENT9 *nextElement = &elements[0]; - - for (BYTE i = 0; i < MAX_VERTEX_ATTRIBS; i++) - { - if (attributes[i].enabled) - { - nextElement->Stream = i + 1; // Stream 0 is skipped because D3D does not permit it to be an instanced stream. - nextElement->Offset = 0; - nextElement->Type = static_cast<BYTE>(mapAttributeType(attributes[i].type, attributes[i].size, attributes[i].normalized)); - nextElement->Method = D3DDECLMETHOD_DEFAULT; - nextElement->Usage = D3DDECLUSAGE_TEXCOORD; - nextElement->UsageIndex = attributes[i].semanticIndex; - nextElement++; - } - } - - static const D3DVERTEXELEMENT9 end = D3DDECL_END(); - *nextElement = end; - - IDirect3DVertexDeclaration9* vertexDeclaration; - hr = mDevice->CreateVertexDeclaration(elements, &vertexDeclaration); - mDevice->SetVertexDeclaration(vertexDeclaration); - vertexDeclaration->Release(); - - mDevice->SetStreamSource(0, NULL, 0, 0); - - bool nonArrayAttributes = false; - - for (size_t i = 0; i < MAX_VERTEX_ATTRIBS; i++) - { - if (attributes[i].enabled) - { - if (attributes[i].nonArray) nonArrayAttributes = true; - - mDevice->SetStreamSource(i + 1, getDxBuffer(attributes[i].buffer), attributes[i].offset, attributes[i].stride); - if (!mAppliedAttribEnabled[i]) - { - mAppliedAttribEnabled[i] = true; - } - } - else - { - if (mAppliedAttribEnabled[i]) - { - mDevice->SetStreamSource(i + 1, 0, 0, 0); - mAppliedAttribEnabled[i] = false; - } - } - } - - if (mUseInstancingForStrideZero) - { - // When there are no stride zero attributes, we disable instancing so that DrawPrimitive can be used. - - if (nonArrayAttributes) - { - if (mStreamFrequency[0] != STREAM_FREQUENCY_INDEXED) - { - mStreamFrequency[0] = STREAM_FREQUENCY_INDEXED; - mDevice->SetStreamSourceFreq(0, D3DSTREAMSOURCE_INDEXEDDATA | 1); - } - - for (size_t i = 0; i < MAX_VERTEX_ATTRIBS; i++) - { - if (attributes[i].enabled) - { - if (attributes[i].nonArray) - { - if (mStreamFrequency[i+1] != STREAM_FREQUENCY_INSTANCED) - { - mStreamFrequency[i+1] = STREAM_FREQUENCY_INSTANCED; - mDevice->SetStreamSourceFreq(i + 1, D3DSTREAMSOURCE_INSTANCEDATA | 1); - } - } - else - { - if (mStreamFrequency[i+1] != STREAM_FREQUENCY_INDEXED) - { - mStreamFrequency[i+1] = STREAM_FREQUENCY_INDEXED; - mDevice->SetStreamSourceFreq(i + 1, D3DSTREAMSOURCE_INDEXEDDATA | 1); - } - } - } - } - } - else - { - for (size_t i = 0; i < MAX_VERTEX_ATTRIBS + 1; i++) - { - if (mStreamFrequency[i] != STREAM_FREQUENCY_UNINSTANCED) - { - mStreamFrequency[i] = STREAM_FREQUENCY_UNINSTANCED; - - // This should not be needed, but otherwise there is a buggy driver that will leave instancing - // enabled for the first draw after it has been turned off. - mDevice->SetStreamSourceFreq(i, D3DSTREAMSOURCE_INDEXEDDATA | 1); - - mDevice->SetStreamSourceFreq(i, 1); - } - } - } - } - - return GL_NO_ERROR; -} - -Dx9BackEnd::Dx9VertexBuffer::Dx9VertexBuffer(IDirect3DDevice9 *device, std::size_t size) - : TranslatedVertexBuffer(size) -{ - HRESULT hr = device->CreateVertexBuffer(size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &mVertexBuffer, NULL); - if (hr != S_OK) - { - ERR("Out of memory allocating a vertex buffer of size %lu.", size); - throw std::bad_alloc(); - } -} - -Dx9BackEnd::Dx9VertexBuffer::Dx9VertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags) - : TranslatedVertexBuffer(size) -{ - HRESULT hr = device->CreateVertexBuffer(size, usageFlags, 0, D3DPOOL_DEFAULT, &mVertexBuffer, NULL); - if (hr != S_OK) - { - ERR("Out of memory allocating a vertex buffer of size %lu.", size); - throw std::bad_alloc(); - } -} - - -Dx9BackEnd::Dx9VertexBuffer::~Dx9VertexBuffer() -{ - mVertexBuffer->Release(); -} - -IDirect3DVertexBuffer9 *Dx9BackEnd::Dx9VertexBuffer::getBuffer() const -{ - return mVertexBuffer; -} - -void *Dx9BackEnd::Dx9VertexBuffer::map() -{ - void *mapPtr; - - mVertexBuffer->Lock(0, 0, &mapPtr, 0); - - return mapPtr; -} - -void Dx9BackEnd::Dx9VertexBuffer::unmap() -{ - mVertexBuffer->Unlock(); -} - -void Dx9BackEnd::Dx9VertexBuffer::recycle() -{ - void *dummy; - mVertexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD); - mVertexBuffer->Unlock(); -} - -void *Dx9BackEnd::Dx9VertexBuffer::streamingMap(std::size_t offset, std::size_t size) -{ - void *mapPtr; - - mVertexBuffer->Lock(offset, size, &mapPtr, D3DLOCK_NOOVERWRITE); - - return mapPtr; -} - -// Normally VBs are created with D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, but some hardware & drivers won't render -// if any stride-zero streams are in D3DUSAGE_DYNAMIC VBs, so this provides a way to create such VBs with only D3DUSAGE_WRITEONLY set. -// D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE are only available on D3DUSAGE_DYNAMIC VBs, so we override methods to avoid using these flags. -Dx9BackEnd::Dx9VertexBufferZeroStrideWorkaround::Dx9VertexBufferZeroStrideWorkaround(IDirect3DDevice9 *device, std::size_t size) - : Dx9VertexBuffer(device, size, D3DUSAGE_WRITEONLY) -{ -} - -void Dx9BackEnd::Dx9VertexBufferZeroStrideWorkaround::recycle() -{ -} - -void *Dx9BackEnd::Dx9VertexBufferZeroStrideWorkaround::streamingMap(std::size_t offset, std::size_t size) -{ - void *mapPtr; - - getBuffer()->Lock(offset, size, &mapPtr, 0); - - return mapPtr; -} - -Dx9BackEnd::Dx9IndexBuffer::Dx9IndexBuffer(IDirect3DDevice9 *device, std::size_t size, GLenum type) - : TranslatedIndexBuffer(size) -{ - ASSERT(type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT); - - D3DFORMAT format = (type == GL_UNSIGNED_SHORT) ? D3DFMT_INDEX16 : D3DFMT_INDEX32; - - HRESULT hr = device->CreateIndexBuffer(size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, format, D3DPOOL_DEFAULT, &mIndexBuffer, NULL); - if (hr != S_OK) - { - ERR("Out of memory allocating an index buffer of size %lu.", size); - throw std::bad_alloc(); - } -} - -Dx9BackEnd::Dx9IndexBuffer::~Dx9IndexBuffer() -{ - mIndexBuffer->Release(); -} - -IDirect3DIndexBuffer9*Dx9BackEnd::Dx9IndexBuffer::getBuffer() const -{ - return mIndexBuffer; -} - -void *Dx9BackEnd::Dx9IndexBuffer::map() -{ - void *mapPtr; - - mIndexBuffer->Lock(0, 0, &mapPtr, 0); - - return mapPtr; -} - -void Dx9BackEnd::Dx9IndexBuffer::unmap() -{ - mIndexBuffer->Unlock(); -} - -void Dx9BackEnd::Dx9IndexBuffer::recycle() -{ - void *dummy; - mIndexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD); - mIndexBuffer->Unlock(); -} - -void *Dx9BackEnd::Dx9IndexBuffer::streamingMap(std::size_t offset, std::size_t size) -{ - void *mapPtr; - - mIndexBuffer->Lock(offset, size, &mapPtr, D3DLOCK_NOOVERWRITE); - - return mapPtr; -} - -} diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.h b/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.h deleted file mode 100644 index 6068dd6..0000000 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/geometry/dx9.h +++ /dev/null @@ -1,137 +0,0 @@ -// -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// - -// geometry/dx9.h: Direct3D 9-based implementation of BufferBackEnd, TranslatedVertexBuffer and TranslatedIndexBuffer. - -#ifndef LIBGLESV2_GEOMETRY_DX9_H_ -#define LIBGLESV2_GEOMETRY_DX9_H_ - -#include <d3d9.h> - -#include "libGLESv2/Buffer.h" -#include "libGLESv2/geometry/backend.h" - -namespace gl -{ - -class Dx9BackEnd : public BufferBackEnd -{ - public: - explicit Dx9BackEnd(Context *context, IDirect3DDevice9 *d3ddevice); - ~Dx9BackEnd(); - - virtual bool supportIntIndices(); - - virtual TranslatedVertexBuffer *createVertexBuffer(std::size_t size); - virtual TranslatedVertexBuffer *createVertexBufferForStrideZero(std::size_t size); - virtual TranslatedIndexBuffer *createIndexBuffer(std::size_t size, GLenum type); - virtual FormatConverter getFormatConverter(GLenum type, std::size_t size, bool normalize); - - virtual bool validateStream(GLenum type, std::size_t size, std::size_t stride, std::size_t offset) const; - - virtual GLenum setupIndicesPreDraw(const TranslatedIndexData &indexInfo); - virtual GLenum setupAttributesPreDraw(const TranslatedAttribute *attributes); - - private: - IDirect3DDevice9 *mDevice; - - bool mUseInstancingForStrideZero; - bool mSupportIntIndices; - - bool mAppliedAttribEnabled[MAX_VERTEX_ATTRIBS]; - - enum StreamFrequency - { - STREAM_FREQUENCY_UNINSTANCED = 0, - STREAM_FREQUENCY_INDEXED, - STREAM_FREQUENCY_INSTANCED - }; - - StreamFrequency mStreamFrequency[MAX_VERTEX_ATTRIBS+1]; - - struct TranslationInfo - { - FormatConverter formatConverter; - D3DDECLTYPE d3dDeclType; - }; - - enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 }; - - TranslationInfo mAttributeTypes[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size-1] - - struct TranslationDescription - { - DWORD capsFlag; - TranslationInfo preferredConversion; - TranslationInfo fallbackConversion; - }; - - // This table is used to generate mAttributeTypes. - static const TranslationDescription mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size-1] - - void checkVertexCaps(DWORD declTypes); - - unsigned int typeIndex(GLenum type) const; - - class Dx9VertexBuffer : public TranslatedVertexBuffer - { - public: - Dx9VertexBuffer(IDirect3DDevice9 *device, std::size_t size); - virtual ~Dx9VertexBuffer(); - - IDirect3DVertexBuffer9 *getBuffer() const; - - protected: - Dx9VertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags); - - virtual void *map(); - virtual void unmap(); - - virtual void recycle(); - virtual void *streamingMap(std::size_t offset, std::size_t size); - - private: - IDirect3DVertexBuffer9 *mVertexBuffer; - }; - - class Dx9VertexBufferZeroStrideWorkaround : public Dx9VertexBuffer - { - public: - Dx9VertexBufferZeroStrideWorkaround(IDirect3DDevice9 *device, std::size_t size); - - protected: - virtual void recycle(); - virtual void *streamingMap(std::size_t offset, std::size_t size); - }; - - class Dx9IndexBuffer : public TranslatedIndexBuffer - { - public: - Dx9IndexBuffer(IDirect3DDevice9 *device, std::size_t size, GLenum type); - virtual ~Dx9IndexBuffer(); - - IDirect3DIndexBuffer9 *getBuffer() const; - - protected: - virtual void *map(); - virtual void unmap(); - - virtual void recycle(); - virtual void *streamingMap(std::size_t offset, std::size_t size); - - private: - IDirect3DIndexBuffer9 *mIndexBuffer; - }; - - IDirect3DVertexBuffer9 *getDxBuffer(TranslatedVertexBuffer *vb) const; - IDirect3DIndexBuffer9 *getDxBuffer(TranslatedIndexBuffer *ib) const; - - D3DDECLTYPE mapAttributeType(GLenum type, std::size_t size, bool normalized) const; -}; - -} - -#endif // LIBGLESV2_GEOMETRY_DX9_H_ diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp index 25d083b..543c0d2 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp @@ -20,6 +20,7 @@ #include "libGLESv2/utilities.h" #include "libGLESv2/Buffer.h" #include "libGLESv2/Context.h" +#include "libGLESv2/Fence.h" #include "libGLESv2/Framebuffer.h" #include "libGLESv2/Program.h" #include "libGLESv2/Renderbuffer.h" @@ -736,7 +737,7 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna try { - if (level < 0 || level > gl::MAX_TEXTURE_LEVELS) + if (level < 0) { return error(GL_INVALID_VALUE); } @@ -746,34 +747,6 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna return error(GL_INVALID_VALUE); } - switch (target) - { - case GL_TEXTURE_2D: - if (width > (gl::MAX_TEXTURE_SIZE >> level) || height > (gl::MAX_TEXTURE_SIZE >> level)) - { - return error(GL_INVALID_VALUE); - } - break; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - if (width != height) - { - return error(GL_INVALID_VALUE); - } - - if (width > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level) || height > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level)) - { - return error(GL_INVALID_VALUE); - } - break; - default: - return error(GL_INVALID_ENUM); - } - switch (internalformat) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: @@ -792,6 +765,41 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna if (context) { + if (level > context->getMaximumTextureLevel()) + { + return error(GL_INVALID_VALUE); + } + + switch (target) + { + case GL_TEXTURE_2D: + if (width > (context->getMaximumTextureDimension() >> level) || + height > (context->getMaximumTextureDimension() >> level)) + { + return error(GL_INVALID_VALUE); + } + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) + { + return error(GL_INVALID_VALUE); + } + + if (width > (context->getMaximumCubeTextureDimension() >> level) || + height > (context->getMaximumCubeTextureDimension() >> level)) + { + return error(GL_INVALID_VALUE); + } + break; + default: + return error(GL_INVALID_ENUM); + } + if (!context->supportsCompressedTextures()) { return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed @@ -859,7 +867,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs return error(GL_INVALID_ENUM); } - if (level < 0 || level > gl::MAX_TEXTURE_LEVELS) + if (level < 0) { return error(GL_INVALID_VALUE); } @@ -888,6 +896,11 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs if (context) { + if (level > context->getMaximumTextureLevel()) + { + return error(GL_INVALID_VALUE); + } + if (!context->supportsCompressedTextures()) { return error(GL_INVALID_ENUM); // in this case, it's as though the format switch has failed. @@ -978,48 +991,6 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma return error(GL_INVALID_VALUE); } - switch (target) - { - case GL_TEXTURE_2D: - if (width > (gl::MAX_TEXTURE_SIZE >> level) || height > (gl::MAX_TEXTURE_SIZE >> level)) - { - return error(GL_INVALID_VALUE); - } - break; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - if (width != height) - { - return error(GL_INVALID_VALUE); - } - - if (width > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level) || height > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level)) - { - return error(GL_INVALID_VALUE); - } - break; - default: - return error(GL_INVALID_ENUM); - } - - switch (internalformat) - { - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_RGBA: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // Compressed textures are not supported here, but if they are unsupported altogether, - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: // a different error is generated than otherwise. That is handled below. - break; - default: - return error(GL_INVALID_VALUE); - } - if (border != 0) { return error(GL_INVALID_VALUE); @@ -1029,20 +1000,38 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma if (context) { - if (internalformat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || - internalformat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) + switch (target) { - if (context->supportsCompressedTextures()) + case GL_TEXTURE_2D: + if (width > (context->getMaximumTextureDimension() >> level) || + height > (context->getMaximumTextureDimension() >> level)) { - return error(GL_INVALID_OPERATION); + return error(GL_INVALID_VALUE); } - else + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) { - return error(GL_INVALID_ENUM); + return error(GL_INVALID_VALUE); } + + if (width > (context->getMaximumCubeTextureDimension() >> level) || + height > (context->getMaximumCubeTextureDimension() >> level)) + { + return error(GL_INVALID_VALUE); + } + break; + default: + return error(GL_INVALID_ENUM); } gl::Framebuffer *framebuffer = context->getReadFramebuffer(); + if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) { return error(GL_INVALID_FRAMEBUFFER_OPERATION); @@ -1054,6 +1043,59 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma } gl::Colorbuffer *source = framebuffer->getColorbuffer(); + GLenum colorbufferFormat = source->getFormat(); + + // [OpenGL ES 2.0.24] table 3.9 + switch (internalformat) + { + case GL_ALPHA: + if (colorbufferFormat != GL_ALPHA && + colorbufferFormat != GL_RGBA && + colorbufferFormat != GL_RGBA4 && + colorbufferFormat != GL_RGB5_A1 && + colorbufferFormat != GL_RGBA8_OES) + { + return error(GL_INVALID_OPERATION); + } + break; + case GL_LUMINANCE: + case GL_RGB: + if (colorbufferFormat != GL_RGB && + colorbufferFormat != GL_RGB565 && + colorbufferFormat != GL_RGB8_OES && + colorbufferFormat != GL_RGBA && + colorbufferFormat != GL_RGBA4 && + colorbufferFormat != GL_RGB5_A1 && + colorbufferFormat != GL_RGBA8_OES) + { + return error(GL_INVALID_OPERATION); + } + break; + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + if (colorbufferFormat != GL_RGBA && + colorbufferFormat != GL_RGBA4 && + colorbufferFormat != GL_RGB5_A1 && + colorbufferFormat != GL_RGBA8_OES) + { + return error(GL_INVALID_OPERATION); + } + break; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + if (context->supportsCompressedTextures()) + { + return error(GL_INVALID_OPERATION); + } + else + { + return error(GL_INVALID_ENUM); + } + break; + default: + return error(GL_INVALID_ENUM); + } + if (target == GL_TEXTURE_2D) { gl::Texture2D *texture = context->getTexture2D(); @@ -1062,11 +1104,6 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma { return error(GL_INVALID_OPERATION); } - - if (texture->isCompressed()) - { - return error(GL_INVALID_OPERATION); - } texture->copyImage(level, internalformat, x, y, width, height, source); } @@ -1079,17 +1116,9 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma return error(GL_INVALID_OPERATION); } - if (texture->isCompressed()) - { - return error(GL_INVALID_OPERATION); - } - texture->copyImage(target, level, internalformat, x, y, width, height, source); } - else - { - UNREACHABLE(); - } + else UNREACHABLE(); } } catch(std::bad_alloc&) @@ -1111,7 +1140,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL return error(GL_INVALID_ENUM); } - if (level < 0 || level > gl::MAX_TEXTURE_LEVELS || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) + if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) { return error(GL_INVALID_VALUE); } @@ -1130,7 +1159,13 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL if (context) { + if (level > context->getMaximumTextureLevel()) + { + return error(GL_INVALID_VALUE); + } + gl::Framebuffer *framebuffer = context->getReadFramebuffer(); + if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) { return error(GL_INVALID_FRAMEBUFFER_OPERATION); @@ -1142,42 +1177,70 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL } gl::Colorbuffer *source = framebuffer->getColorbuffer(); + GLenum colorbufferFormat = source->getFormat(); + gl::Texture *texture = NULL; + if (target == GL_TEXTURE_2D) { - gl::Texture2D *texture = context->getTexture2D(); + texture = context->getTexture2D(); + } + else if (gl::IsCubemapTextureTarget(target)) + { + texture = context->getTextureCubeMap(); + } + else UNREACHABLE(); - if (!texture) - { - return error(GL_INVALID_OPERATION); - } + if (!texture) + { + return error(GL_INVALID_OPERATION); + } - if (texture->isCompressed()) + GLenum textureFormat = texture->getFormat(); + + // [OpenGL ES 2.0.24] table 3.9 + switch (textureFormat) + { + case GL_ALPHA: + if (colorbufferFormat != GL_ALPHA && + colorbufferFormat != GL_RGBA && + colorbufferFormat != GL_RGBA4 && + colorbufferFormat != GL_RGB5_A1 && + colorbufferFormat != GL_RGBA8_OES) { return error(GL_INVALID_OPERATION); } - - texture->copySubImage(level, xoffset, yoffset, x, y, width, height, source); - } - else if (gl::IsCubemapTextureTarget(target)) - { - gl::TextureCubeMap *texture = context->getTextureCubeMap(); - - if (!texture) + break; + case GL_LUMINANCE: + case GL_RGB: + if (colorbufferFormat != GL_RGB && + colorbufferFormat != GL_RGB565 && + colorbufferFormat != GL_RGB8_OES && + colorbufferFormat != GL_RGBA && + colorbufferFormat != GL_RGBA4 && + colorbufferFormat != GL_RGB5_A1 && + colorbufferFormat != GL_RGBA8_OES) { return error(GL_INVALID_OPERATION); } - - if (texture->isCompressed()) + break; + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + if (colorbufferFormat != GL_RGBA && + colorbufferFormat != GL_RGBA4 && + colorbufferFormat != GL_RGB5_A1 && + colorbufferFormat != GL_RGBA8_OES) { return error(GL_INVALID_OPERATION); } - - texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, source); - } - else - { - UNREACHABLE(); + break; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return error(GL_INVALID_OPERATION); + default: + return error(GL_INVALID_OPERATION); } + + texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, source); } } @@ -1293,6 +1356,33 @@ void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) } } +void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) +{ + TRACE("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences); + + try + { + if (n < 0) + { + return error(GL_INVALID_VALUE); + } + + gl::Context *context = gl::getContext(); + + if (context) + { + for (int i = 0; i < n; i++) + { + context->deleteFence(fences[i]); + } + } + } + catch(std::bad_alloc&) + { + return error(GL_OUT_OF_MEMORY); + } +} + void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { TRACE("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers); @@ -1624,7 +1714,7 @@ void __stdcall glDisableVertexAttribArray(GLuint index) if (context) { - context->setVertexAttribEnabled(index, false); + context->setEnableVertexAttribArray(index, false); } } catch(std::bad_alloc&) @@ -1669,20 +1759,25 @@ void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLv return error(GL_INVALID_VALUE); } - switch (type) - { - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_SHORT: - case GL_UNSIGNED_INT: - break; - default: - return error(GL_INVALID_ENUM); - } - gl::Context *context = gl::getContext(); if (context) { + switch (type) + { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + break; + case GL_UNSIGNED_INT: + if (!context->supports32bitIndices()) + { + return error(GL_INVALID_ENUM); + } + break; + default: + return error(GL_INVALID_ENUM); + } + context->drawElements(mode, count, type, indices); } } @@ -1739,7 +1834,33 @@ void __stdcall glEnableVertexAttribArray(GLuint index) if (context) { - context->setVertexAttribEnabled(index, true); + context->setEnableVertexAttribArray(index, true); + } + } + catch(std::bad_alloc&) + { + return error(GL_OUT_OF_MEMORY); + } +} + +void __stdcall glFinishFenceNV(GLuint fence) +{ + TRACE("(GLuint fence = %d)", fence); + + try + { + gl::Context *context = gl::getContext(); + + if (context) + { + gl::Fence* fenceObject = context->getFence(fence); + + if (fenceObject == NULL) + { + return error(GL_INVALID_OPERATION); + } + + fenceObject->finishFence(); } } catch(std::bad_alloc&) @@ -2046,6 +2167,33 @@ void __stdcall glGenerateMipmap(GLenum target) } } +void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) +{ + TRACE("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); + + try + { + if (n < 0) + { + return error(GL_INVALID_VALUE); + } + + gl::Context *context = gl::getContext(); + + if (context) + { + for (int i = 0; i < n; i++) + { + fences[i] = context->createFence(); + } + } + } + catch(std::bad_alloc&) + { + return error(GL_OUT_OF_MEMORY); + } +} + void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) { TRACE("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); @@ -2421,6 +2569,33 @@ GLenum __stdcall glGetError(void) return GL_NO_ERROR; } +void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) +{ + TRACE("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params); + + try + { + + gl::Context *context = gl::getContext(); + + if (context) + { + gl::Fence *fenceObject = context->getFence(fence); + + if (fenceObject == NULL) + { + return error(GL_INVALID_OPERATION); + } + + fenceObject->getFenceiv(pname, params); + } + } + catch(std::bad_alloc&) + { + return error(GL_OUT_OF_MEMORY); + } +} + void __stdcall glGetFloatv(GLenum pname, GLfloat* params) { TRACE("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params); @@ -3287,12 +3462,12 @@ void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) return error(GL_INVALID_VALUE); } - const gl::AttributeState &attribState = context->getVertexAttribState(index); + const gl::VertexAttribute &attribState = context->getVertexAttribState(index); switch (pname) { case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - *params = (GLfloat)(attribState.mEnabled ? GL_TRUE : GL_FALSE); + *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); break; case GL_VERTEX_ATTRIB_ARRAY_SIZE: *params = (GLfloat)attribState.mSize; @@ -3340,12 +3515,12 @@ void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) return error(GL_INVALID_VALUE); } - const gl::AttributeState &attribState = context->getVertexAttribState(index); + const gl::VertexAttribute &attribState = context->getVertexAttribState(index); switch (pname) { case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - *params = (attribState.mEnabled ? GL_TRUE : GL_FALSE); + *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); break; case GL_VERTEX_ATTRIB_ARRAY_SIZE: *params = attribState.mSize; @@ -3414,28 +3589,27 @@ void __stdcall glHint(GLenum target, GLenum mode) try { - switch (target) + switch (mode) { - case GL_GENERATE_MIPMAP_HINT: - switch (mode) - { - case GL_FASTEST: - case GL_NICEST: - case GL_DONT_CARE: - break; - default: - return error(GL_INVALID_ENUM); - } + case GL_FASTEST: + case GL_NICEST: + case GL_DONT_CARE: break; default: - return error(GL_INVALID_ENUM); + return error(GL_INVALID_ENUM); } gl::Context *context = gl::getContext(); - if (context) + switch (target) { - if (target == GL_GENERATE_MIPMAP_HINT) - context->setGenerateMipmapHint(mode); + case GL_GENERATE_MIPMAP_HINT: + if (context) context->setGenerateMipmapHint(mode); + break; + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: + if (context) context->setFragmentShaderDerivativeHint(mode); + break; + default: + return error(GL_INVALID_ENUM); } } catch(std::bad_alloc&) @@ -3504,6 +3678,34 @@ GLboolean __stdcall glIsEnabled(GLenum cap) return false; } +GLboolean __stdcall glIsFenceNV(GLuint fence) +{ + TRACE("(GLuint fence = %d)", fence); + + try + { + gl::Context *context = gl::getContext(); + + if (context) + { + gl::Fence *fenceObject = context->getFence(fence); + + if (fenceObject == NULL) + { + return GL_FALSE; + } + + return fenceObject->isFence(); + } + } + catch(std::bad_alloc&) + { + return error(GL_OUT_OF_MEMORY, GL_FALSE); + } + + return GL_FALSE; +} + GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) { TRACE("(GLuint framebuffer = %d)", framebuffer); @@ -3841,22 +4043,12 @@ void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samp return error(GL_INVALID_ENUM); } - switch (internalformat) + if (!gl::IsColorRenderable(internalformat) && !gl::IsDepthRenderable(internalformat) && !gl::IsStencilRenderable(internalformat)) { - case GL_DEPTH_COMPONENT16: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGB565: - case GL_STENCIL_INDEX8: - case GL_DEPTH24_STENCIL8_OES: - case GL_RGB8_OES: - case GL_RGBA8_OES: - break; - default: return error(GL_INVALID_ENUM); } - if (width < 0 || height < 0 || width > gl::MAX_RENDERBUFFER_SIZE || height > gl::MAX_RENDERBUFFER_SIZE || samples < 0) + if (width < 0 || height < 0 || samples < 0) { return error(GL_INVALID_VALUE); } @@ -3865,7 +4057,9 @@ void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samp if (context) { - if (samples > context->getMaxSupportedSamples()) + if (width > context->getMaximumRenderbufferDimension() || + height > context->getMaximumRenderbufferDimension() || + samples > context->getMaxSupportedSamples()) { return error(GL_INVALID_VALUE); } @@ -3929,6 +4123,37 @@ void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) } } +void __stdcall glSetFenceNV(GLuint fence, GLenum condition) +{ + TRACE("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); + + try + { + if (condition != GL_ALL_COMPLETED_NV) + { + return error(GL_INVALID_ENUM); + } + + gl::Context *context = gl::getContext(); + + if (context) + { + gl::Fence *fenceObject = context->getFence(fence); + + if (fenceObject == NULL) + { + return error(GL_INVALID_OPERATION); + } + + fenceObject->setFence(condition); + } + } + catch(std::bad_alloc&) + { + return error(GL_OUT_OF_MEMORY); + } +} + void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height); @@ -4196,6 +4421,34 @@ void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu } } +GLboolean __stdcall glTestFenceNV(GLuint fence) +{ + TRACE("(GLuint fence = %d)", fence); + + try + { + gl::Context *context = gl::getContext(); + + if (context) + { + gl::Fence *fenceObject = context->getFence(fence); + + if (fenceObject == NULL) + { + return error(GL_INVALID_OPERATION, GL_TRUE); + } + + return fenceObject->testFence(); + } + } + catch(std::bad_alloc&) + { + error(GL_OUT_OF_MEMORY); + } + + return GL_TRUE; +} + void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) { @@ -4215,34 +4468,6 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL return error(GL_INVALID_VALUE); } - switch (target) - { - case GL_TEXTURE_2D: - if (width > (gl::MAX_TEXTURE_SIZE >> level) || height > (gl::MAX_TEXTURE_SIZE >> level)) - { - return error(GL_INVALID_VALUE); - } - break; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - if (width != height) - { - return error(GL_INVALID_VALUE); - } - - if (width > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level) || height > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level)) - { - return error(GL_INVALID_VALUE); - } - break; - default: - return error(GL_INVALID_ENUM); - } - if (internalformat != format) { return error(GL_INVALID_OPERATION); @@ -4256,6 +4481,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL switch (type) { case GL_UNSIGNED_BYTE: + case GL_FLOAT: + case GL_HALF_FLOAT_OES: break; default: return error(GL_INVALID_ENUM); @@ -4266,6 +4493,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL { case GL_UNSIGNED_BYTE: case GL_UNSIGNED_SHORT_5_6_5: + case GL_FLOAT: + case GL_HALF_FLOAT_OES: break; default: return error(GL_INVALID_ENUM); @@ -4277,6 +4506,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL case GL_UNSIGNED_BYTE: case GL_UNSIGNED_SHORT_4_4_4_4: case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_FLOAT: + case GL_HALF_FLOAT_OES: break; default: return error(GL_INVALID_ENUM); @@ -4307,6 +4538,36 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL if (context) { + switch (target) + { + case GL_TEXTURE_2D: + if (width > (context->getMaximumTextureDimension() >> level) || + height > (context->getMaximumTextureDimension() >> level)) + { + return error(GL_INVALID_VALUE); + } + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) + { + return error(GL_INVALID_VALUE); + } + + if (width > (context->getMaximumCubeTextureDimension() >> level) || + height > (context->getMaximumCubeTextureDimension() >> level)) + { + return error(GL_INVALID_VALUE); + } + break; + default: + return error(GL_INVALID_ENUM); + } + if (internalformat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || internalformat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { @@ -4320,6 +4581,21 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL } } + if (type == GL_FLOAT) + { + if (!context->supportsFloatTextures()) + { + return error(GL_INVALID_ENUM); + } + } + else if (type == GL_HALF_FLOAT_OES) + { + if (!context->supportsHalfFloatTextures()) + { + return error(GL_INVALID_ENUM); + } + } + if (target == GL_TEXTURE_2D) { gl::Texture2D *texture = context->getTexture2D(); @@ -4462,7 +4738,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint return error(GL_INVALID_ENUM); } - if (level < 0 || level > gl::MAX_TEXTURE_LEVELS || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) + if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) { return error(GL_INVALID_VALUE); } @@ -4486,6 +4762,26 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint if (context) { + if (level > context->getMaximumTextureLevel()) + { + return error(GL_INVALID_VALUE); + } + + if (format == GL_FLOAT) + { + if (!context->supportsFloatTextures()) + { + return error(GL_INVALID_ENUM); + } + } + else if (format == GL_HALF_FLOAT_OES) + { + if (!context->supportsHalfFloatTextures()) + { + return error(GL_INVALID_ENUM); + } + } + if (target == GL_TEXTURE_2D) { gl::Texture2D *texture = context->getTexture2D(); @@ -4500,6 +4796,11 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint return error(GL_INVALID_OPERATION); } + if (format != texture->getFormat()) + { + return error(GL_INVALID_OPERATION); + } + texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); } else if (gl::IsCubemapTextureTarget(target)) @@ -4516,6 +4817,11 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint return error(GL_INVALID_OPERATION); } + if (format != texture->getFormat()) + { + return error(GL_INVALID_OPERATION); + } + texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); } else @@ -5435,6 +5741,14 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char * { {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, + {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, + {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, + {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, + {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, + {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, + {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, + {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, + {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, }; for (int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++) diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def index a043ed8..b2dc23c 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.def @@ -147,7 +147,14 @@ EXPORTS glTexImage3DOES @143 glBlitFramebufferANGLE @149 glRenderbufferStorageMultisampleANGLE @150 - + glDeleteFencesNV @151 + glFinishFenceNV @152 + glGenFencesNV @153 + glGetFenceivNV @154 + glIsFenceNV @155 + glSetFenceNV @156 + glTestFenceNV @157 + ; EGL dependencies glCreateContext @144 NONAME glDestroyContext @145 NONAME diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.vcproj b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.vcproj index 1f43e7a..0d95080 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.vcproj +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.vcproj @@ -201,6 +201,10 @@ > </File> <File + RelativePath=".\Fence.cpp" + > + </File> + <File RelativePath=".\Framebuffer.cpp" > </File> @@ -244,14 +248,6 @@ Name="Geometry" > <File - RelativePath=".\geometry\backend.cpp" - > - </File> - <File - RelativePath=".\geometry\dx9.cpp" - > - </File> - <File RelativePath=".\geometry\IndexDataManager.cpp" > </File> @@ -279,6 +275,10 @@ > </File> <File + RelativePath=".\Fence.h" + > + </File> + <File RelativePath=".\Framebuffer.h" > </File> @@ -334,14 +334,6 @@ Name="Geometry" > <File - RelativePath=".\geometry\backend.h" - > - </File> - <File - RelativePath=".\geometry\dx9.h" - > - </File> - <File RelativePath=".\geometry\IndexDataManager.h" > </File> diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.cpp index 7fc2bc4..a3f5243 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.cpp +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.cpp @@ -25,6 +25,8 @@ int UniformComponentCount(GLenum type) case GL_BOOL: case GL_FLOAT: case GL_INT: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: return 1; case GL_BOOL_VEC2: case GL_FLOAT_VEC2: @@ -68,6 +70,8 @@ GLenum UniformComponentType(GLenum type) case GL_FLOAT_MAT4: return GL_FLOAT; case GL_INT: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: case GL_INT_VEC2: case GL_INT_VEC3: case GL_INT_VEC4: @@ -247,6 +251,28 @@ int ComputePixelSize(GLenum format, GLenum type) case GL_UNSIGNED_SHORT_5_5_5_1: case GL_UNSIGNED_SHORT_5_6_5: return sizeof(unsigned short); + case GL_FLOAT: + switch (format) + { + case GL_ALPHA: return sizeof(float); + case GL_LUMINANCE: return sizeof(float); + case GL_LUMINANCE_ALPHA: return sizeof(float) * 2; + case GL_RGB: return sizeof(float) * 3; + case GL_RGBA: return sizeof(float) * 4; + default: UNREACHABLE(); + } + break; + case GL_HALF_FLOAT_OES: + switch (format) + { + case GL_ALPHA: return sizeof(unsigned short); + case GL_LUMINANCE: return sizeof(unsigned short); + case GL_LUMINANCE_ALPHA: return sizeof(unsigned short) * 2; + case GL_RGB: return sizeof(unsigned short) * 3; + case GL_RGBA: return sizeof(unsigned short) * 4; + default: UNREACHABLE(); + } + break; default: UNREACHABLE(); } @@ -283,6 +309,21 @@ bool CheckTextureFormatType(GLenum format, GLenum type) return false; } + case GL_FLOAT: + case GL_HALF_FLOAT_OES: + switch (format) + { + case GL_RGBA: + case GL_RGB: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + return true; + + default: + return false; + } + case GL_UNSIGNED_SHORT_4_4_4_4: case GL_UNSIGNED_SHORT_5_5_5_1: return (format == GL_RGBA); @@ -295,6 +336,69 @@ bool CheckTextureFormatType(GLenum format, GLenum type) } } +bool IsColorRenderable(GLenum internalformat) +{ + switch (internalformat) + { + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGB565: + case GL_RGB8_OES: + case GL_RGBA8_OES: + return true; + case GL_DEPTH_COMPONENT16: + case GL_STENCIL_INDEX8: + case GL_DEPTH24_STENCIL8_OES: + return false; + default: + UNIMPLEMENTED(); + } + + return false; +} + +bool IsDepthRenderable(GLenum internalformat) +{ + switch (internalformat) + { + case GL_DEPTH_COMPONENT16: + case GL_DEPTH24_STENCIL8_OES: + return true; + case GL_STENCIL_INDEX8: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGB565: + case GL_RGB8_OES: + case GL_RGBA8_OES: + return false; + default: + UNIMPLEMENTED(); + } + + return false; +} + +bool IsStencilRenderable(GLenum internalformat) +{ + switch (internalformat) + { + case GL_STENCIL_INDEX8: + case GL_DEPTH24_STENCIL8_OES: + return true; + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGB565: + case GL_RGB8_OES: + case GL_RGBA8_OES: + case GL_DEPTH_COMPONENT16: + return false; + default: + UNIMPLEMENTED(); + } + + return false; +} + } namespace es2dx @@ -508,6 +612,10 @@ unsigned int GetAlphaSize(D3DFORMAT colorFormat) { switch (colorFormat) { + case D3DFMT_A16B16G16R16F: + return 16; + case D3DFMT_A32B32G32R32F: + return 32; case D3DFMT_A2R10G10B10: return 2; case D3DFMT_A8R8G8B8: @@ -515,7 +623,6 @@ unsigned int GetAlphaSize(D3DFORMAT colorFormat) case D3DFMT_A1R5G5B5: return 1; case D3DFMT_X8R8G8B8: - case D3DFMT_X1R5G5B5: case D3DFMT_R5G6B5: return 0; default: UNREACHABLE(); @@ -527,6 +634,10 @@ unsigned int GetRedSize(D3DFORMAT colorFormat) { switch (colorFormat) { + case D3DFMT_A16B16G16R16F: + return 16; + case D3DFMT_A32B32G32R32F: + return 32; case D3DFMT_A2R10G10B10: return 10; case D3DFMT_A8R8G8B8: @@ -534,7 +645,6 @@ unsigned int GetRedSize(D3DFORMAT colorFormat) return 8; case D3DFMT_A1R5G5B5: case D3DFMT_R5G6B5: - case D3DFMT_X1R5G5B5: return 5; default: UNREACHABLE(); } @@ -545,13 +655,16 @@ unsigned int GetGreenSize(D3DFORMAT colorFormat) { switch (colorFormat) { + case D3DFMT_A16B16G16R16F: + return 16; + case D3DFMT_A32B32G32R32F: + return 32; case D3DFMT_A2R10G10B10: return 10; case D3DFMT_A8R8G8B8: case D3DFMT_X8R8G8B8: return 8; case D3DFMT_A1R5G5B5: - case D3DFMT_X1R5G5B5: return 5; case D3DFMT_R5G6B5: return 6; @@ -564,6 +677,10 @@ unsigned int GetBlueSize(D3DFORMAT colorFormat) { switch (colorFormat) { + case D3DFMT_A16B16G16R16F: + return 16; + case D3DFMT_A32B32G32R32F: + return 32; case D3DFMT_A2R10G10B10: return 10; case D3DFMT_A8R8G8B8: @@ -571,7 +688,6 @@ unsigned int GetBlueSize(D3DFORMAT colorFormat) return 8; case D3DFMT_A1R5G5B5: case D3DFMT_R5G6B5: - case D3DFMT_X1R5G5B5: return 5; default: UNREACHABLE(); } @@ -591,46 +707,46 @@ unsigned int GetDepthSize(D3DFORMAT depthFormat) case D3DFMT_D16: return 16; case D3DFMT_D32F_LOCKABLE: return 32; case D3DFMT_D24FS8: return 24; -// case D3DFMT_D32_LOCKABLE: return 32; // D3D9Ex only -// case D3DFMT_S8_LOCKABLE: return 0; // D3D9Ex only + //case D3DFMT_D32_LOCKABLE: return 32; // D3D9Ex only + //case D3DFMT_S8_LOCKABLE: return 0; // D3D9Ex only default: UNREACHABLE(); } return 0; } -bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount, +bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount) { switch (primitiveType) { case GL_POINTS: *d3dPrimitiveType = D3DPT_POINTLIST; - *d3dPrimitiveCount = primitiveCount; + *d3dPrimitiveCount = elementCount; break; case GL_LINES: *d3dPrimitiveType = D3DPT_LINELIST; - *d3dPrimitiveCount = primitiveCount / 2; + *d3dPrimitiveCount = elementCount / 2; break; case GL_LINE_LOOP: *d3dPrimitiveType = D3DPT_LINESTRIP; - *d3dPrimitiveCount = primitiveCount; + *d3dPrimitiveCount = elementCount - 1; // D3D doesn't support line loops, so we draw the last line separately break; case GL_LINE_STRIP: *d3dPrimitiveType = D3DPT_LINESTRIP; - *d3dPrimitiveCount = primitiveCount - 1; + *d3dPrimitiveCount = elementCount - 1; break; case GL_TRIANGLES: *d3dPrimitiveType = D3DPT_TRIANGLELIST; - *d3dPrimitiveCount = primitiveCount / 3; + *d3dPrimitiveCount = elementCount / 3; break; case GL_TRIANGLE_STRIP: *d3dPrimitiveType = D3DPT_TRIANGLESTRIP; - *d3dPrimitiveCount = primitiveCount - 2; + *d3dPrimitiveCount = elementCount - 2; break; case GL_TRIANGLE_FAN: *d3dPrimitiveType = D3DPT_TRIANGLEFAN; - *d3dPrimitiveCount = primitiveCount - 2; + *d3dPrimitiveCount = elementCount - 2; break; default: return false; @@ -672,3 +788,40 @@ D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples) } } + +namespace dx2es +{ + +GLenum ConvertBackBufferFormat(D3DFORMAT format) +{ + switch (format) + { + case D3DFMT_A4R4G4B4: return GL_RGBA4; + case D3DFMT_A8R8G8B8: return GL_RGBA8_OES; + case D3DFMT_A1R5G5B5: return GL_RGB5_A1; + case D3DFMT_R5G6B5: return GL_RGB565; + case D3DFMT_X8R8G8B8: return GL_RGB8_OES; + default: + UNREACHABLE(); + } + + return GL_RGBA4; +} + +GLenum ConvertDepthStencilFormat(D3DFORMAT format) +{ + switch (format) + { + case D3DFMT_D16: + case D3DFMT_D24X8: + return GL_DEPTH_COMPONENT16; + case D3DFMT_D24S8: + return GL_DEPTH24_STENCIL8_OES; + default: + UNREACHABLE(); + } + + return GL_DEPTH24_STENCIL8_OES; +} + +} diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.h b/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.h index b6c8ce5..85e8f26 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/utilities.h @@ -36,6 +36,10 @@ bool IsCubemapTextureTarget(GLenum target); bool IsTextureTarget(GLenum target); bool CheckTextureFormatType(GLenum format, GLenum type); +bool IsColorRenderable(GLenum internalformat); +bool IsDepthRenderable(GLenum internalformat); +bool IsStencilRenderable(GLenum internalformat); + } namespace es2dx @@ -57,7 +61,7 @@ unsigned int GetGreenSize(D3DFORMAT colorFormat); unsigned int GetBlueSize(D3DFORMAT colorFormat); unsigned int GetDepthSize(D3DFORMAT depthFormat); unsigned int GetStencilSize(D3DFORMAT stencilFormat); -bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount, +bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount); D3DFORMAT ConvertRenderbufferFormat(GLenum format); D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples); @@ -65,4 +69,12 @@ GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type); } +namespace dx2es +{ + +GLenum ConvertBackBufferFormat(D3DFORMAT format); +GLenum ConvertDepthStencilFormat(D3DFORMAT format); + +} + #endif // LIBGLESV2_UTILITIES_H diff --git a/Source/WebCore/Android.jscbindings.mk b/Source/WebCore/Android.jscbindings.mk index 697f5ef..281425c 100644 --- a/Source/WebCore/Android.jscbindings.mk +++ b/Source/WebCore/Android.jscbindings.mk @@ -113,7 +113,11 @@ LOCAL_SRC_FILES += \ bindings/js/JSDirectoryEntrySyncCustom.cpp \ bindings/js/JSDocumentCustom.cpp \ bindings/js/JSElementCustom.cpp \ +<<<<<<< HEAD bindings/js/JSEntrySyncCustom.cpp \ +======= + bindings/js/JSErrorHandler.cpp \ +>>>>>>> WebKit.org at r76408 bindings/js/JSEventCustom.cpp \ bindings/js/JSEventListener.cpp \ bindings/js/JSEventTarget.cpp \ @@ -187,7 +191,6 @@ LOCAL_SRC_FILES += \ bindings/js/JSWebKitPointCustom.cpp \ bindings/js/JSWorkerContextBase.cpp \ bindings/js/JSWorkerContextCustom.cpp \ - bindings/js/JSWorkerContextErrorHandler.cpp \ bindings/js/JSWorkerCustom.cpp \ bindings/js/JSXMLHttpRequestCustom.cpp \ bindings/js/JSXMLHttpRequestUploadCustom.cpp \ diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk index 102b401..a3e6d09 100644 --- a/Source/WebCore/Android.mk +++ b/Source/WebCore/Android.mk @@ -597,6 +597,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/Path.cpp \ platform/graphics/PathTraversalState.cpp \ platform/graphics/Pattern.cpp \ + platform/graphics/RoundedIntRect.cpp \ platform/graphics/SegmentedFontData.cpp \ platform/graphics/SimpleFontData.cpp \ platform/graphics/StringTruncator.cpp \ diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index 8050b48..95d8790 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -237,6 +237,7 @@ SET(WebCore_IDL_FILES html/HTMLImageElement.idl html/HTMLInputElement.idl html/HTMLIsIndexElement.idl + html/HTMLKeygenElement.idl html/HTMLLabelElement.idl html/HTMLLegendElement.idl html/HTMLLIElement.idl @@ -291,6 +292,7 @@ SET(WebCore_IDL_FILES html/canvas/Int16Array.idl html/canvas/Int32Array.idl html/canvas/Int8Array.idl + html/canvas/OESStandardDerivatives.idl html/canvas/OESTextureFloat.idl html/canvas/Uint16Array.idl html/canvas/Uint32Array.idl @@ -637,6 +639,7 @@ SET(WebCore_SOURCES bindings/js/JSDeviceOrientationEventCustom.cpp bindings/js/JSDocumentCustom.cpp bindings/js/JSElementCustom.cpp + bindings/js/JSErrorHandler.cpp bindings/js/JSEventCustom.cpp bindings/js/JSEventListener.cpp bindings/js/JSEventSourceCustom.cpp @@ -705,7 +708,6 @@ SET(WebCore_SOURCES bindings/js/JSWebSocketCustom.cpp bindings/js/JSWorkerContextBase.cpp bindings/js/JSWorkerContextCustom.cpp - bindings/js/JSWorkerContextErrorHandler.cpp bindings/js/JSWorkerCustom.cpp bindings/js/JSXMLHttpRequestCustom.cpp bindings/js/JSXMLHttpRequestUploadCustom.cpp @@ -1169,6 +1171,7 @@ SET(WebCore_SOURCES inspector/InspectorInstrumentation.cpp inspector/InspectorProfilerAgent.cpp inspector/InspectorResourceAgent.cpp + inspector/InspectorRuntimeAgent.cpp inspector/InspectorSettings.cpp inspector/InspectorState.cpp inspector/InspectorStyleSheet.cpp @@ -1308,8 +1311,8 @@ SET(WebCore_SOURCES platform/Logging.cpp platform/MIMETypeRegistry.cpp platform/ScrollAnimator.cpp + platform/ScrollableArea.cpp platform/Scrollbar.cpp - platform/ScrollbarClient.cpp platform/ScrollbarThemeComposite.cpp platform/ScrollView.cpp platform/SharedBuffer.cpp @@ -1350,6 +1353,7 @@ SET(WebCore_SOURCES platform/graphics/Path.cpp platform/graphics/PathTraversalState.cpp platform/graphics/Pattern.cpp + platform/graphics/RoundedIntRect.cpp platform/graphics/SegmentedFontData.cpp platform/graphics/SimpleFontData.cpp platform/graphics/StringTruncator.cpp diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index e8fe2cd..d523cdb 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,5053 @@ +2011-01-21 Charlie Reis <creis@chromium.org> + + Reviewed by Darin Fisher. + + Crash in WebCore::HistoryController::itemsAreClones + https://bugs.webkit.org/show_bug.cgi?id=52819 + + Adds sanity checks to help diagnose the crash. + + * loader/HistoryController.cpp: + +2011-01-21 Andreas Kling <kling@webkit.org> + + Reviewed by Ariya Hidayat. + + [Qt] Let QPainter decide whether a composition mode is supported or not + + Lacking Porter-Duff support in the paint engine shouldn't exclude the + Source and Source-Over modes (and has nothing to do with the blend + and raster-op modes.) + + Delegate this decision to QPainter instead (this will cause warnings + if an unsupported mode is used, but that's a good thing.) + + * platform/graphics/qt/GraphicsContextQt.cpp: + (WebCore::GraphicsContext::clearRect): + (WebCore::GraphicsContext::setPlatformCompositeOperation): + * platform/graphics/qt/TransparencyLayer.h: + (WebCore::TransparencyLayer::TransparencyLayer): + +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Kenneth Russell. + + fix audio build: header file should be "Noncopyable.h" and not "NonCopyable.h" + https://bugs.webkit.org/show_bug.cgi?id=52933 + + No new tests since this just fixes the build + + * webaudio/RealtimeAnalyser.h: + +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Kenneth Russell. + + Fix audio build: change ChromiumBridge to PlatformBridge + https://bugs.webkit.org/show_bug.cgi?id=52928 + + No new tests since audio API is not yet implemented. + + * platform/audio/chromium/AudioBusChromium.cpp: + (WebCore::AudioBus::loadPlatformResource): + +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Kenneth Russell. + + Add FFTFrameStub to avoid link errors during bringup on platforms without an FFT implementation + https://bugs.webkit.org/show_bug.cgi?id=52922 + + No new tests since audio API is not yet implemented. + + * WebCore.gypi: + * platform/audio/FFTFrameStub.cpp: Added. + (WebCore::FFTFrame::FFTFrame): + (WebCore::FFTFrame::~FFTFrame): + (WebCore::FFTFrame::multiply): + (WebCore::FFTFrame::doFFT): + (WebCore::FFTFrame::doInverseFFT): + (WebCore::FFTFrame::cleanup): + (WebCore::FFTFrame::realData): + (WebCore::FFTFrame::imagData): + +2011-01-21 Tony Chang <tony@chromium.org> + + Reviewed by Sam Weinig. + + reduce number of FrameLoaderClient::didChangeScrollOffset calls + https://bugs.webkit.org/show_bug.cgi?id=52915 + + Only notify of changes in scroll offset when there actually is a change. + This regressed in r76291. + + Covered by Chromium browser_tests. + + * platform/ScrollAnimator.cpp: + (WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation): + +2011-01-21 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: ~InspectorResourceAgent crashes on closing inspected page. + https://bugs.webkit.org/show_bug.cgi?id=52900 + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::~InspectorController): + (WebCore::InspectorController::inspectedPageDestroyed): + +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Darin Fisher. + + Add run-time enable support for the web audio API + https://bugs.webkit.org/show_bug.cgi?id=52741 + + No new tests since audio API is not yet implemented. + + * WebCore.exp.in: + * bindings/generic/RuntimeEnabledFeatures.cpp: + * bindings/generic/RuntimeEnabledFeatures.h: + (WebCore::RuntimeEnabledFeatures::setWebkitAudioContextEnabled): + (WebCore::RuntimeEnabledFeatures::webkitAudioContextEnabled): + * page/DOMWindow.idl: + * page/Settings.cpp: + (WebCore::Settings::Settings): + (WebCore::Settings::setWebAudioEnabled): + * page/Settings.h: + (WebCore::Settings::webAudioEnabled): + +2011-01-21 Martin Robinson <mrobinson@igalia.com> + + Reviewed by Xan Lopez. + + [GTK] Menulist text often collides with separator + https://bugs.webkit.org/show_bug.cgi?id=51155 + + Move menulist rendering to RenderThemeGtk and correct padding code + for separators in menulists. + + * platform/gtk/RenderThemeGtk.cpp: + (WebCore::RenderThemeGtk::RenderThemeGtk): Initialize new widget members. + (WebCore::RenderThemeGtk::getComboBoxSeparatorWidth): Added. + (WebCore::RenderThemeGtk::comboBoxArrowSize): Added. + (WebCore::getButtonInnerBorder): Added. + (WebCore::RenderThemeGtk::getComboBoxPadding): Do this manually instead of using + Mozilla code. + (WebCore::RenderThemeGtk::paintMenuList): Ditto. + (WebCore::setupWidget): Abstracted this part of the setupWidgetAndAddToContainer + out to handle child widgets of comboboxes. + (WebCore::RenderThemeGtk::setupWidgetAndAddToContainer): Abstracted out setupWidget. + (WebCore::RenderThemeGtk::gtkContainer): Added. + (WebCore::getGtkComboBoxButton): Added. + (WebCore::getGtkComboBoxPieces): Added. + (WebCore::RenderThemeGtk::gtkComboBox): Call setupWidget here. + (WebCore::RenderThemeGtk::refreshComboBoxChildren): Added. + (WebCore::RenderThemeGtk::gtkComboBoxButton): Added. + (WebCore::RenderThemeGtk::gtkComboBoxArrow): Added. + (WebCore::RenderThemeGtk::gtkComboBoxSeparator): Added. + * platform/gtk/RenderThemeGtk.h: Added new members and methods. + * platform/gtk/WidgetRenderingContext.h: Added new members and methods. + * platform/gtk/WidgetRenderingContextGtk2.cpp: + (WebCore::WidgetRenderingContext::gtkPaintArrow): + (WebCore::WidgetRenderingContext::gtkPaintVLine): + * platform/gtk/WidgetRenderingContextGtk3.cpp: + (WebCore::WidgetRenderingContext::gtkPaintArrow): + (WebCore::WidgetRenderingContext::gtkPaintVLine): + * platform/gtk/gtk2drawing.c: Removed code for drawing menulists and buttons. + (moz_gtk_init): + (moz_gtk_get_widget_border): + (moz_gtk_widget_paint): + * platform/gtk/gtk3drawing.c: + (moz_gtk_init): + (moz_gtk_get_widget_border): + (moz_gtk_widget_paint): + * platform/gtk/gtkdrawing.h: + +2011-01-21 Sam Weinig <sam@webkit.org> + + Fix chromium mac build. + + * platform/chromium/ScrollbarThemeChromiumMac.mm: + (WebCore::scrollbarStateToThemeState): + (WebCore::ScrollbarThemeChromiumMac::paint): + +2011-01-21 Sam Weinig <sam@webkit.org> + + Fix the windows build. + + * platform/ScrollbarThemeComposite.cpp: + (WebCore::ScrollbarThemeComposite::paint): + +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Kenneth Russell. + + Add chromium bundled audio spatialization resources to WebAudio.grd + https://bugs.webkit.org/show_bug.cgi?id=52651 + + No new tests since audio API is not yet implemented. + + * WebCore.gyp/WebCore.gyp: + * platform/audio/chromium/AudioBusChromium.cpp: + (WebCore::AudioBus::loadPlatformResource): + +2011-01-21 Xiyuan Xia <xiyuan@chromium.org> + + Reviewed by Tony Chang. + + Use WebThemeEngine for relevant RenderTheme parts for chromium/linux. + https://bugs.webkit.org/show_bug.cgi?id=52826 + + * platform/chromium/ChromiumBridge.h: + * rendering/RenderThemeChromiumLinux.cpp: + (WebCore::getWebThemeState): + (WebCore::RenderThemeChromiumLinux::adjustSliderThumbSize): + (WebCore::RenderThemeChromiumLinux::paintCheckbox): + (WebCore::RenderThemeChromiumLinux::setCheckboxSize): + (WebCore::RenderThemeChromiumLinux::paintRadio): + (WebCore::RenderThemeChromiumLinux::setRadioSize): + (WebCore::RenderThemeChromiumLinux::paintButton): + (WebCore::RenderThemeChromiumLinux::paintTextField): + (WebCore::RenderThemeChromiumLinux::paintMenuList): + (WebCore::RenderThemeChromiumLinux::paintSliderTrack): + (WebCore::RenderThemeChromiumLinux::paintSliderThumb): + (WebCore::RenderThemeChromiumLinux::adjustInnerSpinButtonStyle): + (WebCore::RenderThemeChromiumLinux::paintInnerSpinButton): + (WebCore::RenderThemeChromiumLinux::paintProgressBar): + * rendering/RenderThemeChromiumLinux.h: + * rendering/RenderThemeChromiumSkia.cpp: + (WebCore::RenderThemeChromiumSkia::setCheckboxSize): + (WebCore::RenderThemeChromiumSkia::setSizeIfAuto): + (WebCore::RenderThemeChromiumSkia::indeterminateProgressValueRectFor): + * rendering/RenderThemeChromiumSkia.h: + +2011-01-21 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Part 2 of "Cleanup Scrollbar/ScrollbarClient relationship" + https://bugs.webkit.org/show_bug.cgi?id=52779 + + Rename ScrollbarClient -> ScrollableArea. + + - Also replaces Scrollbar::setClient with Scrollbar::disconnectFromScrollableArea + since that was its only use case. + + * CMakeLists.txt: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * accessibility/AccessibilityScrollbar.cpp: + (WebCore::AccessibilityScrollbar::setValue): + * css/CSSStyleSelector.cpp: + (WebCore::CSSStyleSelector::SelectorChecker::checkScrollbarPseudoClass): + * page/FrameView.h: + * platform/PopupMenuClient.h: + * platform/ScrollAnimator.cpp: + (WebCore::ScrollAnimator::create): + (WebCore::ScrollAnimator::ScrollAnimator): + (WebCore::ScrollAnimator::scroll): + (WebCore::ScrollAnimator::notityPositionChanged): + * platform/ScrollAnimator.h: + * platform/ScrollAnimatorWin.cpp: + (WebCore::ScrollAnimator::create): + (WebCore::ScrollAnimatorWin::ScrollAnimatorWin): + (WebCore::ScrollAnimatorWin::scroll): + * platform/ScrollAnimatorWin.h: + * platform/ScrollView.cpp: + (WebCore::ScrollView::scroll): + (WebCore::ScrollView::updateScrollbars): + (WebCore::ScrollView::wheelEvent): + * platform/ScrollView.h: + * platform/ScrollableArea.cpp: Copied from WebCore/platform/ScrollbarClient.cpp. + (WebCore::ScrollableArea::ScrollableArea): + (WebCore::ScrollableArea::~ScrollableArea): + (WebCore::ScrollableArea::scroll): + (WebCore::ScrollableArea::scrollToOffsetWithoutAnimation): + (WebCore::ScrollableArea::scrollToXOffsetWithoutAnimation): + (WebCore::ScrollableArea::scrollToYOffsetWithoutAnimation): + (WebCore::ScrollableArea::setScrollOffsetFromAnimation): + * platform/ScrollableArea.h: Copied from WebCore/platform/ScrollbarClient.h. + * platform/Scrollbar.cpp: + (WebCore::Scrollbar::createNativeScrollbar): + (WebCore::Scrollbar::Scrollbar): + (WebCore::Scrollbar::offsetDidChange): + (WebCore::Scrollbar::autoscrollPressedPart): + (WebCore::Scrollbar::moveThumb): + (WebCore::Scrollbar::mouseMoved): + (WebCore::Scrollbar::isWindowActive): + (WebCore::Scrollbar::invalidateRect): + (WebCore::Scrollbar::convertToContainingView): + (WebCore::Scrollbar::convertFromContainingView): + * platform/Scrollbar.h: + (WebCore::Scrollbar::disconnectFromScrollableArea): + (WebCore::Scrollbar::scrollableArea): + * platform/ScrollbarClient.cpp: Removed. + * platform/ScrollbarClient.h: Removed. + * platform/ScrollbarThemeComposite.cpp: + * platform/chromium/FramelessScrollView.h: + * platform/chromium/ScrollbarThemeChromium.cpp: + (WebCore::ScrollbarThemeChromium::paintTickmarks): + * platform/efl/ScrollbarEfl.cpp: + (Scrollbar::createNativeScrollbar): + (ScrollbarEfl::ScrollbarEfl): + (scrollbarEflEdjeMessage): + * platform/efl/ScrollbarEfl.h: + * platform/gtk/MainFrameScrollbarGtk.cpp: + (MainFrameScrollbarGtk::create): + (MainFrameScrollbarGtk::MainFrameScrollbarGtk): + (MainFrameScrollbarGtk::gtkValueChanged): + * platform/gtk/MainFrameScrollbarGtk.h: + * platform/mac/ScrollAnimatorMac.h: + * platform/mac/ScrollAnimatorMac.mm: + (WebCore::ScrollAnimator::create): + (WebCore::ScrollAnimatorMac::ScrollAnimatorMac): + (WebCore::ScrollAnimatorMac::scroll): + * platform/mac/ScrollbarThemeMac.mm: + (WebCore::ScrollbarThemeMac::paint): + * platform/qt/ScrollbarQt.cpp: + (WebCore::Scrollbar::contextMenu): + * platform/win/PopupMenuWin.cpp: + (WebCore::PopupMenuWin::scrollToRevealSelection): + (WebCore::PopupMenuWin::wndProc): + * platform/win/PopupMenuWin.h: + * platform/win/ScrollbarThemeSafari.cpp: + (WebCore::ScrollbarThemeSafari::paintTrackBackground): + (WebCore::ScrollbarThemeSafari::paintButton): + (WebCore::ScrollbarThemeSafari::paintThumb): + * platform/wx/ScrollbarThemeWx.cpp: + (WebCore::ScrollbarThemeWx::paint): + * rendering/RenderDataGrid.h: + * rendering/RenderLayer.cpp: + (WebCore::RenderLayer::scrollToOffset): + (WebCore::RenderLayer::destroyScrollbar): + (WebCore::RenderLayer::scroll): + * rendering/RenderLayer.h: + * rendering/RenderListBox.cpp: + (WebCore::RenderListBox::scrollToRevealElementAtListIndex): + (WebCore::RenderListBox::scroll): + (WebCore::RenderListBox::logicalScroll): + (WebCore::RenderListBox::setScrollTop): + (WebCore::RenderListBox::destroyScrollbar): + * rendering/RenderListBox.h: + * rendering/RenderMenuList.cpp: + (WebCore::RenderMenuList::createScrollbar): + * rendering/RenderMenuList.h: + * rendering/RenderScrollbar.cpp: + (WebCore::RenderScrollbar::createCustomScrollbar): + (WebCore::RenderScrollbar::RenderScrollbar): + * rendering/RenderScrollbar.h: + * rendering/RenderTextControlSingleLine.cpp: + (WebCore::RenderTextControlSingleLine::createScrollbar): + * rendering/RenderTextControlSingleLine.h: + +2011-01-21 Darin Adler <darin@apple.com> + + Fix Leopard build. + + * rendering/mathml/RenderMathMLFraction.cpp: + (WebCore::RenderMathMLFraction::layout): Use ceilf instead of ceil. + +2011-01-21 Anton Muhin <antonm@chromium.org> + + Reviewed by Nate Chapin. + + [v8] Properly deal with the case when conversion to string throws an exception for HTMLCollection accessors + https://bugs.webkit.org/show_bug.cgi?id=52901 + + Test: fast/dom/htmlcollection-conversion-throws-exception.html + + * bindings/v8/custom/V8HTMLCollectionCustom.cpp: + (WebCore::getItem): + +2011-01-21 Adam Roben <aroben@apple.com> + + Separate flushing layer changes from rendering in CACFLayerTreeHost + + Old model: + 1) A change is made to a GraphicsLayer. + 2) CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon is called, which schedules the + render timer. + 3) The timer fires, which calls through to CACFLayerTreeHost::render, which performs the + flush and then renders. + + New model: + 1) A change is made to a GraphicsLayer. + 2) CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon is called, which tells the new + LayerChangesFlusher singleton that this host has changes that need to be flushed. + 3) LayerChangesFlusher sets up a Windows hook that will get called on the next iteration + of the message loop. + 4) LayerChangesFlusher's hook is called, which calls through to + CACFLayerTreeHost::flushPendingLayerChangesNow. + 5) CACFLayerTreeHost::flushPendingLayerChangesNow schedules the render timer so the changes + that were just flushed to the context will be rendered. + + When a change is made to a PlatformCALayer that doesn't have a corresponding GraphicsLayer + (e.g., for rendering <video>), CACFLayerTreeHost::layerTreeDidChange takes care of + scheduling the flush. + + This change has three advantages: + 1) Whenever we flush layer changes, we first update layout. This can cause the page to + leave compositing mode, which in turn can cause all references to the CACFLayerTreeHost + to be dropped. By separating flushing (and thus updating layout) from rendering, we no + longer have to worry about this happen during rendering. + 2) The new model is much more similar to how things work on the Mac, so will hopefully + reduce the number of platform-specific bugs. + 3) CACFLayerTreeHost::shouldRender, which was used to make sure we didn't render while a + layout was pending, is no longer needed. It actually hasn't been needed since at least + r75987, but removing it before now would have resulted in a crash whenever a page came + out of compositing mode due to (1). + + Fixes <http://webkit.org/b/52852> Flushing layer changes and rendering are intertwined in + CACFLayerTreeHost, but shouldn't be + + Reviewed by Simon Fraser. + + * WebCore.vcproj/WebCore.vcproj: Added LayerChangesFlusher. + + * platform/graphics/ca/win/CACFLayerTreeHost.cpp: Added new #include, sorted existing + #includes. + (WebCore::CACFLayerTreeHost::CACFLayerTreeHost): Initialize new member. + (WebCore::CACFLayerTreeHost::layerTreeDidChange): If we aren't already flushing changes, + schedule a flush. Removed the call to renderSoon(), which now happens when the flush is + finished. + (WebCore::CACFLayerTreeHost::destroyRenderer): Cancel any pending flush we had scheduled. Also + fixed a bug where we'd fail to clear the context's layer. + (WebCore::CACFLayerTreeHost::render): Removed code to ask the client if we should render, which + is no longer needed. Moved code to flush layer changes from here to + flushPendingLayerChangesNow, which is called via the above-described mechanism. + (WebCore::CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon): Schedule a flush. Removed + code to schedule a render, which now happens after we've flushed. + (WebCore::CACFLayerTreeHost::flushPendingLayerChangesNow): Added. Some of this code came from + render(). First we flush GraphicsLayer changes from GraphicsLayers to their underlying + PlatformCALayers, then we flush changes from PlatformCALayers to the context, then we + schedule a render so that the changes will be rendered to the screen. + + * platform/graphics/ca/win/CACFLayerTreeHost.h: Removed + CACFLayerTreeHostClient::shouldRender. Added flushPendingLayerChangesNow and + m_isFlushingLayerChanges. + + * platform/graphics/ca/win/LayerChangesFlusher.cpp: Added. + (WebCore::LayerChangesFlusher::shared): + (WebCore::LayerChangesFlusher::LayerChangesFlusher): + (WebCore::LayerChangesFlusher::flushPendingLayerChangesSoon): + (WebCore::LayerChangesFlusher::cancelPendingFlush): + (WebCore::LayerChangesFlusher::hookCallback): + (WebCore::LayerChangesFlusher::hookFired): + (WebCore::LayerChangesFlusher::setHook): + (WebCore::LayerChangesFlusher::removeHook): + + * platform/graphics/ca/win/LayerChangesFlusher.cpp: Added. + (WebCore::LayerChangesFlusher::shared): Returns the singleton. + (WebCore::LayerChangesFlusher::LayerChangesFlusher): Initialize our members. + (WebCore::LayerChangesFlusher::flushPendingLayerChangesSoon): Add the host to the set of + hosts with changes that need to be flushed, and set up our hook if we haven't already. + (WebCore::LayerChangesFlusher::cancelPendingFlush): Remove the host from the set of hosts + with changes that need to be flushed. If we have no more such hosts, remove our hook, unless + we're currently in the process of calling out to our hosts, in which case we'll take care of + the hook once we're done calling out. + (WebCore::LayerChangesFlusher::hookCallback): This is the function that Windows calls when + our hook fires. Just calls through to hookFired on the singleton. + (WebCore::LayerChangesFlusher::hookFired): Tell all the hosts with changes that needed to be + flushed that it's time to flush. If no hosts re-added themselves to our set during this + process, remove our hook. + (WebCore::LayerChangesFlusher::setHook): Calls through to ::SetWindowsHookExW. + (WebCore::LayerChangesFlusher::removeHook): Calls through to ::UnhookWindowsHookEx. + + * platform/graphics/ca/win/LayerChangesFlusher.h: Added. + +2011-01-21 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Sam Weinig. + + GraphicsLayer should be non-copyable + https://bugs.webkit.org/show_bug.cgi?id=52909 + + Use WTF_MAKE_NONCOPYABLE on GraphicsLayer, and WTF_MAKE_FAST_ALLOCATED + on that and KeyframeValueList. + + * platform/graphics/GraphicsLayer.h: + +2011-01-21 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Sam Weinig. + + Report the sized used by canvases and types arrays + https://bugs.webkit.org/show_bug.cgi?id=52856 + + Report the memory cost associated with canvas elements, + and typed arrays to JavaScript as extraCost, so that it + can figure this into its GC behavior. + + * bindings/js/JSArrayBufferViewHelper.h: + (WebCore::toJSArrayBufferView): New templatized function, similar + to getDOMObjectWrapper() but calls reportExtraMemoryCost() with + the byteLength of the array. + + * bindings/js/JSFloat32ArrayCustom.cpp: + (WebCore::toJS): Use toJSArrayBufferView. + * bindings/js/JSInt16ArrayCustom.cpp: + (WebCore::toJS): Use toJSArrayBufferView. + * bindings/js/JSInt32ArrayCustom.cpp: + (WebCore::toJS): Use toJSArrayBufferView. + * bindings/js/JSInt8ArrayCustom.cpp: + (WebCore::toJS): Use toJSArrayBufferView. + * bindings/js/JSUint16ArrayCustom.cpp: + (WebCore::toJS): Use toJSArrayBufferView. + * bindings/js/JSUint32ArrayCustom.cpp: + (WebCore::toJS): Use toJSArrayBufferView. + * bindings/js/JSUint8ArrayCustom.cpp: + (WebCore::toJS): Use toJSArrayBufferView. + + * html/HTMLCanvasElement.cpp: + (WebCore::HTMLCanvasElement::createImageBuffer): Call heap.reportExtraMemoryCost() + with the size of the canvas backing store. + + * html/canvas/TypedArrayBase.h: + (WebCore::TypedArrayBase::byteLength): byteLength needs to + be public. + + * platform/graphics/ImageBuffer.h: Add dataSize() method. + + * platform/graphics/cairo/ImageBufferCairo.cpp: + (WebCore::ImageBuffer::dataSize): Implement dataSize(). + * platform/graphics/cg/ImageBufferCG.cpp: + (WebCore::ImageBuffer::dataSize): Implement dataSize(). + * platform/graphics/haiku/ImageBufferHaiku.cpp: + (WebCore::ImageBuffer::dataSize): Implement dataSize(). + * platform/graphics/qt/ImageBufferQt.cpp: + (WebCore::ImageBuffer::dataSize): Implement dataSize(). + * platform/graphics/skia/ImageBufferSkia.cpp: + (WebCore::ImageBuffer::dataSize): Implement dataSize(). + * platform/graphics/wince/ImageBufferWinCE.cpp: + (WebCore::ImageBuffer::dataSize): Implement dataSize(). + * platform/graphics/wx/ImageBufferWx.cpp: + (WebCore::ImageBuffer::dataSize): Implement dataSize(). + +2011-01-21 Adam Roben <aroben@apple.com> + + Rename WKCACFLayerRenderer[Client] to CACFLayerTreeHost[Client] + + Also renamed a few functions and data members to match. + + Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't + + Reviewed by Simon Fraser. + + * WebCore.vcproj/WebCore.vcproj: Updated files' names and paths. + + * WebCore.vcproj/WebCoreQuartzCore.vsprops: Added platform/graphics/ca/win to the include + path. + + * WebCore.vcproj/copyForwardingHeaders.cmd: Copy headers from platform/graphics/ca/win, too. + + * platform/graphics/ca/win/CACFLayerTreeHost.cpp: Renamed from Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp. + * platform/graphics/ca/win/CACFLayerTreeHost.h: Renamed from Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h. + + * platform/graphics/ca/win/PlatformCALayerWin.cpp: + * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp: + * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h: + Updated for renames. + +2011-01-21 Patrick Gansterer <paroga@paroga.com> + + Original patch from François Sausset <sausset@gmail.com> + + Reviewed by Darin Adler. + + Code cleaning in rendering/mathml/RenderMathMLFraction.cpp + https://bugs.webkit.org/show_bug.cgi?id=52201 + + Replace unneeded doubles by floats and remove unneeded casts. + + * rendering/mathml/RenderMathMLFraction.cpp: + (WebCore::RenderMathMLFraction::paint): + * rendering/mathml/RenderMathMLFraction.h: + +2011-01-21 Dimitri Glazkov <dglazkov@chromium.org> + + Reviewed by Darin Adler. + + REGRESSION(r73618): Clicking on a search input causes a crash. + https://bugs.webkit.org/show_bug.cgi?id=52905 + + The problem is caused by TextControlInnerElement being used both as + shadow root and an element in a shadow subtree. The code assumed it is + only used as a shadow root. + + Since this code is all just workaround for in-progress conversion to + new shadow DOM, I am just adding a check. This code will disappear + completely once bug 52788 is fixed. + + Test: fast/dom/search-shadow-host-crash.html + + * dom/Node.cpp: + (WebCore::Node::setShadowHost): Added an ASSERT for early detection + of attempting to stomp on the parentNode. + * rendering/TextControlInnerElements.cpp: + (WebCore::TextControlInnerElement::detach): Added a check to only + clear shadow host if we have one. + +2011-01-21 Adam Roben <aroben@apple.com> + + Replace some "sync compositing state" terminology with "flush pending GraphicsLayer changes" + + This seems to be the direction in which our code is moving. I chose "GraphicsLayer" as + opposed to just "layer" because there are cases where we flush changes to CACFLayers that + don't have a corresponding GraphicsLayer. + + Fixes <http://webkit.org/b/52894> "Sync compositing state" terminology in + WKCACFLayerRenderer and friends is confusing + + Reviewed by Simon Fraser. + + * platform/graphics/win/WKCACFLayerRenderer.cpp: + (WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer): + (WebCore::WKCACFLayerRenderer::render): + Updated for renames. + + (WebCore::WKCACFLayerRenderer::flushPendingGraphicsLayerChangesSoon): Renamed from + syncCompositingStateSoon, and updated for other renames. + + * platform/graphics/win/WKCACFLayerRenderer.h: Renamed m_syncLayerChanges to + * m_shouldFlushPendingGraphicsLayerChanges. + (WebCore::WKCACFLayerRendererClient::flushPendingGraphicsLayerChanges): Renamed from + syncCompositingState. + +2011-01-21 Adam Roben <aroben@apple.com> + + Clean up PlatformCAAnimationWin + + Fixes <http://webkit.org/b/52904> PlatformCAAnimationWin is leaky and inefficient + + Reviewed by Simon Fraser. + + * platform/graphics/ca/win/PlatformCAAnimationWin.cpp: + (toCACFFillModeType): + (fromCACFFillModeType): + (toCACFValueFunctionType): + (fromCACFValueFunctionType): + Changed to take and return CFStringRefs. There's no need to convert to WebCore::String just + so we can later convert back to CFStringRef. + + (toCACFTimingFunction): Fixed leaks by changing this to return a RetainPtr and adopting the + results of CACFTimingFunctionCreate. + (PlatformCAAnimation::PlatformCAAnimation): Changed not to needlessly roundtrip through + WebCore::String. Also changed an ASSERT(0) to ASSERT_NOT_REACHED(). + + (PlatformCAAnimation::setFillMode): + (PlatformCAAnimation::setTimingFunction): + (PlatformCAAnimation::setValueFunction): + (PlatformCAAnimation::setTimingFunctions): + Updated for changes to the above conversion functions. + +2011-01-21 Charlie Reis <creis@chromium.org> + + Reviewed by Darin Fisher. + + FrameLoader::checkLoadCompleteForThisFrame uses wrong history item + https://bugs.webkit.org/show_bug.cgi?id=48812 + + Most calls to stopAllLoaders now clear the history's provisional item(s). + We can now avoid resetting the back/forward state if a new navigation + is in progress. + + Test: http/tests/navigation/back-twice-without-commit.html + Test: http/tests/navigation/forward-and-cancel.html + + * loader/FrameLoader.cpp: + * loader/FrameLoader.h: + * loader/FrameLoaderTypes.h: + * WebCore.exp.in: Update stopAllLoaders signature. + +2011-01-21 Carlos Garcia Campos <cgarcia@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Show caps lock indicator in password fields + https://bugs.webkit.org/show_bug.cgi?id=52878 + + Test: manual-tests/password-caps-lock.html + + * platform/gtk/KeyEventGtk.cpp: + (WebCore::PlatformKeyboardEvent::currentCapsLockState): Implement + currentCapsLockState() using GDK API. + * platform/gtk/RenderThemeGtk.cpp: + (WebCore::RenderThemeGtk::paintCapsLockIndicator): Paint an icon + in the password field when the caps lock modifier is locked. + * platform/gtk/RenderThemeGtk.h: + +2011-01-21 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: move sticky breakpoints management from InspectorController to InspectorBrowserDebuggerAgent. + https://bugs.webkit.org/show_bug.cgi?id=52874 + + This is the first step of debugger api refactoring (see bug 52879). + JavaScript breakpoints are still in the same list as native breakpoints and are restored by InspectorBrowserDebuggerAgent. + The second step will be to move sticky JavaScript breakpoints to InspectorDebuggerAgent. + + * inspector/Inspector.idl: + * inspector/InspectorBrowserDebuggerAgent.cpp: + (WebCore::InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints): + (WebCore::InspectorBrowserDebuggerAgent::inspectedURLChanged): + (WebCore::InspectorBrowserDebuggerAgent::restoreStickyBreakpoint): + (WebCore::InspectorBrowserDebuggerAgent::discardBindings): + (WebCore::InspectorBrowserDebuggerAgent::didInsertDOMNode): + (WebCore::InspectorBrowserDebuggerAgent::didRemoveDOMNode): + (WebCore::InspectorBrowserDebuggerAgent::setDOMBreakpoint): + (WebCore::InspectorBrowserDebuggerAgent::removeDOMBreakpoint): + (WebCore::InspectorBrowserDebuggerAgent::descriptionForDOMEvent): + (WebCore::InspectorBrowserDebuggerAgent::hasBreakpoint): + (WebCore::InspectorBrowserDebuggerAgent::updateSubtreeBreakpoints): + * inspector/InspectorBrowserDebuggerAgent.h: + * inspector/InspectorController.cpp: + (WebCore::InspectorController::restoreInspectorStateFromCookie): + (WebCore::InspectorController::connectFrontend): + (WebCore::InspectorController::didCommitLoad): + (WebCore::InspectorController::enableDebugger): + (WebCore::InspectorController::resume): + (WebCore::InspectorController::inspectedURL): + * inspector/InspectorController.h: + * inspector/InspectorState.cpp: + (WebCore::InspectorState::InspectorState): + * inspector/InspectorState.h: + * inspector/front-end/BreakpointManager.js: + (WebInspector.BreakpointManager): + (WebInspector.BreakpointManager.prototype._saveBreakpoints): + +2011-01-21 John Knottenbelt <jknotten@chromium.org> + + Reviewed by Jeremy Orlow. + + Turn off uninitialized errors for ARM linux build. + https://bugs.webkit.org/show_bug.cgi?id=52893 + + Fix ARM compiler breakage. + + * WebCore.gyp/WebCore.gyp: + +2011-01-21 Mikhail Naganov <mnaganov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: [Chromium] REGRESSION: Using the "Back" button + while profiling causes renderer crash. + + https://bugs.webkit.org/show_bug.cgi?id=52808 + + * inspector/InspectorProfilerAgent.cpp: + (WebCore::InspectorProfilerAgent::addProfileFinishedMessageToConsole): + (WebCore::InspectorProfilerAgent::addStartProfilingMessageToConsole): + +2011-01-20 Ilya Tikhonovsky <loislo@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: switch page/Console implementation from InspectorController to InspectorInstrumentation. + + There are some places in WebCore where we still using direct InspectorController calls. + The idea is to pass all the Inspector related calls via InspectorInstrumentaion which is the + Inspector facade for WebCore. + + https://bugs.webkit.org/show_bug.cgi?id=52869 + + * inspector/InspectorController.cpp: + * inspector/InspectorController.h: + * inspector/InspectorInstrumentation.cpp: + (WebCore::InspectorInstrumentation::addProfileImpl): + (WebCore::InspectorInstrumentation::profilerEnabledImpl): + (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl): + * inspector/InspectorInstrumentation.h: + (WebCore::InspectorInstrumentation::addProfile): + (WebCore::InspectorInstrumentation::profilerEnabled): + (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileName): + * page/Console.cpp: + (WebCore::Console::profile): + (WebCore::Console::profileEnd): + +2011-01-12 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: breakpoints are restored incorrectly when reverting live edit. + https://bugs.webkit.org/show_bug.cgi?id=52300 + + Fix breakpoints restoring when reverting to old revision by using text diff. + Move live edit logic from ScriptsPanel to DebuggerModel. + Eliminate unnecessary editLine delegate in TextViewer. + + * inspector/front-end/DebuggerModel.js: + (WebInspector.DebuggerModel): + (WebInspector.DebuggerModel.prototype.reset): + (WebInspector.DebuggerModel.prototype.editScriptSource): + (WebInspector.DebuggerModel.prototype._updateScriptSource): + (WebInspector.DebuggerModel.prototype.get callFrames): + (WebInspector.DebuggerModel.prototype.pausedScript): + (WebInspector.DebuggerModel.prototype.resumedScript): + * inspector/front-end/Script.js: + (WebInspector.Script.prototype.get source): + * inspector/front-end/ScriptView.js: + (WebInspector.ScriptView): + * inspector/front-end/ScriptsPanel.js: + (WebInspector.ScriptsPanel): + (WebInspector.ScriptsPanel.prototype._scriptSourceChanged): + * inspector/front-end/SourceFrame.js: + (WebInspector.SourceFrame): + (WebInspector.SourceFrame.prototype._createViewerIfNeeded): + (WebInspector.SourceFrame.prototype._doubleClick.didEditLine): + (WebInspector.SourceFrame.prototype._doubleClick): + * inspector/front-end/SourceView.js: + (WebInspector.SourceView): + * inspector/front-end/TextViewer.js: + (WebInspector.TextViewer): + (WebInspector.TextViewer.prototype._handleKeyDown): + (WebInspector.TextViewer.prototype.editLine.finishEditing): + (WebInspector.TextViewer.prototype.editLine): + (WebInspector.TextChunk.prototype._createRow): + +2011-01-21 Adam Klein <adamk@chromium.org> + + Reviewed by Eric Seidel. + + [chromium] Rename ChromiumBridge to PlatformBridge + https://bugs.webkit.org/show_bug.cgi?id=52471 + + No tests added as this is a rename; no change in behavior. + + * WebCore.gypi: + * bindings/v8/V8DOMWindowShell.cpp: + (WebCore::reportFatalErrorInV8): + * page/PageGroup.cpp: + (WebCore::PageGroup::isLinkVisited): + * platform/android/PlatformBridge.h: + * platform/audio/chromium/AudioBusChromium.cpp: + (WebCore::createBusFromInMemoryAudioFile): + * platform/chromium/ChromiumBridge.h: Removed. + * platform/chromium/ChromiumDataObjectLegacy.cpp: + (WebCore::ChromiumDataObjectLegacy::getData): + * platform/chromium/DragDataChromium.cpp: + (WebCore::DragData::asURL): + * platform/chromium/FileSystemChromium.cpp: + (WebCore::deleteFile): + (WebCore::deleteEmptyDirectory): + (WebCore::getFileSize): + (WebCore::getFileModificationTime): + (WebCore::revealFolderInOS): + (WebCore::directoryName): + (WebCore::pathByAppendingComponent): + (WebCore::makeAllDirectories): + (WebCore::fileExists): + (WebCore::openFile): + (WebCore::closeFile): + (WebCore::seekFile): + (WebCore::truncateFile): + (WebCore::readFromFile): + (WebCore::writeToFile): + * platform/chromium/LanguageChromium.cpp: + (WebCore::platformDefaultLanguage): + * platform/chromium/LinkHashChromium.cpp: + (WebCore::visitedLinkHash): + * platform/chromium/MIMETypeRegistryChromium.cpp: + (WebCore::MIMETypeRegistry::getMIMETypeForExtension): + (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType): + (WebCore::MIMETypeRegistry::isSupportedImageMIMEType): + (WebCore::MIMETypeRegistry::isSupportedJavaScriptMIMEType): + (WebCore::MIMETypeRegistry::isSupportedNonImageMIMEType): + * platform/chromium/PasteboardChromium.cpp: + (WebCore::Pasteboard::writeSelection): + (WebCore::Pasteboard::writePlainText): + (WebCore::Pasteboard::writeURL): + (WebCore::Pasteboard::writeImage): + (WebCore::Pasteboard::canSmartReplace): + (WebCore::Pasteboard::plainText): + (WebCore::Pasteboard::documentFragment): + * platform/chromium/PlatformBridge.h: + * platform/chromium/PlatformScreenChromium.cpp: + (WebCore::screenDepth): + (WebCore::screenDepthPerComponent): + (WebCore::screenIsMonochrome): + (WebCore::screenRect): + (WebCore::screenAvailableRect): + * platform/chromium/ReadableDataObject.cpp: + (WebCore::ReadableDataObject::getData): + (WebCore::ReadableDataObject::urlTitle): + (WebCore::ReadableDataObject::htmlBaseUrl): + (WebCore::ReadableDataObject::filenames): + (WebCore::ReadableDataObject::ensureTypeCacheInitialized): + * platform/chromium/SSLKeyGeneratorChromium.cpp: + (WebCore::signedPublicKeyAndChallengeString): + * platform/chromium/ScrollbarThemeChromium.cpp: + * platform/chromium/ScrollbarThemeChromiumLinux.cpp: + (WebCore::ScrollbarThemeChromiumLinux::scrollbarThickness): + (WebCore::ScrollbarThemeChromiumLinux::paintTrackPiece): + (WebCore::ScrollbarThemeChromiumLinux::paintButton): + (WebCore::ScrollbarThemeChromiumLinux::paintThumb): + (WebCore::ScrollbarThemeChromiumLinux::buttonSize): + (WebCore::ScrollbarThemeChromiumLinux::minimumThumbLength): + * platform/chromium/ScrollbarThemeChromiumMac.mm: + (WebCore::scrollbarStateToThemeState): + (WebCore::ScrollbarThemeChromiumMac::paint): + * platform/chromium/ScrollbarThemeChromiumWin.cpp: + (WebCore::ScrollbarThemeChromiumWin::scrollbarThickness): + (WebCore::ScrollbarThemeChromiumWin::paintTrackPiece): + (WebCore::ScrollbarThemeChromiumWin::paintButton): + (WebCore::ScrollbarThemeChromiumWin::paintThumb): + (WebCore::ScrollbarThemeChromiumWin::buttonSize): + * platform/chromium/SharedTimerChromium.cpp: + (WebCore::setSharedTimerFiredFunction): + (WebCore::setSharedTimerFireTime): + (WebCore::stopSharedTimer): + * platform/chromium/SuddenTerminationChromium.cpp: + (WebCore::disableSuddenTermination): + (WebCore::enableSuddenTermination): + * platform/chromium/SystemTimeChromium.cpp: + (WebCore::currentTime): + * platform/chromium/WritableDataObject.cpp: + (WebCore::WritableDataObject::setData): + * platform/graphics/chromium/CrossProcessFontLoading.mm: + * platform/graphics/chromium/FontCacheChromiumWin.cpp: + (WebCore::fontContainsCharacter): + (WebCore::FillLogFont): + * platform/graphics/chromium/FontCacheLinux.cpp: + (WebCore::FontCache::getFontDataForCharacters): + * platform/graphics/chromium/FontChromiumWin.cpp: + (WebCore::Font::drawGlyphs): + * platform/graphics/chromium/FontPlatformDataChromiumWin.cpp: + (WebCore::FontPlatformData::scriptFontProperties): + * platform/graphics/chromium/FontPlatformDataLinux.cpp: + (WebCore::FontPlatformData::querySystemForRenderStyle): + * platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp: + (WebCore::fillBMPGlyphs): + * platform/graphics/chromium/ImageChromium.cpp: + (WebCore::Image::loadPlatformResource): + * platform/graphics/chromium/ImageChromiumMac.mm: + (WebCore::Image::loadPlatformResource): + * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: + (WebCore::SimpleFontData::platformInit): + (WebCore::SimpleFontData::determinePitch): + (WebCore::SimpleFontData::platformWidthForGlyph): + * platform/graphics/chromium/UniscribeHelperTextRun.cpp: + (WebCore::UniscribeHelperTextRun::tryToPreloadFont): + * platform/graphics/skia/FontCustomPlatformData.cpp: + (WebCore::FontCustomPlatformData::fontPlatformData): + * platform/network/chromium/CookieJarChromium.cpp: + (WebCore::setCookies): + (WebCore::cookies): + (WebCore::cookieRequestHeaderFieldValue): + (WebCore::cookiesEnabled): + (WebCore::getRawCookies): + (WebCore::deleteCookie): + * platform/network/chromium/DNSChromium.cpp: + (WebCore::prefetchDNS): + * platform/qt/PlatformBridge.h: + * platform/sql/chromium/SQLiteFileSystemChromium.cpp: + (WebCore::SQLiteFileSystem::deleteDatabaseFile): + (WebCore::SQLiteFileSystem::getDatabaseFileSize): + * platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp: + (chromiumOpen): + (chromiumDelete): + (chromiumAccess): + * platform/sql/chromium/SQLiteFileSystemChromiumWin.cpp: + * plugins/chromium/PluginDataChromium.cpp: + (WebCore::PluginCache::plugins): + * rendering/RenderThemeChromiumMac.mm: + (WebCore::RenderThemeChromiumMac::usesTestModeFocusRingColor): + * rendering/RenderThemeChromiumSkia.cpp: + (WebCore::RenderThemeChromiumSkia::caretBlinkInterval): + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::platformActiveSelectionBackgroundColor): + (WebCore::RenderThemeChromiumWin::platformInactiveSelectionBackgroundColor): + (WebCore::RenderThemeChromiumWin::platformActiveSelectionForegroundColor): + (WebCore::RenderThemeChromiumWin::systemColor): + (WebCore::RenderThemeChromiumWin::paintButton): + (WebCore::RenderThemeChromiumWin::paintSliderTrack): + (WebCore::menuListButtonWidth): + (WebCore::RenderThemeChromiumWin::paintMenuList): + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + (WebCore::RenderThemeChromiumWin::paintInnerSpinButton): + (WebCore::RenderThemeChromiumWin::paintProgressBar): + * storage/chromium/IDBFactoryBackendInterface.cpp: + (WebCore::IDBFactoryBackendInterface::create): + (WebCore::IDBFactoryBackendInterface::~IDBFactoryBackendInterface): + * storage/chromium/IDBKeyPathBackendImpl.cpp: + (WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath): + +2011-01-21 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r76335. + http://trac.webkit.org/changeset/76335 + https://bugs.webkit.org/show_bug.cgi?id=52875 + + profiler tests were broken (Requested by loislo on #webkit). + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::addProfile): + (WebCore::InspectorController::getCurrentUserInitiatedProfileName): + * inspector/InspectorController.h: + * inspector/InspectorInstrumentation.cpp: + (WebCore::InspectorInstrumentation::addStartProfilingMessageToConsoleImpl): + * inspector/InspectorInstrumentation.h: + (WebCore::InspectorInstrumentation::addStartProfilingMessageToConsole): + (WebCore::InspectorInstrumentation::inspectorControllerWithFrontendForPage): + * page/Console.cpp: + (WebCore::Console::profile): + (WebCore::Console::profileEnd): + +2011-01-21 Ilya Tikhonovsky <loislo@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: switch page/Console implementation from InspectorController to InspectorInstrumentation. + + There are some places in WebCore where we still using direct InspectorController calls. + The idea is to pass all the Inspector related calls via InspectorInstrumentaion which is the + Inspector facade for WebCore. + + https://bugs.webkit.org/show_bug.cgi?id=52869 + + * inspector/InspectorController.cpp: + * inspector/InspectorController.h: + * inspector/InspectorInstrumentation.cpp: + (WebCore::InspectorInstrumentation::addProfileImpl): + (WebCore::InspectorInstrumentation::profilerEnabledImpl): + (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl): + * inspector/InspectorInstrumentation.h: + (WebCore::InspectorInstrumentation::addProfile): + (WebCore::InspectorInstrumentation::profilerEnabled): + (WebCore::InspectorInstrumentation::getCurrentUserInitiatedProfileName): + * page/Console.cpp: + (WebCore::Console::profile): + (WebCore::Console::profileEnd): + +2011-01-20 Sam Weinig <sam@webkit.org> + + Reviewed by Gavin Barraclough. + + Fix failing tests from r76291. + + * platform/ScrollView.cpp: + (WebCore::ScrollView::scrollPosition): + (WebCore::ScrollView::updateScrollbars): + Take the scroll origin into account in more places. + +2011-01-20 Kent Tamura <tkent@chromium.org> + + Unreviewed, sorting an Xcode project file. + + * WebCore.xcodeproj/project.pbxproj: + +2011-01-20 Ben Vanik <ben.vanik@gmail.com> + + Reviewed by Kenneth Russell. + + Implementation of the OES_standard_derivatives WebGL extension. + https://bugs.webkit.org/show_bug.cgi?id=51678 + + Changes are modeled off of the existing OESTextureFloat extension. New files, + extension retrieval, etc all match the existing code. + + Changed ANGLEWebKitBridge to allow for multiple sets of the ANGLE shader compiler + options. This supports the enabling of the standard derivatives flag when the + extension is enabled. Refactored the cleanup code to make the destruction of the + compilers (if they had been created) cleaner. + + Tested with the WebGL conformance test: + https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/conformance/oes-standard-derivatives.html + Passes on WebKit/OSX, Chromium/OSX, and Chromium/Windows. + + * CMakeLists.txt: + * DerivedSources.make: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pri: + * WebCore.pro: + * WebCore.xcodeproj/project.pbxproj: + * bindings/js/JSWebGLRenderingContextCustom.cpp: + (WebCore::toJS): + * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: + (WebCore::toV8Object): + * html/canvas/OESStandardDerivatives.cpp: Added. + (WebCore::OESStandardDerivatives::OESStandardDerivatives): + (WebCore::OESStandardDerivatives::~OESStandardDerivatives): + (WebCore::OESStandardDerivatives::getName): + (WebCore::OESStandardDerivatives::create): + * html/canvas/OESStandardDerivatives.h: Added. + * html/canvas/OESStandardDerivatives.idl: Added. + * html/canvas/WebGLExtension.h: + * html/canvas/WebGLRenderingContext.cpp: + (WebCore::WebGLRenderingContext::getExtension): Enable and return the new extension. + (WebCore::WebGLRenderingContext::getParameter): Support extension enum when enabled. + (WebCore::WebGLRenderingContext::getSupportedExtensions): + (WebCore::WebGLRenderingContext::hint): Validate extension enum when enabled. + (WebCore::WebGLRenderingContext::getNumberOfExtensions): + (WebCore::WebGLRenderingContext::getExtensionNumber): + * html/canvas/WebGLRenderingContext.h: + * platform/graphics/ANGLEWebKitBridge.cpp: + (WebCore::ANGLEWebKitBridge::~ANGLEWebKitBridge): Cleaned up compiler cleanup. + (WebCore::ANGLEWebKitBridge::cleanupCompilers): Destruct compilers. + (WebCore::ANGLEWebKitBridge::setResources): Cleanup existing compilers when changing + ANGLE settings. + (WebCore::ANGLEWebKitBridge::validateShaderSource): Cleaned up compiler cleanup on error. + * platform/graphics/ANGLEWebKitBridge.h: + (WebCore::ANGLEWebKitBridge::getResources): + * platform/graphics/Extensions3D.h: Added enumeration for the extension. + * platform/graphics/GraphicsContext3D.h: lumbing for GraphicsContext3D. + * platform/graphics/opengl/Extensions3DOpenGL.cpp: + (WebCore::Extensions3DOpenGL::Extensions3DOpenGL): Plumbed through a pointer to the + GraphicsContext3D to handle resetting the shader compilers. + (WebCore::Extensions3DOpenGL::supports): Desktop GL always supports this extension, + so always return true. + (WebCore::Extensions3DOpenGL::ensureEnabled): Reset shader compilers as required. + * platform/graphics/opengl/Extensions3DOpenGL.h: Plumbing for GraphicsContext3D. + * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: + (WebCore::GraphicsContext3D::getExtensions): Plumbing for GraphicsContext3D to + Extensions3DOpenGL. + +2011-01-20 Xiaomei Ji <xji@chromium.org> + + Reviewed by Dan Bernstein. + + Fix regression(r71566): PDF in RTL block might messes up text directionality. + https://bugs.webkit.org/show_bug.cgi?id=52776 + + Test: fast/dom/52776.html + + * platform/text/BidiResolver.h: + (WebCore::::checkDirectionInLowerRaiseEmbeddingLevel): + (WebCore::::lowerExplicitEmbeddingLevel): + (WebCore::::raiseExplicitEmbeddingLevel): + (WebCore::::createBidiRunsForLine): + +2011-01-20 Beth Dakin <bdakin@apple.com> + + Reviewed by Anders Carlsson. + + Follow-on for <rdar://problem/8890255> + + This fixes a painting error with ScrollbarPainter scrollers + and the new drawing area code path. + * platform/mac/ScrollbarThemeMac.mm: + (WebCore::updateArrowPlacement): + +2011-01-20 Levi Weintraub <leviw@chromium.org> + + Unreviewed. + + Fixing build breakage. + + * editing/SelectionController.cpp: + (WebCore::SelectionController::willBeModified): + +2011-01-20 Levi Weintraub <leviw@chromium.org> + + Reviewed by Ryosuke Niwa. + + RTL: Caret goes to the opposite direction when pressing an arrow key after selection is made + https://bugs.webkit.org/show_bug.cgi?id=49511 + + Test: editing/selection/rtl-move-selection-right-left.html + + * editing/SelectionController.cpp: + (WebCore::SelectionController::willBeModified): + Respecting the direction of the containing block when switching selection base and extent in + RTL content. + + (WebCore::SelectionController::modifyMovingRight): + (WebCore::SelectionController::modifyMovingLeft): + Using directionOfEnclosingBlock when deciding to use the selection start or end to do the + correct thing for RTL. + +2011-01-20 Nate Chapin <japhet@chromium.org> + + Reviewed by Adam Barth. + + Null-check m_frame in DOMWindow::setLocation(), since it's + possible to reach this point without it having been checked + already. + https://bugs.webkit.org/show_bug.cgi?id=52769 + + Test: fast/dom/Window/Location/set-location-after-close.html + + * page/DOMWindow.cpp: + (WebCore::DOMWindow::setLocation): + +2011-01-20 Chang Shu <chang.shu@nokia.com> + + Reviewed by Darin Adler. + + setContentEditable with invalid string should throw exception. + https://bugs.webkit.org/show_bug.cgi?id=52057 + + Implemented exception throwing for setContentEditable according to the following spec: + http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#attr-contenteditable + Related quotas: "On setting, if the new value is an ASCII case-insensitive match for the + string 'inherit' then the content attribute must be removed, if the new value is an ASCII + case-insensitive match for the string 'true' then the content attribute must be set to the + string 'true', if the new value is an ASCII case-insensitive match for the string 'false' + then the content attribute must be set to the string 'false', and otherwise the attribute + setter must raise a SYNTAX_ERR exception." + + * html/HTMLElement.cpp: + (WebCore::HTMLElement::setContentEditable): Throw exception on invalid input strings; Make setting values case-insensitive and also convert them to lower cases according to the spec. + * html/HTMLElement.h: Add additional parameter ExceptionCode& for function setContentEditable. + * html/HTMLElement.idl: Add exception throwing support for contentEditable setter. + +2011-01-19 Adrienne Walker <enne@google.com> + + Reviewed by James Robinson. + + [chromium] Composited render surfaces should allow writes to alpha channel. + https://bugs.webkit.org/show_bug.cgi?id=52766 + + Test: LayoutTests/platform/chromium/compositing + + * platform/graphics/chromium/LayerRendererChromium.cpp: + (WebCore::LayerRendererChromium::drawLayers): + +2011-01-14 Jer Noble <jer.noble@apple.com> + + Reviewed by Eric Carlson. + + REGRESSION (r71842): Compass video is not playing in Safari welcome page + https://bugs.webkit.org/show_bug.cgi?id=52506 + + New test: LayoutTests/media/video-currentTime-delay.html + + Call invalidateCachedTime() every time one of the cached property dependencies changes, + i.e. m_paused and m_playbackRate. + + * html/HTMLMediaElement.cpp: + (WebCore::HTMLMediaElement::prepareForLoad): + (WebCore::HTMLMediaElement::setReadyState): + (WebCore::HTMLMediaElement::setPlaybackRate): + (WebCore::HTMLMediaElement::mediaPlayerRateChanged): + +2011-01-20 Beth Dakin <bdakin@apple.com> + + Reviewed by Geoffrey Garen. + + Fix for <rdar://problem/8890255> + + Allow WebKitSystemInterface to draw scrollbars + when appropriate. + * WebCore.exp.in: + * platform/mac/ScrollbarThemeMac.mm: + (WebCore::scrollbarMap): + (+[ScrollbarPrefsObserver appearancePrefsChanged:]): + (WebCore::ScrollbarThemeMac::registerScrollbar): + (WebCore::ScrollbarThemeMac::unregisterScrollbar): + (WebCore::ScrollbarThemeMac::paint): + * platform/mac/WebCoreSystemInterface.h: + * platform/mac/WebCoreSystemInterface.mm: + +2011-01-20 Sam Weinig <sam@webkit.org> + + Reviewed by Dave Hyatt. + + Cleanup Scrollbar/ScrollbarClient relationship + https://bugs.webkit.org/show_bug.cgi?id=52779 + + Pipe all scrolling through the ScrollbarClient/ScrollAnimator + rather than through the Scrollbar. The Scrollbar now is just + a "view" on the scroll position of the scrollable area it is + attached to. + + There are now two ways to scroll a scrollable area: + - ScrollbarClient::scroll() + - ScrollbarClient::scrollToOffsetWithoutAnimation() + + Both of these go through the ScrollAnimator (updating its state + or starting an animation). The ScrollAnimator, in turn, now calls + ScrollbarClient::setScrollOffsetFromAnimation, which tells the + Scrollbars to pull a new offset (via Scrollbar::offsetDidChange) + and tells the class that derives from ScrollbarClient to scroll + its contents (via ScrollbarClient::setScrollOffset). + + * WebCore.xcodeproj/project.pbxproj: + Move Scrollbar.cpp to the right place. + + * accessibility/AccessibilityScrollbar.cpp: + (WebCore::AccessibilityScrollbar::setValue): + Initiate the scroll through the scrollbar client, rather than the + scrollbar itself. + + * page/FrameView.cpp: + (WebCore::FrameView::scrollTo): + * page/FrameView.h: + Condense the two valueChanged overrides to a single override of the + scrollTo function. + + * platform/ScrollAnimator.cpp: + (WebCore::ScrollAnimator::scroll): + (WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation): + (WebCore::ScrollAnimator::currentPosition): + (WebCore::ScrollAnimator::notityPositionChanged): + * platform/ScrollAnimator.h: + * platform/ScrollAnimatorWin.cpp: + (WebCore::ScrollAnimatorWin::scrollToOffsetWithoutAnimation): + (WebCore::ScrollAnimatorWin::animateScroll): + * platform/ScrollAnimatorWin.h: + * platform/mac/ScrollAnimatorMac.h: + * platform/mac/ScrollAnimatorMac.mm: + (WebCore::ScrollAnimatorMac::scrollToOffsetWithoutAnimation): + (WebCore::ScrollAnimatorMac::immediateScrollToPoint): + Change setScrollPositionAndStopAnimation to scrollToOffsetWithoutAnimation + and bottleneck all client notification of changed position through a new + notityPositionChanged() function. + + * platform/ScrollView.cpp: + (WebCore::ScrollView::setScrollOffset): + (WebCore::ScrollView::scrollTo): + (WebCore::ScrollView::scrollPosition): + (WebCore::ScrollView::scroll): + (WebCore::ScrollView::updateScrollbars): + (WebCore::ScrollView::wheelEvent): + * platform/ScrollView.h: + (WebCore::ScrollView::horizontalScrollbar): + (WebCore::ScrollView::verticalScrollbar): + Update to scroll via the ScrollbarClient rather than the Scrollbar. + + * platform/Scrollbar.cpp: + (WebCore::Scrollbar::offsetDidChange): + (WebCore::Scrollbar::autoscrollPressedPart): + (WebCore::Scrollbar::moveThumb): + (WebCore::Scrollbar::mouseMoved): + * platform/Scrollbar.h: + (WebCore::Scrollbar::setPressedPos): + Change the scrollbar to only updates its offset in response to + an offsetDidChange call. + + * platform/ScrollbarClient.cpp: + (WebCore::ScrollbarClient::scroll): + (WebCore::ScrollbarClient::scrollToOffsetWithoutAnimation): + (WebCore::ScrollbarClient::scrollToXOffsetWithoutAnimation): + (WebCore::ScrollbarClient::scrollToYOffsetWithoutAnimation): + (WebCore::ScrollbarClient::setScrollOffsetFromAnimation): + * platform/ScrollbarClient.h: + (WebCore::ScrollbarClient::horizontalScrollbar): + (WebCore::ScrollbarClient::verticalScrollbar): + Make the increasingly misnamed ScrollbarClient responsible for + scrolling. + + * platform/efl/ScrollbarEfl.cpp: + (scrollbarEflEdjeMessage): + * platform/gtk/MainFrameScrollbarGtk.cpp: + (MainFrameScrollbarGtk::gtkValueChanged): + * platform/qt/ScrollbarQt.cpp: + (WebCore::Scrollbar::contextMenu): + Update to move scrolling through the client. + + * platform/win/PopupMenuWin.cpp: + (WebCore::PopupMenuWin::scrollToRevealSelection): + (WebCore::PopupMenuWin::scrollPosition): + (WebCore::PopupMenuWin::setScrollOffset): + (WebCore::PopupMenuWin::scrollTo): + (WebCore::PopupMenuWin::wndProc): + * platform/win/PopupMenuWin.h: + (WebCore::PopupMenuWin::verticalScrollbar): + * rendering/RenderLayer.cpp: + (WebCore::RenderLayer::scrollToOffset): + (WebCore::RenderLayer::scrollTo): + (WebCore::RenderLayer::setScrollOffset): + (WebCore::RenderLayer::scrollPosition): + (WebCore::RenderLayer::updateScrollInfoAfterLayout): + (WebCore::RenderLayer::scroll): + * rendering/RenderLayer.h: + * rendering/RenderListBox.cpp: + (WebCore::RenderListBox::scrollToRevealElementAtListIndex): + (WebCore::RenderListBox::scroll): + (WebCore::RenderListBox::logicalScroll): + (WebCore::RenderListBox::scrollPosition): + (WebCore::RenderListBox::setScrollOffset): + (WebCore::RenderListBox::scrollTo): + (WebCore::RenderListBox::setScrollTop): + * rendering/RenderListBox.h: + (WebCore::RenderListBox::verticalScrollbar): + Update to scroll via the ScrollbarClient rather than the Scrollbar. + + * rendering/RenderMarquee.cpp: + (WebCore::RenderMarquee::start): + Simplify initial paint to just do an immediate scroll to the position. + +2011-01-20 Patrick Gansterer <paroga@webkit.org> + + Unreviewed WinCE build fix for r76170. + + * platform/graphics/wince/FontWinCE.cpp: Added a missing include. + * platform/graphics/wince/ImageBufferData.h: Added a missing include and fixed style. + +2011-01-20 James Robinson <jamesr@chromium.org> + + Reviewed by Darin Fisher. + + Implement mozilla's requestAnimationFrame API + https://bugs.webkit.org/show_bug.cgi?id=51218 + + This implements mozilla's proposed requestAnimationFrame API. The idea with this API is that + an author driving an animation from script could use window.requestAnimationFrame(callback) + instead of window.setTimeout(callback, 0) to schedule their update logic and let the browser + decide when to update the animations. This avoids doing unnecessary work when the page content + is offscreen or is being displayed at a different framerate than what the page author expects. + + Mozilla's proposal is here: https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame + This implements window.mozRequestAnimationFrame as window.webkitRequestAnimationFrame with the + following changes: + *) Only the callback syntax is supported, there is no before paint event + *) webkitRequestAnimationFrame supports a second parameter Element to let the author indicate + what content they intend to animate. That way if the page is being displayed but the element + in question is offscreen, we can avoid invoking the callback. + *) No timestamp is provided to the caller and there is no window.animationStartTime property + (see https://bugs.webkit.org/show_bug.cgi?id=51952 for discussion of this property) + *) window.webkitRequestAnimationFrame returns a numerical id that can be used to cancel the callback + using window.cancelWebkitRequestAnimationFrame, to parallel window.setTimeout()/window.clearTime(). + + The implementation depends on the embedder scheduling the callbacks since the callback invocation + depends on the page's visibility and the embedder's paint scheduling, neither of which are exposed + to WebCore. The expectation for the embedder is that at some point Chrome::scheduleAnimation() is + called FrameView::serviceScriptedAnimations() should be called for the associated Page's main frame. + Ideally serviceScriptedAnimations() would be called prior to rendering - although in practice the + embedder has to rate limit callbacks and may not be able to tie the callback directly to the + rendering loop. + + Tests: fast/animation/request-animation-frame-cancel.html + fast/animation/request-animation-frame-cancel2.html + fast/animation/request-animation-frame-display.html + fast/animation/request-animation-frame-within-callback.html + fast/animation/request-animation-frame.html + + * WebCore.gypi: + * dom/Document.cpp: + (WebCore::Document::Document): + (WebCore::Document::webkitRequestAnimationFrame): + (WebCore::Document::webkitCancelRequestAnimationFrame): + (WebCore::Document::serviceScriptedAnimations): + * dom/Document.h: + * dom/RequestAnimationFrameCallback.h: Added. + (WebCore::RequestAnimationFrameCallback::~RequestAnimationFrameCallback): + * dom/RequestAnimationFrameCallback.idl: Added. + * loader/EmptyClients.h: + (WebCore::EmptyChromeClient::scheduleAnimation): + * page/Chrome.cpp: + (WebCore::Chrome::scheduleAnimation): + * page/Chrome.h: + * page/ChromeClient.h: + * page/DOMWindow.cpp: + (WebCore::DOMWindow::webkitRequestAnimationFrame): + (WebCore::DOMWindow::webkitCancelRequestAnimationFrame): + * page/DOMWindow.h: + * page/DOMWindow.idl: + * page/FrameView.cpp: + (WebCore::FrameView::scheduleAnimation): + (WebCore::FrameView::serviceScriptedAnimations): + * page/FrameView.h: + * platform/HostWindow.h: + +2011-01-20 James Robinson <jamesr@chromium.org> + + Reviewed by Nate Chapin. + + [v8] CodeGeneratorV8 generates incorrect code for callbacks with no parameters + https://bugs.webkit.org/show_bug.cgi?id=52837 + + When generating code to invoke a callback with no parameters CodeGeneratorV8.pm was generating the following: + v8::Handle<v8::Value> argv[] = {}; which does not compile in visual studio. Instead, if the argument count + is 0, we can just pass a NULL pointer for the argv parameter. + + Test added to bindings/scripts/test/TestCallback.idl and covered by run-bindings-tests. This + patch also includes some spurious changes to the bindings tests golden files (mostly GObject) + because the old golden files were out of date. + + * bindings/scripts/CodeGeneratorV8.pm: + * bindings/scripts/test/CPP/WebDOMTestCallback.cpp: + (WebDOMTestCallback::callbackWithNoParam): + * bindings/scripts/test/CPP/WebDOMTestCallback.h: + * bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp: + (webkit_dom_test_callback_callback_with_no_param): + * bindings/scripts/test/GObject/WebKitDOMTestCallback.h: + * bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp: + * bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp: + * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: + * bindings/scripts/test/JS/JSTestCallback.cpp: + (WebCore::JSTestCallback::callbackWithNoParam): + * bindings/scripts/test/JS/JSTestCallback.h: + * bindings/scripts/test/JS/JSTestInterface.cpp: + * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp: + * bindings/scripts/test/JS/JSTestObj.cpp: + * bindings/scripts/test/ObjC/DOMTestCallback.h: + * bindings/scripts/test/ObjC/DOMTestCallback.mm: + (-[DOMTestCallback callbackWithNoParam]): + * bindings/scripts/test/TestCallback.idl: + * bindings/scripts/test/V8/V8TestCallback.cpp: + (WebCore::V8TestCallback::callbackWithNoParam): + * bindings/scripts/test/V8/V8TestCallback.h: + * bindings/scripts/test/V8/V8TestObj.cpp: + (WebCore::TestObjInternal::reflectedUnsignedIntegralAttrAttrGetter): + +2011-01-20 James Robinson <jamesr@chromium.org> + + Reviewed by Eric "Baller" Seidel. + + RenderTableSection's setNeedsCellRecalc needs to null check table() + https://bugs.webkit.org/show_bug.cgi?id=52770 + + Null checks table() before deferencing it in RenderTableSection::setNeedsCellRecalc. + This can be null during detach(). Test constructed by Eric Seidel. + + Test: fast/css-generated-content/table-with-scrollbar-corner.html + + * rendering/RenderTableSection.cpp: + (WebCore::RenderTableSection::setNeedsCellRecalc): + * rendering/RenderTableSection.h: + +2011-01-20 Dirk Schulze <krit@webkit.org> + + Reviewed by Rob Buis. + + SVG Pattern doesn't take preserveAspectRatio of references Pattern + https://bugs.webkit.org/show_bug.cgi?id=52802 + + SVGPattern didn't take preserveAspectRatio of a referenced SVGPattern into account. Store preserveAspectRatio + in PatternAttributes as well, if the attribute was set on the referenced SVGPattern element. + + Test: svg/custom/pattern-referencing-preserve-aspect-ratio.svg + + * rendering/svg/RenderSVGResourcePattern.cpp: + (WebCore::RenderSVGResourcePattern::buildTileImageTransform): + * svg/PatternAttributes.h: + (WebCore::PatternAttributes::PatternAttributes): + (WebCore::PatternAttributes::preserveAspectRatio): + (WebCore::PatternAttributes::setPreserveAspectRatio): + (WebCore::PatternAttributes::hasPreserveAspectRatio): + * svg/SVGPatternElement.cpp: + (WebCore::SVGPatternElement::collectPatternAttributes): + +2011-01-20 Dan Bernstein <mitz@apple.com> + + Reviewed by Adele Peterson. + + <rdar://problem/8765498> REGRESSION (r72141): Cannot order prints with Aperture 3.1 + + <rdar://problem/8884648> REGRESSION (r72141): Safari hangs when visiting a page on www.bfmtv.com + https://bugs.webkit.org/show_bug.cgi?id=52765 + + <rdar://problem/8890909> REGRESSION (r72141): Very Slow Rendering With Certain Markup + https://bugs.webkit.org/show_bug.cgi?id=52265 + + Test: fast/block/line-layout/negative-max-height.html + + Integer overflow detection led to a block having a huge height. This manifested as broken layout + in the first bug and as extreme slowness in the latter bugs because of + https://bugs.webkit.org/show_bug.cgi?id=52832 + + * rendering/RootInlineBox.cpp: + (WebCore::RootInlineBox::alignBoxesInBlockDirection): Clamp maxHeight to 0 so the next line + cannot start above this line. The negative maxHeight also caused the integer overflow detection + logic to give the block a huge height. + +2011-01-20 Yi Shen <yi.4.shen@nokia.com> + + Reviewed by Eric Carlson. + + Clean up the Media Controls CSS for Qt + https://bugs.webkit.org/show_bug.cgi?id=52822 + + Split the audio::-webkit-media-xxx and video::-webkit-media-xxx rules + in mediaControlsQt.css, and remove the duplicate audio::-webkit-media-xxx + rules from mediaControlsQtFullscreen.css. + + * css/mediaControlsQt.css: + (audio::-webkit-media-controls-panel): + (video::-webkit-media-controls-panel): + (audio::-webkit-media-controls-mute-button): + (video::-webkit-media-controls-mute-button): + (audio::-webkit-media-controls-play-button): + (video::-webkit-media-controls-play-button): + (audio::-webkit-media-controls-timeline-container): + (video::-webkit-media-controls-timeline-container): + (audio::-webkit-media-controls-current-time-display): + (video::-webkit-media-controls-current-time-display): + (audio::-webkit-media-controls-time-remaining-display): + (video::-webkit-media-controls-time-remaining-display): + (audio::-webkit-media-controls-timeline): + (video::-webkit-media-controls-timeline): + (audio::-webkit-media-controls-volume-slider-container): + (video::-webkit-media-controls-volume-slider-container): + (audio::-webkit-media-controls-volume-slider): + (video::-webkit-media-controls-volume-slider): + (audio::-webkit-media-controls-seek-back-button): + (video::-webkit-media-controls-seek-back-button): + (audio::-webkit-media-controls-seek-forward-button): + (video::-webkit-media-controls-seek-forward-button): + (audio::-webkit-media-controls-fullscreen-button): + (video::-webkit-media-controls-fullscreen-button): + (audio::-webkit-media-controls-rewind-button): + (video::-webkit-media-controls-rewind-button): + (audio::-webkit-media-controls-return-to-realtime-button): + (video::-webkit-media-controls-return-to-realtime-button): + (audio::-webkit-media-controls-toggle-closed-captions-button): + (video::-webkit-media-controls-toggle-closed-captions-button): + * css/mediaControlsQtFullscreen.css: + (video::-webkit-media-controls-time-remaining-display): + (video::-webkit-media-controls-seek-back-button): + (video::-webkit-media-controls-seek-forward-button): + (video::-webkit-media-controls-rewind-button): + (video::-webkit-media-controls-return-to-realtime-button): + (video::-webkit-media-controls-toggle-closed-captions-button): + +2011-01-20 Alexander Pavlov <apavlov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: [REGRESSION] Canceling of CSS numeric values increment/decrement is broken + https://bugs.webkit.org/show_bug.cgi?id=52816 + + * inspector/front-end/StylesSidebarPane.js: + (WebInspector.StylePropertyTreeElement.prototype): + +2011-01-20 Dawit Alemayehu <adawit@kde.org> + + Reviewed by Andreas Kling. + + [Qt] Fix Layering violation in MediaPlayerPrivateQt. + https://bugs.webkit.org/show_bug.cgi?id=52733 + + No new tests. no behavioral change. + + * platform/graphics/qt/MediaPlayerPrivateQt.cpp: + (WebCore::MediaPlayerPrivateQt::commitLoad): + +2011-01-20 Nate Chapin <japhet@chromium.org> + + Reviewed by Darin Fisher. + + [V8] Call malloc and memcpy directly instead of + of strdup in convertV8ObjectToNPVariant() when + converting strings. If there is a null character + in the string, our use of strdup causes us to allocate + too little memory, leading to out of bounds reads. + + https://bugs.webkit.org/show_bug.cgi?id=52631 + + * bindings/v8/V8NPUtils.cpp: + (WebCore::convertV8ObjectToNPVariant): + +2011-01-20 Andreas Kling <kling@webkit.org> + + Reviewed by Ariya Hidayat. + + [Qt] Fill shadow scratch buffer with proper transparent pixels + + QImage::fill() has no Qt::GlobalColor overload in Qt 4.7 (coming in 4.8) + so doing QImage::fill(Qt::transparent) will actually fill all pixels with + the RGBA value 0x00000013. + + * platform/graphics/qt/ContextShadowQt.cpp: + (WebCore::ShadowBuffer::scratchImage): + +2011-01-19 Adam Roben <aroben@apple.com> + + Remove WKCACFContextFlusher + + It wasn't doing anything. + + Fixes <http://webkit.org/b/52752> WKCACFContextFlusher is unused + + Reviewed by Simon Fraser. + + * WebCore.vcproj/WebCore.vcproj: Removed WKCACFContextFlusher. Also let VS have its way with + the file. + + * platform/graphics/win/WKCACFContextFlusher.cpp: Removed. + * platform/graphics/win/WKCACFContextFlusher.h: Removed. + + * platform/graphics/win/WKCACFLayerRenderer.cpp: + (WebCore::WKCACFLayerRenderer::~WKCACFLayerRenderer): + (WebCore::WKCACFLayerRenderer::layerTreeDidChange): + Stop telling WKCACFContextFlusher about our context, since it never did anything with it. + +2011-01-19 Adam Roben <aroben@apple.com> + + Only flush our own context when we get resized + + Fixes <http://webkit.org/b/52751> All WKCACFContexts with uncommitted + changes get flushed whenever any composited page is resized + + Reviewed by Simon Fraser. + + * platform/graphics/win/WKCACFLayerRenderer.cpp: + (WebCore::WKCACFLayerRenderer::resize): Just flush our own context, not all contexts + WKCACFContextFlusher knows about. After all, ours is the only one that just got resized! + +2011-01-19 Adam Roben <aroben@apple.com> + + Make WKCACFLayerRenderer ref-counted + + This will be needed to handle cases where the client might release its reference to us while + we're calling out to it. + + WKCACFLayerRenderer now has a setClient function, which is used rather than passing the + client to create(). This allows clients to null out the client pointer when they're done + with the renderer. + + Fixes <http://webkit.org/b/52749> WKCACFLayerRenderer should be + ref-counted + + Reviewed by Simon Fraser. + + * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp: + (WebCore::MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow): + * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h: + Updated for WKCACFLayerRenderer changes. + + * platform/graphics/win/WKCACFLayerRenderer.cpp: + (WebCore::WKCACFLayerRenderer::acceleratedCompositingAvailable): Updated for changes to + create(). + (WebCore::WKCACFLayerRenderer::create): No longer takes a WKCACFLayerRendererClient. Now + returns a PassOwnPtr. + (WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer): No longer takes a + WKCACFLayerRendererClient. + + * platform/graphics/win/WKCACFLayerRenderer.h: Made WKCACFLayerRenderer inherit from + RefCounted. + (WebCore::WKCACFLayerRenderer::setClient): Added this simple setter. + +2011-01-20 Csaba Osztrogonác <ossy@webkit.org> + + [Qt][V8] Unreviewed buildfix after r76248. + + * bindings/v8/ScriptCachedFrameData.h: Add missing include. + +2011-01-20 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: enable resource agent upon request. + https://bugs.webkit.org/show_bug.cgi?id=52815 + + We should not send network-related notifications unless front-end + is interested. + + * inspector/Inspector.idl: + * inspector/InspectorController.cpp: + (WebCore::InspectorController::restoreInspectorStateFromCookie): + (WebCore::InspectorController::connectFrontend): + (WebCore::InspectorController::resourceAgent): + * inspector/InspectorController.h: + (WebCore::InspectorController::consoleAgent): + (WebCore::InspectorController::cssAgent): + (WebCore::InspectorController::domAgent): + (WebCore::InspectorController::injectedScriptAgent): + (WebCore::InspectorController::runtimeAgent): + (WebCore::InspectorController::databaseAgent): + (WebCore::InspectorController::domStorageAgent): + (WebCore::InspectorController::fileSystemAgent): + * inspector/InspectorInstrumentation.cpp: + (WebCore::InspectorInstrumentation::retrieveResourceAgent): + * inspector/InspectorResourceAgent.cpp: + (WebCore::InspectorResourceAgent::restore): + (WebCore::InspectorResourceAgent::~InspectorResourceAgent): + (WebCore::InspectorResourceAgent::InspectorResourceAgent): + * inspector/InspectorResourceAgent.h: + (WebCore::InspectorResourceAgent::create): + * inspector/InspectorState.cpp: + (WebCore::InspectorState::InspectorState): + * inspector/InspectorState.h: + +2011-01-20 Zoltan Horvath <zoltan@webkit.org> + + Reviewed by Csaba Osztrogonác. + + Refactoring of the custom allocation framework + https://bugs.webkit.org/show_bug.cgi?id=49897 + + Inheriting from FastAllocBase can result in objects getting larger (bug #33896, #46589). + The modification replaces Noncopyable and FastAllocBase classes and these inherits with their + equivalent macro implementation at the necessary places. + +2011-01-20 Mikhail Naganov <mnaganov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: [Chromium] CPU Profiles are cleared when navigating back and forth. + + Profiles are now not cleared unless renderer instance was changed. + + https://bugs.webkit.org/show_bug.cgi?id=52807 + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::restoreProfiler): + * inspector/InspectorProfilerAgent.cpp: + (WebCore::InspectorProfilerAgent::resetState): + (WebCore::InspectorProfilerAgent::resetFrontendProfiles): + * inspector/InspectorProfilerAgent.h: + +2011-01-20 Alexander Pavlov <apavlov@chromium.org> + + Unreviewed, add new JS file refs missing from r76116. + + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * inspector/front-end/WebKit.qrc: + +2011-01-20 Alexander Pavlov <apavlov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: Crash when adding a rule for an ImageDocument + https://bugs.webkit.org/show_bug.cgi?id=52811 + + * inspector/InspectorCSSAgent.cpp: + (WebCore::InspectorCSSAgent::addRule2): + (WebCore::InspectorCSSAgent::viaInspectorStyleSheet): + +2011-01-20 Ilya Tikhonovsky <loislo@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: cleanup InspectorController's friends list. + We have a plan to extract InspectorAgent from InspectorController. + InspectorAgent will be accessible only from InspectorController. + As result we can simply made some methods public and remove long + friends list. + + https://bugs.webkit.org/show_bug.cgi?id=52806 + + * inspector/InjectedScriptHost.cpp: + (WebCore::InjectedScriptHost::databaseForId): + (WebCore::InjectedScriptHost::selectDatabase): + (WebCore::InjectedScriptHost::selectDOMStorage): + (WebCore::InjectedScriptHost::inspectorDOMAgent): + (WebCore::InjectedScriptHost::frontend): + * inspector/InspectorBrowserDebuggerAgent.cpp: + (WebCore::InspectorBrowserDebuggerAgent::setDOMBreakpoint): + (WebCore::InspectorBrowserDebuggerAgent::removeDOMBreakpoint): + (WebCore::InspectorBrowserDebuggerAgent::willInsertDOMNode): + (WebCore::InspectorBrowserDebuggerAgent::willRemoveDOMNode): + (WebCore::InspectorBrowserDebuggerAgent::willModifyDOMAttr): + (WebCore::InspectorBrowserDebuggerAgent::descriptionForDOMEvent): + (WebCore::InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded): + (WebCore::InspectorBrowserDebuggerAgent::willSendXMLHttpRequest): + * inspector/InspectorController.h: + (WebCore::InspectorController::frontend): + * inspector/InspectorInstrumentation.cpp: + (WebCore::InspectorInstrumentation::willInsertDOMNodeImpl): + (WebCore::InspectorInstrumentation::didInsertDOMNodeImpl): + (WebCore::InspectorInstrumentation::willRemoveDOMNodeImpl): + (WebCore::InspectorInstrumentation::didRemoveDOMNodeImpl): + (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl): + (WebCore::InspectorInstrumentation::didModifyDOMAttrImpl): + (WebCore::InspectorInstrumentation::characterDataModifiedImpl): + (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl): + (WebCore::InspectorInstrumentation::didReceiveResourceResponseImpl): + (WebCore::InspectorInstrumentation::didFailLoadingImpl): + (WebCore::InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl): + (WebCore::InspectorInstrumentation::addStartProfilingMessageToConsoleImpl): + (WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded): + (WebCore::InspectorInstrumentation::cancelPauseOnNativeEvent): + (WebCore::InspectorInstrumentation::retrieveTimelineAgent): + (WebCore::InspectorInstrumentation::retrieveResourceAgent): + +2011-01-19 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: implement JavaScriptBreakpointsSidebarPane based on events from debugger model. + https://bugs.webkit.org/show_bug.cgi?id=52723 + + Extract all breakpoints-related presentation code from debugger model to JavaScriptBreakpointSidebarPane. + + * inspector/front-end/Breakpoint.js: + (WebInspector.Breakpoint): + (WebInspector.Breakpoint.prototype.get data): + (WebInspector.Breakpoint.prototype.remove): + * inspector/front-end/BreakpointsSidebarPane.js: + (WebInspector.JavaScriptBreakpointsSidebarPane): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointAdded): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointRemoved): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointEnableChanged): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointItemCheckboxClicked): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._contextMenuEventFired): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._debuggerPaused): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._debuggerResumed): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._addListElement): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._removeListElement): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._projectChanged): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._compare): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._compareBreakpoints): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._setupBreakpointElement.didGetSourceLine): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._setupBreakpointElement): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointIdForDebuggerPausedEvent): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._setBreakpointEnabled): + (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._removeBreakpoint): + (WebInspector.NativeBreakpointsSidebarPane): + (WebInspector.XHRBreakpointsSidebarPane.prototype.addBreakpointItem): + * inspector/front-end/DebuggerModel.js: + (WebInspector.DebuggerModel.prototype.removeBreakpoint): + (WebInspector.DebuggerModel.prototype.breakpointForId): + (WebInspector.DebuggerModel.prototype._pausedScript): + (WebInspector.DebuggerModel.prototype._resumedScript): + * inspector/front-end/ScriptsPanel.js: + (WebInspector.ScriptsPanel): + * inspector/front-end/inspector.js: + +2011-01-20 Dirk Schulze <krit@webkit.org> + + Reviewed by Andreas Kling. + + SVG Pattern doesn't take the viewBox of a referenced Pattern + https://bugs.webkit.org/show_bug.cgi?id=52804 + + SVGPattern element didn't use the viewBox of another SVGPattern element, referenced + by xlink:href. Modified PatternAttributes, to take the value of the viewBox of the + SVGPattern element as well, if the attribute was set. + This gets checked by a W3C SVG test case. + + Test: svg/W3C-SVG-1.1-SE/pservers-pattern-04-f.svg + + * rendering/svg/RenderSVGResourcePattern.cpp: + (WebCore::RenderSVGResourcePattern::buildTileImageTransform): + * svg/PatternAttributes.h: + (WebCore::PatternAttributes::PatternAttributes): + (WebCore::PatternAttributes::viewBox): + (WebCore::PatternAttributes::setViewBox): + (WebCore::PatternAttributes::hasViewBox): + * svg/SVGPatternElement.cpp: + (WebCore::SVGPatternElement::collectPatternAttributes): + +2011-01-19 Stephen White <senorblanco@chromium.org> + + [Re-land of r76159 with a compile fix for the Chromium linux shlib + build.] + + Reviewed by James Robinson. + + Implement accelerated path drawing and clipping for the Canvas2D GPU + path. + https://bugs.webkit.org/show_bug.cgi?id=52627 + + This is done with a simple curve interpolator and the GLU tesselator, + which is good enough for a 3-5X speedup on + http://ie.microsoft.com/testdrive/Performance/Galactic/Default.html. + + Covered by canvas/philip/2d.path.clip.basic.html, and many, many more. + All tests canvas/philip and fast/canvas paths pass with no + regressions, although two have minor pixel differences which require + rebaselining. + + * WebCore.gyp/WebCore.gyp: + Add internal_glu include path to chromium build. + * WebCore.gypi: + Add internal_glu files to chromium build. + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::reset): + (WebCore::CanvasRenderingContext2D::platformLayer): + Make CanvasRenderingContext2D more robust against failure to create + a DrawingBuffer. + * platform/graphics/chromium/DrawingBufferChromium.cpp: + (WebCore::DrawingBuffer::DrawingBuffer): + As in DrawingBufferMac.cpp, call reset() from the constructor. + Also initialize size to (-1, -1), so reset() doesn't early-out. + Add initializers for depthBuffer and stencilBuffer, and remove + multisampleDepthStencilBuffer. + * platform/graphics/chromium/GLES2Canvas.cpp: + Remove some unused #includes. + (WebCore::GLES2Canvas::State::State): + Add clipping state, and implement save/restore via the copy constructor. + (WebCore::operator*): + (WebCore::Quadratic::Quadratic): + (WebCore::Quadratic::fromBezier): + (WebCore::Quadratic::evaluate): + Quadratic Bezier curve class. + (WebCore::Cubic::Cubic): + (WebCore::Cubic::fromBezier): + (WebCore::Cubic::evaluate): + Cubic Bezier curve class. + (WebCore::GLES2Canvas::clearRect): + Add clipping support to clearRect(). + (WebCore::GLES2Canvas::fillPath): + Implement fillPath(). + (WebCore::GLES2Canvas::fillRect): + Add clipping support to fillRect(). + (WebCore::GLES2Canvas::clipPath): + Implement clipPath(). + (WebCore::GLES2Canvas::clipOut): + Stub out clipOut() (not called by Canvas 2D). + (WebCore::GLES2Canvas::restore): + When restoring, draw any remaining clipping paths to the stencil buffer. + (WebCore::GLES2Canvas::drawTexturedRect): + Add clipping support. + (WebCore::interpolateQuadratic): + (WebCore::interpolateCubic): + Simple curve interpolation, using the Cubic and Quadratic classes. + (WebCore::PolygonData::PolygonData): + A struct to hold the tesselation data for callbacks. + (WebCore::beginData): + (WebCore::edgeFlagData): + (WebCore::vertexData): + (WebCore::endData): + (WebCore::combineData): + internal_glu tesselation callbacks. + (WebCore::GLES2Canvas::createVertexBufferFromPath): + Build an interpolated, tesselated vertex buffer and element array buffer from a given path, suitable for filling. + (WebCore::GLES2Canvas::beginStencilDraw): + Enable stencilling, and disable draws to the color buffer. + (WebCore::GLES2Canvas::applyClipping): + If clipping is enabled, set the appropriate GL state. + * platform/graphics/chromium/GLES2Canvas.h: + Document the flavours of drawTexturedRect() a bit, so I don't get confused. + * platform/graphics/gpu/DrawingBuffer.cpp: + (WebCore::DrawingBuffer::clear): + (WebCore::DrawingBuffer::createSecondaryBuffers): + (WebCore::DrawingBuffer::resizeDepthStencil): + (WebCore::DrawingBuffer::reset): + * platform/graphics/gpu/DrawingBuffer.h: + Unify m_multisampleDepthStencilBuffer with m_depthStencilBuffer. + Implement separate depth and stencil buffers for when + OES_packed_depth_stencil is not available. Refactor creation of + multisampled and non-multisampled depth and stencil buffers into + resizeDepthStencil(). + * platform/graphics/gpu/SharedGraphicsContext3D.cpp: + (WebCore::SharedGraphicsContext3D::create): + Turn on stencil, turn off depth, turn off antialiasing (for now). + (WebCore::SharedGraphicsContext3D::enableStencil): + * platform/graphics/gpu/SharedGraphicsContext3D.h: + Implement stencil enable/disable. + * platform/graphics/gpu/mac/DrawingBufferMac.mm: + (WebCore::DrawingBuffer::DrawingBuffer): + Remove m_multisampleDepthStencilBuffer. Set the size to (-1, -1) + on creation, so reset() doesn't early-out. Initialize m_depthBuffer + and m_stencilBuffer. + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::canvasClip): + (WebCore::GraphicsContext::clipOut): + (WebCore::GraphicsContext::clipPath): + (WebCore::GraphicsContext::fillPath): + Put in GPU hooks for path clipping, and path drawing. + * platform/graphics/skia/PlatformContextSkia.cpp: + (WebCore::PlatformContextSkia::canAccelerate): + Don't check for clipping paths in canAccelerate() (since we can + now accelerate them). + (WebCore::PlatformContextSkia::uploadSoftwareToHardware): + Don't do clipping when uploading software draws to hardware. + * thirdparty/glu/README.webkit: + * thirdparty/glu/gluos.h: + #undef MIN and MAX, to fix warnings-as-errors in Chrome/Mac build. + * thirdparty/glu/libtess/geom.c: + * thirdparty/glu/libtess/priorityq.c: + * thirdparty/glu/libtess/render.c: + Use do{}while(0) instead of if(1)else construct in macro. + * thirdparty/glu/libtess/sweep.c: + (IsWindingInside): + (DoneEdgeDict): + Fix some warnings treated as errors for the Linux Release build. + + +2011-01-20 Pavel Feldman <pfeldman@chromium.org> + + Web Inspector: move releaseObjectGroup to the new Runtime agent. + https://bugs.webkit.org/show_bug.cgi?id=52803 + (accedentally landed as r76231) + + * inspector/InspectorContorller.h: + * inspector/InspectorContorller.cpp: + * inspector/InspectorRuntimeAgent.h: + * inspector/InspectorRuntimeAgent.cpp: + +2011-01-20 Pavel Feldman <pfeldman@chromium.org> + + Not reviewed: build fix. + + * inspector/InspectorState.h: + (WebCore::InspectorState::setBoolean): + (WebCore::InspectorState::setString): + (WebCore::InspectorState::setLong): + +2011-01-20 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: further simplify InspectorState. + https://bugs.webkit.org/show_bug.cgi?id=52731 + + This change moves XHR logging flag into console agent, + removes InspectorState pushing to the front-end. + + * inspector/Inspector.idl: + * inspector/InspectorConsoleAgent.cpp: + (WebCore::InspectorConsoleAgent::InspectorConsoleAgent): + (WebCore::InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest): + (WebCore::InspectorConsoleAgent::setMonitoringXHREnabled): + (WebCore::InspectorConsoleAgent::setConsoleMessagesEnabled): + (WebCore::InspectorConsoleAgent::addConsoleMessage): + * inspector/InspectorConsoleAgent.h: + * inspector/InspectorController.cpp: + (WebCore::InspectorController::InspectorController): + * inspector/InspectorController.h: + (WebCore::InspectorController::state): + (WebCore::InspectorController::settings): + * inspector/InspectorState.cpp: + (WebCore::InspectorState::InspectorState): + (WebCore::InspectorState::registerBoolean): + (WebCore::InspectorState::registerString): + (WebCore::InspectorState::registerLong): + (WebCore::InspectorState::registerObject): + (WebCore::InspectorState::Property::create): + * inspector/InspectorState.h: + * inspector/front-end/ConsoleView.js: + (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.consoleMessagesCleared): + (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.monitoringXHRStateChanged): + (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher): + (WebInspector.ConsoleView.prototype._handleContextMenuEvent): + * inspector/front-end/inspector.js: + +2011-01-20 Csaba Osztrogonác <ossy@webkit.org> + + Unreviewed buildfix. + + [Qt][V8] Remove unnecessary files after r76224. + + * WebCore.pro: + +2011-01-20 Ilya Tikhonovsky <loislo@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: prepare for extracting InspectorAgent from InspectorController. + https://bugs.webkit.org/show_bug.cgi?id=52797 + + * inspector/CodeGeneratorInspector.pm: + * inspector/InspectorController.h: + (WebCore::InspectorController::inspectorAgent): + (WebCore::InspectorController::cssAgent): + (WebCore::InspectorController::injectedScriptAgent): + (WebCore::InspectorController::resourceAgent): + (WebCore::InspectorController::runtimeAgent): + (WebCore::InspectorController::timelineAgent): + (WebCore::InspectorController::databaseAgent): + (WebCore::InspectorController::domStorageAgent): + (WebCore::InspectorController::fileSystemAgent): + (WebCore::InspectorController::browserDebuggerAgent): + (WebCore::InspectorController::debuggerAgent): + (WebCore::InspectorController::profilerAgent): + (WebCore::InspectorController::applicationCacheAgent): + +2011-01-20 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r76215. + http://trac.webkit.org/changeset/76215 + https://bugs.webkit.org/show_bug.cgi?id=52799 + + Caused regressions in Chromium; morrita is going to look at it + tomrorow (Requested by jorlow on #webkit). + + * dom/TextEvent.h: + * dom/TextEventInputType.h: + * editing/CompositeEditCommand.cpp: + (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): + * editing/CompositeEditCommand.h: + * editing/Editor.cpp: + (WebCore::Editor::insertTextWithoutSendingTextEvent): + (WebCore::Editor::confirmComposition): + (WebCore::Editor::setComposition): + * editing/Editor.h: + * editing/InsertTextCommand.cpp: + (WebCore::InsertTextCommand::input): + * editing/InsertTextCommand.h: + * editing/TypingCommand.cpp: + (WebCore::TypingCommand::TypingCommand): + (WebCore::TypingCommand::insertText): + (WebCore::TypingCommand::insertTextRunWithoutNewlines): + * editing/TypingCommand.h: + (WebCore::TypingCommand::create): + +2010-12-14 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Adam Barth. + + [V8] Get rid of delayed exception reporting in V8ConsoleMessage.cpp + https://bugs.webkit.org/show_bug.cgi?id=51044 + + * WebCore.gypi: + * bindings/v8/V8ConsoleMessage.cpp: Removed. + * bindings/v8/V8ConsoleMessage.h: Removed. + * bindings/v8/V8DOMWindowShell.cpp: + (WebCore::v8UncaughtExceptionHandler): + (WebCore::reportUnsafeJavaScriptAccess): + (WebCore::V8DOMWindowShell::initContextIfNeeded): + * bindings/v8/V8Proxy.cpp: + (WebCore::addMessageToConsole): + (WebCore::logInfo): + (WebCore::V8Proxy::reportUnsafeAccessTo): + (WebCore::V8Proxy::runScript): + (WebCore::V8Proxy::callFunction): + (WebCore::V8Proxy::newInstance): + * bindings/v8/V8Proxy.h: + * bindings/v8/WorkerContextExecutionProxy.cpp: + * bindings/v8/specialization/V8BindingState.cpp: + (WebCore::::immediatelyReportUnsafeAccessTo): + +2011-01-19 MORITA Hajime <morrita@google.com> + + Reviewed by Eric Seidel. + + ShadowElement::m_shadowParent should be removed + https://bugs.webkit.org/show_bug.cgi?id=52558 + + No new tests. No behavioral change. + + * rendering/ShadowElement.h: + (WebCore::ShadowElement::ShadowElement): + +2011-01-20 Hans Wennborg <hans@chromium.org> + + Reviewed by Jeremy Orlow. + + IndexedDB: IDBObjectStore.get should fire onsuccess rather than onerror + https://bugs.webkit.org/show_bug.cgi?id=52725 + + Let IDBObjectStore.get() fire the onsuccess handler with the value + 'undefined' for when an object does not exist in the store. + + Update SerializedScriptValue to provide such an undefined value. + + * bindings/v8/SerializedScriptValue.cpp: + (WebCore::SerializedScriptValue::nullValue): + (WebCore::SerializedScriptValue::undefinedValue): + * bindings/v8/SerializedScriptValue.h: + * storage/IDBObjectStoreBackendImpl.cpp: + (WebCore::IDBObjectStoreBackendImpl::getInternal): + +2010-12-27 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown + https://bugs.webkit.org/show_bug.cgi?id=8519 + + Uncaught exceptions are propagated to window.onerror hander if one is present. + The handler is expected to be a function accepting three arguments: error message, + resource url and line number where the exception occured. + + It was decided to dispatch ErrorEvent to all listeners/handlers no matter if they + were created in the same isolated world where the exception occured or not. + + Tests: fast/events/window-onerror1.html + fast/events/window-onerror10.html + fast/events/window-onerror11.html + fast/events/window-onerror12.html + fast/events/window-onerror2.html + fast/events/window-onerror3.html + fast/events/window-onerror4.html + fast/events/window-onerror5.html + fast/events/window-onerror6.html + fast/events/window-onerror7.html + fast/events/window-onerror8.html + fast/events/window-onerror9.html + http/tests/security/window-onerror-exception-in-iframe.html + userscripts/window-onerror-for-isolated-world-1.html + userscripts/window-onerror-for-isolated-world-2.html + + * Android.jscbindings.mk: + * CMakeLists.txt: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.order: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * bindings/js/JSBindingsAllInOne.cpp: + * bindings/js/JSDOMBinding.cpp: + (WebCore::reportException): + * bindings/js/JSErrorHandler.cpp: Renamed from WebCore/bindings/js/JSWorkerContextErrorHandler.cpp. + (WebCore::JSErrorHandler::JSErrorHandler): + (WebCore::JSErrorHandler::~JSErrorHandler): + (WebCore::JSErrorHandler::handleEvent): + * bindings/js/JSErrorHandler.h: Copied from WebCore/bindings/js/JSWorkerContextErrorHandler.h. + (WebCore::JSErrorHandler::create): + (WebCore::createJSErrorHandler): + * bindings/js/JSEventListener.h: + * bindings/scripts/CodeGeneratorJS.pm: + * bindings/scripts/CodeGeneratorV8.pm: + * bindings/v8/V8ConsoleMessage.cpp: + (WebCore::V8ConsoleMessage::dispatchNow): + (WebCore::V8ConsoleMessage::handler): the method was changed to use generic WebCore exception + reporting mechanism which is also used by JSC bindings. + * bindings/v8/V8ConsoleMessage.h: + * bindings/v8/V8EventListener.h: + * bindings/v8/V8WindowErrorHandler.cpp: Renamed from WebCore/bindings/js/JSWorkerContextErrorHandler.h. + (WebCore::V8WindowErrorHandler::V8WindowErrorHandler): + (WebCore::V8WindowErrorHandler::callListenerFunction): + * bindings/v8/V8WindowErrorHandler.h: Copied from WebCore/dom/ErrorEvent.cpp. + (WebCore::V8WindowErrorHandler::create): + * bindings/v8/WorkerContextExecutionProxy.cpp: + (WebCore::v8MessageHandler): + * bindings/v8/WorkerScriptController.cpp: + (WebCore::WorkerScriptController::evaluate): + * dom/Document.cpp: + (WebCore::Document::errorEventTarget): + (WebCore::Document::logExceptionToConsole): + (WebCore::Document::addMessage): + * dom/Document.h: + * dom/ErrorEvent.cpp: + * dom/ErrorEvent.h: + * dom/Event.cpp: + (WebCore::Event::isErrorEvent): + * dom/Event.h: + * dom/ScriptExecutionContext.cpp: + (WebCore::ScriptExecutionContext::PendingException::PendingException): + (WebCore::ScriptExecutionContext::ScriptExecutionContext): + (WebCore::ScriptExecutionContext::reportException): this method is not virtual anymore to + ensure that error event dispatching algorithm is the same in WorkerContext and in Document. + (WebCore::ScriptExecutionContext::dispatchErrorEvent): + * dom/ScriptExecutionContext.h: + * websockets/WebSocket.cpp: + (WebCore::WebSocket::connect): + * websockets/WebSocketChannel.cpp: + (WebCore::WebSocketChannel::didOpen): + (WebCore::WebSocketChannel::didFail): + (WebCore::WebSocketChannel::appendToBuffer): + * websockets/WebSocketHandshake.cpp: + (WebCore::WebSocketHandshake::readServerHandshake): + (WebCore::WebSocketHandshake::readStatusLine): + (WebCore::WebSocketHandshake::readHTTPHeaders): + (WebCore::WebSocketHandshake::checkResponseHeaders): + * workers/DefaultSharedWorkerRepository.cpp: + (WebCore::postExceptionTask): + (WebCore::postConsoleMessageTask): + * workers/WorkerContext.cpp: + (WebCore::WorkerContext::WorkerContext): + (WebCore::WorkerContext::errorEventTarget): + (WebCore::WorkerContext::logExceptionToConsole): + (WebCore::WorkerContext::addMessage): + * workers/WorkerContext.h: + * workers/WorkerMessagingProxy.cpp: + (WebCore::WorkerExceptionTask::performTask): + (WebCore::postConsoleMessageTask): + * xml/XMLHttpRequest.cpp: + (WebCore::reportUnsafeUsage): + +2011-01-19 MORITA Hajime <morrita@google.com> + + Reviewed by Ryosuke Niwa. + + Space and tab characters "sent" by an input method give totally different results than typing them directly + https://bugs.webkit.org/show_bug.cgi?id=5241 + + * Introduced TextEvent::InputTypeComposition and TypingCommand::TextCompositionType to + distinguish text input which is originated by composition. + * Generalized rebalanceWhitespaceAt() to rebalanceWhitespaceOnTextSubstring() to rebalancing + range of string on text node, instead of surrounding part of that. + + Test: editing/inserting/insert-composition-whitespace.html + + * dom/TextEvent.h: + (WebCore::TextEvent::isComposition): + * dom/TextEventInputType.h: Added TextEventInputComposition as a member of TextEvent::InputType + * editing/CompositeEditCommand.cpp: + (WebCore::containsOnlyWhitespace): + (WebCore::CompositeEditCommand::shouldRebalanceLeadingWhitespaceFor): + (WebCore::CompositeEditCommand::canRebalance): + (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): + (WebCore::CompositeEditCommand::rebalanceWhitespaceOnTextSubstring): Added: A generalized version of rebalanceWhitespaceAt(), which takes a range inside Text string. + * editing/CompositeEditCommand.h: + * editing/Editor.cpp: + (WebCore::Editor::insertTextForConfirmedComposition): Added. + (WebCore::Editor::insertTextWithoutSendingTextEvent): + (WebCore::Editor::confirmComposition): Now uses insertTextForConfirmedComposition(). + (WebCore::Editor::setComposition): + * editing/Editor.h: + * editing/InsertTextCommand.cpp: + (WebCore::InsertTextCommand::input): + * editing/InsertTextCommand.h: + * editing/TypingCommand.cpp: + (WebCore::TypingCommand::TypingCommand): + (WebCore::TypingCommand::insertText): + (WebCore::TypingCommand::insertTextRunWithoutNewlines): + * editing/TypingCommand.h: Added TypingCommand::m_compositionType and TypingCommand::TextCompositionType + (WebCore::TypingCommand::setCompositionType): Added. + (WebCore::TypingCommand::create): + +2011-01-19 Dominic Cooney <dominicc@google.com> + + Reviewed by Kent Tamura. + + Make <keygen> no longer appear to be a <select> element to script. + https://bugs.webkit.org/show_bug.cgi?id=52557 + + The intent is to put <keygen> options into shadow DOM. This change + takes the first step by hiding the <select> element from + JavaScript. + + Test: fast/dom/HTMLKeygenElement/keygen.html + + * CMakeLists.txt: Adds new IDL-derived wrapper. + * DerivedSources.cpp: + * DerivedSources.make: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pri: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * bindings/gobject/GNUmakefile.am: + * bindings/gobject/WebKitHTMLElementWrapperFactory.cpp: + (WebKit::createKeygenWrapper): + (WebKit::createHTMLElementWrapper): + * bindings/objc/DOM.mm: + (WebCore::createElementClassMap): Keygen no longer DOMHTMLSelectElement + * html/HTMLKeygenElement.h: + (WebCore::HTMLKeygenElement::willValidate): Now public. + * html/HTMLKeygenElement.idl: Added. + * html/HTMLTagNames.in: Keygen's wrapper is HTMLKeygenElement. + * page/DOMWindow.idl: Add HTMLKeygenElement constructor. + +2011-01-19 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r76203. + http://trac.webkit.org/changeset/76203 + https://bugs.webkit.org/show_bug.cgi?id=52784 + + Broke Win compile on Chromium bots (Requested by dimich on + #webkit). + + * WebCore.gypi: + * bindings/v8/V8DOMWindowShell.cpp: + (WebCore::reportFatalErrorInV8): + * page/PageGroup.cpp: + (WebCore::PageGroup::isLinkVisited): + * platform/android/PlatformBridge.h: + * platform/audio/chromium/AudioBusChromium.cpp: + (WebCore::createBusFromInMemoryAudioFile): + * platform/chromium/ChromiumBridge.h: Added. + * platform/chromium/ChromiumDataObjectLegacy.cpp: + (WebCore::ChromiumDataObjectLegacy::getData): + * platform/chromium/DragDataChromium.cpp: + (WebCore::DragData::asURL): + * platform/chromium/FileSystemChromium.cpp: + (WebCore::deleteFile): + (WebCore::deleteEmptyDirectory): + (WebCore::getFileSize): + (WebCore::getFileModificationTime): + (WebCore::revealFolderInOS): + (WebCore::directoryName): + (WebCore::pathByAppendingComponent): + (WebCore::makeAllDirectories): + (WebCore::fileExists): + (WebCore::openFile): + (WebCore::closeFile): + (WebCore::seekFile): + (WebCore::truncateFile): + (WebCore::readFromFile): + (WebCore::writeToFile): + * platform/chromium/LanguageChromium.cpp: + (WebCore::platformDefaultLanguage): + * platform/chromium/LinkHashChromium.cpp: + (WebCore::visitedLinkHash): + * platform/chromium/MIMETypeRegistryChromium.cpp: + (WebCore::MIMETypeRegistry::getMIMETypeForExtension): + (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType): + (WebCore::MIMETypeRegistry::isSupportedImageMIMEType): + (WebCore::MIMETypeRegistry::isSupportedJavaScriptMIMEType): + (WebCore::MIMETypeRegistry::isSupportedNonImageMIMEType): + * platform/chromium/PasteboardChromium.cpp: + (WebCore::Pasteboard::writeSelection): + (WebCore::Pasteboard::writePlainText): + (WebCore::Pasteboard::writeURL): + (WebCore::Pasteboard::writeImage): + (WebCore::Pasteboard::canSmartReplace): + (WebCore::Pasteboard::plainText): + (WebCore::Pasteboard::documentFragment): + * platform/chromium/PlatformBridge.h: + * platform/chromium/PlatformScreenChromium.cpp: + (WebCore::screenDepth): + (WebCore::screenDepthPerComponent): + (WebCore::screenIsMonochrome): + (WebCore::screenRect): + (WebCore::screenAvailableRect): + * platform/chromium/ReadableDataObject.cpp: + (WebCore::ReadableDataObject::getData): + (WebCore::ReadableDataObject::urlTitle): + (WebCore::ReadableDataObject::htmlBaseUrl): + (WebCore::ReadableDataObject::filenames): + (WebCore::ReadableDataObject::ensureTypeCacheInitialized): + * platform/chromium/SSLKeyGeneratorChromium.cpp: + (WebCore::signedPublicKeyAndChallengeString): + * platform/chromium/ScrollbarThemeChromium.cpp: + * platform/chromium/ScrollbarThemeChromiumLinux.cpp: + (WebCore::ScrollbarThemeChromiumLinux::scrollbarThickness): + (WebCore::ScrollbarThemeChromiumLinux::paintTrackPiece): + (WebCore::ScrollbarThemeChromiumLinux::paintButton): + (WebCore::ScrollbarThemeChromiumLinux::paintThumb): + (WebCore::ScrollbarThemeChromiumLinux::buttonSize): + (WebCore::ScrollbarThemeChromiumLinux::minimumThumbLength): + * platform/chromium/ScrollbarThemeChromiumMac.mm: + (WebCore::scrollbarStateToThemeState): + (WebCore::ScrollbarThemeChromiumMac::paint): + * platform/chromium/ScrollbarThemeChromiumWin.cpp: + (WebCore::ScrollbarThemeChromiumWin::scrollbarThickness): + (WebCore::ScrollbarThemeChromiumWin::paintTrackPiece): + (WebCore::ScrollbarThemeChromiumWin::paintButton): + (WebCore::ScrollbarThemeChromiumWin::paintThumb): + (WebCore::ScrollbarThemeChromiumWin::buttonSize): + * platform/chromium/SharedTimerChromium.cpp: + (WebCore::setSharedTimerFiredFunction): + (WebCore::setSharedTimerFireTime): + (WebCore::stopSharedTimer): + * platform/chromium/SuddenTerminationChromium.cpp: + (WebCore::disableSuddenTermination): + (WebCore::enableSuddenTermination): + * platform/chromium/SystemTimeChromium.cpp: + (WebCore::currentTime): + * platform/chromium/WritableDataObject.cpp: + (WebCore::WritableDataObject::setData): + * platform/graphics/chromium/CrossProcessFontLoading.mm: + * platform/graphics/chromium/FontCacheChromiumWin.cpp: + (WebCore::fontContainsCharacter): + (WebCore::FillLogFont): + * platform/graphics/chromium/FontCacheLinux.cpp: + (WebCore::FontCache::getFontDataForCharacters): + * platform/graphics/chromium/FontChromiumWin.cpp: + (WebCore::Font::drawGlyphs): + * platform/graphics/chromium/FontPlatformDataChromiumWin.cpp: + (WebCore::FontPlatformData::scriptFontProperties): + * platform/graphics/chromium/FontPlatformDataLinux.cpp: + (WebCore::FontPlatformData::querySystemForRenderStyle): + * platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp: + (WebCore::fillBMPGlyphs): + * platform/graphics/chromium/ImageChromium.cpp: + (WebCore::Image::loadPlatformResource): + * platform/graphics/chromium/ImageChromiumMac.mm: + (WebCore::Image::loadPlatformResource): + * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: + (WebCore::SimpleFontData::platformInit): + (WebCore::SimpleFontData::determinePitch): + (WebCore::SimpleFontData::platformWidthForGlyph): + * platform/graphics/chromium/UniscribeHelperTextRun.cpp: + (WebCore::UniscribeHelperTextRun::tryToPreloadFont): + * platform/graphics/skia/FontCustomPlatformData.cpp: + (WebCore::FontCustomPlatformData::fontPlatformData): + * platform/network/chromium/CookieJarChromium.cpp: + (WebCore::setCookies): + (WebCore::cookies): + (WebCore::cookieRequestHeaderFieldValue): + (WebCore::cookiesEnabled): + (WebCore::getRawCookies): + (WebCore::deleteCookie): + * platform/network/chromium/DNSChromium.cpp: + (WebCore::prefetchDNS): + * platform/qt/PlatformBridge.h: + * platform/sql/chromium/SQLiteFileSystemChromium.cpp: + (WebCore::SQLiteFileSystem::deleteDatabaseFile): + (WebCore::SQLiteFileSystem::getDatabaseFileSize): + * platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp: + (chromiumOpen): + (chromiumDelete): + (chromiumAccess): + * platform/sql/chromium/SQLiteFileSystemChromiumWin.cpp: + * plugins/chromium/PluginDataChromium.cpp: + (WebCore::PluginCache::plugins): + * rendering/RenderThemeChromiumMac.mm: + (WebCore::RenderThemeChromiumMac::usesTestModeFocusRingColor): + * rendering/RenderThemeChromiumSkia.cpp: + (WebCore::RenderThemeChromiumSkia::caretBlinkInterval): + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::platformActiveSelectionBackgroundColor): + (WebCore::RenderThemeChromiumWin::platformInactiveSelectionBackgroundColor): + (WebCore::RenderThemeChromiumWin::platformActiveSelectionForegroundColor): + (WebCore::RenderThemeChromiumWin::systemColor): + (WebCore::RenderThemeChromiumWin::paintButton): + (WebCore::RenderThemeChromiumWin::paintSliderTrack): + (WebCore::menuListButtonWidth): + (WebCore::RenderThemeChromiumWin::paintMenuList): + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + (WebCore::RenderThemeChromiumWin::paintInnerSpinButton): + (WebCore::RenderThemeChromiumWin::paintProgressBar): + * storage/chromium/IDBFactoryBackendInterface.cpp: + (WebCore::IDBFactoryBackendInterface::create): + (WebCore::IDBFactoryBackendInterface::~IDBFactoryBackendInterface): + * storage/chromium/IDBKeyPathBackendImpl.cpp: + (WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath): + +2011-01-19 Helder Correia <helder@sencha.com> + + Reviewed by Andreas Kling. + + [Qt] GraphicsContext::strokePath() paints solid shadows with incorrect alpha + https://bugs.webkit.org/show_bug.cgi?id=52705 + + This is related to bug 52611. The shadow color alpha must be multiplied + by the context pen alpha. Fixing this results in correct behavior for + Canvas path stroke() and strokeRect() [which relies on stroke()]. + + Tests: fast/canvas/canvas-strokePath-alpha-shadow.html + fast/canvas/canvas-strokeRect-alpha-shadow.html + + * platform/graphics/qt/GraphicsContextQt.cpp: + (WebCore::GraphicsContext::strokePath): + +2011-01-19 Darin Fisher <darin@chromium.org> + + Reviewed by Mihai Parparita. + + Re-initialize the HistoryItem fully when navigating to a HistoryItem, + or replacing a HistoryItem, results in a different URL. + + https://bugs.webkit.org/show_bug.cgi?id=49654 + + This patch also forces all HistoryItems to record the post-redirect + URL. Previously, frames would remember the pre-redirect URL. This is + problematic since other members of the HistoryItem correspond to the + post-redirect URL. + + Tests: fast/history/history-replace-updates-current-item.html + http/tests/navigation/redirect-on-back-updates-history-item.html + http/tests/navigation/redirect-on-reload-updates-history-item.html + + * history/HistoryItem.cpp: + (WebCore::HistoryItem::HistoryItem): + (WebCore::HistoryItem::reset): + * history/HistoryItem.h: + * loader/HistoryController.cpp: + (WebCore::HistoryController::updateForBackForwardNavigation): + (WebCore::HistoryController::updateForReload): + (WebCore::HistoryController::updateForStandardLoad): + (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList): + (WebCore::HistoryController::initializeItem): + (WebCore::HistoryController::createItem): + (WebCore::HistoryController::createItemTree): + (WebCore::HistoryController::updateCurrentItem): + * loader/HistoryController.h: + +2011-01-19 Adam Klein <adamk@chromium.org> + + Reviewed by Darin Fisher. + + [chromium] Rename ChromiumBridge to PlatformBridge + https://bugs.webkit.org/show_bug.cgi?id=52471 + + No tests added as this is a rename; no change in behavior. + + * WebCore.gypi: + * bindings/v8/V8DOMWindowShell.cpp: + (WebCore::reportFatalErrorInV8): + * page/PageGroup.cpp: + (WebCore::PageGroup::isLinkVisited): + * platform/android/PlatformBridge.h: + * platform/audio/chromium/AudioBusChromium.cpp: + (WebCore::createBusFromInMemoryAudioFile): + * platform/chromium/ChromiumBridge.h: Removed. + * platform/chromium/ChromiumDataObjectLegacy.cpp: + (WebCore::ChromiumDataObjectLegacy::getData): + * platform/chromium/DragDataChromium.cpp: + (WebCore::DragData::asURL): + * platform/chromium/FileSystemChromium.cpp: + (WebCore::deleteFile): + (WebCore::deleteEmptyDirectory): + (WebCore::getFileSize): + (WebCore::getFileModificationTime): + (WebCore::revealFolderInOS): + (WebCore::directoryName): + (WebCore::pathByAppendingComponent): + (WebCore::makeAllDirectories): + (WebCore::fileExists): + (WebCore::openFile): + (WebCore::closeFile): + (WebCore::seekFile): + (WebCore::truncateFile): + (WebCore::readFromFile): + (WebCore::writeToFile): + * platform/chromium/LanguageChromium.cpp: + (WebCore::platformDefaultLanguage): + * platform/chromium/LinkHashChromium.cpp: + (WebCore::visitedLinkHash): + * platform/chromium/MIMETypeRegistryChromium.cpp: + (WebCore::MIMETypeRegistry::getMIMETypeForExtension): + (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType): + (WebCore::MIMETypeRegistry::isSupportedImageMIMEType): + (WebCore::MIMETypeRegistry::isSupportedJavaScriptMIMEType): + (WebCore::MIMETypeRegistry::isSupportedNonImageMIMEType): + * platform/chromium/PasteboardChromium.cpp: + (WebCore::Pasteboard::writeSelection): + (WebCore::Pasteboard::writePlainText): + (WebCore::Pasteboard::writeURL): + (WebCore::Pasteboard::writeImage): + (WebCore::Pasteboard::canSmartReplace): + (WebCore::Pasteboard::plainText): + (WebCore::Pasteboard::documentFragment): + * platform/chromium/PlatformBridge.h: + * platform/chromium/PlatformScreenChromium.cpp: + (WebCore::screenDepth): + (WebCore::screenDepthPerComponent): + (WebCore::screenIsMonochrome): + (WebCore::screenRect): + (WebCore::screenAvailableRect): + * platform/chromium/ReadableDataObject.cpp: + (WebCore::ReadableDataObject::getData): + (WebCore::ReadableDataObject::urlTitle): + (WebCore::ReadableDataObject::htmlBaseUrl): + (WebCore::ReadableDataObject::filenames): + (WebCore::ReadableDataObject::ensureTypeCacheInitialized): + * platform/chromium/SSLKeyGeneratorChromium.cpp: + (WebCore::signedPublicKeyAndChallengeString): + * platform/chromium/ScrollbarThemeChromium.cpp: + * platform/chromium/ScrollbarThemeChromiumLinux.cpp: + (WebCore::ScrollbarThemeChromiumLinux::scrollbarThickness): + (WebCore::ScrollbarThemeChromiumLinux::paintTrackPiece): + (WebCore::ScrollbarThemeChromiumLinux::paintButton): + (WebCore::ScrollbarThemeChromiumLinux::paintThumb): + (WebCore::ScrollbarThemeChromiumLinux::buttonSize): + (WebCore::ScrollbarThemeChromiumLinux::minimumThumbLength): + * platform/chromium/ScrollbarThemeChromiumMac.mm: + (WebCore::scrollbarStateToThemeState): + (WebCore::ScrollbarThemeChromiumMac::paint): + * platform/chromium/ScrollbarThemeChromiumWin.cpp: + (WebCore::ScrollbarThemeChromiumWin::scrollbarThickness): + (WebCore::ScrollbarThemeChromiumWin::paintTrackPiece): + (WebCore::ScrollbarThemeChromiumWin::paintButton): + (WebCore::ScrollbarThemeChromiumWin::paintThumb): + (WebCore::ScrollbarThemeChromiumWin::buttonSize): + * platform/chromium/SharedTimerChromium.cpp: + (WebCore::setSharedTimerFiredFunction): + (WebCore::setSharedTimerFireTime): + (WebCore::stopSharedTimer): + * platform/chromium/SuddenTerminationChromium.cpp: + (WebCore::disableSuddenTermination): + (WebCore::enableSuddenTermination): + * platform/chromium/SystemTimeChromium.cpp: + (WebCore::currentTime): + * platform/chromium/WritableDataObject.cpp: + (WebCore::WritableDataObject::setData): + * platform/graphics/chromium/CrossProcessFontLoading.mm: + * platform/graphics/chromium/FontCacheChromiumWin.cpp: + (WebCore::fontContainsCharacter): + (WebCore::FillLogFont): + * platform/graphics/chromium/FontCacheLinux.cpp: + (WebCore::FontCache::getFontDataForCharacters): + * platform/graphics/chromium/FontChromiumWin.cpp: + (WebCore::Font::drawGlyphs): + * platform/graphics/chromium/FontPlatformDataChromiumWin.cpp: + (WebCore::FontPlatformData::scriptFontProperties): + * platform/graphics/chromium/FontPlatformDataLinux.cpp: + (WebCore::FontPlatformData::querySystemForRenderStyle): + * platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp: + (WebCore::fillBMPGlyphs): + * platform/graphics/chromium/ImageChromium.cpp: + (WebCore::Image::loadPlatformResource): + * platform/graphics/chromium/ImageChromiumMac.mm: + (WebCore::Image::loadPlatformResource): + * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: + (WebCore::SimpleFontData::platformInit): + (WebCore::SimpleFontData::determinePitch): + (WebCore::SimpleFontData::platformWidthForGlyph): + * platform/graphics/chromium/UniscribeHelperTextRun.cpp: + (WebCore::UniscribeHelperTextRun::tryToPreloadFont): + * platform/graphics/skia/FontCustomPlatformData.cpp: + (WebCore::FontCustomPlatformData::fontPlatformData): + * platform/network/chromium/CookieJarChromium.cpp: + (WebCore::setCookies): + (WebCore::cookies): + (WebCore::cookieRequestHeaderFieldValue): + (WebCore::cookiesEnabled): + (WebCore::getRawCookies): + (WebCore::deleteCookie): + * platform/network/chromium/DNSChromium.cpp: + (WebCore::prefetchDNS): + * platform/qt/PlatformBridge.h: + * platform/sql/chromium/SQLiteFileSystemChromium.cpp: + (WebCore::SQLiteFileSystem::deleteDatabaseFile): + (WebCore::SQLiteFileSystem::getDatabaseFileSize): + * platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp: + (chromiumOpen): + (chromiumDelete): + (chromiumAccess): + * platform/sql/chromium/SQLiteFileSystemChromiumWin.cpp: + * plugins/chromium/PluginDataChromium.cpp: + (WebCore::PluginCache::plugins): + * rendering/RenderThemeChromiumMac.mm: + (WebCore::RenderThemeChromiumMac::usesTestModeFocusRingColor): + * rendering/RenderThemeChromiumSkia.cpp: + (WebCore::RenderThemeChromiumSkia::caretBlinkInterval): + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::platformActiveSelectionBackgroundColor): + (WebCore::RenderThemeChromiumWin::platformInactiveSelectionBackgroundColor): + (WebCore::RenderThemeChromiumWin::platformActiveSelectionForegroundColor): + (WebCore::RenderThemeChromiumWin::systemColor): + (WebCore::RenderThemeChromiumWin::paintButton): + (WebCore::RenderThemeChromiumWin::paintSliderTrack): + (WebCore::menuListButtonWidth): + (WebCore::RenderThemeChromiumWin::paintMenuList): + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + (WebCore::RenderThemeChromiumWin::paintInnerSpinButton): + (WebCore::RenderThemeChromiumWin::paintProgressBar): + * storage/chromium/IDBFactoryBackendInterface.cpp: + (WebCore::IDBFactoryBackendInterface::create): + (WebCore::IDBFactoryBackendInterface::~IDBFactoryBackendInterface): + * storage/chromium/IDBKeyPathBackendImpl.cpp: + (WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath): + +2011-01-19 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r76187. + http://trac.webkit.org/changeset/76187 + https://bugs.webkit.org/show_bug.cgi?id=52778 + + Broke caret-showing tests on SnowLeopard and Chromium + (Requested by dimich on #webkit). + + * rendering/RenderText.cpp: + (WebCore::RenderText::localCaretRect): + +2011-01-19 Yuzo Fujishima <yuzo@google.com> + + Reviewed by Kent Tamura. + + Fix for Bug 52279 - WebCore::RenderBlock::updateFirstLetter crashes for anonymous blocks + https://bugs.webkit.org/show_bug.cgi?id=52279 + + In constructing text fragments to handle first-letter rule, first add + the text for the non-first letters and then remove the original text, + rather than the other way around. Otherwise, the text can be added to + an anoymous block that is different from the original one. This breaks + the assumption that a first letter render object has a non-null sibling + for the non-first letters and causes a crash. + + Test: fast/css/first-letter-anonymous-block-crash.html + + * rendering/RenderBlock.cpp: + (WebCore::RenderBlock::updateFirstLetter): + +2011-01-19 James Robinson <jamesr@chromium.org> + + Unreviewed, rolling out r76194. + http://trac.webkit.org/changeset/76194 + https://bugs.webkit.org/show_bug.cgi?id=51218 + + Caused mysterious compile failure on the chromium win + build.webkit.org bots + + * WebCore.gypi: + * dom/Document.cpp: + (WebCore::Document::Document): + * dom/Document.h: + * dom/RequestAnimationFrameCallback.h: Removed. + * dom/RequestAnimationFrameCallback.idl: Removed. + * loader/EmptyClients.h: + * page/Chrome.cpp: + * page/Chrome.h: + * page/ChromeClient.h: + * page/DOMWindow.cpp: + * page/DOMWindow.h: + * page/DOMWindow.idl: + * page/FrameView.cpp: + * page/FrameView.h: + * platform/HostWindow.h: + +2011-01-19 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Sam Weinig. + + GraphicsLayers in subframes can get sync'd multiple times + https://bugs.webkit.org/show_bug.cgi?id=52489 + + Some cleanup that will work towards fixing this bug. + + Tested by existing iframe compositing tests. + + * WebCore.exp.in: syncCompositingStateRecursive() + was renamed to syncCompositingStateIncludingSubframes(). + + * page/FrameView.h: + * page/FrameView.cpp: + (WebCore::FrameView::syncCompositingStateForThisFrame): Some + code cleanup: do all the word we need to do for this frame, + including the needsLayout() check. + (WebCore::FrameView::syncCompositingStateIncludingSubframes): + This is no longer recursive; instead, it iterates over descendant + frames via the frame tree, calling syncCompositingStateForThisFrame() + on each Frame's view. + + * rendering/RenderLayerCompositor.h: + (WebCore::RenderLayerCompositor::isFlushingLayers): Getter for the flag. + * rendering/RenderLayerCompositor.cpp: + (WebCore::RenderLayerCompositor::RenderLayerCompositor): + (WebCore::RenderLayerCompositor::flushPendingLayerChanges): Maintain + a flag to say if we're flushing, which allows us to assert on re-entrant flushes. + (WebCore::RenderLayerCompositor::enclosingCompositorFlushingLayers): + Add the ability to get the rootmost compositor that is in the middle + of a flush. + +2011-01-19 James Robinson <jamesr@chromium.org> + + Reviewed by Darin Fisher. + + Implement mozilla's requestAnimationFrame API + https://bugs.webkit.org/show_bug.cgi?id=51218 + + This implements mozilla's proposed requestAnimationFrame API. The idea with this API is that + an author driving an animation from script could use window.requestAnimationFrame(callback) + instead of window.setTimeout(callback, 0) to schedule their update logic and let the browser + decide when to update the animations. This avoids doing unnecessary work when the page content + is offscreen or is being displayed at a different framerate than what the page author expects. + + Mozilla's proposal is here: https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame + This implements window.mozRequestAnimationFrame as window.webkitRequestAnimationFrame with the + following changes: + *) Only the callback syntax is supported, there is no before paint event + *) webkitRequestAnimationFrame supports a second parameter Element to let the author indicate + what content they intend to animate. That way if the page is being displayed but the element + in question is offscreen, we can avoid invoking the callback. + *) No timestamp is provided to the caller and there is no window.animationStartTime property + (see https://bugs.webkit.org/show_bug.cgi?id=51952 for discussion of this property) + *) window.webkitRequestAnimationFrame returns a numerical id that can be used to cancel the callback + using window.cancelWebkitRequestAnimationFrame, to parallel window.setTimeout()/window.clearTime(). + + The implementation depends on the embedder scheduling the callbacks since the callback invocation + depends on the page's visibility and the embedder's paint scheduling, neither of which are exposed + to WebCore. The expectation for the embedder is that at some point Chrome::scheduleAnimation() is + called FrameView::serviceScriptedAnimations() should be called for the associated Page's main frame. + Ideally serviceScriptedAnimations() would be called prior to rendering - although in practice the + embedder has to rate limit callbacks and may not be able to tie the callback directly to the + rendering loop. + + Tests: fast/animation/request-animation-frame-cancel.html + fast/animation/request-animation-frame-cancel2.html + fast/animation/request-animation-frame-display.html + fast/animation/request-animation-frame-within-callback.html + fast/animation/request-animation-frame.html + + * WebCore.gypi: + * dom/Document.cpp: + (WebCore::Document::Document): + (WebCore::Document::webkitRequestAnimationFrame): + (WebCore::Document::webkitCancelRequestAnimationFrame): + (WebCore::Document::serviceScriptedAnimations): + * dom/Document.h: + * dom/RequestAnimationFrameCallback.h: Added. + (WebCore::RequestAnimationFrameCallback::~RequestAnimationFrameCallback): + * dom/RequestAnimationFrameCallback.idl: Added. + * loader/EmptyClients.h: + (WebCore::EmptyChromeClient::scheduleAnimation): + * page/Chrome.cpp: + (WebCore::Chrome::scheduleAnimation): + * page/Chrome.h: + * page/ChromeClient.h: + * page/DOMWindow.cpp: + (WebCore::DOMWindow::webkitRequestAnimationFrame): + (WebCore::DOMWindow::webkitCancelRequestAnimationFrame): + * page/DOMWindow.h: + * page/DOMWindow.idl: + * page/FrameView.cpp: + (WebCore::FrameView::scheduleAnimation): + (WebCore::FrameView::serviceScriptedAnimations): + * page/FrameView.h: + * platform/HostWindow.h: + +2011-01-13 Martin Robinson <mrobinson@igalia.com> + + Reviewed by Daniel Bates. + + [GTK] Move progress bar painting out of gtk2drawing.c + https://bugs.webkit.org/show_bug.cgi?id=52385 + + Move progress bar painting to RenderThemeGtk2 and share some animation + logic between the GTK+ 2.x and GTK+ 3.x port. + + No new tests. This should not change functionality. + + * platform/gtk/RenderThemeGtk.cpp: + (WebCore::RenderThemeGtk::animationRepeatIntervalForProgressBar): Moved from RenderThemeGtk3. + (WebCore::RenderThemeGtk::animationDurationForProgressBar): Ditto. + (WebCore::RenderThemeGtk::calculateProgressRect): Calculate the proper rectangle for the + progress indicator given the rect for the maximum size of the indicator. + * platform/gtk/RenderThemeGtk.h: Added calculateProgressRect declaration and + a new widget member for GTK+ 2.x + * platform/gtk/RenderThemeGtk2.cpp: + (WebCore::RenderThemeGtk::platformInit): Added initialization for the new widget member. + (WebCore::RenderThemeGtk::paintProgressBar): Paint the progress bar manually instead of + calling the old Mozilla code. + (WebCore::RenderThemeGtk::gtkProgressBar): Added. + * platform/gtk/RenderThemeGtk3.cpp: + (WebCore::RenderThemeGtk::paintProgressBar): Call calculateProgressRect now to get + the area of the progress indicator. + * platform/gtk/gtk2drawing.c: Remove unused code. + (moz_gtk_get_widget_border): + (moz_gtk_widget_paint): + * platform/gtk/gtkdrawing.h: Ditto. + +2011-01-19 Dmitry Titov <dimich@chromium.org> + + [Chromium] Not reviewed, reverts the following changes: + http://trac.webkit.org/changeset/76164 (build fix) + http://trac.webkit.org/changeset/76159 (main change) + + The change broke Chromium Linux-shlib build. + + Original issue: + Accelerated canvas2D has bad clipping performance. + https://bugs.webkit.org/show_bug.cgi?id=52627 + + * WebCore.gyp/WebCore.gyp: + * WebCore.gypi: + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::reset): + (WebCore::CanvasRenderingContext2D::platformLayer): + * platform/graphics/chromium/DrawingBufferChromium.cpp: + (WebCore::DrawingBuffer::DrawingBuffer): + * platform/graphics/chromium/GLES2Canvas.cpp: + (WebCore::GLES2Canvas::State::State): + (WebCore::GLES2Canvas::clearRect): + (WebCore::GLES2Canvas::fillRect): + (WebCore::GLES2Canvas::restore): + (WebCore::GLES2Canvas::drawTexturedRect): + * platform/graphics/chromium/GLES2Canvas.h: + * platform/graphics/gpu/DrawingBuffer.cpp: + (WebCore::DrawingBuffer::clear): + (WebCore::DrawingBuffer::createSecondaryBuffers): + (WebCore::DrawingBuffer::reset): + * platform/graphics/gpu/DrawingBuffer.h: + * platform/graphics/gpu/SharedGraphicsContext3D.cpp: + (WebCore::SharedGraphicsContext3D::create): + * platform/graphics/gpu/SharedGraphicsContext3D.h: + * platform/graphics/gpu/mac/DrawingBufferMac.mm: + (WebCore::DrawingBuffer::DrawingBuffer): + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::canvasClip): + (WebCore::GraphicsContext::clipOut): + (WebCore::GraphicsContext::clipPath): + (WebCore::GraphicsContext::fillPath): + * platform/graphics/skia/PlatformContextSkia.cpp: + (WebCore::PlatformContextSkia::canAccelerate): + (WebCore::PlatformContextSkia::uploadSoftwareToHardware): + * thirdparty/glu/README.webkit: + * thirdparty/glu/gluos.h: + * thirdparty/glu/libtess/geom.c: + * thirdparty/glu/libtess/priorityq.c: + * thirdparty/glu/libtess/render.c: + * thirdparty/glu/libtess/sweep.c: + (IsWindingInside): + (DoneEdgeDict): + +2011-01-19 Levi Weintraub <leviw@google.com> + + Reviewed by Darin Adler. + + Re-committing this with the proper expected results. + + Changing RenderText::localCaretRect to clip to its containing block's logicalLeft and + logicalRightLayoutOverflow instead of simply using logicalLeft and logicalRight, as this + resulted in the caret being placed incorrectly in overflowing editable IFrame content. + + Long lines in non-white-space-pre editable documents show cursor in wrong place + https://bugs.webkit.org/show_bug.cgi?id=48132 + + Test: editing/selection/caret-painting-in-overflowing-autowrap-content.html + + * rendering/RenderText.cpp: + (WebCore::RenderText::localCaretRect): + +2011-01-18 MORITA Hajime <morrita@google.com> + + Reviewed by David Levin. + + ElementRareData::m_shadowRoot should not be RefPtr. + https://bugs.webkit.org/show_bug.cgi?id=51914 + + Makes ElementRareData::m_shadowRoot a raw pointer because + ElementRareData::m_shadowRoot should be like a + ContaineNode::m_firstChild, which is also a raw pointer. + pointer. Which also means that both the shadow root and the shadow + host reference each other as a parent-and-child relationship, via + a raw pointer. + + Note that it is safe not to manipulate the ref-count of + m_shadowRoot because Node::m_parent of the shadow root points its + shadow host, and the object isn't deleted even if the refcount is + zero, as long as the node has non-null m_parent. (See TreeShared.) + + The shadow root node is finally destroyed inside + removeShadowRoot(), where we store the root node into a local + RefPtr, then make the node's m_parent null, which results the + destroy the node, at the end of the function, by RefPtr::~RefPtr. + + No new tests. No behavioral change. + + * dom/Element.cpp: + (WebCore::Element::~Element): + (WebCore::Element::shadowRoot): + (WebCore::Element::setShadowRoot): + (WebCore::Element::removeShadowRoot): + * dom/ElementRareData.h: + (WebCore::ElementRareData::ElementRareData): + (WebCore::ElementRareData::~ElementRareData): + +2011-01-12 Martin Robinson <mrobinson@igalia.com> + + Reviewed by Gustavo Noronha Silva. + + [GTK] Move text field painting out of gtk2drawing.c + https://bugs.webkit.org/show_bug.cgi?id=52327 + + No new tests. This should not change behavior. + + * platform/gtk/RenderThemeGtk2.cpp: + (WebCore::RenderThemeGtk::paintButton): Use the setWidgetHasFocus helper. + (WebCore::RenderThemeGtk::paintTextField): Do this manually now instead + of calling into the Mozilla code. + * platform/gtk/WidgetRenderingContext.cpp: Added a couple more wrappers + for GTK+ theme functions. + (WebCore::WidgetRenderingContext::gtkPaintFlatBox): + (WebCore::WidgetRenderingContext::gtkPaintShadow): + * platform/gtk/WidgetRenderingContext.h: Added new method declarations. + * platform/gtk/gtk2drawing.c: Remove unused code. + (moz_gtk_get_widget_border): + (moz_gtk_widget_paint): + * platform/gtk/gtkdrawing.h: + +2011-01-19 Antti Koivisto <antti@apple.com> + + Reviewed by Oliver Hunt. + + Cache function offsets to speed up javascript parsing + https://bugs.webkit.org/show_bug.cgi?id=52622 + + Use cache to save function offsets and some other info. + This avoids quite a bit of work when reparsing the source. + + * bindings/js/CachedScriptSourceProvider.h: + (WebCore::CachedScriptSourceProvider::cache): + (WebCore::CachedScriptSourceProvider::cacheSizeChanged): + (WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider): + * bindings/js/ScriptSourceProvider.h: + (WebCore::ScriptSourceProvider::ScriptSourceProvider): + * loader/cache/CachedScript.cpp: + (WebCore::CachedScript::destroyDecodedData): + (WebCore::CachedScript::sourceProviderCache): + (WebCore::CachedScript::sourceProviderCacheSizeChanged): + * loader/cache/CachedScript.h: + +2011-01-11 Martin Robinson <mrobinson@igalia.com> + + Reviewed by Gustavo Noronha Silva. + + [GTK] Move toggle button rendering out of gtk2drawing.c + https://bugs.webkit.org/show_bug.cgi?id=52258 + + * platform/gtk/RenderThemeGtk.h: + * platform/gtk/RenderThemeGtk2.cpp: + (WebCore::RenderThemeGtk::platformInit): Initialize new button members. + (WebCore::adjustRectForFocus): Added this function which inflates a rect based + on a widget's exterior focus. + (WebCore::RenderThemeGtk::adjustRepaintRect): Account for exterior focus. + (WebCore::setToggleSize): Only listen to indicator-size to properly size + checkboxes and radio buttons. + (WebCore::RenderThemeGtk::setCheckboxSize): Call new setToggleSize properly. + (WebCore::paintToggle): Added. + (WebCore::RenderThemeGtk::paintCheckbox): Call paintToggle. + (WebCore::RenderThemeGtk::setRadioSize): Call new setToggleSize properly. + (WebCore::RenderThemeGtk::paintRadio): Call paintToggle. + (WebCore::RenderThemeGtk::gtkRadioButton): Added. + (WebCore::RenderThemeGtk::gtkCheckButton): Added. + * platform/gtk/WidgetRenderingContext.cpp: + (WebCore::WidgetRenderingContext::WidgetRenderingContext): Use a static extra space + variable. This is good enough for all themes that I've tested and prevents having to + pass information from RenderThemeGtk about every single type of widget. + (WebCore::WidgetRenderingContext::gtkPaintFocus): Use the paintRect + to draw instead of m_paintRect. This is important when we're painting + something that isn't the size of the total rect. + (WebCore::WidgetRenderingContext::gtkPaintCheck): Added. + (WebCore::WidgetRenderingContext::gtkPaintOption): Added. + * platform/gtk/WidgetRenderingContext.h: Updated to reflect new methods. + * platform/gtk/gtkdrawing.h: Remove newly unused code. + * platform/gtk/gtk2drawing.c: Ditto. + +2011-01-19 Tony Gentilcore <tonyg@chromium.org> + + Unreviewed build fix. + + Build fix for r76170 + https://bugs.webkit.org/show_bug.cgi?id=52758 + + * platform/graphics/chromium/UniscribeHelperTextRun.cpp: + +2011-01-19 David D. Kilzer <ddkilzer@apple.com> + + <http://webkit.org/b/52687> Clean up FrameLoader methods for PLUGIN_PROXY_FOR_VIDEO + + Reviewed by Eric Carlson. + + * loader/FrameLoader.cpp: Declare the methods here. + (WebCore::FrameLoader::hideMediaPlayerProxyPlugin): + (WebCore::FrameLoader::showMediaPlayerProxyPlugin): + * loader/FrameLoader.cpp: Moved methods to here... + (WebCore::FrameLoader::hideMediaPlayerProxyPlugin): + (WebCore::FrameLoader::showMediaPlayerProxyPlugin): + * loader/SubframeLoader.cpp: ...from here. + (WebCore::FrameLoader::hideMediaPlayerProxyPlugin): + (WebCore::FrameLoader::showMediaPlayerProxyPlugin): + +2011-01-19 Tony Gentilcore <tonyg@chromium.org> + + Reviewed by Mihai Parparita. + + Perform some forward declaration + https://bugs.webkit.org/show_bug.cgi?id=52522 + + No new tests because no new functionality. + + * accessibility/AccessibilityObject.h: + * css/WebKitCSSMatrix.cpp: + * html/HTMLAreaElement.cpp: + * html/canvas/CanvasRenderingContext2D.cpp: + * inspector/InspectorController.cpp: + * platform/graphics/FloatPoint.cpp: + * platform/graphics/Font.cpp: + * platform/graphics/Font.h: + * platform/graphics/FontFastPath.cpp: + * platform/graphics/GraphicsContext.cpp: + * platform/graphics/ImageBuffer.h: + * platform/graphics/StringTruncator.cpp: + * platform/graphics/WidthIterator.cpp: + * platform/graphics/mac/ComplexTextController.cpp: + * platform/graphics/mac/ComplexTextControllerCoreText.cpp: + * platform/graphics/mac/FontComplexTextMac.cpp: + * platform/graphics/transforms/TransformationMatrix.cpp: + * platform/graphics/transforms/TransformationMatrix.h: + * rendering/EllipsisBox.cpp: + * rendering/InlineTextBox.cpp: + * rendering/RenderBlock.cpp: + * rendering/RenderBlockLineLayout.cpp: + * rendering/RenderEmbeddedObject.cpp: + * rendering/RenderFileUploadControl.cpp: + * rendering/RenderFlexibleBox.cpp: + * rendering/RenderImage.cpp: + * rendering/RenderListBox.cpp: + * rendering/RenderListMarker.cpp: + * rendering/RenderMenuList.cpp: + * rendering/RenderObject.h: + * rendering/RenderText.cpp: + * rendering/RenderTextControl.cpp: + * rendering/svg/SVGInlineTextBox.cpp: + * rendering/svg/SVGMarkerLayoutInfo.h: + * rendering/svg/SVGTextMetrics.cpp: + * svg/SVGFont.cpp: + +2011-01-19 Adrienne Walker <enne@google.com> + + Reviewed by Kenneth Russell. + + [chromium] Tiled compositor should use texture manager + https://bugs.webkit.org/show_bug.cgi?id=52418 + + Test: compositing/ + + * platform/graphics/chromium/LayerRendererChromium.cpp: + (WebCore::LayerRendererChromium::~LayerRendererChromium): + (WebCore::LayerRendererChromium::cleanupSharedObjects): + * platform/graphics/chromium/LayerTilerChromium.cpp: + (WebCore::LayerTilerChromium::LayerTilerChromium): + (WebCore::LayerTilerChromium::reset): + (WebCore::LayerTilerChromium::createTile): + (WebCore::LayerTilerChromium::update): + (WebCore::LayerTilerChromium::draw): + * platform/graphics/chromium/LayerTilerChromium.h: + (WebCore::LayerTilerChromium::Tile::Tile): + (WebCore::LayerTilerChromium::Tile::texture): + +2011-01-19 Stephen White <senorblanco@chromium.org> + + Unreviewed; build fix for chromium. + + * platform/graphics/chromium/GLES2Canvas.cpp: + (WebCore::GLES2Canvas::fillPath): + +2011-01-18 Stephen White <senorblanco@chromium.org> + + Reviewed by James Robinson. + + Implement accelerated path drawing and clipping for the Canvas2D GPU + path. + https://bugs.webkit.org/show_bug.cgi?id=52627 + + This is done with a simple curve interpolator and the GLU tesselator, + which is good enough for a 3-5X speedup on + http://ie.microsoft.com/testdrive/Performance/Galactic/Default.html. + + Covered by canvas/philip/2d.path.clip.basic.html, and many, many more. + All tests canvas/philip and fast/canvas paths pass with no + regressions, although two have minor pixel differences which require + rebaselining. + + * WebCore.gyp/WebCore.gyp: + Add internal_glu include path to chromium build. + * WebCore.gypi: + Add internal_glu files to chromium build. + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::reset): + (WebCore::CanvasRenderingContext2D::platformLayer): + Make CanvasRenderingContext2D more robust against failure to create + a DrawingBuffer. + * platform/graphics/chromium/DrawingBufferChromium.cpp: + (WebCore::DrawingBuffer::DrawingBuffer): + As in DrawingBufferMac.cpp, call reset() from the constructor. + Also initialize size to (-1, -1), so reset() doesn't early-out. + Add initializers for depthBuffer and stencilBuffer, and remove + multisampleDepthStencilBuffer. + * platform/graphics/chromium/GLES2Canvas.cpp: + Remove some unused #includes. + (WebCore::GLES2Canvas::State::State): + Add clipping state, and implement save/restore via the copy constructor. + (WebCore::operator*): + (WebCore::Quadratic::Quadratic): + (WebCore::Quadratic::fromBezier): + (WebCore::Quadratic::evaluate): + Quadratic Bezier curve class. + (WebCore::Cubic::Cubic): + (WebCore::Cubic::fromBezier): + (WebCore::Cubic::evaluate): + Cubic Bezier curve class. + (WebCore::GLES2Canvas::clearRect): + Add clipping support to clearRect(). + (WebCore::GLES2Canvas::fillPath): + Implement fillPath(). + (WebCore::GLES2Canvas::fillRect): + Add clipping support to fillRect(). + (WebCore::GLES2Canvas::clipPath): + Implement clipPath(). + (WebCore::GLES2Canvas::clipOut): + Stub out clipOut() (not called by Canvas 2D). + (WebCore::GLES2Canvas::restore): + When restoring, draw any remaining clipping paths to the stencil buffer. + (WebCore::GLES2Canvas::drawTexturedRect): + Add clipping support. + (WebCore::interpolateQuadratic): + (WebCore::interpolateCubic): + Simple curve interpolation, using the Cubic and Quadratic classes. + (WebCore::PolygonData::PolygonData): + A struct to hold the tesselation data for callbacks. + (WebCore::beginData): + (WebCore::edgeFlagData): + (WebCore::vertexData): + (WebCore::endData): + (WebCore::combineData): + internal_glu tesselation callbacks. + (WebCore::GLES2Canvas::createVertexBufferFromPath): + Build an interpolated, tesselated vertex buffer and element array buffer from a given path, suitable for filling. + (WebCore::GLES2Canvas::beginStencilDraw): + Enable stencilling, and disable draws to the color buffer. + (WebCore::GLES2Canvas::applyClipping): + If clipping is enabled, set the appropriate GL state. + * platform/graphics/chromium/GLES2Canvas.h: + Document the flavours of drawTexturedRect() a bit, so I don't get confused. + * platform/graphics/gpu/DrawingBuffer.cpp: + (WebCore::DrawingBuffer::clear): + (WebCore::DrawingBuffer::createSecondaryBuffers): + (WebCore::DrawingBuffer::resizeDepthStencil): + (WebCore::DrawingBuffer::reset): + * platform/graphics/gpu/DrawingBuffer.h: + Unify m_multisampleDepthStencilBuffer with m_depthStencilBuffer. + Implement separate depth and stencil buffers for when + OES_packed_depth_stencil is not available. Refactor creation of + multisampled and non-multisampled depth and stencil buffers into + resizeDepthStencil(). + * platform/graphics/gpu/SharedGraphicsContext3D.cpp: + (WebCore::SharedGraphicsContext3D::create): + Turn on stencil, turn off depth, turn off antialiasing (for now). + (WebCore::SharedGraphicsContext3D::enableStencil): + * platform/graphics/gpu/SharedGraphicsContext3D.h: + Implement stencil enable/disable. + * platform/graphics/gpu/mac/DrawingBufferMac.mm: + (WebCore::DrawingBuffer::DrawingBuffer): + Remove m_multisampleDepthStencilBuffer. Set the size to (-1, -1) + on creation, so reset() doesn't early-out. Initialize m_depthBuffer + and m_stencilBuffer. + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::canvasClip): + (WebCore::GraphicsContext::clipOut): + (WebCore::GraphicsContext::clipPath): + (WebCore::GraphicsContext::fillPath): + Put in GPU hooks for path clipping, and path drawing. + * platform/graphics/skia/PlatformContextSkia.cpp: + (WebCore::PlatformContextSkia::canAccelerate): + Don't check for clipping paths in canAccelerate() (since we can + now accelerate them). + (WebCore::PlatformContextSkia::uploadSoftwareToHardware): + Don't do clipping when uploading software draws to hardware. + * thirdparty/glu/README.webkit: + * thirdparty/glu/gluos.h: + #undef MIN and MAX, to fix warnings-as-errors in Chrome/Mac build. + * thirdparty/glu/libtess/geom.c: + * thirdparty/glu/libtess/priorityq.c: + * thirdparty/glu/libtess/render.c: + Use do{}while(0) instead of if(1)else construct in macro. + * thirdparty/glu/libtess/sweep.c: + (IsWindingInside): + (DoneEdgeDict): + Fix some warnings treated as errors for the Linux Release build. + +2011-01-19 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r76144. + http://trac.webkit.org/changeset/76144 + https://bugs.webkit.org/show_bug.cgi?id=52737 + + Broke tests on multiple bots, mostly Chromium Canaries + (Requested by dimich on #webkit). + + * rendering/RenderText.cpp: + (WebCore::RenderText::localCaretRect): + +2011-01-19 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Adam Roben. + + [CSS Gradients] Crash due to out-of-memory with repeating-linear-gradient and latter stop positioned before former + https://bugs.webkit.org/show_bug.cgi?id=52732 + + When repeating gradient stops, make sure that the first and last stops are not at the same + place, otherwise we'll add stops indefinitely and run out of memory. + + Test: fast/gradients/zero-range-repeating-gradient-hang.html + + * css/CSSGradientValue.cpp: + (WebCore::CSSGradientValue::addStops): + +2011-01-14 Dimitri Glazkov <dglazkov@chromium.org> + + Reviewed by Darin Adler. + + Remove event forwarding logic from input[type=range], simplify event flow and thumb positioning logic. + https://bugs.webkit.org/show_bug.cgi?id=52464 + + This change has two parts: + + 1) Utilize shadow DOM event retargeting to get rid of forwarding events + via render tree; + 2) Move thumb positioning logic from RenderSlider to SliderThumbElement. + + These two are highly co-dependent. It looked ugly when I tried to + separate them. + + No change in behavior, covered by existing tests. + + * html/HTMLInputElement.cpp: + (WebCore::HTMLInputElement::defaultEventHandler): Added invocation of + InputType::handleMouseDownEvent. + * html/InputType.cpp: + (WebCore::InputType::handleMouseDownEvent): Added empty decl. + * html/InputType.h: Added def. + * html/RangeInputType.cpp: + (WebCore::RangeInputType::handleMouseDownEvent): Added to handle the case + when the user clicks on the track of the slider. Also removed the + forwardEvent method. + * html/RangeInputType.h: Added/removed defs. + * html/shadow/SliderThumbElement.cpp: + (WebCore::SliderThumbElement::dragFrom): Added a helper method to start + dragging from any position. + (WebCore::SliderThumbElement::dragTo): Added a helper method to drag to + specified position. + (WebCore::SliderThumbElement::setPosition): Collapsed most of the positioning + logic in RenderSlider into this method, which is now a simple calculation + and adjusting of thumb position based on supplied coordinates. + (WebCore::SliderThumbElement::startDragging): Added. + (WebCore::SliderThumbElement::stopDragging): Added. + (WebCore::SliderThumbElement::defaultEventHandler): Removed most of the + old position-sniffing logic and replaced with simple calls to start, + stop, and drag the thumb. + * html/shadow/SliderThumbElement.h: Added defs. + * rendering/RenderSlider.cpp: Removed a bunch of code that is no longer + necessary. + * rendering/RenderSlider.h: Removed defs, removed now-unnecessary friendliness. + +2011-01-19 Shane Stephens <shanestephens@google.com> + + Reviewed by Chris Marrin. + + Make AffineTransform and TransformationMatrix do matrix multiplication in the correct order (Column Major) + https://bugs.webkit.org/show_bug.cgi?id=48031 + + Fixed reversal, renamed matrix methods to be clearer, found all examples of operator* and + operator*= usage and switched operand order. + + No new tests as this refactor doesn't add functionality. + + * html/HTMLCanvasElement.cpp: + (WebCore::HTMLCanvasElement::baseTransform): + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::transform): + (WebCore::CanvasRenderingContext2D::setTransform): + * platform/graphics/cg/PatternCG.cpp: + (WebCore::Pattern::createPlatformPattern): + * platform/graphics/chromium/GLES2Canvas.cpp: + (WebCore::GLES2Canvas::fillRect): + (WebCore::GLES2Canvas::concatCTM): + (WebCore::GLES2Canvas::drawQuad): + * platform/graphics/chromium/TransparencyWin.cpp: + (WebCore::TransparencyWin::setupLayerForOpaqueCompositeLayer): + (WebCore::TransparencyWin::setupTransformForKeepTransform): + * platform/graphics/transforms/AffineTransform.cpp: + (WebCore::AffineTransform::multiply): + (WebCore::AffineTransform::rotate): + * platform/graphics/transforms/AffineTransform.h: + (WebCore::AffineTransform::operator*=): + (WebCore::AffineTransform::operator*): + * platform/graphics/wince/GraphicsContextWinCE.cpp: + (WebCore::GraphicsContextPlatformPrivate::concatCTM): + * platform/graphics/wince/SharedBitmap.cpp: + (WebCore::SharedBitmap::drawPattern): + * rendering/svg/RenderSVGResourceContainer.cpp: + (WebCore::RenderSVGResourceContainer::transformOnNonScalingStroke): + * rendering/svg/RenderSVGResourceGradient.cpp: + (WebCore::clipToTextMask): + (WebCore::RenderSVGResourceGradient::applyResource): + * rendering/svg/RenderSVGResourcePattern.cpp: + (WebCore::RenderSVGResourcePattern::applyResource): + * rendering/svg/RenderSVGRoot.cpp: + (WebCore::RenderSVGRoot::localToBorderBoxTransform): + * rendering/svg/SVGImageBufferTools.cpp: + (WebCore::SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem): + (WebCore::SVGImageBufferTools::renderSubtreeToImageBuffer): + * rendering/svg/SVGTextLayoutEngine.cpp: + (WebCore::SVGTextLayoutEngine::finalizeTransformMatrices): + * svg/SVGLocatable.cpp: + (WebCore::SVGLocatable::computeCTM): + (WebCore::SVGLocatable::getTransformToElement): + * svg/SVGMatrix.h: + (WebCore::SVGMatrix::multiply): + * svg/SVGSVGElement.cpp: + (WebCore::SVGSVGElement::localCoordinateSpaceTransform): + (WebCore::SVGSVGElement::viewBoxToViewTransform): + * svg/SVGStyledTransformableElement.cpp: + (WebCore::SVGStyledTransformableElement::animatedLocalTransform): + * svg/SVGTextElement.cpp: + (WebCore::SVGTextElement::animatedLocalTransform): + * svg/SVGTransformList.cpp: + (WebCore::SVGTransformList::concatenate): + +2011-01-19 Chang Shu <chang.shu@nokia.com> + + Reviewed by Darin Adler. + + The return value of contentEditable() function should depend on the DOM attribute + instead of render style userModify. The code change fixed test cases in the bug + and partially fixed test cases in other contentEditable bugs; + + https://bugs.webkit.org/show_bug.cgi?id=52056 + + * html/HTMLElement.cpp: + (WebCore::HTMLElement::contentEditable): + +2011-01-19 Levi Weintraub <leviw@chromium.org> + + Reviewed by Darin Adler. + + Changing RenderText::localCaretRect to clip to its containing block's logicalLeft and + logicalRightLayoutOverflow instead of simply using logicalLeft and logicalRight, as this + resulted in the caret being placed incorrectly in overflowing editable IFrame content. + + Long lines in non-white-space-pre editable documents show cursor in wrong place + https://bugs.webkit.org/show_bug.cgi?id=48132 + + Test: editing/selection/caret-painting-in-overflowing-autowrap-content.html + + * rendering/RenderText.cpp: + (WebCore::RenderText::localCaretRect): + +2011-01-19 Chris Marrin <cmarrin@apple.com> + + Reviewed by Simon Fraser. + + WK2 - Multiple crashes in PlatformCALayer::replaceSublayer + https://bugs.webkit.org/show_bug.cgi?id=52695 + + Added ASSERTs to the places we assume a non-null superlayer. + + * platform/graphics/ca/GraphicsLayerCA.cpp: + (WebCore::GraphicsLayerCA::ensureStructuralLayer): + (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer): + +2011-01-18 Beth Dakin <bdakin@apple.com> + + Reviewed by Maciej Stachowiak. + + Fix for <rdar://problem/8882916> Overlay scrollers require + content to layout underneath the scrollbar area + + The render tree should not include scrollbar size for + overlay scrollers. This patch will allow scrollers on + the WebView to behave like overflow:overlay. + + Treat overlay scrollers the same way as the !includeScrollbars + case. + * platform/ScrollView.cpp: + (WebCore::ScrollView::visibleContentRect): + + No corner rect for overlay scrollers. + (WebCore::ScrollView::scrollCornerRect): + + usesOverlayScrollbars() currently always returns no. + * platform/ScrollbarTheme.h: + (WebCore::ScrollbarTheme::usesOverlayScrollbars): + * platform/mac/ScrollbarThemeMac.h: + * platform/mac/ScrollbarThemeMac.mm: + (WebCore::ScrollbarThemeMac::usesOverlayScrollbars): + + includeVerticalScrollbarSize() and includeHorizontalScrollbarSize() + should return false for overlay scrollers. They already return + false for overflow:overlay. + * rendering/RenderBox.cpp: + (WebCore::RenderBox::includeVerticalScrollbarSize): + (WebCore::RenderBox::includeHorizontalScrollbarSize): + * rendering/RenderBox.h: + + In the render tree, always treat overlay scrollers like + they have a width and height of 0. + * rendering/RenderLayer.cpp: + (WebCore::RenderLayer::verticalScrollbarWidth): + (WebCore::RenderLayer::horizontalScrollbarHeight): + * rendering/RenderListBox.cpp: + (WebCore::RenderListBox::verticalScrollbarWidth): + +2011-01-18 Evan Martin <evan@chromium.org> + + Reviewed by Tony Chang. + + [chromium] simplify complex text code, fixing a handful of layout tests + https://bugs.webkit.org/show_bug.cgi?id=52661 + + Change ComplexTextControllerLinux to lay out RTL text to the left from + the starting point. (Previously it always went to the right.) This allows + us to map pixel offsets more directly into offsets within the text runs, + simplifying a few of the text-fiddling functions (they no longer need to + track the current position, as ComplexTextController now does it). + + * platform/graphics/chromium/ComplexTextControllerLinux.cpp: + (WebCore::ComplexTextController::ComplexTextController): + (WebCore::ComplexTextController::reset): + (WebCore::ComplexTextController::setGlyphXPositions): + * platform/graphics/chromium/ComplexTextControllerLinux.h: + (WebCore::ComplexTextController::offsetX): + * platform/graphics/chromium/FontLinux.cpp: + (WebCore::Font::drawComplexText): + (WebCore::Font::floatWidthForComplexText): + (WebCore::glyphIndexForXPositionInScriptRun): + (WebCore::Font::offsetForPositionForComplexText): + (WebCore::Font::selectionRectForComplexText): + +2011-01-19 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: move methods from InjectedScript domain into DOM, + Runtime and Debugger domains. Introduce InspectorRuntimeAgent. + https://bugs.webkit.org/show_bug.cgi?id=52717 + + * CMakeLists.txt: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * inspector/CodeGeneratorInspector.pm: + * inspector/InjectedScript.cpp: + (WebCore::InjectedScript::evaluateOnCallFrame): + (WebCore::InjectedScript::getCompletions): + (WebCore::InjectedScript::getCompletionsOnCallFrame): + * inspector/InjectedScript.h: + * inspector/InjectedScriptHost.cpp: + (WebCore::InjectedScriptHost::injectedScriptForMainWorld): + * inspector/InjectedScriptHost.h: + * inspector/InjectedScriptSource.js: + (.): + (): + * inspector/Inspector.idl: + * inspector/InspectorController.cpp: + (WebCore::InspectorController::connectFrontend): + (WebCore::InspectorController::releaseFrontendLifetimeAgents): + * inspector/InspectorController.h: + * inspector/InspectorDOMAgent.cpp: + (WebCore::InspectorDOMAgent::InspectorDOMAgent): + (WebCore::InspectorDOMAgent::resolveNode): + (WebCore::InspectorDOMAgent::getNodeProperties): + (WebCore::InspectorDOMAgent::getNodePrototypes): + (WebCore::InspectorDOMAgent::injectedScriptForNodeId): + * inspector/InspectorDOMAgent.h: + (WebCore::EventListenerInfo::EventListenerInfo): + (WebCore::InspectorDOMAgent::DOMListener::~DOMListener): + (WebCore::InspectorDOMAgent::create): + (WebCore::InspectorDOMAgent::cast): + (WebCore::InspectorDOMAgent::documents): + * inspector/InspectorDebuggerAgent.cpp: + (WebCore::InspectorDebuggerAgent::evaluateOnCallFrame): + (WebCore::InspectorDebuggerAgent::getCompletionsOnCallFrame): + (WebCore::InspectorDebuggerAgent::injectedScriptForCallFrameId): + * inspector/InspectorDebuggerAgent.h: + * inspector/InspectorRuntimeAgent.cpp: Added. + (WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent): + (WebCore::InspectorRuntimeAgent::~InspectorRuntimeAgent): + (WebCore::InspectorRuntimeAgent::evaluate): + (WebCore::InspectorRuntimeAgent::getCompletions): + (WebCore::InspectorRuntimeAgent::getProperties): + (WebCore::InspectorRuntimeAgent::setPropertyValue): + (WebCore::InspectorRuntimeAgent::pushNodeToFrontend): + (WebCore::InspectorRuntimeAgent::injectedScriptForObjectId): + * inspector/InspectorRuntimeAgent.h: Copied from Source/WebCore/inspector/InjectedScript.h. + (WebCore::InspectorRuntimeAgent::create): + * inspector/front-end/ConsoleView.js: + (WebInspector.ConsoleView.prototype.completions): + * inspector/front-end/ScriptsPanel.js: + (WebInspector.ScriptsPanel.prototype.doEvalInCallFrame): + +2011-01-18 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: add UglifyJS parser and formatter files + https://bugs.webkit.org/show_bug.cgi?id=51702 + + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * inspector/front-end/ScriptFormatter.js: + (WebInspector.ScriptFormatter.positionToLocation): + (WebInspector.ScriptFormatter.prototype.format.messageHandler): + (WebInspector.ScriptFormatter.prototype.format): + (WebInspector.ScriptFormatter.prototype._buildMapping): + (WebInspector.ScriptFormatter.prototype._convertPosition): + * inspector/front-end/SourceFrame.js: + (WebInspector.SourceFrame.prototype.formatSource.didFormat): + (WebInspector.SourceFrame.prototype.formatSource): + * inspector/front-end/WebKit.qrc: + * inspector/front-end/parse-js.js: Added. UglifyJS parser. + * inspector/front-end/process.js: Added. UglifyJS formatter. + * inspector/front-end/scriptFormatterWorker.js: Added. Worker script that wraps UglifyJS code. + (onmessage): + (beautify): + (loadModule): + (require): + * inspector/front-end/utilities.js: + (): + +2011-01-19 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: [JSC] scripts have incorrect starting line (always 1). + https://bugs.webkit.org/show_bug.cgi?id=52721 + + Test: inspector/debugger-scripts.html + + * bindings/js/ScriptDebugServer.cpp: + (WebCore::ScriptDebugServer::dispatchDidParseSource): + (WebCore::ScriptDebugServer::dispatchFailedToParseSource): + (WebCore::ScriptDebugServer::sourceParsed): + * bindings/js/ScriptDebugServer.h: + * bindings/js/ScriptSourceCode.h: + (WebCore::ScriptSourceCode::ScriptSourceCode): + * bindings/js/StringSourceProvider.h: + (WebCore::StringSourceProvider::create): + (WebCore::StringSourceProvider::startPosition): + (WebCore::StringSourceProvider::StringSourceProvider): + +2011-01-19 Satish Sampath <satish@chromium.org> + + Reviewed by Jeremy Orlow. + + Send origin/url as part of speech input requests to the embedder. + https://bugs.webkit.org/show_bug.cgi?id=52718 + + * page/SpeechInput.cpp: + (WebCore::SpeechInput::startRecognition): Pass up additional origin parameter. + * page/SpeechInput.h: + * page/SpeechInputClient.h: + * platform/mock/SpeechInputClientMock.cpp: + (WebCore::SpeechInputClientMock::startRecognition): Updated prototype. + * platform/mock/SpeechInputClientMock.h: + * rendering/TextControlInnerElements.cpp: + (WebCore::InputFieldSpeechButtonElement::defaultEventHandler): Pass the frame origin to speech input request. + +2011-01-19 Hans Wennborg <hans@chromium.org> + + Reviewed by Jeremy Orlow. + + IndexedDB: Support auto-increment keys + https://bugs.webkit.org/show_bug.cgi?id=52576 + + Add support for auto-increment keys. + + Test: storage/indexeddb/objectstore-autoincrement.html + + * storage/IDBDatabase.cpp: + (WebCore::IDBDatabase::createObjectStore): + * storage/IDBObjectStoreBackendImpl.cpp: + (WebCore::genAutoIncrementKey): + (WebCore::IDBObjectStoreBackendImpl::putInternal): + +2011-01-19 Csaba Osztrogonác <ossy@webkit.org> + + Reviewed by Laszlo Gombos and Tor Arne Vestbø. + + [Qt] Remove unnecessary "../Source" from paths + after moving source files into Source is finished. + + * WebCore.pri: + * WebCore.pro: + +2011-01-19 Alexander Pavlov <apavlov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: Employ TextPrompt for CSS property name/value autocompletion + https://bugs.webkit.org/show_bug.cgi?id=52212 + + WebInspector.CSSKeywordCompletions contains a hand-written list of accepted CSS property value keywords + for each property. WebInspector.TextPrompt is used to suggest both the name and value keywords while + editing styles, in place of the old custom suggestion code. + + * inspector/front-end/CSSCompletions.js: + (WebInspector.CSSCompletions.prototype.startsWith): Fix array-out-of-bounds error. + * inspector/front-end/CSSKeywordCompletions.js: Added. + (WebInspector.CSSKeywordCompletions.forProperty): + * inspector/front-end/StylesSidebarPane.js: + (WebInspector.StylePropertyTreeElement.prototype.updateTitle): + (WebInspector.StylePropertyTreeElement.prototype): + (): + * inspector/front-end/TextPrompt.js: + (WebInspector.TextPrompt): + (WebInspector.TextPrompt.prototype.removeFromElement): + (WebInspector.TextPrompt.prototype._onKeyDown): + (WebInspector.TextPrompt.prototype.tabKeyPressed): + (WebInspector.TextPrompt.prototype.upKeyPressed): + (WebInspector.TextPrompt.prototype.downKeyPressed): + (WebInspector.TextPrompt.prototype._moveBackInHistory): + (WebInspector.TextPrompt.prototype._moveForwardInHistory): + * inspector/front-end/inspector.css: + (.auto-complete-text, .editing .auto-complete-text): + * inspector/front-end/inspector.html: + +2011-01-19 Dai Mikurube <dmikurube@google.com> + + Reviewed by Kent Tamura. + + Implement onformchange and onforminput event handlers + https://bugs.webkit.org/show_bug.cgi?id=26141 + + Tests: fast/forms/formchange-event.html + fast/forms/forminput-event.html + + * bindings/scripts/CodeGeneratorGObject.pm: Added event names. + * dom/Document.h: Added event definitions. + * dom/Document.idl: Added event definitions. + * dom/Element.h: Added event definitions. + * dom/Element.idl: Added event definitions. + * dom/Event.cpp: + (WebCore::Event::fromUserGesture): Added a condition for a formchange event in handling user gestures. + * dom/EventNames.h: Added event definitions. + * dom/InputElement.cpp: + (WebCore::InputElement::setValueFromRenderer): Replaced a direct dispatchEvent() call into dispatchInputEvents(), a virtual function which broadcasts forminput events for HTML elements. + * dom/Node.cpp: + (WebCore::Node::dispatchInputEvents): Defined basic dispatchInputEvents() described above. + (WebCore::Node::dispatchChangeEvents): Defined basic dispatchChangeEvents() described above. + (WebCore::Node::defaultEventHandler): Replaced a direct dispatchEvent() call into dispatchInputEvents(). + * dom/Node.h: + * html/FormAssociatedElement.h: Added isResettable() to check the element is resettable or not. + * html/HTMLAttributeNames.in: Added event names. + * html/HTMLElement.cpp: + (WebCore::HTMLElement::parseMappedAttribute): Added event handling. + (WebCore::HTMLElement::shadowAncestorOwnerForm): Added to get an ancestor <form> element from a shadow element. + (WebCore::HTMLElement::dispatchChangeEvents): Defined dispatchChangeEvents() for HTML elements described above. + (WebCore::HTMLElement::dispatchInputEvents): Defined dispatchInputEvents() for HTML elements described above. + * html/HTMLElement.h: + * html/HTMLFormControlElement.cpp: + (WebCore::HTMLFormControlElement::dispatchFormControlChangeEvent): Added calling dispatchFormChange() to broadcast formchange events. + (WebCore::HTMLFormControlElement::dispatchFormControlInputEvent): Defined newly to dispatch an input event with broadcasting forminput events. + * html/HTMLFormControlElement.h: Added isResettable(). + * html/HTMLFormElement.cpp: + (WebCore::HTMLFormElement::broadcastFormEvent): Added to broadcast forminput or formchange events. + (WebCore::HTMLFormElement::dispatchFormInput): Defined newly to broadcast forminput events. + (WebCore::HTMLFormElement::dispatchFormChange): Defined newly to broadcast formchange events. + * html/HTMLFormElement.h: + * html/HTMLFormElement.idl: Added dispatchFormInput() and dispatchFormChange() DOM API definitions. + * html/HTMLInputElement.cpp: + (WebCore::HTMLInputElement::stepUpFromRenderer): Replaced a direct dispatchEvent() call into dispatchInputEvents(). + * html/HTMLInputElement.h: Added isResettable(). + * html/HTMLKeygenElement.h: Added isResettable(). + * html/HTMLObjectElement.h: Added isResettable(). + * html/HTMLOutputElement.h: Added isResettable(). + * html/HTMLSelectElement.h: Added isResettable(). + * html/HTMLTextAreaElement.h: Added isResettable(). + * page/DOMWindow.h: Added event definitions. + * page/DOMWindow.idl: Added event definitions. + * rendering/TextControlInnerElements.cpp: + (WebCore::SearchFieldCancelButtonElement::defaultEventHandler): Replaced a direct dispatchEvent() call into dispatchInputEvents(). + +2011-01-19 Andrey Kosyakov <caseq@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: [Extensions API] delete pending callback from callback map before invoking it + https://bugs.webkit.org/show_bug.cgi?id=52707 + + * inspector/front-end/ExtensionAPI.js: + (WebInspector.injectedExtensionAPI.ExtensionServerClient.prototype._onCallback): + +2011-01-19 Levi Weintraub <leviw@google.com> + + Reviewed by Ryosuke Niwa. + + Replaced rangeCompliantEquivalent with Position::parentAnchoredEquivalent + and simplified the logic a bit. Unfortunately, Tables and some legacy + editing positions still need to be handled specifically. + + remove rangeCompliantEquivalent and replace it with Position methods + https://bugs.webkit.org/show_bug.cgi?id=25057 + + No new tests as this is a refactor that doesn't change behavior. + + * WebCore.exp.in: + * dom/Document.cpp: + (WebCore::Document::caretRangeFromPoint): + * dom/Position.cpp: + (WebCore::Position::parentAnchoredEquivalent): + * dom/Position.h: + * editing/ApplyStyleCommand.cpp: + (WebCore::ApplyStyleCommand::applyBlockStyle): + * editing/CompositeEditCommand.cpp: + (WebCore::CompositeEditCommand::insertNodeAt): + (WebCore::CompositeEditCommand::moveParagraphs): + * editing/DeleteSelectionCommand.cpp: + (WebCore::DeleteSelectionCommand::initializePositionData): + (WebCore::DeleteSelectionCommand::mergeParagraphs): + * editing/Editor.cpp: + (WebCore::Editor::textDirectionForSelection): + (WebCore::Editor::advanceToNextMisspelling): + * editing/InsertLineBreakCommand.cpp: + (WebCore::InsertLineBreakCommand::shouldUseBreakElement): + * editing/InsertParagraphSeparatorCommand.cpp: + (WebCore::InsertParagraphSeparatorCommand::doApply): + * editing/ReplaceSelectionCommand.cpp: + (WebCore::handleStyleSpansBeforeInsertion): + * editing/VisiblePosition.cpp: + (WebCore::makeRange): + (WebCore::setStart): + (WebCore::setEnd): + * editing/VisibleSelection.cpp: + (WebCore::VisibleSelection::firstRange): + (WebCore::VisibleSelection::toNormalizedRange): + (WebCore::makeSearchRange): + * editing/htmlediting.cpp: + (WebCore::indexForVisiblePosition): + * editing/htmlediting.h: + * editing/visible_units.cpp: + (WebCore::previousBoundary): + (WebCore::nextBoundary): + * page/DOMSelection.cpp: + (WebCore::anchorPosition): + (WebCore::focusPosition): + (WebCore::basePosition): + (WebCore::extentPosition): + +2011-01-19 Peter Rybin <peter.rybin@gmail.com> + + Reviewed by Yury Semikhatsky. + + Web Inspector: script column offset is incorrect + https://bugs.webkit.org/show_bug.cgi?id=52580 + + Column is updated in 3 places, 2 less probable places contained error. + Fixed now. + + * platform/text/SegmentedString.cpp: + (WebCore::SegmentedString::advanceSlowCase): + * platform/text/SegmentedString.h: + (WebCore::SegmentedString::advancePastNewline): + +2011-01-18 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: make InjectedScriptAccess API a part of Web Inspector protocol. + https://bugs.webkit.org/show_bug.cgi?id=52652 + + Calls served by the InjectedScript should be first class protocol + citizens, not dispatched via single protocol message. + + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * inspector/CodeGeneratorInspector.pm: + * inspector/InjectedScript.cpp: + (WebCore::InjectedScript::evaluate): + (WebCore::InjectedScript::evaluateInCallFrame): + (WebCore::InjectedScript::evaluateOnSelf): + (WebCore::InjectedScript::getCompletions): + (WebCore::InjectedScript::getProperties): + (WebCore::InjectedScript::pushNodeToFrontend): + (WebCore::InjectedScript::resolveNode): + (WebCore::InjectedScript::getNodeProperties): + (WebCore::InjectedScript::getNodePrototypes): + (WebCore::InjectedScript::setPropertyValue): + (WebCore::InjectedScript::makeCall): + * inspector/InjectedScript.h: + * inspector/InjectedScriptHost.cpp: + (WebCore::InjectedScriptHost::evaluate): + (WebCore::InjectedScriptHost::evaluateInCallFrame): + (WebCore::InjectedScriptHost::evaluateOnSelf): + (WebCore::InjectedScriptHost::getCompletions): + (WebCore::InjectedScriptHost::getProperties): + (WebCore::InjectedScriptHost::pushNodeToFrontend): + (WebCore::InjectedScriptHost::resolveNode): + (WebCore::InjectedScriptHost::getNodeProperties): + (WebCore::InjectedScriptHost::getNodePrototypes): + (WebCore::InjectedScriptHost::setPropertyValue): + (WebCore::InjectedScriptHost::injectedScriptForObjectId): + (WebCore::InjectedScriptHost::injectedScriptForNodeId): + (WebCore::InjectedScriptHost::injectedScriptForMainWorld): + * inspector/InjectedScriptHost.h: + * inspector/InjectedScriptSource.js: + (.): + * inspector/Inspector.idl: + * inspector/InspectorController.cpp: + * inspector/InspectorController.h: + * inspector/InspectorValues.cpp: + (WebCore::InspectorObject::getNumber): + * inspector/InspectorValues.h: + * inspector/front-end/AuditRules.js: + (WebInspector.AuditRules.evaluateInTargetWindow): + * inspector/front-end/ConsoleView.js: + (WebInspector.ConsoleView.prototype.completions): + (WebInspector.ConsoleView.prototype.doEvalInWindow): + * inspector/front-end/ElementsTreeOutline.js: + (WebInspector.ElementsTreeElement.prototype._createTooltipForNode): + * inspector/front-end/ExtensionPanel.js: + (WebInspector.ExtensionWatchSidebarPane.prototype.setExpression): + * inspector/front-end/ExtensionServer.js: + (WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage): + * inspector/front-end/InjectedScriptAccess.js: Removed. + * inspector/front-end/PropertiesSidebarPane.js: + (WebInspector.PropertiesSidebarPane.prototype.update.callback): + (WebInspector.PropertiesSidebarPane.prototype.update): + * inspector/front-end/RemoteObject.js: + (WebInspector.RemoteObject.resolveNode): + (WebInspector.RemoteObject.prototype.getProperties): + (WebInspector.RemoteObject.prototype.setPropertyValue): + (WebInspector.RemoteObject.prototype.pushNodeToFrontend): + * inspector/front-end/ScriptsPanel.js: + (WebInspector.ScriptsPanel.prototype.doEvalInCallFrame): + * inspector/front-end/WebKit.qrc: + * inspector/front-end/inspector.html: + +2011-01-18 Anton Muhin <antonm@chromium.org> + + Reviewed by Adam Barth. + + [v8] Minor cleanup: make 2nd argument of removeIfPresnt accept only a value type stored in the DOM map + https://bugs.webkit.org/show_bug.cgi?id=51683 + + Covered by the existing tests. + + * bindings/v8/DOMDataStore.cpp: + (WebCore::DOMDataStore::weakNodeCallback): + (WebCore::DOMDataStore::IntrusiveDOMWrapperMap::removeIfPresent): + * bindings/v8/DOMDataStore.h: + * bindings/v8/V8DOMMap.h: + (WebCore::WeakReferenceMap::removeIfPresent): + +2011-01-18 MORITA Hajime <morrita@google.com> + + Reviewed by Ryosuke Niwa. + + Refactoring: EventHandler::handleTextInputEvent should accept an enum instead of bools. + https://bugs.webkit.org/show_bug.cgi?id=52608 + + No new tests. no behavioral change. + + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * dom/TextEvent.cpp: + (WebCore::TextEvent::create): + (WebCore::TextEvent::createForDrop): + (WebCore::TextEvent::TextEvent): + * dom/TextEvent.h: + (WebCore::TextEvent::isLineBreak): + (WebCore::TextEvent::isBackTab): + (WebCore::TextEvent::isPaste): + (WebCore::TextEvent::isDrop): + * dom/TextEventInputType.h: Added. Extracted from TextEvent::TextInputType. + * editing/EditorCommand.cpp: + (WebCore::executeInsertBacktab): + (WebCore::executeInsertLineBreak): + (WebCore::executeInsertNewline): + (WebCore::executeInsertTab): + * page/EventHandler.cpp: + (WebCore::EventHandler::handleTextInputEvent): + * page/EventHandler.h: + +2011-01-18 Ben Vanik <ben.vanik@gmail.com> + + Reviewed by Kenneth Russell. + + Updating ANGLE in WebKit to r533. + https://bugs.webkit.org/show_bug.cgi?id=47194 + + * platform/graphics/ANGLEWebKitBridge.cpp: + (WebCore::ANGLEWebKitBridge::ANGLEWebKitBridge): + (WebCore::ANGLEWebKitBridge::~ANGLEWebKitBridge): + (WebCore::ANGLEWebKitBridge::validateShaderSource): + Update to new ANGLE API for shader validation. + * platform/graphics/ANGLEWebKitBridge.h: + (WebCore::ANGLEWebKitBridge::setResources): + Renaming types to new names. + * platform/graphics/mac/GraphicsContext3DMac.mm: + (WebCore::GraphicsContext3D::GraphicsContext3D): + Initialize ANGLEResources with ANGLE init call to prevent uninitialized variables. + +2011-01-18 MORITA Hajime <morrita@google.com> + + Reviewed by Simon Fraser. + + Refactoring: Extract RoundedIntRect class + https://bugs.webkit.org/show_bug.cgi?id=51664 + + RoundedIntRect is a pair of rect and four IntSize objects which represent + corner radii of the rectangle. IntSize is grouped into RoundedIntRect::Radii. + Now RenderStyle::getRoundedBorderFor() and RenderStyle::getRoundedInnerBorderWithBorderWidths() + return RoundedIntRect and GraphicsContext::addRoundedRectClip(), GraphicsContext::fillRoundedRect() + and other functions accept RoundedIntRect as an argument. + + * Android.mk: + * CMakeLists.txt: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * platform/graphics/GraphicsContext.cpp: + (WebCore::GraphicsContext::addRoundedRectClip): + (WebCore::GraphicsContext::clipOutRoundedRect): + (WebCore::GraphicsContext::fillRoundedRect): + * platform/graphics/GraphicsContext.h: + * platform/graphics/RoundedIntRect.cpp: Added. + (WebCore::RoundedIntRect::Radii::isZero): + (WebCore::RoundedIntRect::Radii::scale): + (WebCore::RoundedIntRect::Radii::expand): + (WebCore::RoundedIntRect::Radii::includeLogicalEdges): + (WebCore::RoundedIntRect::Radii::excludeLogicalEdges): + (WebCore::RoundedIntRect::RoundedIntRect): + (WebCore::RoundedIntRect::includeLogicalEdges): + (WebCore::RoundedIntRect::excludeLogicalEdges): + * platform/graphics/RoundedIntRect.h: Added. + (WebCore::RoundedIntRect::Radii::Radii): + (WebCore::RoundedIntRect::Radii::setTopLeft): + (WebCore::RoundedIntRect::Radii::setTopRight): + (WebCore::RoundedIntRect::Radii::setBottomLeft): + (WebCore::RoundedIntRect::Radii::setBottomRight): + (WebCore::RoundedIntRect::Radii::topLeft): + (WebCore::RoundedIntRect::Radii::topRight): + (WebCore::RoundedIntRect::Radii::bottomLeft): + (WebCore::RoundedIntRect::Radii::bottomRight): + (WebCore::RoundedIntRect::Radii::expand): + (WebCore::RoundedIntRect::Radii::shrink): + (WebCore::RoundedIntRect::rect): + (WebCore::RoundedIntRect::radii): + (WebCore::RoundedIntRect::isRounded): + (WebCore::RoundedIntRect::isEmpty): + (WebCore::RoundedIntRect::setRect): + (WebCore::RoundedIntRect::setRadii): + (WebCore::RoundedIntRect::move): + (WebCore::RoundedIntRect::inflate): + (WebCore::RoundedIntRect::inflateWithRadii): + (WebCore::RoundedIntRect::expandRadii): + (WebCore::RoundedIntRect::shrinkRadii): + * rendering/RenderBox.cpp: + (WebCore::RenderBox::pushContentsClip): + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelObject::paintFillLayerExtended): + (WebCore::RenderBoxModelObject::paintBorder): + (WebCore::RenderBoxModelObject::clipBorderSidePolygon): + (WebCore::RenderBoxModelObject::paintBoxShadow): + * rendering/RenderBoxModelObject.h: + * rendering/RenderObject.cpp: + (WebCore::RenderObject::drawBoxSideFromPath): + * rendering/RenderReplaced.cpp: + (WebCore::RenderReplaced::paint): + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + * rendering/RenderThemeMac.mm: + (WebCore::RenderThemeMac::paintMenuListButtonGradients): + (WebCore::RenderThemeMac::paintSliderTrack): + * rendering/RenderThemeSafari.cpp: + (WebCore::RenderThemeSafari::paintMenuListButtonGradients): + (WebCore::RenderThemeSafari::paintSliderTrack): + * rendering/RenderThemeWinCE.cpp: + (WebCore::RenderThemeWinCE::paintSearchFieldCancelButton): + * rendering/RenderWidget.cpp: + (WebCore::RenderWidget::paint): + * rendering/style/BorderData.h: + * rendering/style/RenderStyle.cpp: + (WebCore::calcRadiiFor): + (WebCore::calcConstraintScaleFor): + (WebCore::RenderStyle::getRoundedBorderFor): + (WebCore::RenderStyle::getRoundedInnerBorderWithBorderWidths): + * rendering/style/RenderStyle.h: + (WebCore::InheritedFlags::setBorderRadius): + +2011-01-18 MORITA Hajime <morrita@google.com> + + Reviewed by Simon Fraser. + + Refactoring: Extract RoundedIntRect class + https://bugs.webkit.org/show_bug.cgi?id=51664 + + RoundedIntRect is a pair of rect and four IntSize objects which represent + corner radii of the rectangle. IntSize is grouped into RoundedIntRect::Radii. + Now RenderStyle::getRoundedBorderFor() and RenderStyle::getRoundedInnerBorderWithBorderWidths() + return RoundedIntRect and GraphicsContext::addRoundedRectClip(), GraphicsContext::fillRoundedRect() + and other functions accept RoundedIntRect as an argument. + + No new tests. No behavioral change. + + * Android.mk: + * CMakeLists.txt: + * WebCore.gypi: + * WebCore.pro: + * WebCore.xcodeproj/project.pbxproj: + * platform/graphics/GraphicsContext.cpp: + (WebCore::GraphicsContext::addRoundedRectClip): + (WebCore::GraphicsContext::clipOutRoundedRect): + (WebCore::GraphicsContext::fillRoundedRect): + * platform/graphics/GraphicsContext.h: + * platform/graphics/RoundedIntRect.cpp: Added. + (WebCore::RoundedIntRect::Radii::isZero): + (WebCore::RoundedIntRect::Radii::scale): + (WebCore::RoundedIntRect::Radii::expand): + (WebCore::RoundedIntRect::Radii::includeLogicalEdges): + (WebCore::RoundedIntRect::Radii::excludeLogicalEdges): + (WebCore::RoundedIntRect::RoundedIntRect): + (WebCore::RoundedIntRect::includeLogicalEdges): + (WebCore::RoundedIntRect::excludeLogicalEdges): + * platform/graphics/RoundedIntRect.h: Added. + (WebCore::RoundedIntRect::Radii::Radii): + (WebCore::RoundedIntRect::Radii::setTopLeft): + (WebCore::RoundedIntRect::Radii::setTopRight): + (WebCore::RoundedIntRect::Radii::setBottomLeft): + (WebCore::RoundedIntRect::Radii::setBottomRight): + (WebCore::RoundedIntRect::Radii::topLeft): + (WebCore::RoundedIntRect::Radii::topRight): + (WebCore::RoundedIntRect::Radii::bottomLeft): + (WebCore::RoundedIntRect::Radii::bottomRight): + (WebCore::RoundedIntRect::Radii::expand): + (WebCore::RoundedIntRect::Radii::shrink): + (WebCore::RoundedIntRect::rect): + (WebCore::RoundedIntRect::radii): + (WebCore::RoundedIntRect::isRounded): + (WebCore::RoundedIntRect::isEmpty): + (WebCore::RoundedIntRect::setRect): + (WebCore::RoundedIntRect::setRadii): + (WebCore::RoundedIntRect::move): + (WebCore::RoundedIntRect::inflate): + (WebCore::RoundedIntRect::inflateWithRadii): + (WebCore::RoundedIntRect::expandRadii): + (WebCore::RoundedIntRect::shrinkRadii): + * rendering/RenderBox.cpp: + (WebCore::RenderBox::pushContentsClip): + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelObject::paintFillLayerExtended): + (WebCore::RenderBoxModelObject::paintBorder): + (WebCore::RenderBoxModelObject::clipBorderSidePolygon): + (WebCore::RenderBoxModelObject::paintBoxShadow): + * rendering/RenderBoxModelObject.h: + * rendering/RenderObject.cpp: + (WebCore::RenderObject::drawBoxSideFromPath): + * rendering/RenderReplaced.cpp: + (WebCore::RenderReplaced::paint): + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + * rendering/RenderThemeMac.mm: + (WebCore::RenderThemeMac::paintMenuListButtonGradients): + (WebCore::RenderThemeMac::paintSliderTrack): + * rendering/RenderThemeSafari.cpp: + (WebCore::RenderThemeSafari::paintMenuListButtonGradients): + (WebCore::RenderThemeSafari::paintSliderTrack): + * rendering/RenderThemeWinCE.cpp: + (WebCore::RenderThemeWinCE::paintSearchFieldCancelButton): + * rendering/RenderWidget.cpp: + (WebCore::RenderWidget::paint): + * rendering/style/BorderData.h: + * rendering/style/RenderStyle.cpp: + (WebCore::calcRadiiFor): + (WebCore::calcConstraintScaleFor): + (WebCore::RenderStyle::getRoundedBorderFor): + (WebCore::RenderStyle::getRoundedInnerBorderWithBorderWidths): + * rendering/style/RenderStyle.h: + (WebCore::InheritedFlags::setBorderRadius): + +2011-01-18 Victoria Kirst <vrk@chromium.org> + + Reviewed by Kenneth Russell. + + [chromium] Adding support for YV16 video frame formats. + https://bugs.webkit.org/show_bug.cgi?id=52345 + + * platform/graphics/chromium/VideoLayerChromium.cpp: + (WebCore::VideoLayerChromium::determineTextureFormat): + (WebCore::VideoLayerChromium::draw): + +2011-01-18 David Hyatt <hyatt@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/8479998> REGRESSION (r67660): broken button layout at devforums.apple.com + + Exclude floating objects from shrinking to avoid floats. They should never do this. Timing-related bugs could + occur as a result of this mistake, and the change to rewrite pagination to defer layout of floats until they + got encountered on the correct line exposed this issue. + + Added /fast/block/float/float-overflow-hidden-containing-block-width.html. + + * rendering/RenderBox.cpp: + (WebCore::RenderBox::shrinkToAvoidFloats): + +2011-01-18 Zhenyao Mo <zmo@google.com> + + Reviewed by Kenneth Russell. + + Make CheckedInt<long> and CheckedInt<unsigned long> work + https://bugs.webkit.org/show_bug.cgi?id=52401 + + * html/canvas/CheckedInt.h: + (WebCore::CheckedInt::CheckedInt): Merge with the patch provided by Benoit Jacob. + * html/canvas/WebGLBuffer.cpp: + (WebCore::WebGLBuffer::associateBufferDataImpl): Use CheckedInt<long> instead of CheckedInt<int>. + (WebCore::WebGLBuffer::associateBufferSubDataImpl): Ditto. + +2011-01-18 Kenneth Russell <kbr@google.com> + + Reviewed by David Levin. + + Must strip comments from WebGL shaders before enforcing character set + https://bugs.webkit.org/show_bug.cgi?id=52390 + + Strip comments from incoming shaders, preserving line numbers, + before validating that they conform to the ESSL character set. + Revert changes from http://trac.webkit.org/changeset/75735 which + allowed invalid characters to be passed to certain APIs. + + Tested with WebGL layout tests, conformance test suite and several + WebGL demos in both Safari and Chromium. + + * html/canvas/WebGLRenderingContext.cpp: + (WebCore::StripComments::StripComments::process): + (WebCore::WebGLRenderingContext::shaderSource): + +2011-01-18 Ryosuke Niwa <rniwa@webkit.org> + + Reviewed by Eric Seidel. + + Stop instantiating legacy editing positions in DeleteSelectionCommand, IndentOudentCommand, + InsertLineBreakCommand, InsertListCOmmand.cpp, InsertParagraphSeparatorCommand, and htmlediting.cpp + https://bugs.webkit.org/show_bug.cgi?id=52644 + + This is a cleanup to stop instantiating legacy editing positions in the following tests. + firstDeepEditingPositionForNode and lastDeepEditingPositionForNode in htmlediting.h are not updated + because doing so requires significant code changes. They are tracked on the bug 52642. + + * editing/DeleteSelectionCommand.cpp: + (WebCore::DeleteSelectionCommand::initializeStartEnd): + (WebCore::updatePositionForNodeRemoval): + (WebCore::DeleteSelectionCommand::removeNode): + (WebCore::updatePositionForTextRemoval): + (WebCore::DeleteSelectionCommand::handleGeneralDelete): + * editing/IndentOutdentCommand.cpp: + (WebCore::IndentOutdentCommand::outdentParagraph): + * editing/InsertLineBreakCommand.cpp: + (WebCore::InsertLineBreakCommand::doApply): + * editing/InsertListCommand.cpp: + (WebCore::InsertListCommand::doApplyForSingleParagraph): + (WebCore::InsertListCommand::unlistifyParagraph): + (WebCore::InsertListCommand::listifyParagraph): + * editing/InsertParagraphSeparatorCommand.cpp: + (WebCore::InsertParagraphSeparatorCommand::doApply): + * editing/htmlediting.cpp: + (WebCore::enclosingBlock): + (WebCore::enclosingList): + (WebCore::enclosingListChild): + (WebCore::indexForVisiblePosition): + (WebCore::isNodeVisiblyContainedWithin): + (WebCore::avoidIntersectionWithNode): + +2011-01-18 Benjamin Kalman <kalman@chromium.org> + + Reviewed by Ryosuke Niwa. + + Tweak style in visible_units.cpp and TextIterator.cpp in preparation for another patch + https://bugs.webkit.org/show_bug.cgi?id=52610 + + This is a purely aesthetic change. + + * editing/TextIterator.cpp: + (WebCore::SimplifiedBackwardsTextIterator::advance): + * editing/visible_units.cpp: + (WebCore::previousBoundary): + +2011-01-18 Adam Klein <adamk@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] Replace ChromiumBridge::widgetSetCursor with ChromeClient::setCursor + https://bugs.webkit.org/show_bug.cgi?id=42236 + + * platform/chromium/ChromiumBridge.h: + * platform/chromium/WidgetChromium.cpp: + (WebCore::Widget::setCursor): + +2011-01-18 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Darin Adler. + + REGRESSION: A problem with Voiceover and finding links + https://bugs.webkit.org/show_bug.cgi?id=52324 + + Fallout from recent change to make WebCore return its own scroll view. + 1) There were two scroll views in the hierarchy, one which no needed to be ignored. + 2) Hit tests for sub frames needed to be offset. + 3) The check for whether an attachment is ignored must happen earlier than using + the helpText to determine if an element should be ignored. + + Test: platform/mac/accessibility/iframe-with-title-correct-hierarchy.html + + * accessibility/AccessibilityObject.cpp: + (WebCore::AccessibilityObject::elementAccessibilityHitTest): + * accessibility/AccessibilityRenderObject.cpp: + (WebCore::AccessibilityRenderObject::accessibilityIsIgnored): + * accessibility/mac/AccessibilityObjectWrapper.mm: + (-[AccessibilityObjectWrapper scrollViewParent]): + +2011-01-18 Adam Roben <aroben@apple.com> + + Call alternate CFHTTPCookie functions if available + + Fixes <http://webkit.org/b/52637> <rdar://problem/8878984>. + + Reviewed by Darin Adler. + + * platform/network/cf/CookieJarCFNet.cpp: Added soft-linking macros to + pull in the alternate CFHTTPCookie functions. + + (WebCore::cookieDomain): + (WebCore::cookieExpirationTime): + (WebCore::cookieName): + (WebCore::cookiePath): + (WebCore::cookieValue): + Added these wrappers around the CFHTTPCookie functions. We call the + alternate functions if they exist, otherwise fall back to the current + functions. + + (WebCore::filterCookies): + (WebCore::getRawCookies): + (WebCore::deleteCookie): + Changed to use the wrapper functions. + +2011-01-18 Martin Robinson <mrobinson@igalia.com> + + Reviewed by Eric Seidel. + + [GTK] Filenames are converted to URLs during edit drags + https://bugs.webkit.org/show_bug.cgi?id=52096 + + * platform/gtk/DragDataGtk.cpp: Only advertise and deliver filenames as URLs if the + conversion policy allows it. + (WebCore::DragData::containsURL): Ditto. + (WebCore::DragData::asURL): Ditto. + +2011-01-18 Helder Correia <helder@sencha.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Incorrect shadow alpha with semi-transparent solid fillStyle + https://bugs.webkit.org/show_bug.cgi?id=52611 + + This is related to bug 52559. The shadow color alpha must be multiplied + by the context brush alpha. + + Test: fast/canvas/canvas-fillPath-alpha-shadow.html + + * platform/graphics/qt/GraphicsContextQt.cpp: + (WebCore::GraphicsContext::fillPath): + +2011-01-18 Andrey Kosyakov <caseq@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: fail resource.requestContent() immediately for WebSocket resources + https://bugs.webkit.org/show_bug.cgi?id=52628 + + * English.lproj/localizedStrings.js: Rename WebSocket -> WebSockets in resource catetegories (rest are in plural, too) + * inspector/front-end/ExtensionServer.js: Do not expose webInspector.resources.Types in extensions API (obsolete) + (WebInspector.ExtensionServer.prototype._buildExtensionAPIInjectedScript): + * inspector/front-end/Resource.js: + (WebInspector.Resource.Type.toUIString): Remove ResourceType.Media as it's not used. + (WebInspector.Resource.Type.toString): ditto. + (WebInspector.Resource.prototype.requestContent): Fail immediately for WebSocket resources. + * inspector/front-end/inspector.js: Rename WebSocket -> WebSockets in resource catetegories (rest are in plural, too) + +2011-01-18 Helder Correia <helder@sencha.com> + + Reviewed by Dirk Schulze. + + REGRESSION(75139): SVG gradients are not applied to texts + https://bugs.webkit.org/show_bug.cgi?id=52531 + + r75139 caused a problem with filling and stroking text with a gradient + fill in SVG. The order of CGContextConcatCTM and CGContextClipToRect + was mixed up. + + Test: svg/css/text-gradient-shadow.svg + + * platform/graphics/cg/GraphicsContextCG.cpp: + (WebCore::GraphicsContext::fillRect): + +2011-01-18 Leo Yang <leo.yang@torchmobile.com.cn> + + Reviewed by Nikolas Zimmermann. + + Unable to indirectly animate visibility of SVGUseElement + https://bugs.webkit.org/show_bug.cgi?id=50240 + + SVGUseElement::recalcStyle should take care of its shadow + tree's style recalculation when it is called with change >= Inherit + or when childNeedsStyleRecalc() is true because in these two + cases needStyleRecalc() may not be true. + + Test: svg/custom/use-inherit-style.svg + + * svg/SVGUseElement.cpp: + (WebCore::SVGUseElement::recalcStyle): + +2011-01-18 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: provide script length to frontend. + https://bugs.webkit.org/show_bug.cgi?id=52620 + + * inspector/Inspector.idl: + * inspector/InspectorDebuggerAgent.cpp: + (WebCore::InspectorDebuggerAgent::didParseSource): + * inspector/front-end/DebuggerModel.js: + (WebInspector.DebuggerModel.prototype._parsedScriptSource): + (WebInspector.DebuggerDispatcher.prototype.parsedScriptSource): + * inspector/front-end/Script.js: + (WebInspector.Script): + +2011-01-18 Zoltan Herczeg <zherczeg@webkit.org> + + Rubber-stamped by Csaba Osztrogonác + + Fixing ChangeLog + + Removing a line introduced by + http://trac.webkit.org/changeset/75743/trunk/Source/WebCore/ChangeLog + Removing an unnecessary space before a time stamp. + +2011-01-17 Andrey Kosyakov <caseq@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: [refactoring] use events to notify NetworkManager clients + https://bugs.webkit.org/show_bug.cgi?id=52588 + + * inspector/front-end/AuditLauncherView.js: + (WebInspector.AuditLauncherView): Do not expose public interface to resource count. Do not reset resource count upon reset(). + (WebInspector.AuditLauncherView.prototype._resetResourceCount): + (WebInspector.AuditLauncherView.prototype._onResourceStarted): + (WebInspector.AuditLauncherView.prototype._onResourceFinished): + * inspector/front-end/AuditsPanel.js: Do not expose public interface to resource start/finish events. + * inspector/front-end/ExtensionServer.js: + (WebInspector.ExtensionServer): + (WebInspector.ExtensionServer.prototype._notifyResourceFinished): + (WebInspector.ExtensionServer.prototype.initExtensions): + * inspector/front-end/NetworkManager.js: Dispatch events rather than directly call clients. + (WebInspector.NetworkManager): + (WebInspector.NetworkManager.prototype.willSendRequest): + (WebInspector.NetworkManager.prototype.markResourceAsCached): + (WebInspector.NetworkManager.prototype.didReceiveResponse): + (WebInspector.NetworkManager.prototype.didReceiveContentLength): + (WebInspector.NetworkManager.prototype.setInitialContent): + (WebInspector.NetworkManager.prototype.didCommitLoadForFrame): + (WebInspector.NetworkManager.prototype.willSendWebSocketHandshakeRequest): + (WebInspector.NetworkManager.prototype.didReceiveWebSocketHandshakeResponse): + (WebInspector.NetworkManager.prototype._startResource): + (WebInspector.NetworkManager.prototype._finishResource): + * inspector/front-end/NetworkPanel.js: + (WebInspector.NetworkPanel): + (WebInspector.NetworkPanel.prototype._onResourceStarted): + (WebInspector.NetworkPanel.prototype._appendResource): + (WebInspector.NetworkPanel.prototype._onResourceUpdated): + (WebInspector.NetworkPanel.prototype._refreshResource): + (WebInspector.NetworkPanel.prototype._onMainResourceChanged): + * inspector/front-end/ResourcesPanel.js: + (WebInspector.ResourcesPanel): + (WebInspector.ResourcesPanel.prototype._refreshResource): + +2011-01-18 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: preserve pause on exception state in settings. + https://bugs.webkit.org/show_bug.cgi?id=52619 + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::getInspectorState): + * inspector/InspectorDebuggerAgent.cpp: + (WebCore::InspectorDebuggerAgent::setPauseOnExceptionsState): + * inspector/InspectorDebuggerAgent.h: + * inspector/front-end/ScriptsPanel.js: + (WebInspector.ScriptsPanel): + (WebInspector.ScriptsPanel.prototype.debuggerWasEnabled): + (WebInspector.ScriptsPanel.prototype._updatePauseOnExceptionsState): + (WebInspector.ScriptsPanel.prototype._togglePauseOnExceptions): + (WebInspector.ScriptsPanel.prototype._setPauseOnExceptions): + * inspector/front-end/Settings.js: + (WebInspector.Settings): + * inspector/front-end/inspector.js: + (WebInspector.doLoadedDone.populateInspectorState): + +2011-01-18 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: [REGRESSION] JavaScript exceptions aren't shown in source frame. + https://bugs.webkit.org/show_bug.cgi?id=52623 + + * inspector/front-end/ConsoleView.js: + (WebInspector.ConsoleMessage): + (WebInspector.ConsoleMessage.prototype._formatMessage): + +2011-01-18 Pavel Feldman <pfeldman@chromium.org> + + Revert r76017. No need to guard InspectorInstrumentation:: in WebCore. + + * page/Page.cpp: + (WebCore::networkStateChanged): + +2011-01-18 Konstantin Tokarev <annulen@yandex.ru> + + Reviewed by Kent Tamura. + + Fixed compilation when Inspector is disabled + https://bugs.webkit.org/show_bug.cgi?id=52564 + + * page/Page.cpp: + (WebCore::networkStateChanged): Added ENABLE(INSPECTOR) guard + +2011-01-18 MORITA Hajime <morrita@google.com> + + Unreviewed, rolling out r76004, r76005, r76007, and r76011. + http://trac.webkit.org/changeset/76004 + http://trac.webkit.org/changeset/76005 + http://trac.webkit.org/changeset/76007 + http://trac.webkit.org/changeset/76011 + https://bugs.webkit.org/show_bug.cgi?id=51664 + + The r76004 broke pixel tests. + (The failure was missed due to the tolerance.) + + * Android.mk: + * CMakeLists.txt: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * platform/graphics/GraphicsContext.cpp: + (WebCore::GraphicsContext::addRoundedRectClip): + (WebCore::GraphicsContext::clipOutRoundedRect): + * platform/graphics/GraphicsContext.h: + * platform/graphics/RoundedIntRect.cpp: Removed. + * platform/graphics/RoundedIntRect.h: Removed. + * rendering/RenderBox.cpp: + (WebCore::RenderBox::pushContentsClip): + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelObject::paintFillLayerExtended): + (WebCore::RenderBoxModelObject::paintBorder): + (WebCore::RenderBoxModelObject::clipBorderSidePolygon): + (WebCore::uniformlyExpandBorderRadii): + (WebCore::RenderBoxModelObject::paintBoxShadow): + * rendering/RenderBoxModelObject.h: + * rendering/RenderObject.cpp: + (WebCore::RenderObject::drawBoxSideFromPath): + * rendering/RenderReplaced.cpp: + (WebCore::RenderReplaced::paint): + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + * rendering/RenderThemeMac.mm: + (WebCore::RenderThemeMac::paintMenuListButtonGradients): + (WebCore::RenderThemeMac::paintSliderTrack): + * rendering/RenderThemeSafari.cpp: + (WebCore::RenderThemeSafari::paintMenuListButtonGradients): + (WebCore::RenderThemeSafari::paintSliderTrack): + * rendering/RenderThemeWinCE.cpp: + (WebCore::RenderThemeWinCE::paintSearchFieldCancelButton): + * rendering/RenderWidget.cpp: + (WebCore::RenderWidget::paint): + * rendering/style/BorderData.h: + * rendering/style/RenderStyle.cpp: + (WebCore::constrainCornerRadiiForRect): + (WebCore::RenderStyle::getBorderRadiiForRect): + (WebCore::RenderStyle::getInnerBorderRadiiForRectWithBorderWidths): + * rendering/style/RenderStyle.h: + +2011-01-17 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: add source column field to debugger call frames. + https://bugs.webkit.org/show_bug.cgi?id=52443 + + * bindings/js/JavaScriptCallFrame.cpp: + (WebCore::JavaScriptCallFrame::JavaScriptCallFrame): + * bindings/js/JavaScriptCallFrame.h: + (WebCore::JavaScriptCallFrame::create): + (WebCore::JavaScriptCallFrame::line): + (WebCore::JavaScriptCallFrame::column): + (WebCore::JavaScriptCallFrame::update): + * bindings/js/ScriptDebugServer.cpp: + (WebCore::ScriptDebugServer::createCallFrameAndPauseIfNeeded): + (WebCore::ScriptDebugServer::updateCallFrameAndPauseIfNeeded): + (WebCore::ScriptDebugServer::callEvent): + (WebCore::ScriptDebugServer::atStatement): + (WebCore::ScriptDebugServer::returnEvent): + (WebCore::ScriptDebugServer::exception): + (WebCore::ScriptDebugServer::willExecuteProgram): + (WebCore::ScriptDebugServer::didExecuteProgram): + (WebCore::ScriptDebugServer::didReachBreakpoint): + * bindings/js/ScriptDebugServer.h: + * bindings/v8/DebuggerScript.js: + (): + * bindings/v8/JavaScriptCallFrame.cpp: + (WebCore::JavaScriptCallFrame::column): + * bindings/v8/JavaScriptCallFrame.h: + * inspector/InjectedScriptSource.js: + (): + * inspector/JavaScriptCallFrame.idl: + +2011-01-18 Antti Koivisto <antti@apple.com> + + Reviewed by Dave Hyatt. + + https://bugs.webkit.org/show_bug.cgi?id=52370 + <rdar://problem/8856808> + Style sharing optimization no longer works on major web sites + + The code in CSSStyleSelector::locateSharedStyle() that tries to share style information between element has been defeated + by widespread use of certain CSS selectors (:first-child pseudo class and similar). The current implementation disables + the sharing optimization for the whole page if one of these constructs is seen in any style sheet used by the page. + + This patch gets the style sharing back to 25-40% range on most web sites. + + * css/CSSMutableStyleDeclaration.h: + (WebCore::CSSMutableStyleDeclaration::propertiesEqual): + + Needed to improve equality checking in NamedNodeMap::mappedMapsEquivalent. + + * css/CSSSelector.h: + (WebCore::CSSSelector::isSiblingSelector): + + Test for selectors that are affected by the sibling elements. + + * css/CSSStyleSelector.cpp: + (WebCore::elementCanUseSimpleDefaultStyle): + (WebCore::collectSiblingRulesInDefaultStyle): + (WebCore::assertNoSiblingRulesInDefaultStyle): + + Extract sibling rules from the MathML default stylesheet. + Assert that no other default stylesheet has them. + + (WebCore::CSSStyleSelector::CSSStyleSelector): + (WebCore::CSSStyleSelector::locateCousinList): + (WebCore::CSSStyleSelector::matchesSiblingRules): + (WebCore::CSSStyleSelector::canShareStyleWithElement): + (WebCore::CSSStyleSelector::locateSharedStyle): + (WebCore::CSSStyleSelector::styleForElement): + (WebCore::collectIdsAndSiblingRulesFromList): + (WebCore::CSSRuleSet::collectIdsAndSiblingRules): + + Track sibling rules and ids used in the stylesheets to allow much more fine-grained rejection of cases + where style sharing can't be used. + + * css/CSSStyleSelector.h: + * dom/NamedNodeMap.cpp: + (WebCore::NamedNodeMap::mappedMapsEquivalent): + + Check also for CSSValue mutation from DOM. + + * mathml/MathMLMathElement.cpp: + (WebCore::MathMLMathElement::insertedIntoDocument): + * mathml/MathMLMathElement.h: + + MathML default style sheet has sibling rules which don't get noticed by the normal document + stylesheet parsing. + + * rendering/style/RenderStyle.h: + (WebCore::InheritedFlags::setFirstChildState): + (WebCore::InheritedFlags::setLastChildState): + (WebCore::InheritedFlags::setChildIndex): + + These all make style non-shareable (unique). + +2011-01-18 MORITA Hajime <morrita@google.com> + + Unreviewed crash fix on release builds. + + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelObject::paintFillLayerExtended): + +2011-01-18 Pavel Podivilov <podivilov@chromium.org> + + Unreviewed, update localizedStrings.js. + + * English.lproj/localizedStrings.js: + +2011-01-11 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: implement script beautifier prototype. + https://bugs.webkit.org/show_bug.cgi?id=51588 + + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * inspector/front-end/ScriptFormatter.js: Added. + (WebInspector.ScriptFormatter): Implements JavaScript source beautification and conversion between original and + formatted line numbers + (WebInspector.ScriptFormatter.findLineEndings): + (WebInspector.ScriptFormatter.locationToPosition): + (WebInspector.ScriptFormatter.positionToLocation): + (WebInspector.ScriptFormatter.upperBound): + (WebInspector.ScriptFormatter.prototype.format): + (WebInspector.ScriptFormatter.prototype.originalLineNumberToFormattedLineNumber): + (WebInspector.ScriptFormatter.prototype.formattedLineNumberToOriginalLineNumber): + (WebInspector.ScriptFormatter.prototype.originalPositionToFormattedLineNumber): + (WebInspector.ScriptFormatter.prototype.formattedLineNumberToOriginalPosition): + (WebInspector.ScriptFormatter.prototype._convertPosition): + * inspector/front-end/ScriptsPanel.js: + (WebInspector.ScriptsPanel): + (WebInspector.ScriptsPanel.prototype._clearCurrentExecutionLine): + (WebInspector.ScriptsPanel.prototype._callFrameSelected): + (WebInspector.ScriptsPanel.prototype._formatScript): + * inspector/front-end/SourceFrame.js: Convert original line numbers to UI line numbers and vice versa + * inspector/front-end/WebKit.qrc: + * inspector/front-end/inspector.html: + +2011-01-18 Philippe Normand <pnormand@igalia.com> + + Unreviewed, GTK build fix as follow-up of r76004. + + * GNUmakefile.am: Include RoundedIntRect files in the build + +2011-01-18 Philippe Normand <pnormand@igalia.com> + + Unreviewed, rolling out r76002. + http://trac.webkit.org/changeset/76002 + https://bugs.webkit.org/show_bug.cgi?id=49790 + + breaks a bunch of fast/forms tests on mac and GTK + + * html/HTMLOptionElement.cpp: + (WebCore::HTMLOptionElement::setRenderStyle): + +2011-01-18 MORITA Hajime <morrita@google.com> + + Unreviewed windows build fix. + + * WebCore.vcproj/WebCore.vcproj: + +2011-01-17 MORITA Hajime <morrita@google.com> + + Reviewed by Simon Fraser. + + Refactoring: Extract RoundedIntRect class + https://bugs.webkit.org/show_bug.cgi?id=51664 + + RoundedIntRect is a pair of rect and four IntSize objects which represent + corner radii of the rectangle. IntSize is grouped into RoundedIntRect::Radii. + Now RenderStyle::getRoundedBorderFor() and RenderStyle::getRoundedInnerBorderWithBorderWidths() + return RoundedIntRect and GraphicsContext::addRoundedRectClip(), GraphicsContext::fillRoundedRect() + and other functions accept RoundedIntRect as an argument. + + No new tests. No behavioral change. + + * Android.mk: + * CMakeLists.txt: + * WebCore.gypi: + * WebCore.pro: + * WebCore.xcodeproj/project.pbxproj: + * platform/graphics/GraphicsContext.cpp: + (WebCore::GraphicsContext::addRoundedRectClip): + (WebCore::GraphicsContext::clipOutRoundedRect): + (WebCore::GraphicsContext::fillRoundedRect): + * platform/graphics/GraphicsContext.h: + * platform/graphics/RoundedIntRect.cpp: Added. + (WebCore::RoundedIntRect::Radii::isZero): + (WebCore::RoundedIntRect::Radii::scale): + (WebCore::RoundedIntRect::Radii::expand): + (WebCore::RoundedIntRect::Radii::includeLogicalEdges): + (WebCore::RoundedIntRect::Radii::excludeLogicalEdges): + (WebCore::RoundedIntRect::RoundedIntRect): + (WebCore::RoundedIntRect::includeLogicalEdges): + (WebCore::RoundedIntRect::excludeLogicalEdges): + * platform/graphics/RoundedIntRect.h: Added. + (WebCore::RoundedIntRect::Radii::Radii): + (WebCore::RoundedIntRect::Radii::setTopLeft): + (WebCore::RoundedIntRect::Radii::setTopRight): + (WebCore::RoundedIntRect::Radii::setBottomLeft): + (WebCore::RoundedIntRect::Radii::setBottomRight): + (WebCore::RoundedIntRect::Radii::topLeft): + (WebCore::RoundedIntRect::Radii::topRight): + (WebCore::RoundedIntRect::Radii::bottomLeft): + (WebCore::RoundedIntRect::Radii::bottomRight): + (WebCore::RoundedIntRect::Radii::expand): + (WebCore::RoundedIntRect::Radii::shrink): + (WebCore::RoundedIntRect::location): + (WebCore::RoundedIntRect::size): + (WebCore::RoundedIntRect::x): + (WebCore::RoundedIntRect::y): + (WebCore::RoundedIntRect::width): + (WebCore::RoundedIntRect::height): + (WebCore::RoundedIntRect::right): + (WebCore::RoundedIntRect::bottom): + (WebCore::RoundedIntRect::rect): + (WebCore::RoundedIntRect::radii): + (WebCore::RoundedIntRect::isRounded): + (WebCore::RoundedIntRect::isEmpty): + (WebCore::RoundedIntRect::setRect): + (WebCore::RoundedIntRect::setRadii): + (WebCore::RoundedIntRect::move): + (WebCore::RoundedIntRect::inflate): + (WebCore::RoundedIntRect::inflateWithRadii): + (WebCore::RoundedIntRect::expandRadii): + (WebCore::RoundedIntRect::shrinkRadii): + * rendering/RenderBox.cpp: + (WebCore::RenderBox::pushContentsClip): + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelObject::paintFillLayerExtended): + (WebCore::RenderBoxModelObject::paintBorder): + (WebCore::RenderBoxModelObject::clipBorderSidePolygon): + (WebCore::RenderBoxModelObject::paintBoxShadow): + * rendering/RenderBoxModelObject.h: + * rendering/RenderObject.cpp: + (WebCore::RenderObject::drawBoxSideFromPath): + * rendering/RenderReplaced.cpp: + (WebCore::RenderReplaced::paint): + * rendering/RenderThemeChromiumWin.cpp: + (WebCore::RenderThemeChromiumWin::paintTextFieldInternal): + * rendering/RenderThemeMac.mm: + (WebCore::RenderThemeMac::paintMenuListButtonGradients): + (WebCore::RenderThemeMac::paintSliderTrack): + * rendering/RenderThemeSafari.cpp: + (WebCore::RenderThemeSafari::paintMenuListButtonGradients): + (WebCore::RenderThemeSafari::paintSliderTrack): + * rendering/RenderThemeWinCE.cpp: + (WebCore::RenderThemeWinCE::paintSearchFieldCancelButton): + * rendering/RenderWidget.cpp: + (WebCore::RenderWidget::paint): + * rendering/style/BorderData.h: + * rendering/style/RenderStyle.cpp: + (WebCore::calcRadiiFor): + (WebCore::calcConstraintScaleFor): + (WebCore::RenderStyle::getRoundedBorderFor): + (WebCore::RenderStyle::getRoundedInnerBorderWithBorderWidths): + * rendering/style/RenderStyle.h: + (WebCore::InheritedFlags::setBorderRadius): + +2011-01-17 Rob Buis <rwlbuis@gmail.com> + + Reviewed by Kent Tamura. + + Color changes to option elements in a select multiple aren't drawn immediately + https://bugs.webkit.org/show_bug.cgi?id=49790 + + Redirect style changes on <option> element to the owner <select> element. + + Tests: fast/forms/select-option-background-color-change.html + fast/forms/select-option-color-change.html + fast/forms/select-option-visibility-change.html + + * html/HTMLOptionElement.cpp: + (WebCore::HTMLOptionElement::setRenderStyle): + +2011-01-17 MORITA Hajime <morrita@google.com> + + Unreviewed, rolling out r75995. + http://trac.webkit.org/changeset/75995 + https://bugs.webkit.org/show_bug.cgi?id=51914 + + Causes assertion failures. + + * dom/Element.cpp: + (WebCore::Element::shadowRoot): + (WebCore::Element::setShadowRoot): + (WebCore::Element::removeShadowRoot): + * dom/ElementRareData.h: + (WebCore::ElementRareData::ElementRareData): + +2011-01-17 MORITA Hajime <morrita@google.com> + + Unreviewed, rolling out r75999. + http://trac.webkit.org/changeset/75999 + + * dom/Element.cpp: + (WebCore::Element::removeShadowRoot): + +2011-01-17 MORITA Hajime <morrita@google.com> + + Unreviewed crash fix, which introduced at r75995 + + * dom/Element.cpp: + (WebCore::Element::removeShadowRoot): + +2011-01-17 MORITA Hajime <morrita@google.com> + + Reviewed by Dimitri Glazkov. + + ElementRareData::m_shadowRoot should not be RefPtr. + https://bugs.webkit.org/show_bug.cgi?id=51914 + + This change makes m_shadowRoot a raw pointer, as Node::m_parent is. + This change is safe because shadow host pointer is stored as TreeShared::m_parent + which prevents deletion unless set to null. + + No test, no behavioral change. + + * dom/Element.cpp: + (WebCore::Element::shadowRoot): + (WebCore::Element::setShadowRoot): + (WebCore::Element::removeShadowRoot): + * dom/ElementRareData.h: + (WebCore::ElementRareData::ElementRareData): + +2011-01-17 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Dan Bernstein. + + Some WebKit2 layout tests crash due to focus being on a frame in the page cache + https://bugs.webkit.org/show_bug.cgi?id=52607 + + No new tests. Existing tests crash in WebKit2 without this fix. + + I suspect there are other consequences besides the WebKit2 crash, but I + was unable to identify any for certain. + + * history/CachedFrame.cpp: + (WebCore::CachedFrame::CachedFrame): If a frame still has focus when its page + goes in the page cache, reset focus to the main frame. + 2011-01-17 Adam Roben <aroben@apple.com> Simplify WKCACFLayerRenderer's API @@ -2759,7 +7809,6 @@ * html/canvas/WebGLRenderingContext.cpp: ->>>>>>> .r75740 2011-01-13 Adrienne Walker <enne@google.com> Reviewed by Kenneth Russell. diff --git a/Source/WebCore/DerivedSources.cpp b/Source/WebCore/DerivedSources.cpp index 1be63f3..21271ea 100644 --- a/Source/WebCore/DerivedSources.cpp +++ b/Source/WebCore/DerivedSources.cpp @@ -167,6 +167,7 @@ #include "JSHTMLImageElement.cpp" #include "JSHTMLInputElement.cpp" #include "JSHTMLIsIndexElement.cpp" +#include "JSHTMLKeygenElement.cpp" #include "JSHTMLLabelElement.cpp" #include "JSHTMLLegendElement.cpp" #include "JSHTMLLIElement.cpp" diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make index e1b4db4..ef2dc2f 100644 --- a/Source/WebCore/DerivedSources.make +++ b/Source/WebCore/DerivedSources.make @@ -234,6 +234,7 @@ DOM_CLASSES = \ HTMLImageElement \ HTMLInputElement \ HTMLIsIndexElement \ + HTMLKeygenElement \ HTMLLIElement \ HTMLLabelElement \ HTMLLegendElement \ @@ -311,6 +312,7 @@ DOM_CLASSES = \ Notation \ Notification \ NotificationCenter \ + OESStandardDerivatives \ OESTextureFloat \ OverflowEvent \ PageTransitionEvent \ diff --git a/Source/WebCore/English.lproj/localizedStrings.js b/Source/WebCore/English.lproj/localizedStrings.js Binary files differindex 0d8edc2..7bd3da8 100644 --- a/Source/WebCore/English.lproj/localizedStrings.js +++ b/Source/WebCore/English.lproj/localizedStrings.js diff --git a/Source/WebCore/GNUmakefile.am b/Source/WebCore/GNUmakefile.am index efbbb70..0975094 100644 --- a/Source/WebCore/GNUmakefile.am +++ b/Source/WebCore/GNUmakefile.am @@ -354,6 +354,8 @@ webcore_built_sources += \ DerivedSources/WebCore/JSHTMLInputElement.h \ DerivedSources/WebCore/JSHTMLIsIndexElement.cpp \ DerivedSources/WebCore/JSHTMLIsIndexElement.h \ + DerivedSources/WebCore/JSHTMLKeygenElement.cpp \ + DerivedSources/WebCore/JSHTMLKeygenElement.h \ DerivedSources/WebCore/JSHTMLLabelElement.cpp \ DerivedSources/WebCore/JSHTMLLabelElement.h \ DerivedSources/WebCore/JSHTMLLegendElement.cpp \ @@ -480,6 +482,8 @@ webcore_built_sources += \ DerivedSources/WebCore/JSNotificationCenter.h \ DerivedSources/WebCore/JSNotification.cpp \ DerivedSources/WebCore/JSNotification.h \ + DerivedSources/WebCore/JSOESStandardDerivatives.cpp \ + DerivedSources/WebCore/JSOESStandardDerivatives.h \ DerivedSources/WebCore/JSOESTextureFloat.cpp \ DerivedSources/WebCore/JSOESTextureFloat.h \ DerivedSources/WebCore/JSOverflowEvent.cpp \ @@ -775,6 +779,8 @@ webcore_sources += \ Source/WebCore/bindings/js/JSEventSourceCustom.cpp \ Source/WebCore/bindings/js/JSEventTarget.cpp \ Source/WebCore/bindings/js/JSEventTarget.h \ + Source/WebCore/bindings/js/JSErrorHandler.cpp \ + Source/WebCore/bindings/js/JSErrorHandler.h \ Source/WebCore/bindings/js/JSExceptionBase.cpp \ Source/WebCore/bindings/js/JSExceptionBase.h \ Source/WebCore/bindings/js/JSFileReaderCustom.cpp \ @@ -866,8 +872,6 @@ webcore_sources += \ Source/WebCore/bindings/js/JSWorkerContextBase.cpp \ Source/WebCore/bindings/js/JSWorkerContextBase.h \ Source/WebCore/bindings/js/JSWorkerContextCustom.cpp \ - Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp \ - Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h \ Source/WebCore/bindings/js/JSWorkerCustom.cpp \ Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp \ Source/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp \ @@ -1300,6 +1304,7 @@ webcore_sources += \ Source/WebCore/dom/Text.cpp \ Source/WebCore/dom/TextEvent.cpp \ Source/WebCore/dom/TextEvent.h \ + Source/WebCore/dom/TextEventInputType.h \ Source/WebCore/dom/Text.h \ Source/WebCore/dom/TouchList.h \ Source/WebCore/dom/TransformSource.h \ @@ -1579,6 +1584,8 @@ webcore_sources += \ Source/WebCore/html/canvas/Int8Array.cpp \ Source/WebCore/html/canvas/Int8Array.h \ Source/WebCore/html/canvas/IntegralTypedArrayBase.h \ + Source/WebCore/html/canvas/OESStandardDerivatives.cpp \ + Source/WebCore/html/canvas/OESStandardDerivatives.h \ Source/WebCore/html/canvas/OESTextureFloat.cpp \ Source/WebCore/html/canvas/OESTextureFloat.h \ Source/WebCore/html/canvas/TypedArrayBase.h \ @@ -1981,6 +1988,8 @@ webcore_sources += \ Source/WebCore/inspector/InspectorProfilerAgent.h \ Source/WebCore/inspector/InspectorResourceAgent.cpp \ Source/WebCore/inspector/InspectorResourceAgent.h \ + Source/WebCore/inspector/InspectorRuntimeAgent.cpp \ + Source/WebCore/inspector/InspectorRuntimeAgent.h \ Source/WebCore/inspector/InspectorSettings.cpp \ Source/WebCore/inspector/InspectorSettings.h \ Source/WebCore/inspector/InspectorState.cpp \ @@ -2435,6 +2444,8 @@ webcore_sources += \ Source/WebCore/platform/graphics/PathTraversalState.h \ Source/WebCore/platform/graphics/Pattern.cpp \ Source/WebCore/platform/graphics/Pattern.h \ + Source/WebCore/platform/graphics/RoundedIntRect.cpp \ + Source/WebCore/platform/graphics/RoundedIntRect.h \ Source/WebCore/platform/graphics/SegmentedFontData.cpp \ Source/WebCore/platform/graphics/SegmentedFontData.h \ Source/WebCore/platform/graphics/SimpleFontData.cpp \ @@ -2563,8 +2574,8 @@ webcore_sources += \ Source/WebCore/platform/SchemeRegistry.h \ Source/WebCore/platform/ScrollAnimator.cpp \ Source/WebCore/platform/ScrollAnimator.h \ - Source/WebCore/platform/ScrollbarClient.cpp \ - Source/WebCore/platform/ScrollbarClient.h \ + Source/WebCore/platform/ScrollableArea.cpp \ + Source/WebCore/platform/ScrollableArea.h \ Source/WebCore/platform/Scrollbar.cpp \ Source/WebCore/platform/Scrollbar.h \ Source/WebCore/platform/ScrollbarThemeComposite.cpp \ diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in index a3132f5..250b629 100644 --- a/Source/WebCore/WebCore.exp.in +++ b/Source/WebCore/WebCore.exp.in @@ -163,7 +163,7 @@ __ZN7WebCore11FrameLoader11shouldCloseEv __ZN7WebCore11FrameLoader11urlSelectedERKNS_4KURLERKN3WTF6StringENS4_10PassRefPtrINS_5EventEEEbbNS_14ReferrerPolicyE __ZN7WebCore11FrameLoader12shouldReloadERKNS_4KURLES3_ __ZN7WebCore11FrameLoader14detachChildrenEv -__ZN7WebCore11FrameLoader14stopAllLoadersENS_14DatabasePolicyE +__ZN7WebCore11FrameLoader14stopAllLoadersENS_14DatabasePolicyENS_26ClearProvisionalItemPolicyE __ZN7WebCore11FrameLoader16detachFromParentEv __ZN7WebCore11FrameLoader16loadFrameRequestERKNS_16FrameLoadRequestEbbN3WTF10PassRefPtrINS_5EventEEENS5_INS_9FormStateEEENS_14ReferrerPolicyE __ZN7WebCore11FrameLoader17stopForUserCancelEb @@ -545,7 +545,6 @@ __ZN7WebCore24createFragmentFromMarkupEPNS_8DocumentERKN3WTF6StringES5_NS_27Frag __ZN7WebCore24decodeURLEscapeSequencesERKN3WTF6StringE __ZN7WebCore24fileSystemRepresentationERKN3WTF6StringE __ZN7WebCore24notifyHistoryItemChangedE -__ZN7WebCore24rangeCompliantEquivalentERKNS_8PositionE __ZN7WebCore25HistoryPropertyListWriter11releaseDataEv __ZN7WebCore25HistoryPropertyListWriter12writeObjectsERNS_30BinaryPropertyListObjectStreamE __ZN7WebCore25HistoryPropertyListWriter16writeHistoryItemERNS_30BinaryPropertyListObjectStreamEPNS_11HistoryItemE @@ -782,6 +781,7 @@ __ZN7WebCore8GradientC1ERKNS_10FloatPointES3_ __ZN7WebCore8IntPointC1ERK8_NSPoint __ZN7WebCore8PositionC1EN3WTF10PassRefPtrINS_4NodeEEEi __ZN7WebCore8Settings14setJavaEnabledEb +__ZN7WebCore8Settings18setWebAudioEnabledEb __ZN7WebCore8Settings15setWebGLEnabledEb __ZN7WebCore8Settings16setUsesPageCacheEb __ZN7WebCore8Settings17setPluginsEnabledEb @@ -875,7 +875,7 @@ __ZN7WebCore9FrameView23updateCanHaveScrollbarsEv __ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeEfNS_5Frame19AdjustViewSizeOrNotE __ZN7WebCore9FrameView26adjustPageHeightDeprecatedEPffff __ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb -__ZN7WebCore9FrameView29syncCompositingStateRecursiveEv +__ZN7WebCore9FrameView38syncCompositingStateIncludingSubframesEv __ZN7WebCore9FrameView37updateLayoutAndStyleIfNeededRecursiveEv __ZN7WebCore9FrameView38scrollPositionChangedViaPlatformWidgetEv __ZN7WebCore9FrameView6createEPNS_5FrameE @@ -1195,6 +1195,7 @@ __ZNK7WebCore8Document6domainEv __ZNK7WebCore8IntPointcv7CGPointEv __ZNK7WebCore8IntPointcv8_NSPointEv __ZNK7WebCore8Position10downstreamENS_27EditingBoundaryCrossingRuleE +__ZNK7WebCore8Position24parentAnchoredEquivalentEv __ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb __ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb __ZNK7WebCore8Position8upstreamENS_27EditingBoundaryCrossingRuleE @@ -1288,6 +1289,8 @@ _wkSignalCFReadStreamHasBytes _wkCreateCTTypesetterWithUniCharProviderAndOptions _wkIOSurfaceContextCreate _wkIOSurfaceContextCreateImage +_wkMakeScrollbarPainter +_wkScrollbarPainterPaint #endif #if ENABLE(3D_RENDERING) diff --git a/Source/WebCore/WebCore.gyp/WebCore.gyp b/Source/WebCore/WebCore.gyp/WebCore.gyp index 34066f7..f96753c 100644 --- a/Source/WebCore/WebCore.gyp/WebCore.gyp +++ b/Source/WebCore/WebCore.gyp/WebCore.gyp @@ -185,6 +185,7 @@ '../svg/graphics', '../svg/graphics/filters', '../svg/properties', + '../thirdparty/glu', '../webaudio', '../websockets', '../workers', @@ -1117,6 +1118,8 @@ # Use LinkHashChromium.cpp instead ['exclude', 'platform/LinkHash\\.cpp$'], + + ['include', 'thirdparty/glu/libtess/'], ], 'conditions': [ ['OS=="linux" or OS=="freebsd"', { @@ -1133,6 +1136,10 @@ '<(chromium_src_dir)/third_party/harfbuzz/harfbuzz.gyp:harfbuzz', ], }], + ['OS=="linux" and target_arch=="arm"', { + # Due to a bug in gcc arm, we get warnings about uninitialized timesNewRoman.unstatic.3258 + 'cflags': ['-Wno-uninitialized'], + }], ['OS=="mac"', { # Necessary for Mac .mm stuff. 'include_dirs': [ @@ -1173,9 +1180,7 @@ ['include', 'platform/(graphics/)?mac/[^/]*Font[^/]*\\.(cpp|mm?)$'], ['include', 'platform/graphics/mac/ComplexText[^/]*\\.(cpp|h)$'], - # AudioBusMac is necessary for web audio API bringup on Chrome. - # It will later be replaced with chromium-specific code. - ['include', 'platform/audio/mac/AudioBusMac\\.mm$'], + # We can use this for the fast Accelerate.framework FFT. ['include', 'platform/audio/mac/FFTFrameMac\\.cpp$'], # Cherry-pick some files that can't be included by broader regexps. diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index f4a239f..ca52804 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -75,6 +75,7 @@ 'dom/ProgressEvent.idl', 'dom/Range.idl', 'dom/RangeException.idl', + 'dom/RequestAnimationFrameCallback.idl', 'dom/Text.idl', 'dom/TextEvent.idl', 'dom/Touch.idl', @@ -160,6 +161,7 @@ 'html/HTMLImageElement.idl', 'html/HTMLInputElement.idl', 'html/HTMLIsIndexElement.idl', + 'html/HTMLKeygenElement.idl', 'html/HTMLLIElement.idl', 'html/HTMLLabelElement.idl', 'html/HTMLLegendElement.idl', @@ -214,6 +216,7 @@ 'html/canvas/Int16Array.idl', 'html/canvas/Int32Array.idl', 'html/canvas/Int8Array.idl', + 'html/canvas/OESStandardDerivatives.idl', 'html/canvas/OESTextureFloat.idl', 'html/canvas/Uint16Array.idl', 'html/canvas/Uint32Array.idl', @@ -625,6 +628,8 @@ 'bindings/js/JSElementCustom.cpp', 'bindings/js/JSEntryCustom.cpp', 'bindings/js/JSEntrySyncCustom.cpp', + 'bindings/js/JSErrorHandler.cpp', + 'bindings/js/JSErrorHandler.h', 'bindings/js/JSEventCustom.cpp', 'bindings/js/JSEventListener.cpp', 'bindings/js/JSEventListener.h', @@ -722,8 +727,6 @@ 'bindings/js/JSWorkerContextBase.cpp', 'bindings/js/JSWorkerContextBase.h', 'bindings/js/JSWorkerContextCustom.cpp', - 'bindings/js/JSWorkerContextErrorHandler.cpp', - 'bindings/js/JSWorkerContextErrorHandler.h', 'bindings/js/JSWorkerCustom.cpp', 'bindings/js/JSXMLHttpRequestCustom.cpp', 'bindings/js/JSXMLHttpRequestUploadCustom.cpp', @@ -948,8 +951,6 @@ 'bindings/v8/V8Binding.h', 'bindings/v8/V8Collection.cpp', 'bindings/v8/V8Collection.h', - 'bindings/v8/V8ConsoleMessage.cpp', - 'bindings/v8/V8ConsoleMessage.h', 'bindings/v8/V8DataGridDataSource.cpp', 'bindings/v8/V8DataGridDataSource.h', 'bindings/v8/V8DOMMap.cpp', @@ -984,6 +985,8 @@ 'bindings/v8/V8Proxy.h', 'bindings/v8/V8Utilities.cpp', 'bindings/v8/V8Utilities.h', + 'bindings/v8/V8WindowErrorHandler.cpp', + 'bindings/v8/V8WindowErrorHandler.h', 'bindings/v8/V8WorkerContextErrorHandler.cpp', 'bindings/v8/V8WorkerContextErrorHandler.h', 'bindings/v8/V8WorkerContextEventListener.cpp', @@ -1315,6 +1318,7 @@ 'dom/Range.h', 'dom/RangeBoundaryPoint.h', 'dom/RangeException.h', + 'dom/RequestAnimationFrameCallback.h', 'dom/RawDataDocumentParser.h', 'dom/RegisteredEventListener.cpp', 'dom/RegisteredEventListener.h', @@ -1348,6 +1352,7 @@ 'dom/Text.h', 'dom/TextEvent.cpp', 'dom/TextEvent.h', + 'dom/TextEventInputType.h', 'dom/Touch.cpp', 'dom/Touch.h', 'dom/TouchEvent.cpp', @@ -1916,6 +1921,8 @@ 'html/canvas/Int8Array.cpp', 'html/canvas/Int8Array.h', 'html/canvas/IntegralTypedArrayBase.h', + 'html/canvas/OESStandardDerivatives.cpp', + 'html/canvas/OESStandardDerivatives.h', 'html/canvas/OESTextureFloat.cpp', 'html/canvas/OESTextureFloat.h', 'html/canvas/TypedArrayBase.h', @@ -2034,6 +2041,8 @@ 'inspector/InspectorProfilerAgent.h', 'inspector/InspectorResourceAgent.cpp', 'inspector/InspectorResourceAgent.h', + 'inspector/InspectorRuntimeAgent.cpp', + 'inspector/InspectorRuntimeAgent.h', 'inspector/InspectorState.cpp', 'inspector/InspectorSettings.h', 'inspector/InspectorSettings.cpp', @@ -2396,6 +2405,7 @@ 'platform/audio/FFTConvolver.cpp', 'platform/audio/FFTFrame.h', 'platform/audio/FFTFrame.cpp', + 'platform/audio/FFTFrameStub.cpp', 'platform/audio/HRTFDatabase.h', 'platform/audio/HRTFDatabase.cpp', 'platform/audio/HRTFDatabaseLoader.h', @@ -2437,7 +2447,6 @@ 'platform/cf/SchedulePair.cpp', 'platform/cf/SchedulePair.h', 'platform/cf/SharedBufferCF.cpp', - 'platform/chromium/ChromiumBridge.h', 'platform/chromium/ChromiumDataObject.cpp', 'platform/chromium/ChromiumDataObject.h', 'platform/chromium/ChromiumDataObjectLegacy.cpp', @@ -2474,6 +2483,7 @@ 'platform/chromium/MIMETypeRegistryChromium.cpp', 'platform/chromium/PasteboardChromium.cpp', 'platform/chromium/PasteboardPrivate.h', + 'platform/chromium/PlatformBridge.h', 'platform/chromium/PlatformCursor.h', 'platform/chromium/PlatformKeyboardEventChromium.cpp', 'platform/chromium/PlatformScreenChromium.cpp', @@ -2942,6 +2952,8 @@ 'platform/graphics/PathTraversalState.h', 'platform/graphics/Pattern.cpp', 'platform/graphics/Pattern.h', + 'platform/graphics/RoundedIntRect.cpp', + 'platform/graphics/RoundedIntRect.h', 'platform/graphics/SegmentedFontData.cpp', 'platform/graphics/SegmentedFontData.h', 'platform/graphics/SimpleFontData.cpp', @@ -3501,10 +3513,10 @@ 'platform/ScrollView.h', 'platform/SchemeRegistry.cpp', 'platform/SchemeRegistry.h', + 'platform/ScrollableArea.cpp', + 'platform/ScrollableArea.h', 'platform/Scrollbar.cpp', 'platform/Scrollbar.h', - 'platform/ScrollbarClient.cpp', - 'platform/ScrollbarClient.h', 'platform/ScrollbarTheme.h', 'platform/ScrollbarThemeComposite.cpp', 'platform/ScrollbarThemeComposite.h', @@ -4433,6 +4445,29 @@ 'svg/SVGZoomAndPan.h', 'svg/SVGZoomEvent.cpp', 'svg/SVGZoomEvent.h', + 'thirdparty/glu/libtess/dict.h', + 'thirdparty/glu/libtess/dict-list.h', + 'thirdparty/glu/libtess/geom.h', + 'thirdparty/glu/libtess/memalloc.h', + 'thirdparty/glu/libtess/mesh.h', + 'thirdparty/glu/libtess/normal.h', + 'thirdparty/glu/libtess/priorityq-heap.h', + 'thirdparty/glu/libtess/priorityq-sort.h', + 'thirdparty/glu/libtess/priorityq.h', + 'thirdparty/glu/libtess/render.h', + 'thirdparty/glu/libtess/sweep.h', + 'thirdparty/glu/libtess/tess.h', + 'thirdparty/glu/libtess/tessmono.h', + 'thirdparty/glu/libtess/dict.c', + 'thirdparty/glu/libtess/geom.c', + 'thirdparty/glu/libtess/memalloc.c', + 'thirdparty/glu/libtess/mesh.c', + 'thirdparty/glu/libtess/normal.c', + 'thirdparty/glu/libtess/priorityq.c', + 'thirdparty/glu/libtess/render.c', + 'thirdparty/glu/libtess/sweep.c', + 'thirdparty/glu/libtess/tess.c', + 'thirdparty/glu/libtess/tessmono.c', 'webaudio/AudioBasicProcessorNode.cpp', 'webaudio/AudioBasicProcessorNode.h', 'webaudio/AudioBuffer.h', @@ -4617,6 +4652,7 @@ 'inspector/front-end/CookieParser.js', 'inspector/front-end/CookiesTable.js', 'inspector/front-end/CSSCompletions.js', + 'inspector/front-end/CSSKeywordCompletions.js', 'inspector/front-end/CSSStyleModel.js', 'inspector/front-end/Database.js', 'inspector/front-end/DatabaseQueryView.js', @@ -4646,7 +4682,6 @@ 'inspector/front-end/ImageView.js', 'inspector/front-end/InspectorFrontendHostStub.js', 'inspector/front-end/InjectedFakeWorker.js', - 'inspector/front-end/InjectedScriptAccess.js', 'inspector/front-end/inspector.js', 'inspector/front-end/KeyboardShortcut.js', 'inspector/front-end/MetricsSidebarPane.js', @@ -4675,6 +4710,8 @@ 'inspector/front-end/ResourcesPanel.js', 'inspector/front-end/ScopeChainSidebarPane.js', 'inspector/front-end/Script.js', + 'inspector/front-end/ScriptFormatter.js', + 'inspector/front-end/ScriptFormatterWorker.js', 'inspector/front-end/ScriptsPanel.js', 'inspector/front-end/ScriptView.js', 'inspector/front-end/ShortcutsHelp.js', @@ -4708,6 +4745,8 @@ 'inspector/front-end/WatchExpressionsSidebarPane.js', 'inspector/front-end/WelcomeView.js', 'inspector/front-end/WorkersSidebarPane.js', + 'inspector/front-end/UglifyJS/parse-js.js', + 'inspector/front-end/UglifyJS/process.js', 'inspector/front-end/audits.css', 'inspector/front-end/goToLineDialog.css', 'inspector/front-end/heapProfiler.css', diff --git a/Source/WebCore/WebCore.order b/Source/WebCore/WebCore.order index e88c444..136a34d 100644 --- a/Source/WebCore/WebCore.order +++ b/Source/WebCore/WebCore.order @@ -25208,13 +25208,9 @@ __ZN7WebCore15JSWorkerContext10setTimeoutEPN3JSC9ExecStateERKNS1_7ArgListE __ZN7WebCore13WorkerContext10setTimeoutEPNS_15ScheduledActionEi __ZN7WebCore17WorkerSharedTimer11setFireTimeEd __ZN7WebCore15ScheduledAction7executeEPNS_13WorkerContextE -__ZN7WebCore27JSWorkerContextErrorHandlerC1EPN3JSC8JSObjectES3_bPNS_15DOMWrapperWorldE -__ZN7WebCore27JSWorkerContextErrorHandlerC2EPN3JSC8JSObjectES3_bPNS_15DOMWrapperWorldE __ZN7WebCore10ErrorEventC1ERKNS_6StringES3_j __ZN7WebCore10ErrorEventC2ERKNS_6StringES3_j -__ZN7WebCore27JSWorkerContextErrorHandler11handleEventEPNS_22ScriptExecutionContextEPNS_5EventE __ZN7WebCore10ErrorEventD0Ev -__ZN7WebCore27JSWorkerContextErrorHandlerD0Ev __ZN7WebCore17jsWorkerOnmessageEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE __ZN7WebCore34jsWorkerPrototypeFunctionTerminateEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgListE __ZThn8_N7WebCore20WorkerMessagingProxy19workerContextClosedEv diff --git a/Source/WebCore/WebCore.pri b/Source/WebCore/WebCore.pri index 736d534..ad1835f 100644 --- a/Source/WebCore/WebCore.pri +++ b/Source/WebCore/WebCore.pri @@ -193,6 +193,7 @@ IDL_BINDINGS += \ html/canvas/CanvasPattern.idl \ html/canvas/CanvasRenderingContext.idl \ html/canvas/CanvasRenderingContext2D.idl \ + html/canvas/OESStandardDerivatives.idl \ html/canvas/OESTextureFloat.idl \ html/canvas/WebGLActiveInfo.idl \ html/canvas/WebGLBuffer.idl \ @@ -253,6 +254,7 @@ IDL_BINDINGS += \ html/HTMLImageElement.idl \ html/HTMLInputElement.idl \ html/HTMLIsIndexElement.idl \ + html/HTMLKeygenElement.idl \ html/HTMLLabelElement.idl \ html/HTMLLegendElement.idl \ html/HTMLLIElement.idl \ @@ -747,10 +749,10 @@ addExtraCompiler(xpathbison) # GENERATOR 11: WebKit Version # The appropriate Apple-maintained Version.xcconfig file for WebKit version information is in Source/WebKit/mac/Configurations/. -webkitversion.wkScript = $$PWD/../../Source/WebKit/scripts/generate-webkitversion.pl +webkitversion.wkScript = $$PWD/../WebKit/scripts/generate-webkitversion.pl webkitversion.output = $${WC_GENERATED_SOURCES_DIR}/WebKitVersion.h webkitversion.input = webkitversion.wkScript -webkitversion.commands = perl $$webkitversion.wkScript --config $$PWD/../../Source/WebKit/mac/Configurations/Version.xcconfig --outputDir $${WC_GENERATED_SOURCES_DIR}/ +webkitversion.commands = perl $$webkitversion.wkScript --config $$PWD/../WebKit/mac/Configurations/Version.xcconfig --outputDir $${WC_GENERATED_SOURCES_DIR}/ webkitversion.clean = ${QMAKE_VAR_WC_GENERATED_SOURCES_DIR}/WebKitVersion.h webkitversion.wkAddOutputToSources = false addExtraCompiler(webkitversion) diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro index d37cdc7..7b953f3 100644 --- a/Source/WebCore/WebCore.pro +++ b/Source/WebCore/WebCore.pro @@ -52,12 +52,12 @@ symbian: { " " webkitlibs.pkg_prerules = vendorinfo - webkitbackup.sources = ../../Source/WebKit/qt/symbian/backup_registration.xml + webkitbackup.sources = ../WebKit/qt/symbian/backup_registration.xml webkitbackup.path = /private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) contains(QT_CONFIG, declarative) { declarativeImport.sources = $$QT_BUILD_TREE/imports/QtWebKit/qmlwebkitplugin$${QT_LIBINFIX}.dll - declarativeImport.sources += ../../Source/WebKit/qt/declarative/qmldir + declarativeImport.sources += ../WebKit/qt/declarative/qmldir declarativeImport.path = c:$$QT_IMPORTS_BASE_DIR/QtWebKit DEPLOYMENT += declarativeImport } @@ -90,7 +90,7 @@ CONFIG(standalone_package) { isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/generated isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = $$PWD/../JavaScriptCore/generated - PRECOMPILED_HEADER = $$PWD/../../Source/WebKit/qt/WebKit_pch.h + PRECOMPILED_HEADER = $$PWD/../WebKit/qt/WebKit_pch.h } else { isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = generated isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = ../JavaScriptCore/generated @@ -110,7 +110,7 @@ CONFIG(QTDIR_build) { !static: DEFINES += QT_MAKEDLL symbian: TARGET =$$TARGET$${QT_LIBINFIX} } -moduleFile=$$PWD/../../Source/WebKit/qt/qt_webkit_version.pri +moduleFile=$$PWD/../WebKit/qt/qt_webkit_version.pri isEmpty(QT_BUILD_TREE):include($$moduleFile) VERSION = $${QT_WEBKIT_MAJOR_VERSION}.$${QT_WEBKIT_MINOR_VERSION}.$${QT_WEBKIT_PATCH_VERSION} @@ -181,8 +181,8 @@ include($$PWD/../JavaScriptCore/JavaScriptCore.pri) !v8: addJavaScriptCoreLib(../JavaScriptCore) webkit2 { - include($$PWD/../../Source/WebKit2/WebKit2.pri) - addWebKit2LibWholeArchive(../../Source/WebKit2) + include($$PWD/../WebKit2/WebKit2.pri) + addWebKit2LibWholeArchive(../WebKit2) } # Extract sources to build from the generator definitions @@ -285,8 +285,8 @@ WEBCORE_INCLUDEPATH = \ $$PWD/platform/graphics/qt \ $$PWD/platform/network/qt \ $$PWD/platform/qt \ - $$PWD/../../Source/WebKit/qt/Api \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport \ + $$PWD/../WebKit/qt/Api \ + $$PWD/../WebKit/qt/WebCoreSupport \ $$WEBCORE_INCLUDEPATH symbian { @@ -390,7 +390,6 @@ v8 { bindings/v8/V8AbstractEventListener.cpp \ bindings/v8/V8Binding.cpp \ bindings/v8/V8Collection.cpp \ - bindings/v8/V8ConsoleMessage.cpp \ bindings/v8/V8DOMMap.cpp \ bindings/v8/V8DOMWrapper.cpp \ bindings/v8/V8DataGridDataSource.cpp \ @@ -407,6 +406,7 @@ v8 { bindings/v8/V8NodeFilterCondition.cpp \ bindings/v8/V8Proxy.cpp \ bindings/v8/V8Utilities.cpp \ + bindings/v8/V8WindowErrorHandler.cpp \ bindings/v8/V8WorkerContextEventListener.cpp \ bindings/v8/WorkerContextExecutionProxy.cpp \ bindings/v8/WorkerScriptController.cpp \ @@ -548,6 +548,7 @@ v8 { bindings/js/JSDeviceOrientationEventCustom.cpp \ bindings/js/JSDocumentCustom.cpp \ bindings/js/JSElementCustom.cpp \ + bindings/js/JSErrorHandler.cpp \ bindings/js/JSEventCustom.cpp \ bindings/js/JSEventListener.cpp \ bindings/js/JSEventSourceCustom.cpp \ @@ -606,7 +607,6 @@ v8 { bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp \ bindings/js/JSWebKitCSSMatrixCustom.cpp \ bindings/js/JSWebKitPointCustom.cpp \ - bindings/js/JSWorkerContextErrorHandler.cpp \ bindings/js/JSXMLHttpRequestCustom.cpp \ bindings/js/JSXMLHttpRequestUploadCustom.cpp \ bindings/js/ScheduledAction.cpp \ @@ -1060,6 +1060,7 @@ SOURCES += \ inspector/InspectorInstrumentation.cpp \ inspector/InspectorProfilerAgent.cpp \ inspector/InspectorResourceAgent.cpp \ + inspector/InspectorRuntimeAgent.cpp \ inspector/InspectorSettings.cpp \ inspector/InspectorState.cpp \ inspector/InspectorStyleSheet.cpp \ @@ -1210,6 +1211,7 @@ SOURCES += \ platform/graphics/Path.cpp \ platform/graphics/PathTraversalState.cpp \ platform/graphics/Pattern.cpp \ + platform/graphics/RoundedIntRect.cpp \ platform/graphics/SegmentedFontData.cpp \ platform/graphics/SimpleFontData.cpp \ platform/graphics/TiledBackingStore.cpp \ @@ -1253,9 +1255,9 @@ SOURCES += \ platform/network/ResourceResponseBase.cpp \ platform/text/RegularExpression.cpp \ platform/SchemeRegistry.cpp \ + platform/ScrollableArea.cpp \ platform/ScrollAnimator.cpp \ platform/Scrollbar.cpp \ - platform/ScrollbarClient.cpp \ platform/ScrollbarThemeComposite.cpp \ platform/ScrollView.cpp \ platform/text/SegmentedString.cpp \ @@ -1463,7 +1465,6 @@ v8 { bindings/v8/V8AbstractEventListener.h \ bindings/v8/V8Binding.h \ bindings/v8/V8Collection.h \ - bindings/v8/V8ConsoleMessage.h \ bindings/v8/V8DataGridDataSource.h \ bindings/v8/V8DOMMap.h \ bindings/v8/V8DOMWindowShell.h \ @@ -1480,6 +1481,7 @@ v8 { bindings/v8/V8NPUtils.h \ bindings/v8/V8Proxy.h \ bindings/v8/V8Utilities.h \ + bindings/v8/V8WindowErrorHandler.h \ bindings/v8/V8WorkerContextEventListener.h \ bindings/v8/WorkerContextExecutionProxy.h \ bindings/v8/WorkerScriptController.h \ @@ -1506,6 +1508,7 @@ v8 { bindings/js/JSDOMWindowCustom.h \ bindings/js/JSDOMWindowShell.h \ bindings/js/JSDOMWrapper.h \ + bindings/js/JSErrorHandler.h \ bindings/js/JSEventListener.h \ bindings/js/JSEventTarget.h \ bindings/js/JSHistoryCustom.h \ @@ -1523,7 +1526,6 @@ v8 { bindings/js/JSPluginElementFunctions.h \ bindings/js/JSStorageCustom.h \ bindings/js/JSWorkerContextBase.h \ - bindings/js/JSWorkerContextErrorHandler.h \ bindings/js/JavaScriptCallFrame.h \ bindings/js/ScheduledAction.h \ bindings/js/ScriptCachedFrameData.h \ @@ -1713,6 +1715,7 @@ HEADERS += \ dom/StyleElement.h \ dom/TagNodeList.h \ dom/TextEvent.h \ + dom/TextEventInputType.h \ dom/Text.h \ dom/Touch.h \ dom/TouchEvent.h \ @@ -1954,6 +1957,7 @@ HEADERS += \ inspector/InspectorInstrumentation.h \ inspector/InspectorProfilerAgent.h \ inspector/InspectorResourceAgent.h \ + inspector/InspectorRuntimeAgent.h \ inspector/InspectorSettings.h \ inspector/InspectorState.h \ inspector/InspectorStyleSheet.h \ @@ -2129,6 +2133,7 @@ HEADERS += \ platform/graphics/Path.h \ platform/graphics/PathTraversalState.h \ platform/graphics/Pattern.h \ + platform/graphics/RoundedIntRect.h \ platform/graphics/qt/FontCustomPlatformData.h \ platform/graphics/qt/ImageDecoderQt.h \ platform/graphics/qt/StillImageQt.h \ @@ -2189,9 +2194,9 @@ HEADERS += \ platform/qt/QtStyleOptionWebComboBox.h \ platform/qt/RenderThemeQt.h \ platform/qt/ScrollbarThemeQt.h \ + platform/ScrollableArea.h \ platform/ScrollAnimator.h \ platform/Scrollbar.h \ - platform/ScrollbarClient.h \ platform/ScrollbarThemeComposite.h \ platform/ScrollView.h \ platform/SearchPopupMenu.h \ @@ -2655,18 +2660,18 @@ HEADERS += \ xml/XSLTExtensions.h \ xml/XSLTProcessor.h \ xml/XSLTUnicodeSort.h \ - $$PWD/../../Source/WebKit/qt/Api/qwebplugindatabase_p.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/InspectorServerQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/PageClientQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/PopupMenuQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h \ + $$PWD/../WebKit/qt/Api/qwebplugindatabase_p.h \ + $$PWD/../WebKit/qt/WebCoreSupport/InspectorServerQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h \ + $$PWD/../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/PageClientQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/QtPlatformPlugin.h \ + $$PWD/../WebKit/qt/WebCoreSupport/PopupMenuQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h \ + $$PWD/../WebKit/qt/WebCoreSupport/WebPlatformStrategies.h \ $$PWD/platform/network/qt/DnsPrefetchHelper.h v8 { @@ -2754,39 +2759,39 @@ SOURCES += \ platform/text/qt/TextCodecQt.cpp \ platform/qt/WheelEventQt.cpp \ platform/qt/WidgetQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/DragClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/EditCommandQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/PopupMenuQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp \ - ../../Source/WebKit/qt/Api/qwebframe.cpp \ - ../../Source/WebKit/qt/Api/qgraphicswebview.cpp \ - ../../Source/WebKit/qt/Api/qwebpage.cpp \ - ../../Source/WebKit/qt/Api/qwebview.cpp \ - ../../Source/WebKit/qt/Api/qwebelement.cpp \ - ../../Source/WebKit/qt/Api/qwebhistory.cpp \ - ../../Source/WebKit/qt/Api/qwebsettings.cpp \ - ../../Source/WebKit/qt/Api/qwebhistoryinterface.cpp \ - ../../Source/WebKit/qt/Api/qwebplugindatabase.cpp \ - ../../Source/WebKit/qt/Api/qwebpluginfactory.cpp \ - ../../Source/WebKit/qt/Api/qwebsecurityorigin.cpp \ - ../../Source/WebKit/qt/Api/qwebscriptworld.cpp \ - ../../Source/WebKit/qt/Api/qwebdatabase.cpp \ - ../../Source/WebKit/qt/Api/qwebinspector.cpp \ - ../../Source/WebKit/qt/Api/qwebkitversion.cpp + ../WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp \ + ../WebKit/qt/WebCoreSupport/ChromeClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/DragClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp \ + ../WebKit/qt/WebCoreSupport/EditorClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/EditCommandQt.cpp \ + ../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp \ + ../WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/InspectorClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/InspectorServerQt.cpp \ + ../WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/PageClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/PopupMenuQt.cpp \ + ../WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp \ + ../WebKit/qt/WebCoreSupport/SearchPopupMenuQt.cpp \ + ../WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp \ + ../WebKit/qt/Api/qwebframe.cpp \ + ../WebKit/qt/Api/qgraphicswebview.cpp \ + ../WebKit/qt/Api/qwebpage.cpp \ + ../WebKit/qt/Api/qwebview.cpp \ + ../WebKit/qt/Api/qwebelement.cpp \ + ../WebKit/qt/Api/qwebhistory.cpp \ + ../WebKit/qt/Api/qwebsettings.cpp \ + ../WebKit/qt/Api/qwebhistoryinterface.cpp \ + ../WebKit/qt/Api/qwebplugindatabase.cpp \ + ../WebKit/qt/Api/qwebpluginfactory.cpp \ + ../WebKit/qt/Api/qwebsecurityorigin.cpp \ + ../WebKit/qt/Api/qwebscriptworld.cpp \ + ../WebKit/qt/Api/qwebdatabase.cpp \ + ../WebKit/qt/Api/qwebinspector.cpp \ + ../WebKit/qt/Api/qwebkitversion.cpp contains(DEFINES, WTF_USE_QT_MOBILE_THEME=1) { HEADERS += platform/qt/QtMobileWebStyle.h @@ -2794,8 +2799,8 @@ contains(DEFINES, WTF_USE_QT_MOBILE_THEME=1) { } maemo5 { - HEADERS += ../../Source/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.h - SOURCES += ../../Source/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.cpp + HEADERS += ../WebKit/qt/WebCoreSupport/QtMaemoWebPopup.h + SOURCES += ../WebKit/qt/WebCoreSupport/QtMaemoWebPopup.cpp } contains(DEFINES, ENABLE_SMOOTH_SCROLLING=1) { @@ -3259,11 +3264,11 @@ contains(DEFINES, ENABLE_VIDEO=1) { } else:contains(MOBILITY_CONFIG, multimedia) { HEADERS += \ platform/graphics/qt/MediaPlayerPrivateQt.h \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h + $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoQt.h SOURCES += \ platform/graphics/qt/MediaPlayerPrivateQt.cpp \ - $$PWD/../../Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp + $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp CONFIG *= mobility MOBILITY += multimedia @@ -3449,18 +3454,18 @@ contains(DEFINES, ENABLE_GEOLOCATION=1) { contains(DEFINES, ENABLE_DEVICE_ORIENTATION=1) { HEADERS += \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceMotionClientQt.h \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceMotionProviderQt.h \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceOrientationClientQt.h \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.h \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.h + ../WebKit/qt/WebCoreSupport/DeviceMotionClientQt.h \ + ../WebKit/qt/WebCoreSupport/DeviceMotionProviderQt.h \ + ../WebKit/qt/WebCoreSupport/DeviceOrientationClientQt.h \ + ../WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.h \ + ../WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.h SOURCES += \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceMotionClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceMotionProviderQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceOrientationClientQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.cpp \ - ../../Source/WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.cpp + ../WebKit/qt/WebCoreSupport/DeviceMotionClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/DeviceMotionProviderQt.cpp \ + ../WebKit/qt/WebCoreSupport/DeviceOrientationClientQt.cpp \ + ../WebKit/qt/WebCoreSupport/DeviceOrientationClientMockQt.cpp \ + ../WebKit/qt/WebCoreSupport/DeviceOrientationProviderQt.cpp CONFIG += mobility MOBILITY += sensors @@ -3805,6 +3810,7 @@ contains(DEFINES, ENABLE_3D_CANVAS=1) { html/canvas/WebGLRenderbuffer.h \ html/canvas/WebGLRenderingContext.h \ html/canvas/WebGLShader.h \ + html/canvas/OESStandardDerivatives.h \ html/canvas/OESTextureFloat.h \ html/canvas/WebGLTexture.h \ html/canvas/WebGLUniformLocation.h \ @@ -3829,6 +3835,7 @@ contains(DEFINES, ENABLE_3D_CANVAS=1) { html/canvas/WebGLRenderbuffer.cpp \ html/canvas/WebGLRenderingContext.cpp \ html/canvas/WebGLShader.cpp \ + html/canvas/OESStandardDerivatives.cpp \ html/canvas/OESTextureFloat.cpp \ html/canvas/WebGLTexture.cpp \ html/canvas/WebGLUniformLocation.cpp \ @@ -3865,7 +3872,7 @@ contains(DEFINES, ENABLE_SYMBIAN_DIALOG_PROVIDERS) { QMAKE_EXTRA_TARGETS += install } -include($$PWD/../../Source/WebKit/qt/Api/headers.pri) +include($$PWD/../WebKit/qt/Api/headers.pri) HEADERS += $$WEBKIT_API_HEADERS @@ -3993,9 +4000,9 @@ contains(CONFIG, texmap) { symbian { shared { contains(CONFIG, def_files) { - DEF_FILE=../../Source/WebKit/qt/symbian + DEF_FILE=../WebKit/qt/symbian # defFilePath is for Qt4.6 compatibility - defFilePath=../../Source/WebKit/qt/symbian + defFilePath=../WebKit/qt/symbian } else { MMP_RULES += EXPORTUNFROZEN } diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj index 39671a0..f1da922 100755 --- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj @@ -558,6 +558,10 @@ > </File> <File + RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\InjectedScriptSource.h" + > + </File> + <File RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\InspectorBackendDispatcher.cpp" > </File> @@ -574,10 +578,6 @@ > </File> <File - RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\InjectedScriptSource.h" - > - </File> - <File RelativePath="$(ConfigurationBuildDir)\obj\WebCore\DerivedSources\JSAbstractWorker.cpp" > <FileConfiguration @@ -7726,6 +7726,62 @@ > </File> <File + RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSHTMLKeygenElement.cpp" + > + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug_All|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_LTCG|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + </File> + <File + RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSHTMLKeygenElement.h" + > + </File> + <File RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSHTMLLabelElement.cpp" > <FileConfiguration @@ -24842,10 +24898,6 @@ Name="loader" > <File - RelativePath="..\loader\ResourceLoadScheduler.h" - > - </File> - <File RelativePath="..\loader\CrossOriginAccessControl.cpp" > </File> @@ -25074,6 +25126,10 @@ > </File> <File + RelativePath="..\loader\ResourceLoadScheduler.h" + > + </File> + <File RelativePath="..\loader\SinkDocument.cpp" > </File> @@ -25421,7 +25477,7 @@ RelativePath="..\platform\ContentType.h" > </File> - <File + <File RelativePath="..\platform\ContextMenu.cpp" > </File> @@ -25429,7 +25485,7 @@ RelativePath="..\platform\ContextMenu.h" > </File> - <File + <File RelativePath="..\platform\ContextMenuItem.cpp" > </File> @@ -25698,19 +25754,19 @@ > </File> <File - RelativePath="..\platform\Scrollbar.cpp" + RelativePath="..\platform\ScrollableArea.cpp" > </File> <File - RelativePath="..\platform\Scrollbar.h" + RelativePath="..\platform\ScrollableArea.h" > </File> <File - RelativePath="..\platform\ScrollbarClient.cpp" + RelativePath="..\platform\Scrollbar.cpp" > </File> <File - RelativePath="..\platform\ScrollbarClient.h" + RelativePath="..\platform\Scrollbar.h" > </File> <File @@ -26693,6 +26749,14 @@ > </File> <File + RelativePath="..\platform\graphics\RoundedIntRect.cpp" + > + </File> + <File + RelativePath="..\platform\graphics\RoundedIntRect.h" + > + </File> + <File RelativePath="..\platform\graphics\SegmentedFontData.cpp" > </File> @@ -27332,86 +27396,6 @@ > </File> <File - RelativePath="..\platform\graphics\win\WKCACFContextFlusher.cpp" - > - <FileConfiguration - Name="Debug_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Release_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - </File> - <File - RelativePath="..\platform\graphics\win\WKCACFContextFlusher.h" - > - <FileConfiguration - Name="Debug_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCustomBuildTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Release_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCustomBuildTool" - /> - </FileConfiguration> - </File> - <File - RelativePath="..\platform\graphics\win\WKCACFLayerRenderer.cpp" - > - <FileConfiguration - Name="Debug_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Release_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - </File> - <File - RelativePath="..\platform\graphics\win\WKCACFLayerRenderer.h" - > - <FileConfiguration - Name="Debug_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCustomBuildTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Release_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCustomBuildTool" - /> - </FileConfiguration> - </File> - <File RelativePath="..\platform\graphics\win\WKCAImageQueue.cpp" > <FileConfiguration @@ -28871,6 +28855,86 @@ Name="win" > <File + RelativePath="..\platform\graphics\ca\win\CACFLayerTreeHost.cpp" + > + <FileConfiguration + Name="Debug_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + </File> + <File + RelativePath="..\platform\graphics\ca\win\CACFLayerTreeHost.h" + > + <FileConfiguration + Name="Debug_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCustomBuildTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCustomBuildTool" + /> + </FileConfiguration> + </File> + <File + RelativePath="..\platform\graphics\ca\win\LayerChangesFlusher.cpp" + > + <FileConfiguration + Name="Debug_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + </File> + <File + RelativePath="..\platform\graphics\ca\win\LayerChangesFlusher.h" + > + <FileConfiguration + Name="Debug_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCustomBuildTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCustomBuildTool" + /> + </FileConfiguration> + </File> + <File RelativePath="..\platform\graphics\ca\win\PlatformCAAnimationWin.cpp" > </File> @@ -28888,7 +28952,7 @@ </File> </Filter> </Filter> - </Filter> + </Filter> <Filter Name="network" > @@ -38464,88 +38528,88 @@ > </File> <Filter - Name="mathml" - > - <File - RelativePath="..\rendering\mathml\RenderMathMLBlock.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLBlock.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLFenced.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLFenced.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLFraction.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLFraction.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLMath.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLMath.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLOperator.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLOperator.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLRoot.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLRoot.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLRow.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLRow.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLSquareRoot.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLSquareRoot.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLSubSup.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLSubSup.h" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLUnderOver.cpp" - > - </File> - <File - RelativePath="..\rendering\mathml\RenderMathMLUnderOver.h" - > - </File> + Name="mathml" + > + <File + RelativePath="..\rendering\mathml\RenderMathMLBlock.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLBlock.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLFenced.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLFenced.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLFraction.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLFraction.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLMath.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLMath.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLOperator.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLOperator.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLRoot.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLRoot.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLRow.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLRow.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLSquareRoot.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLSquareRoot.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLSubSup.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLSubSup.h" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLUnderOver.cpp" + > + </File> + <File + RelativePath="..\rendering\mathml\RenderMathMLUnderOver.h" + > + </File> </Filter> <Filter Name="style" @@ -43633,7 +43697,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Debug_Cairo_CFLite|Win32" + Name="Debug_All|Win32" ExcludedFromBuild="true" > <Tool @@ -43641,7 +43705,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Release_Cairo_CFLite|Win32" + Name="Debug_Cairo_CFLite|Win32" ExcludedFromBuild="true" > <Tool @@ -43649,7 +43713,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Debug_All|Win32" + Name="Release_Cairo_CFLite|Win32" ExcludedFromBuild="true" > <Tool @@ -43657,7 +43721,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Release_LTCG|Win32" + Name="Debug_All|Win32" ExcludedFromBuild="true" > <Tool @@ -43670,7 +43734,7 @@ > </File> <File - RelativePath="..\dom\EventTarget.cpp" + RelativePath="..\dom\EventQueue.cpp" > <FileConfiguration Name="Debug|Win32" @@ -43705,7 +43769,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Debug_All|Win32" + Name="Release_LTCG|Win32" ExcludedFromBuild="true" > <Tool @@ -43725,8 +43789,8 @@ RelativePath="..\dom\EventTarget.h" > </File> - <File - RelativePath="..\dom\EventQueue.cpp" + <File + RelativePath="..\dom\EventTarget.cpp" > <FileConfiguration Name="Debug|Win32" @@ -46186,6 +46250,10 @@ > </File> <File + RelativePath="..\dom\TextEventInputType.h" + > + </File> + <File RelativePath="..\dom\TransformSource.h" > </File> @@ -58133,6 +58201,62 @@ > </File> <File + RelativePath="..\bindings\js\JSErrorHandler.cpp" + > + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_Cairo_CFLite|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug_All|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_LTCG|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> + </File> + <File + RelativePath="..\bindings\js\JSErrorHandler.h" + > + </File> + <File RelativePath="..\bindings\js\JSEventCustom.cpp" > <FileConfiguration @@ -61649,62 +61773,6 @@ </FileConfiguration> </File> <File - RelativePath="..\bindings\js\JSWorkerContextErrorHandler.cpp" - > - <FileConfiguration - Name="Debug|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Release_Cairo_CFLite|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Debug_All|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - <FileConfiguration - Name="Release_LTCG|Win32" - ExcludedFromBuild="true" - > - <Tool - Name="VCCLCompilerTool" - /> - </FileConfiguration> - </File> - <File - RelativePath="..\bindings\js\JSWorkerContextErrorHandler.h" - > - </File> - <File RelativePath="..\bindings\js\JSWorkerCustom.cpp" > <FileConfiguration @@ -65150,6 +65218,14 @@ > </File> <File + RelativePath="..\inspector\InspectorRuntimeAgent.cpp" + > + </File> + <File + RelativePath="..\inspector\InspectorRuntimeAgent.h" + > + </File> + <File RelativePath="..\inspector\InspectorSettings.cpp" > </File> @@ -65333,6 +65409,14 @@ > </File> <File + RelativePath="..\inspector\front-end\CSSCompletions.js" + > + </File> + <File + RelativePath="..\inspector\front-end\CSSKeywordCompletions.js" + > + </File> + <File RelativePath="..\inspector\front-end\CSSStyleModel.js" > </File> @@ -65457,10 +65541,6 @@ > </File> <File - RelativePath="..\inspector\front-end\InjectedScriptAccess.js" - > - </File> - <File RelativePath="..\inspector\front-end\inspector.css" > </File> @@ -65589,6 +65669,14 @@ > </File> <File + RelativePath="..\inspector\front-end\ScriptFormatter.js" + > + </File> + <File + RelativePath="..\inspector\front-end\scriptFormatterWorker.js" + > + </File> + <File RelativePath="..\inspector\front-end\ScriptsPanel.js" > </File> @@ -65724,6 +65812,14 @@ RelativePath="..\inspector\front-end\WorkersSidebarPane.js" > </File> + <File + RelativePath="..\inspector\front-end\UglifyJS\parse-js.js" + > + </File> + <File + RelativePath="..\inspector\front-end\UglifyJS\process.js" + > + </File> </Filter> </Filter> <Filter diff --git a/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops b/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops index a9866d9..48328c9 100644 --- a/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops +++ b/Source/WebCore/WebCore.vcproj/WebCoreQuartzCore.vsprops @@ -6,7 +6,7 @@ > <Tool Name="VCCLCompilerTool" - AdditionalIncludeDirectories=""$(DXSDK_DIR)\Include"" + AdditionalIncludeDirectories=""$(ProjectDir)\..\platform\graphics\ca\win";"$(DXSDK_DIR)\Include"" PreprocessorDefinitions="QUARTZCORE_DLL" /> </VisualStudioPropertySheet> diff --git a/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd b/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd index 7393d34..b3f19c6 100755 --- a/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd +++ b/Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd @@ -39,6 +39,7 @@ xcopy /y /d "%ProjectDir%..\platform\graphics\*.h" "%CONFIGURATIONBUILDDIR%\incl xcopy /y /d "%ProjectDir%..\platform\graphics\%1\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore" xcopy /y /d "%ProjectDir%..\platform\graphics\transforms\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore" xcopy /y /d "%ProjectDir%..\platform\graphics\ca\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore" +xcopy /y /d "%ProjectDir%..\platform\graphics\ca\win\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore" xcopy /y /d "%ProjectDir%..\platform\graphics\win\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore" xcopy /y /d "%ProjectDir%..\platform\graphics\win\%1\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore" xcopy /y /d "%ProjectDir%..\platform\graphics\opentype\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore" diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj index ed86c67..4f01530 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -1664,9 +1664,11 @@ 7A74ECBA101839A600BF939E /* InspectorDOMStorageAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECB8101839A500BF939E /* InspectorDOMStorageAgent.cpp */; }; 7A74ECBB101839A600BF939E /* InspectorDOMStorageAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A74ECB9101839A600BF939E /* InspectorDOMStorageAgent.h */; }; 7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */; }; + 7AA365EE12E7265400DCA242 /* InspectorRuntimeAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA365ED12E7265400DCA242 /* InspectorRuntimeAgent.cpp */; }; 7AB0B1C01211A62200A76940 /* InspectorDatabaseAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AB0B1BE1211A62200A76940 /* InspectorDatabaseAgent.cpp */; }; 7AB0B1C11211A62200A76940 /* InspectorDatabaseAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB0B1BF1211A62200A76940 /* InspectorDatabaseAgent.h */; }; 7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */; }; + 7AF11A5A12E727490061F23C /* InspectorRuntimeAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF11A5912E727490061F23C /* InspectorRuntimeAgent.h */; }; 7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; }; 7AFD4FF4113277B60035B883 /* ScriptDebugListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */; settings = {ATTRIBUTES = (Private, ); }; }; 7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E33CD00127F340D00BE8F17 /* PurgePriority.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -2758,6 +2760,11 @@ 8F67561B1288B17B0047ACA3 /* EventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 8F6756191288B17B0047ACA3 /* EventQueue.h */; }; 8F67561C1288B17B0047ACA3 /* EventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F67561A1288B17B0047ACA3 /* EventQueue.cpp */; }; 8FAC774D119872CB0015AE94 /* JSMainThreadExecState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */; }; + 9001774012E0347800648462 /* OESStandardDerivatives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9001773D12E0347800648462 /* OESStandardDerivatives.cpp */; }; + 9001774112E0347800648462 /* OESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001773E12E0347800648462 /* OESStandardDerivatives.h */; }; + 9001774212E0347800648462 /* OESStandardDerivatives.idl in Resources */ = {isa = PBXBuildFile; fileRef = 9001773F12E0347800648462 /* OESStandardDerivatives.idl */; }; + 9001788012E0370700648462 /* JSOESStandardDerivatives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */; }; + 9001788112E0370700648462 /* JSOESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001787F12E0370700648462 /* JSOESStandardDerivatives.h */; }; 9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */; }; 9302B0BF0D79F82C00C7EE83 /* PageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */; settings = {ATTRIBUTES = (Private, ); }; }; 9305B24D098F1B6B00C28855 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9305B24C098F1B6B00C28855 /* Timer.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -3157,12 +3164,19 @@ A59E3C1F11580F510072928E /* KeyEventIPhone.mm in Sources */ = {isa = PBXBuildFile; fileRef = A59E3C1D11580F510072928E /* KeyEventIPhone.mm */; }; A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; }; A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; }; + A6148A6212E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */; }; + A6148A6712E41D940044A784 /* DOMHTMLKeygenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */; }; + A6148A6812E41D940044A784 /* DOMHTMLKeygenElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = A6148A6612E41D940044A784 /* DOMHTMLKeygenElement.mm */; }; + A6148A7812E41E3B0044A784 /* JSHTMLKeygenElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A6148A7612E41E3B0044A784 /* JSHTMLKeygenElement.cpp */; }; + A6148A7912E41E3B0044A784 /* JSHTMLKeygenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A7712E41E3B0044A784 /* JSHTMLKeygenElement.h */; }; A622A8FB122C44A600A785B3 /* BindingSecurity.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F5122C44A600A785B3 /* BindingSecurity.h */; }; A622A8FC122C44A600A785B3 /* BindingSecurityBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */; }; A622A8FD122C44A600A785B3 /* BindingSecurityBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F7122C44A600A785B3 /* BindingSecurityBase.h */; }; A622A8FF122C44A600A785B3 /* GenericBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F9122C44A600A785B3 /* GenericBinding.h */; }; A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; }; A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */; }; + A73F95FE12C97BFE0031AAF9 /* RoundedIntRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73F95FC12C97BFE0031AAF9 /* RoundedIntRect.cpp */; }; + A73F95FF12C97BFE0031AAF9 /* RoundedIntRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A73F95FD12C97BFE0031AAF9 /* RoundedIntRect.h */; settings = {ATTRIBUTES = (Private, ); }; }; A75E497610752ACB00C9B896 /* SerializedScriptValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A75E497410752ACB00C9B896 /* SerializedScriptValue.h */; settings = {ATTRIBUTES = (Private, ); }; }; A75E497710752ACB00C9B896 /* SerializedScriptValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */; }; A75E8B880E1DE2D6007F2481 /* FEBlend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75E8B800E1DE2D6007F2481 /* FEBlend.cpp */; }; @@ -3177,6 +3191,7 @@ A779791A0D6B9D0C003851B9 /* ImageData.h in Headers */ = {isa = PBXBuildFile; fileRef = A77979140D6B9D0C003851B9 /* ImageData.h */; }; A77979280D6B9E64003851B9 /* JSImageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A77979240D6B9E64003851B9 /* JSImageData.cpp */; }; A77979290D6B9E64003851B9 /* JSImageData.h in Headers */ = {isa = PBXBuildFile; fileRef = A77979250D6B9E64003851B9 /* JSImageData.h */; }; + A77B41A012E675A90054343D /* TextEventInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = A77B419F12E675A90054343D /* TextEventInputType.h */; settings = {ATTRIBUTES = (Private, ); }; }; A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A784941A0B5FE507001E237A /* Clipboard.cpp */; }; A78FE13B12366B1000ACE8D0 /* SpellChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */; }; A78FE13C12366B1000ACE8D0 /* SpellChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = A78FE13A12366B1000ACE8D0 /* SpellChecker.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -5044,6 +5059,8 @@ BC82432A0D0CE8A200460C8F /* JSSQLTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8243260D0CE8A200460C8F /* JSSQLTransaction.h */; }; BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8243E60D0CFD7500460C8F /* WindowFeatures.cpp */; }; BC8243E90D0CFD7500460C8F /* WindowFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8243E70D0CFD7500460C8F /* WindowFeatures.h */; settings = {ATTRIBUTES = (Private, ); }; }; + BC8AE34E12EA096A00EB3AE6 /* ScrollableArea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8AE34C12EA096A00EB3AE6 /* ScrollableArea.cpp */; }; + BC8AE34F12EA096A00EB3AE6 /* ScrollableArea.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8AE34D12EA096A00EB3AE6 /* ScrollableArea.h */; settings = {ATTRIBUTES = (Private, ); }; }; BC8B853E0E7C7F1100AB6984 /* ScrollbarThemeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */; }; BC8B854B0E7C7F5600AB6984 /* ScrollbarTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8B854A0E7C7F5600AB6984 /* ScrollbarTheme.h */; settings = {ATTRIBUTES = (Private, ); }; }; BC8BF151105813BF00A40A07 /* UserStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8BF150105813BF00A40A07 /* UserStyleSheet.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -5078,8 +5095,6 @@ BC99812E0DBE807A008CE9EF /* DOMAbstractViewFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = BC99812D0DBE807A008CE9EF /* DOMAbstractViewFrame.h */; }; BC9ADD230CC4032600098C4C /* WebKitCSSTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9ADD220CC4032600098C4C /* WebKitCSSTransformValue.h */; settings = {ATTRIBUTES = (Private, ); }; }; BC9ADD800CC4092200098C4C /* WebKitCSSTransformValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9ADD7F0CC4092200098C4C /* WebKitCSSTransformValue.cpp */; }; - BC9BC64D0E7C4889008B9849 /* ScrollbarClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9BC64B0E7C4889008B9849 /* ScrollbarClient.cpp */; settings = {ATTRIBUTES = (Private, ); }; }; - BC9BC64E0E7C4889008B9849 /* ScrollbarClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9BC64C0E7C4889008B9849 /* ScrollbarClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; BCA169A20BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCA169A00BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp */; }; BCA169A30BFD55B40019CA76 /* JSHTMLTableCaptionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA169A10BFD55B40019CA76 /* JSHTMLTableCaptionElement.h */; }; BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA257141293C010007A263D /* VerticalPositionCache.h */; }; @@ -5609,8 +5624,8 @@ F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */; }; F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; }; F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; }; - F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; }; - F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; }; + F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */; }; + F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSErrorHandler.h */; }; F3D4C47812E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D4C47612E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp */; }; F3D4C47912E07663003DA150 /* InspectorBrowserDebuggerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D4C47712E07663003DA150 /* InspectorBrowserDebuggerAgent.h */; }; F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; }; @@ -8086,9 +8101,11 @@ 7A74ECB8101839A500BF939E /* InspectorDOMStorageAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDOMStorageAgent.cpp; sourceTree = "<group>"; }; 7A74ECB9101839A600BF939E /* InspectorDOMStorageAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDOMStorageAgent.h; sourceTree = "<group>"; }; 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorFrontendHostCustom.cpp; sourceTree = "<group>"; }; + 7AA365ED12E7265400DCA242 /* InspectorRuntimeAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorRuntimeAgent.cpp; sourceTree = "<group>"; }; 7AB0B1BE1211A62200A76940 /* InspectorDatabaseAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDatabaseAgent.cpp; sourceTree = "<group>"; }; 7AB0B1BF1211A62200A76940 /* InspectorDatabaseAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDatabaseAgent.h; sourceTree = "<group>"; }; 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextMenuProvider.h; sourceTree = "<group>"; }; + 7AF11A5912E727490061F23C /* InspectorRuntimeAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorRuntimeAgent.h; sourceTree = "<group>"; }; 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptBreakpoint.h; sourceTree = "<group>"; }; 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptDebugListener.h; sourceTree = "<group>"; }; 7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; }; @@ -9135,6 +9152,11 @@ 8F67561A1288B17B0047ACA3 /* EventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventQueue.cpp; sourceTree = "<group>"; }; 8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMainThreadExecState.h; sourceTree = "<group>"; }; 8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMainThreadExecState.cpp; sourceTree = "<group>"; }; + 9001773D12E0347800648462 /* OESStandardDerivatives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OESStandardDerivatives.cpp; path = canvas/OESStandardDerivatives.cpp; sourceTree = "<group>"; }; + 9001773E12E0347800648462 /* OESStandardDerivatives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESStandardDerivatives.h; path = canvas/OESStandardDerivatives.h; sourceTree = "<group>"; }; + 9001773F12E0347800648462 /* OESStandardDerivatives.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OESStandardDerivatives.idl; path = canvas/OESStandardDerivatives.idl; sourceTree = "<group>"; }; + 9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESStandardDerivatives.cpp; sourceTree = "<group>"; }; + 9001787F12E0370700648462 /* JSOESStandardDerivatives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESStandardDerivatives.h; sourceTree = "<group>"; }; 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageGroup.cpp; sourceTree = "<group>"; }; 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageGroup.h; sourceTree = "<group>"; }; 9305B24C098F1B6B00C28855 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = "<group>"; }; @@ -9526,6 +9548,12 @@ A5AFB34E115151A700B045CB /* StepRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StepRange.h; sourceTree = "<group>"; }; A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCocoa.h; path = cocoa/KeyEventCocoa.h; sourceTree = "<group>"; }; A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventCocoa.mm; path = cocoa/KeyEventCocoa.mm; sourceTree = "<group>"; }; + A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLKeygenElementInternal.h; sourceTree = "<group>"; }; + A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLKeygenElement.h; sourceTree = "<group>"; }; + A6148A6612E41D940044A784 /* DOMHTMLKeygenElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLKeygenElement.mm; sourceTree = "<group>"; }; + A6148A7612E41E3B0044A784 /* JSHTMLKeygenElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLKeygenElement.cpp; sourceTree = "<group>"; }; + A6148A7712E41E3B0044A784 /* JSHTMLKeygenElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLKeygenElement.h; sourceTree = "<group>"; }; + A6148A7F12E41ED10044A784 /* HTMLKeygenElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLKeygenElement.idl; sourceTree = "<group>"; }; A622A8F5122C44A600A785B3 /* BindingSecurity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingSecurity.h; path = generic/BindingSecurity.h; sourceTree = "<group>"; }; A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BindingSecurityBase.cpp; path = generic/BindingSecurityBase.cpp; sourceTree = "<group>"; }; A622A8F7122C44A600A785B3 /* BindingSecurityBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingSecurityBase.h; path = generic/BindingSecurityBase.h; sourceTree = "<group>"; }; @@ -9533,6 +9561,8 @@ A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; }; A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = "<group>"; }; A71A70C911AFB02000989D6D /* HTMLMeterElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLMeterElement.idl; sourceTree = "<group>"; }; + A73F95FC12C97BFE0031AAF9 /* RoundedIntRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RoundedIntRect.cpp; sourceTree = "<group>"; }; + A73F95FD12C97BFE0031AAF9 /* RoundedIntRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoundedIntRect.h; sourceTree = "<group>"; }; A75E497410752ACB00C9B896 /* SerializedScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedScriptValue.h; sourceTree = "<group>"; }; A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerializedScriptValue.cpp; sourceTree = "<group>"; }; A75E8B800E1DE2D6007F2481 /* FEBlend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FEBlend.cpp; path = filters/FEBlend.cpp; sourceTree = "<group>"; }; @@ -9548,6 +9578,7 @@ A77979150D6B9D0C003851B9 /* ImageData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ImageData.idl; sourceTree = "<group>"; }; A77979240D6B9E64003851B9 /* JSImageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageData.cpp; sourceTree = "<group>"; }; A77979250D6B9E64003851B9 /* JSImageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSImageData.h; sourceTree = "<group>"; }; + A77B419F12E675A90054343D /* TextEventInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEventInputType.h; sourceTree = "<group>"; }; A784941A0B5FE507001E237A /* Clipboard.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Clipboard.cpp; sourceTree = "<group>"; }; A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpellChecker.cpp; sourceTree = "<group>"; }; A78FE13A12366B1000ACE8D0 /* SpellChecker.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = SpellChecker.h; sourceTree = "<group>"; }; @@ -11336,6 +11367,8 @@ BC8243260D0CE8A200460C8F /* JSSQLTransaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLTransaction.h; sourceTree = "<group>"; }; BC8243E60D0CFD7500460C8F /* WindowFeatures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowFeatures.cpp; sourceTree = "<group>"; }; BC8243E70D0CFD7500460C8F /* WindowFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowFeatures.h; sourceTree = "<group>"; }; + BC8AE34C12EA096A00EB3AE6 /* ScrollableArea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollableArea.cpp; sourceTree = "<group>"; }; + BC8AE34D12EA096A00EB3AE6 /* ScrollableArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollableArea.h; sourceTree = "<group>"; }; BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollbarThemeMac.h; sourceTree = "<group>"; }; BC8B854A0E7C7F5600AB6984 /* ScrollbarTheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollbarTheme.h; sourceTree = "<group>"; }; BC8BF150105813BF00A40A07 /* UserStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserStyleSheet.h; sourceTree = "<group>"; }; @@ -11373,8 +11406,6 @@ BC99812D0DBE807A008CE9EF /* DOMAbstractViewFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMAbstractViewFrame.h; sourceTree = "<group>"; }; BC9ADD220CC4032600098C4C /* WebKitCSSTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebKitCSSTransformValue.h; sourceTree = "<group>"; }; BC9ADD7F0CC4092200098C4C /* WebKitCSSTransformValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSTransformValue.cpp; sourceTree = "<group>"; }; - BC9BC64B0E7C4889008B9849 /* ScrollbarClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollbarClient.cpp; sourceTree = "<group>"; }; - BC9BC64C0E7C4889008B9849 /* ScrollbarClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollbarClient.h; sourceTree = "<group>"; }; BCA169A00BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTableCaptionElement.cpp; sourceTree = "<group>"; }; BCA169A10BFD55B40019CA76 /* JSHTMLTableCaptionElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLTableCaptionElement.h; sourceTree = "<group>"; }; BCA257141293C010007A263D /* VerticalPositionCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VerticalPositionCache.h; sourceTree = "<group>"; }; @@ -11394,7 +11425,7 @@ BCA8CA5D11E4E6D100812FB7 /* BackForwardListImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackForwardListImpl.cpp; sourceTree = "<group>"; }; BCA8CA5E11E4E6D100812FB7 /* BackForwardListImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackForwardListImpl.h; sourceTree = "<group>"; }; BCA979161215D055005C485C /* ImageBufferData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBufferData.h; sourceTree = "<group>"; }; - BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Scrollbar.cpp; path = platform/Scrollbar.cpp; sourceTree = SOURCE_ROOT; }; + BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Scrollbar.cpp; sourceTree = "<group>"; }; BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentURLPattern.cpp; sourceTree = "<group>"; }; BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentURLPattern.h; sourceTree = "<group>"; }; BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimatorMac.h; sourceTree = "<group>"; }; @@ -11953,8 +11984,8 @@ F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; }; F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; }; F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; }; - F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; }; - F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; }; + F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorHandler.cpp; sourceTree = "<group>"; }; + F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; }; F3D4C47612E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorBrowserDebuggerAgent.cpp; sourceTree = "<group>"; }; F3D4C47712E07663003DA150 /* InspectorBrowserDebuggerAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorBrowserDebuggerAgent.h; sourceTree = "<group>"; }; F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; }; @@ -12936,8 +12967,6 @@ 7A0E76F710BF08ED00A0276E /* InjectedScriptHost.h */, 7A0E76F810BF08ED00A0276E /* InjectedScriptHost.idl */, 7A563F9512DF5C9100F4536D /* InjectedScriptSource.js */, - 7A5640BD12DF9E5E00F4536D /* InspectorSettings.cpp */, - 7A5640BE12DF9E5E00F4536D /* InspectorSettings.h */, B885E8D211E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp */, B885E8D311E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h */, F3D4C47612E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp */, @@ -12976,6 +13005,10 @@ 9F0D6B2D121BFEBA006C0288 /* InspectorProfilerAgent.h */, 82AB1771125C826700C5069D /* InspectorResourceAgent.cpp */, 82AB1772125C826700C5069D /* InspectorResourceAgent.h */, + 7AA365ED12E7265400DCA242 /* InspectorRuntimeAgent.cpp */, + 7AF11A5912E727490061F23C /* InspectorRuntimeAgent.h */, + 7A5640BD12DF9E5E00F4536D /* InspectorSettings.cpp */, + 7A5640BE12DF9E5E00F4536D /* InspectorSettings.h */, 4FA3B908125CD12100300BAD /* InspectorState.cpp */, 4FA3B909125CD12200300BAD /* InspectorState.h */, 82AB176F125C826700C5069D /* InspectorStyleSheet.cpp */, @@ -13267,6 +13300,9 @@ 49C7B9AC1042D32E0009D447 /* Int8Array.h */, 49C7B9AD1042D32E0009D447 /* Int8Array.idl */, 6E96BB1A11986EE1007D94CD /* IntegralTypedArrayBase.h */, + 9001773D12E0347800648462 /* OESStandardDerivatives.cpp */, + 9001773E12E0347800648462 /* OESStandardDerivatives.h */, + 9001773F12E0347800648462 /* OESStandardDerivatives.idl */, 6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */, 6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */, 6EBF0E4712A8926100DB1709 /* OESTextureFloat.idl */, @@ -13867,7 +13903,6 @@ 1CE24F960D7CAF0E007E04C2 /* SchedulePairMac.mm */, BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */, BC51156D12B1749C00C96754 /* ScrollAnimatorMac.mm */, - BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */, BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */, BCEF869E0E844E9D00A85CD5 /* ScrollbarThemeMac.mm */, 9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */, @@ -14828,6 +14863,8 @@ 1CCA732110ADD43E00FD440D /* DOMHTMLInputElementPrivate.h */, 859A9C410AA5E3BD00B694B2 /* DOMHTMLIsIndexElement.h */, 859A9C420AA5E3BD00B694B2 /* DOMHTMLIsIndexElement.mm */, + A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */, + A6148A6612E41D940044A784 /* DOMHTMLKeygenElement.mm */, 85BA4CD90AA6861B0088052D /* DOMHTMLLabelElement.h */, 85BA4CDA0AA6861B0088052D /* DOMHTMLLabelElement.mm */, 85BA4CDB0AA6861B0088052D /* DOMHTMLLegendElement.h */, @@ -14963,6 +15000,7 @@ 85E711630AC5D5350053270F /* DOMHTMLImageElementInternal.h */, 85E711640AC5D5350053270F /* DOMHTMLInputElementInternal.h */, 85E711650AC5D5350053270F /* DOMHTMLIsIndexElementInternal.h */, + A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */, 85E711660AC5D5350053270F /* DOMHTMLLabelElementInternal.h */, 85E711670AC5D5350053270F /* DOMHTMLLegendElementInternal.h */, 85E711680AC5D5350053270F /* DOMHTMLLIElementInternal.h */, @@ -15576,6 +15614,7 @@ 1AE2AA850A1CDCCE00B42B25 /* HTMLIsIndexElement.idl */, A81369C9097374F600D74463 /* HTMLKeygenElement.cpp */, A81369C8097374F500D74463 /* HTMLKeygenElement.h */, + A6148A7F12E41ED10044A784 /* HTMLKeygenElement.idl */, A81369C7097374F500D74463 /* HTMLLabelElement.cpp */, A81369C6097374F500D74463 /* HTMLLabelElement.h */, 1AE2AABE0A1CDD8300B42B25 /* HTMLLabelElement.idl */, @@ -16082,6 +16121,8 @@ A80E7E8D0A1A83E3007FB8C5 /* JSHTMLInputElement.h */, 1AE2AA950A1CDD2D00B42B25 /* JSHTMLIsIndexElement.cpp */, 1AE2AA960A1CDD2D00B42B25 /* JSHTMLIsIndexElement.h */, + A6148A7612E41E3B0044A784 /* JSHTMLKeygenElement.cpp */, + A6148A7712E41E3B0044A784 /* JSHTMLKeygenElement.h */, 1AE2AB170A1CE63B00B42B25 /* JSHTMLLabelElement.cpp */, 1AE2AB180A1CE63B00B42B25 /* JSHTMLLabelElement.h */, 1AE2AB190A1CE63B00B42B25 /* JSHTMLLegendElement.cpp */, @@ -16164,6 +16205,8 @@ 49C7B9831042D2D30009D447 /* JSInt8Array.h */, E44614100CD6826900FADA75 /* JSMediaError.cpp */, E44614110CD6826900FADA75 /* JSMediaError.h */, + 9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */, + 9001787F12E0370700648462 /* JSOESStandardDerivatives.h */, 6EBF0E7412A9868800DB1709 /* JSOESTextureFloat.cpp */, 6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */, BCEF45F30E687B5C001C1287 /* JSTextMetrics.cpp */, @@ -17460,6 +17503,8 @@ A88DD4860B4629A300C02990 /* PathTraversalState.h */, A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */, A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */, + A73F95FC12C97BFE0031AAF9 /* RoundedIntRect.cpp */, + A73F95FD12C97BFE0031AAF9 /* RoundedIntRect.h */, 371F4FFB0D25E7F300ECE0D5 /* SegmentedFontData.cpp */, 371F4FFA0D25E7F300ECE0D5 /* SegmentedFontData.h */, B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */, @@ -17675,6 +17720,8 @@ BCBFB53B0DCD29CF0019B3E5 /* JSDOMWindowShell.h */, BC53DAC611433064000D817E /* JSDOMWrapper.cpp */, 65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */, + F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */, + F3D461471161D53200CA0D09 /* JSErrorHandler.h */, BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */, BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */, 3314ACE910892086000F0E56 /* JSExceptionBase.cpp */, @@ -17686,8 +17733,6 @@ 14CD8D81106B529000A46D23 /* JSSharedWorkerCustom.cpp */, E1C36D320EB0A094007410BC /* JSWorkerContextBase.cpp */, E1C36D330EB0A094007410BC /* JSWorkerContextBase.h */, - F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */, - F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */, BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */, BCA378BB0D15F64200B793D6 /* ScheduledAction.h */, 41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */, @@ -18245,11 +18290,12 @@ 1C63A2460F71646600C09D5A /* RunLoopTimer.h */, 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */, 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */, + BC8AE34C12EA096A00EB3AE6 /* ScrollableArea.cpp */, + BC8AE34D12EA096A00EB3AE6 /* ScrollableArea.h */, CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */, CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */, + BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */, BC7B2AF80450824100A8000F /* Scrollbar.h */, - BC9BC64B0E7C4889008B9849 /* ScrollbarClient.cpp */, - BC9BC64C0E7C4889008B9849 /* ScrollbarClient.h */, BC8B854A0E7C7F5600AB6984 /* ScrollbarTheme.h */, BC1402880E83680800319717 /* ScrollbarThemeComposite.cpp */, BC1402890E83680800319717 /* ScrollbarThemeComposite.h */, @@ -19079,6 +19125,7 @@ 933A142B0B7D188600A53FFD /* TextEvent.cpp */, 933A142D0B7D188600A53FFD /* TextEvent.h */, 933A142C0B7D188600A53FFD /* TextEvent.idl */, + A77B419F12E675A90054343D /* TextEventInputType.h */, 5DB1BC6810715A6400EFAA49 /* TransformSource.h */, 5DB1BC6910715A6400EFAA49 /* TransformSourceLibxslt.cpp */, 854FE72C0A2297BE0058D7AD /* Traversal.cpp */, @@ -19855,6 +19902,8 @@ 85E711B30AC5D5350053270F /* DOMHTMLInputElementInternal.h in Headers */, 859A9C4B0AA5E3BD00B694B2 /* DOMHTMLIsIndexElement.h in Headers */, 85E711B40AC5D5350053270F /* DOMHTMLIsIndexElementInternal.h in Headers */, + A6148A6712E41D940044A784 /* DOMHTMLKeygenElement.h in Headers */, + A6148A6212E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h in Headers */, 85BA4CE10AA6861B0088052D /* DOMHTMLLabelElement.h in Headers */, 85E711B50AC5D5350053270F /* DOMHTMLLabelElementInternal.h in Headers */, 85BA4CE30AA6861B0088052D /* DOMHTMLLegendElement.h in Headers */, @@ -20434,6 +20483,7 @@ 850B41C30AD9E7E700A6ED4F /* DOMTreeWalkerInternal.h in Headers */, 85C7F4910AAF79DC004014DD /* DOMUIEvent.h in Headers */, 85989DD00ACC8BBD00A0BC51 /* DOMUIEventInternal.h in Headers */, + 2E37DFDB12DBAFB800A6B233 /* DOMURL.h in Headers */, 15C770A6100D41CD005BA267 /* DOMValidityState.h in Headers */, BC1A37C0097C715F0019F3D8 /* DOMViews.h in Headers */, 31C0FF490E4CEFDD007D6FE5 /* DOMWebKitAnimationEvent.h in Headers */, @@ -20833,6 +20883,7 @@ 93309DF2099E64920056E581 /* InsertTextCommand.h in Headers */, B885E8D511E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h in Headers */, 4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */, + F3D4C47912E07663003DA150 /* InspectorBrowserDebuggerAgent.h in Headers */, 1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */, F3335BF912E07DC300D33011 /* InspectorConsoleAgent.h in Headers */, 1C81B95A0E97330800266E07 /* InspectorController.h in Headers */, @@ -20850,6 +20901,8 @@ 20D629271253690B00081543 /* InspectorInstrumentation.h in Headers */, 9F0D6B2F121BFEBA006C0288 /* InspectorProfilerAgent.h in Headers */, 82AB1776125C826700C5069D /* InspectorResourceAgent.h in Headers */, + 7AF11A5A12E727490061F23C /* InspectorRuntimeAgent.h in Headers */, + 7A5640C012DF9E5E00F4536D /* InspectorSettings.h in Headers */, 4FA3B90B125CD12200300BAD /* InspectorState.h in Headers */, 82AB1774125C826700C5069D /* InspectorStyleSheet.h in Headers */, 754133A8102E00E800075D00 /* InspectorTimelineAgent.h in Headers */, @@ -20973,6 +21026,7 @@ C5137CF311A58378004ADB99 /* JSDOMStringList.h in Headers */, BC64649811D82349006455B0 /* JSDOMStringMap.h in Headers */, 7694563D1214D97C0007CBAE /* JSDOMTokenList.h in Headers */, + 2E37E00612DBC5A400A6B233 /* JSDOMURL.h in Headers */, BC6932740D7E293900AE44D1 /* JSDOMWindowBase.h in Headers */, 652FBBBC0DE27CB60001D386 /* JSDOMWindowCustom.h in Headers */, BCBFB53D0DCD29CF0019B3E5 /* JSDOMWindowShell.h in Headers */, @@ -20988,6 +21042,7 @@ 893C483B12495472002B3D86 /* JSEntrySync.h in Headers */, 898785AF122CA2A7003AABDA /* JSErrorCallback.h in Headers */, 2ECF7ADD10162B3800427DE7 /* JSErrorEvent.h in Headers */, + F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */, 14E8378E09F85D4F00B85AE4 /* JSEvent.h in Headers */, BC60D9C00D2A269A00B9918F /* JSEventException.h in Headers */, 93B70D6A09EB0C7C009D8468 /* JSEventListener.h in Headers */, @@ -21055,6 +21110,7 @@ A80E7E970A1A83E3007FB8C5 /* JSHTMLInputElement.h in Headers */, E1AD14231295EA7F00ACA989 /* JSHTMLInputElementCustom.h in Headers */, 1AE2AA9A0A1CDD2D00B42B25 /* JSHTMLIsIndexElement.h in Headers */, + A6148A7912E41E3B0044A784 /* JSHTMLKeygenElement.h in Headers */, 1AE2AB220A1CE63B00B42B25 /* JSHTMLLabelElement.h in Headers */, 1AE2AB240A1CE63B00B42B25 /* JSHTMLLegendElement.h in Headers */, 1AE2AB260A1CE63B00B42B25 /* JSHTMLLIElement.h in Headers */, @@ -21143,6 +21199,7 @@ 65DF31FE09D1CC60000BE325 /* JSNotation.h in Headers */, 33503CA410179AD7003B47E1 /* JSNotification.h in Headers */, 33503CA610179AD7003B47E1 /* JSNotificationCenter.h in Headers */, + 9001788112E0370700648462 /* JSOESStandardDerivatives.h in Headers */, 6EBF0E7712A9868800DB1709 /* JSOESTextureFloat.h in Headers */, A826E8AE0A1A8F2300CD1BB6 /* JSOptionConstructor.h in Headers */, 1A0D57410A5C7867007EDD4C /* JSOverflowEvent.h in Headers */, @@ -21352,7 +21409,6 @@ E1CAA5C60E8BD23600A73ECA /* JSWorker.h in Headers */, E18256900EF2B02D00933242 /* JSWorkerContext.h in Headers */, E1C36D350EB0A094007410BC /* JSWorkerContextBase.h in Headers */, - F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */, E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */, E1271A580EEECDE400F61213 /* JSWorkerNavigator.h in Headers */, BC348BD40DB7F804004ABAB9 /* JSXMLHttpRequest.h in Headers */, @@ -21487,6 +21543,7 @@ 1CF6BDFA0E9BB26A0025E1CD /* ObjCEventListener.h in Headers */, 1CF6BE150E9BB4670025E1CD /* ObjCNodeFilterCondition.h in Headers */, E16982551134629D00894115 /* ObjCRuntimeObject.h in Headers */, + 9001774112E0347800648462 /* OESStandardDerivatives.h in Headers */, 6EBF0E4912A8926100DB1709 /* OESTextureFloat.h in Headers */, F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */, 087281560F26B9B600AFC596 /* OptionElement.h in Headers */, @@ -21726,6 +21783,7 @@ BC74DA371013F3F7007987AD /* RGBColor.h in Headers */, A8CFF5E10A155A05000A4234 /* RootInlineBox.h in Headers */, 49E911C90EF86D47009D0CAF /* RotateTransformOperation.h in Headers */, + A73F95FF12C97BFE0031AAF9 /* RoundedIntRect.h in Headers */, 1C63A2480F71646600C09D5A /* RunLoopTimer.h in Headers */, 1A569D1F0D7E2B82007C3983 /* runtime_array.h in Headers */, 1A569D210D7E2B82007C3983 /* runtime_method.h in Headers */, @@ -21769,7 +21827,6 @@ CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */, BCAE1FA712939DB7004CB026 /* ScrollAnimatorMac.h in Headers */, 93F199B808245E59001E9ABC /* Scrollbar.h in Headers */, - BC9BC64E0E7C4889008B9849 /* ScrollbarClient.h in Headers */, BC8B854B0E7C7F5600AB6984 /* ScrollbarTheme.h in Headers */, BC14028B0E83680800319717 /* ScrollbarThemeComposite.h in Headers */, BC8B853E0E7C7F1100AB6984 /* ScrollbarThemeMac.h in Headers */, @@ -22138,6 +22195,7 @@ C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */, B2C3DA490D006C1D00EF6F26 /* TextEncodingRegistry.h in Headers */, 933A14300B7D188600A53FFD /* TextEvent.h in Headers */, + A77B41A012E675A90054343D /* TextEventInputType.h in Headers */, F55B3DD81251F12D003EF269 /* TextFieldInputType.h in Headers */, 93309E18099E64920056E581 /* TextGranularity.h in Headers */, F55B3DDA1251F12D003EF269 /* TextInputType.h in Headers */, @@ -22352,10 +22410,7 @@ 93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */, E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */, 97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */, - 2E37DFDB12DBAFB800A6B233 /* DOMURL.h in Headers */, - 2E37E00612DBC5A400A6B233 /* JSDOMURL.h in Headers */, - 7A5640C012DF9E5E00F4536D /* InspectorSettings.h in Headers */, - F3D4C47912E07663003DA150 /* InspectorBrowserDebuggerAgent.h in Headers */, + BC8AE34F12EA096A00EB3AE6 /* ScrollableArea.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -22468,6 +22523,7 @@ 85136CA20AED665900F90A3D /* northWestResizeCursor.png in Resources */, 85136CA30AED665900F90A3D /* northWestSouthEastResizeCursor.png in Resources */, 464EA2740B8A350B00A8E6E3 /* notAllowedCursor.png in Resources */, + 9001774212E0347800648462 /* OESStandardDerivatives.idl in Resources */, 46F9D5DF0B0D60170028EE36 /* progressCursor.png in Resources */, 85136CA40AED665900F90A3D /* southEastResizeCursor.png in Resources */, 85136CA50AED665900F90A3D /* southResizeCursor.png in Resources */, @@ -23020,6 +23076,7 @@ 85DF812A0AA7787200486AD7 /* DOMHTMLImageElement.mm in Sources */, 85F32AED0AA63B8700FF3184 /* DOMHTMLInputElement.mm in Sources */, 859A9C4C0AA5E3BD00B694B2 /* DOMHTMLIsIndexElement.mm in Sources */, + A6148A6812E41D940044A784 /* DOMHTMLKeygenElement.mm in Sources */, 85BA4CE20AA6861B0088052D /* DOMHTMLLabelElement.mm in Sources */, 85BA4CE40AA6861B0088052D /* DOMHTMLLegendElement.mm in Sources */, 85BA4D120AA688680088052D /* DOMHTMLLIElement.mm in Sources */, @@ -23227,6 +23284,7 @@ 76FC2B0B12370DA0006A991A /* DOMTokenList.cpp in Sources */, 85526CD30AB0B7DA000302EA /* DOMTreeWalker.mm in Sources */, 85C7F4920AAF79DC004014DD /* DOMUIEvent.mm in Sources */, + 2E37DFDA12DBAFB800A6B233 /* DOMURL.cpp in Sources */, BC1A37BF097C715F0019F3D8 /* DOMUtility.mm in Sources */, 15C770A5100D41CD005BA267 /* DOMValidityState.mm in Sources */, 31C0FF4A0E4CEFDD007D6FE5 /* DOMWebKitAnimationEvent.mm in Sources */, @@ -23566,6 +23624,7 @@ 93309DF1099E64920056E581 /* InsertTextCommand.cpp in Sources */, B885E8D411E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp in Sources */, 4F707A9911EF679400ACDA69 /* InspectorBackendDispatcher.cpp in Sources */, + F3D4C47812E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp in Sources */, 7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */, F3335BF812E07DC300D33011 /* InspectorConsoleAgent.cpp in Sources */, 1C81B95B0E97330800266E07 /* InspectorController.cpp in Sources */, @@ -23583,6 +23642,8 @@ 20D629261253690B00081543 /* InspectorInstrumentation.cpp in Sources */, 9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */, 82AB1775125C826700C5069D /* InspectorResourceAgent.cpp in Sources */, + 7AA365EE12E7265400DCA242 /* InspectorRuntimeAgent.cpp in Sources */, + 7A5640BF12DF9E5E00F4536D /* InspectorSettings.cpp in Sources */, 4FA3B90A125CD12200300BAD /* InspectorState.cpp in Sources */, 82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */, 754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */, @@ -23742,6 +23803,7 @@ BC64649711D82349006455B0 /* JSDOMStringMap.cpp in Sources */, BC64649C11D8238C006455B0 /* JSDOMStringMapCustom.cpp in Sources */, 7694563C1214D97C0007CBAE /* JSDOMTokenList.cpp in Sources */, + 2E37E00512DBC5A400A6B233 /* JSDOMURL.cpp in Sources */, 1403BA0C09EB18C700797C7F /* JSDOMWindow.cpp in Sources */, BC6932730D7E293900AE44D1 /* JSDOMWindowBase.cpp in Sources */, BCD9C2620C17AA67005C90A2 /* JSDOMWindowCustom.cpp in Sources */, @@ -23761,6 +23823,7 @@ 893C485312499B06002B3D86 /* JSEntrySyncCustom.cpp in Sources */, 898785AE122CA2A7003AABDA /* JSErrorCallback.cpp in Sources */, 2ECF7ADC10162B3800427DE7 /* JSErrorEvent.cpp in Sources */, + F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */, 14E8378409F85D1C00B85AE4 /* JSEvent.cpp in Sources */, BCEFAF4E0C317E6900FA81F6 /* JSEventCustom.cpp in Sources */, BC60D9BF0D2A269A00B9918F /* JSEventException.cpp in Sources */, @@ -23843,6 +23906,7 @@ A80E7E980A1A83E3007FB8C5 /* JSHTMLInputElement.cpp in Sources */, BCC438780E886CC700533DD5 /* JSHTMLInputElementCustom.cpp in Sources */, 1AE2AA990A1CDD2D00B42B25 /* JSHTMLIsIndexElement.cpp in Sources */, + A6148A7812E41E3B0044A784 /* JSHTMLKeygenElement.cpp in Sources */, 1AE2AB210A1CE63B00B42B25 /* JSHTMLLabelElement.cpp in Sources */, 1AE2AB230A1CE63B00B42B25 /* JSHTMLLegendElement.cpp in Sources */, 1AE2AB250A1CE63B00B42B25 /* JSHTMLLIElement.cpp in Sources */, @@ -23955,6 +24019,7 @@ 65DF31FD09D1CC60000BE325 /* JSNotation.cpp in Sources */, 33503CA310179AD7003B47E1 /* JSNotification.cpp in Sources */, 33503CA510179AD7003B47E1 /* JSNotificationCenter.cpp in Sources */, + 9001788012E0370700648462 /* JSOESStandardDerivatives.cpp in Sources */, 6EBF0E7612A9868800DB1709 /* JSOESTextureFloat.cpp in Sources */, A826EC480A1B0CBE00CD1BB6 /* JSOptionConstructor.cpp in Sources */, 1A0D57400A5C7867007EDD4C /* JSOverflowEvent.cpp in Sources */, @@ -24189,7 +24254,6 @@ E182568F0EF2B02D00933242 /* JSWorkerContext.cpp in Sources */, E1C36D340EB0A094007410BC /* JSWorkerContextBase.cpp in Sources */, E18258AC0EF3CD7000933242 /* JSWorkerContextCustom.cpp in Sources */, - F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */, E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */, E1C362F00EAF2AA9007410BC /* JSWorkerLocation.cpp in Sources */, E1271A590EEECDE400F61213 /* JSWorkerNavigator.cpp in Sources */, @@ -24309,6 +24373,7 @@ 1CF6BDFB0E9BB26A0025E1CD /* ObjCEventListener.mm in Sources */, 1CF6BE140E9BB4670025E1CD /* ObjCNodeFilterCondition.mm in Sources */, E16982601134636A00894115 /* ObjCRuntimeObject.mm in Sources */, + 9001774012E0347800648462 /* OESStandardDerivatives.cpp in Sources */, 6EBF0E4812A8926100DB1709 /* OESTextureFloat.cpp in Sources */, F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */, 087281550F26B9B600AFC596 /* OptionElement.cpp in Sources */, @@ -24517,6 +24582,7 @@ BC74DA381013F3F7007987AD /* RGBColor.cpp in Sources */, A8CFF5E70A155A05000A4234 /* RootInlineBox.cpp in Sources */, 49E911C80EF86D47009D0CAF /* RotateTransformOperation.cpp in Sources */, + A73F95FE12C97BFE0031AAF9 /* RoundedIntRect.cpp in Sources */, 1C63A2490F71646600C09D5A /* RunLoopTimerCF.cpp in Sources */, 1A569D1E0D7E2B82007C3983 /* runtime_array.cpp in Sources */, 1A569D200D7E2B82007C3983 /* runtime_method.cpp in Sources */, @@ -24555,7 +24621,6 @@ CA3BF67C10D99BAE00E6CE53 /* ScrollAnimator.cpp in Sources */, BC51156E12B1749C00C96754 /* ScrollAnimatorMac.mm in Sources */, BCAA90C30A7EBA60008B1229 /* Scrollbar.cpp in Sources */, - BC9BC64D0E7C4889008B9849 /* ScrollbarClient.cpp in Sources */, BC14028A0E83680800319717 /* ScrollbarThemeComposite.cpp in Sources */, BCEF869F0E844E9D00A85CD5 /* ScrollbarThemeMac.mm in Sources */, 5D925B670F64D4DD00B847F0 /* ScrollBehavior.cpp in Sources */, @@ -25040,10 +25105,7 @@ 93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */, E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */, 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */, - 2E37DFDA12DBAFB800A6B233 /* DOMURL.cpp in Sources */, - 2E37E00512DBC5A400A6B233 /* JSDOMURL.cpp in Sources */, - 7A5640BF12DF9E5E00F4536D /* InspectorSettings.cpp in Sources */, - F3D4C47812E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp in Sources */, + BC8AE34E12EA096A00EB3AE6 /* ScrollableArea.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/WebCore/accessibility/AXObjectCache.h b/Source/WebCore/accessibility/AXObjectCache.h index 670d6e0..00e7fbc 100644 --- a/Source/WebCore/accessibility/AXObjectCache.h +++ b/Source/WebCore/accessibility/AXObjectCache.h @@ -60,7 +60,8 @@ struct TextMarkerData { enum PostType { PostSynchronously, PostAsynchronously }; -class AXObjectCache : public Noncopyable { +class AXObjectCache { + WTF_MAKE_NONCOPYABLE(AXObjectCache); WTF_MAKE_FAST_ALLOCATED; public: AXObjectCache(const Document*); ~AXObjectCache(); diff --git a/Source/WebCore/accessibility/AccessibilityObject.cpp b/Source/WebCore/accessibility/AccessibilityObject.cpp index 511bd3f..f2a2d7d 100644 --- a/Source/WebCore/accessibility/AccessibilityObject.cpp +++ b/Source/WebCore/accessibility/AccessibilityObject.cpp @@ -1013,8 +1013,9 @@ AccessibilityObject* AccessibilityObject::elementAccessibilityHitTest(const IntP // Send the hit test back into the sub-frame if necessary. if (isAttachment()) { Widget* widget = widgetForAttachmentView(); + // Normalize the point for the widget's bounds. if (widget && widget->isFrameView()) - return axObjectCache()->getOrCreate(static_cast<ScrollView*>(widget))->accessibilityHitTest(point); + return axObjectCache()->getOrCreate(widget)->accessibilityHitTest(IntPoint(point - widget->frameRect().location())); } return const_cast<AccessibilityObject*>(this); diff --git a/Source/WebCore/accessibility/AccessibilityObject.h b/Source/WebCore/accessibility/AccessibilityObject.h index 45b54fc..c8d887b 100644 --- a/Source/WebCore/accessibility/AccessibilityObject.h +++ b/Source/WebCore/accessibility/AccessibilityObject.h @@ -31,7 +31,6 @@ #define AccessibilityObject_h #include "IntRect.h" -#include "Range.h" #include "VisiblePosition.h" #include "VisibleSelection.h" #include <wtf/Forward.h> diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp index 8b0c5ca..ca8d4a7 100644 --- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp +++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp @@ -1772,6 +1772,10 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const if (!isAllowedChildOfTree()) return true; + // Allow the platform to decide if the attachment is ignored or not. + if (isAttachment()) + return accessibilityIgnoreAttachment(); + // ignore popup menu items because AppKit does for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->parent()) { if (parent->isBoxModelObject() && toRenderBoxModelObject(parent)->isMenuList()) @@ -1817,9 +1821,6 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const if (ariaRoleAttribute() != UnknownRole) return false; - if (!helpText().isEmpty()) - return false; - // don't ignore labels, because they serve as TitleUIElements Node* node = m_renderer->node(); if (node && node->hasTagName(labelTag)) @@ -1877,11 +1878,17 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const return false; } - // make a platform-specific decision - if (isAttachment()) - return accessibilityIgnoreAttachment(); + if (isWebArea() || m_renderer->isListMarker()) + return false; + + // Using the help text to decide an element's visibility is not as definitive + // as previous checks, so this should remain as one of the last. + if (!helpText().isEmpty()) + return false; - return !m_renderer->isListMarker() && !isWebArea(); + // By default, objects should be ignored so that the AX hierarchy is not + // filled with unnecessary items. + return true; } bool AccessibilityRenderObject::isLoaded() const diff --git a/Source/WebCore/accessibility/AccessibilityScrollbar.cpp b/Source/WebCore/accessibility/AccessibilityScrollbar.cpp index 865797a..b225af8 100644 --- a/Source/WebCore/accessibility/AccessibilityScrollbar.cpp +++ b/Source/WebCore/accessibility/AccessibilityScrollbar.cpp @@ -97,9 +97,11 @@ void AccessibilityScrollbar::setValue(float value) if (!m_scrollbar) return; + if (!m_scrollbar->scrollableArea()) + return; + float newValue = value * m_scrollbar->maximum(); - - m_scrollbar->setValue(newValue, Scrollbar::NotFromScrollAnimator); + m_scrollbar->scrollableArea()->scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), newValue); } } // namespace WebCore diff --git a/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm b/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm index f3b388b..c2e3724 100644 --- a/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm +++ b/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm @@ -1455,7 +1455,7 @@ static NSString* roleValueToNSString(AccessibilityRole value) return nil; if (scroll->platformWidget()) - return scroll->platformWidget(); + return NSAccessibilityUnignoredAncestor(scroll->platformWidget()); return [self remoteAccessibilityParentObject]; } diff --git a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp index 9a96f22..dadcc1c 100644 --- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp +++ b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp @@ -48,6 +48,7 @@ bool RuntimeEnabledFeatures::isWebkitNotificationsEnabled = false; bool RuntimeEnabledFeatures::isApplicationCacheEnabled = true; bool RuntimeEnabledFeatures::isGeolocationEnabled = true; bool RuntimeEnabledFeatures::isIndexedDBEnabled = false; +bool RuntimeEnabledFeatures::isWebAudioEnabled = false; bool RuntimeEnabledFeatures::isWebGLEnabled = false; bool RuntimeEnabledFeatures::isPushStateEnabled = false; bool RuntimeEnabledFeatures::isTouchEnabled = true; diff --git a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h index 343c535..c1b9b8a 100644 --- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h +++ b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h @@ -92,6 +92,11 @@ public: static bool openDatabaseSyncEnabled(); #endif +#if ENABLE(WEB_AUDIO) + static void setWebkitAudioContextEnabled(bool isEnabled) { isWebAudioEnabled = isEnabled; } + static bool webkitAudioContextEnabled() { return isWebAudioEnabled; } +#endif + #if ENABLE(3D_CANVAS) || ENABLE(BLOB) static void setWebGLEnabled(bool isEnabled) { isWebGLEnabled = isEnabled; } static bool arrayBufferEnabled() { return isWebGLEnabled; } @@ -174,6 +179,7 @@ private: static bool isApplicationCacheEnabled; static bool isGeolocationEnabled; static bool isIndexedDBEnabled; + static bool isWebAudioEnabled; static bool isWebGLEnabled; static bool isPushStateEnabled; static bool isTouchEnabled; diff --git a/Source/WebCore/bindings/gobject/GNUmakefile.am b/Source/WebCore/bindings/gobject/GNUmakefile.am index b4f98d1..4067dbc 100644 --- a/Source/WebCore/bindings/gobject/GNUmakefile.am +++ b/Source/WebCore/bindings/gobject/GNUmakefile.am @@ -130,6 +130,8 @@ webkitgtk_gdom_built_sources += \ DerivedSources/webkit/WebKitDOMHTMLInputElementPrivate.h \ DerivedSources/webkit/WebKitDOMHTMLIsIndexElement.cpp \ DerivedSources/webkit/WebKitDOMHTMLIsIndexElementPrivate.h \ + DerivedSources/webkit/WebKitDOMHTMLKeygenElement.cpp \ + DerivedSources/webkit/WebKitDOMHTMLKeygenElementPrivate.h \ DerivedSources/webkit/WebKitDOMHTMLLabelElement.cpp \ DerivedSources/webkit/WebKitDOMHTMLLabelElementPrivate.h \ DerivedSources/webkit/WebKitDOMHTMLLegendElement.cpp \ @@ -323,6 +325,7 @@ webkitgtk_built_h_api += \ DerivedSources/webkit/WebKitDOMHTMLImageElement.h \ DerivedSources/webkit/WebKitDOMHTMLInputElement.h \ DerivedSources/webkit/WebKitDOMHTMLIsIndexElement.h \ + DerivedSources/webkit/WebKitDOMHTMLKeygenElement.h \ DerivedSources/webkit/WebKitDOMHTMLLabelElement.h \ DerivedSources/webkit/WebKitDOMHTMLLegendElement.h \ DerivedSources/webkit/WebKitDOMHTMLLIElement.h \ diff --git a/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp b/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp index da420ae..3ac13d1 100644 --- a/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp +++ b/Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp @@ -62,6 +62,7 @@ #include "HTMLImageElement.h" #include "HTMLInputElement.h" #include "HTMLIsIndexElement.h" +#include "HTMLKeygenElement.h" #include "HTMLLIElement.h" #include "HTMLLabelElement.h" #include "HTMLLegendElement.h" @@ -121,6 +122,7 @@ #include "webkit/WebKitDOMHTMLImageElementPrivate.h" #include "webkit/WebKitDOMHTMLInputElementPrivate.h" #include "webkit/WebKitDOMHTMLIsIndexElementPrivate.h" +#include "webkit/WebKitDOMHTMLKeygenElementPrivate.h" #include "webkit/WebKitDOMHTMLLIElementPrivate.h" #include "webkit/WebKitDOMHTMLLabelElementPrivate.h" #include "webkit/WebKitDOMHTMLLegendElementPrivate.h" @@ -322,6 +324,11 @@ static gpointer createIsIndexWrapper(PassRefPtr<HTMLElement> element) return wrapHTMLIsIndexElement(static_cast<HTMLIsIndexElement*>(element.get())); } +static gpointer createKeygenWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLKeygenElement(static_cast<HTMLKeygenElement*>(element.get())); +} + static gpointer createLabelWrapper(PassRefPtr<HTMLElement> element) { return wrapHTMLLabelElement(static_cast<HTMLLabelElement*>(element.get())); @@ -523,7 +530,7 @@ gpointer createHTMLElementWrapper(PassRefPtr<WebCore::HTMLElement> element) map.set(h6Tag.localName().impl(), createHeadingWrapper); map.set(imageTag.localName().impl(), createImageWrapper); map.set(insTag.localName().impl(), createModWrapper); - map.set(keygenTag.localName().impl(), createSelectWrapper); + map.set(keygenTag.localName().impl(), createKeygenWrapper); map.set(listingTag.localName().impl(), createPreWrapper); map.set(tfootTag.localName().impl(), createTableSectionWrapper); map.set(thTag.localName().impl(), createTableCellWrapper); diff --git a/Source/WebCore/bindings/js/CachedScriptSourceProvider.h b/Source/WebCore/bindings/js/CachedScriptSourceProvider.h index 809a488..9bae8ca 100644 --- a/Source/WebCore/bindings/js/CachedScriptSourceProvider.h +++ b/Source/WebCore/bindings/js/CachedScriptSourceProvider.h @@ -36,6 +36,7 @@ namespace WebCore { class CachedScriptSourceProvider : public ScriptSourceProvider, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<CachedScriptSourceProvider> create(CachedScript* cachedScript) { return adoptRef(new CachedScriptSourceProvider(cachedScript)); } @@ -49,9 +50,14 @@ namespace WebCore { int length() const { return m_cachedScript->script().length(); } const String& source() const { return m_cachedScript->script(); } + virtual void cacheSizeChanged(int delta) + { + m_cachedScript->sourceProviderCacheSizeChanged(delta); + } + private: CachedScriptSourceProvider(CachedScript* cachedScript) - : ScriptSourceProvider(stringToUString(cachedScript->url())) + : ScriptSourceProvider(stringToUString(cachedScript->url()), cachedScript->sourceProviderCache()) , m_cachedScript(cachedScript) { m_cachedScript->addClient(this); diff --git a/Source/WebCore/bindings/js/GCController.h b/Source/WebCore/bindings/js/GCController.h index 4c25407..91f1e4c 100644 --- a/Source/WebCore/bindings/js/GCController.h +++ b/Source/WebCore/bindings/js/GCController.h @@ -26,12 +26,12 @@ #ifndef GCController_h #define GCController_h -#include <wtf/Noncopyable.h> #include "Timer.h" namespace WebCore { - class GCController : public Noncopyable { + class GCController { + WTF_MAKE_NONCOPYABLE(GCController); WTF_MAKE_FAST_ALLOCATED; friend GCController& gcController(); public: diff --git a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h index e010406..73229da 100644 --- a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h +++ b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h @@ -181,6 +181,19 @@ PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec) return result; } +template <typename JSType, typename WebCoreType> +static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebCoreType* object) +{ + if (!object) + return JSC::jsNull(); + + if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec, object)) + return wrapper; + + exec->heap()->reportExtraMemoryCost(object->byteLength()); + return createDOMObjectWrapper<JSType>(exec, globalObject, object); +} + } // namespace WebCore #endif // JSArrayBufferViewHelper_h diff --git a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp index 853e2ef..af74e8c 100644 --- a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -71,6 +71,7 @@ #include "JSDeviceOrientationEventCustom.cpp" #include "JSDocumentCustom.cpp" #include "JSElementCustom.cpp" +#include "JSErrorHandler.cpp" #include "JSEventCustom.cpp" #include "JSEventListener.cpp" #include "JSEventSourceCustom.cpp" @@ -139,7 +140,6 @@ #include "JSWebSocketCustom.cpp" #include "JSWorkerContextBase.cpp" #include "JSWorkerContextCustom.cpp" -#include "JSWorkerContextErrorHandler.cpp" #include "JSWorkerCustom.cpp" #include "JSXMLHttpRequestCustom.cpp" #include "JSXMLHttpRequestUploadCustom.cpp" diff --git a/Source/WebCore/bindings/js/JSDOMBinding.cpp b/Source/WebCore/bindings/js/JSDOMBinding.cpp index 72c7cd6..e53dcfb 100644 --- a/Source/WebCore/bindings/js/JSDOMBinding.cpp +++ b/Source/WebCore/bindings/js/JSDOMBinding.cpp @@ -53,6 +53,7 @@ #include "ProcessingInstruction.h" #include "RangeException.h" #include "ScriptCachedFrameData.h" +#include "ScriptCallStack.h" #include "ScriptController.h" #include "Settings.h" #include "WebCoreJSClientData.h" @@ -589,7 +590,7 @@ void reportException(ExecState* exec, JSValue exception) if (!scriptExecutionContext) return; - scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL)); + scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL), 0); } void reportCurrentException(ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSDebugWrapperSet.h b/Source/WebCore/bindings/js/JSDebugWrapperSet.h index 94b6f78..e1138ed 100644 --- a/Source/WebCore/bindings/js/JSDebugWrapperSet.h +++ b/Source/WebCore/bindings/js/JSDebugWrapperSet.h @@ -37,7 +37,8 @@ namespace WebCore { // - wrappers being deleted without being removed from the cache // - wrappers being cached twice -class JSDebugWrapperSet : public Noncopyable { +class JSDebugWrapperSet { + WTF_MAKE_NONCOPYABLE(JSDebugWrapperSet); friend class WTF::ThreadSpecific<JSDebugWrapperSet>; public: static JSDebugWrapperSet& shared(); diff --git a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp b/Source/WebCore/bindings/js/JSErrorHandler.cpp index f7d2b02..ae8e363 100644 --- a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp +++ b/Source/WebCore/bindings/js/JSErrorHandler.cpp @@ -30,9 +30,7 @@ #include "config.h" -#if ENABLE(WORKERS) - -#include "JSWorkerContextErrorHandler.h" +#include "JSErrorHandler.h" #include "ErrorEvent.h" #include "Event.h" @@ -43,21 +41,26 @@ using namespace JSC; namespace WebCore { -JSWorkerContextErrorHandler::JSWorkerContextErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) +JSErrorHandler::JSErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) : JSEventListener(function, wrapper, isAttribute, isolatedWorld) { } -JSWorkerContextErrorHandler::~JSWorkerContextErrorHandler() +JSErrorHandler::~JSErrorHandler() { } -void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) +void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) { + if (!event->isErrorEvent()) + return JSEventListener::handleEvent(scriptExecutionContext, event); + ASSERT(scriptExecutionContext); if (!scriptExecutionContext) return; + ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); + JSLock lock(SilenceAssertionsOnly); JSObject* jsFunction = this->jsFunction(scriptExecutionContext); @@ -74,15 +77,11 @@ void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExec CallType callType = jsFunction->getCallData(callData); if (callType != CallTypeNone) { - - ref(); + RefPtr<JSErrorHandler> protectedctor(this); Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); - ASSERT(event->isErrorEvent()); - ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); - MarkedArgumentBuffer args; args.append(jsString(exec, errorEvent->message())); args.append(jsString(exec, errorEvent->filename())); @@ -106,11 +105,7 @@ void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExec if (returnValue.getBoolean(retvalbool) && !retvalbool) event->preventDefault(); } - - deref(); } } } // namespace WebCore - -#endif // ENABLE(WORKERS) diff --git a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h b/Source/WebCore/bindings/js/JSErrorHandler.h index a188299..957fd81 100644 --- a/Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h +++ b/Source/WebCore/bindings/js/JSErrorHandler.h @@ -28,37 +28,37 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWorkerContextErrorHandler_h -#define JSWorkerContextErrorHandler_h +#ifndef JSErrorHandler_h +#define JSErrorHandler_h #include "JSEventListener.h" namespace WebCore { -class JSWorkerContextErrorHandler : public JSEventListener { +class JSErrorHandler : public JSEventListener { public: - static PassRefPtr<JSWorkerContextErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) + static PassRefPtr<JSErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) { - return adoptRef(new JSWorkerContextErrorHandler(listener, wrapper, isAttribute, isolatedWorld)); + return adoptRef(new JSErrorHandler(listener, wrapper, isAttribute, isolatedWorld)); } - virtual ~JSWorkerContextErrorHandler(); + virtual ~JSErrorHandler(); private: - JSWorkerContextErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld); + JSErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld); virtual void handleEvent(ScriptExecutionContext*, Event*); }; // Creates a JS EventListener for "onerror" event handler in worker context. It has custom implementation because // unlike other event listeners it accepts three parameters. -inline PassRefPtr<JSWorkerContextErrorHandler> createJSWorkerContextErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper) +inline PassRefPtr<JSErrorHandler> createJSErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper) { if (!listener.isObject()) return 0; - return JSWorkerContextErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec)); + return JSErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec)); } } // namespace WebCore -#endif // JSWorkerContextErrorHandler_h +#endif // JSErrorHandler_h diff --git a/Source/WebCore/bindings/js/JSEventListener.h b/Source/WebCore/bindings/js/JSEventListener.h index b15c589..83d0d2e 100644 --- a/Source/WebCore/bindings/js/JSEventListener.h +++ b/Source/WebCore/bindings/js/JSEventListener.h @@ -59,11 +59,11 @@ namespace WebCore { virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const; virtual void markJSFunction(JSC::MarkStack&); virtual void invalidateJSFunction(JSC::JSObject*); - virtual void handleEvent(ScriptExecutionContext*, Event*); virtual bool virtualisAttribute() const; protected: JSEventListener(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld); + virtual void handleEvent(ScriptExecutionContext*, Event*); private: mutable JSC::JSObject* m_jsFunction; diff --git a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp index 880d68c..eb4608c 100644 --- a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSFloat32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVa JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float32Array* object) { - return getDOMObjectWrapper<JSFloat32Array>(exec, globalObject, object); + return toJSArrayBufferView<JSFloat32Array>(exec, globalObject, object); } JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp index e08da8a..2e56d0b 100644 --- a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSInt16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int16Array* object) { - return getDOMObjectWrapper<JSInt16Array>(exec, globalObject, object); + return toJSArrayBufferView<JSInt16Array>(exec, globalObject, object); } JSC::JSValue JSInt16Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp index 5aa64bb..eaf474a 100644 --- a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSInt32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int32Array* object) { - return getDOMObjectWrapper<JSInt32Array>(exec, globalObject, object); + return toJSArrayBufferView<JSInt32Array>(exec, globalObject, object); } JSC::JSValue JSInt32Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp index b63de54..c4bd007 100644 --- a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp @@ -44,7 +44,7 @@ void JSInt8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int8Array* object) { - return getDOMObjectWrapper<JSInt8Array>(exec, globalObject, object); + return toJSArrayBufferView<JSInt8Array>(exec, globalObject, object); } JSC::JSValue JSInt8Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSMainThreadExecState.h b/Source/WebCore/bindings/js/JSMainThreadExecState.h index 8193d7c..349dc14 100644 --- a/Source/WebCore/bindings/js/JSMainThreadExecState.h +++ b/Source/WebCore/bindings/js/JSMainThreadExecState.h @@ -30,11 +30,11 @@ #ifndef NDEBUG #include <wtf/MainThread.h> #endif -#include <wtf/Noncopyable.h> namespace WebCore { -class JSMainThreadExecState : public Noncopyable { +class JSMainThreadExecState { + WTF_MAKE_NONCOPYABLE(JSMainThreadExecState); public: static JSC::ExecState* currentState() { diff --git a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp index 6a024ee..9e476f2 100644 --- a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSUint16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint16Array* object) { - return getDOMObjectWrapper<JSUint16Array>(exec, globalObject, object); + return toJSArrayBufferView<JSUint16Array>(exec, globalObject, object); } JSC::JSValue JSUint16Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp index 34eb8de..d221c2a 100644 --- a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSUint32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint32Array* object) { - return getDOMObjectWrapper<JSUint32Array>(exec, globalObject, object); + return toJSArrayBufferView<JSUint32Array>(exec, globalObject, object); } JSC::JSValue JSUint32Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp index a9ed73f..b37eea8 100644 --- a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp @@ -43,7 +43,7 @@ void JSUint8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8Array* object) { - return getDOMObjectWrapper<JSUint8Array>(exec, globalObject, object); + return toJSArrayBufferView<JSUint8Array>(exec, globalObject, object); } JSC::JSValue JSUint8Array::set(JSC::ExecState* exec) diff --git a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp index ed4a9ca..dc32d5f 100644 --- a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp @@ -37,6 +37,7 @@ #include "JSHTMLCanvasElement.h" #include "JSHTMLImageElement.h" #include "JSImageData.h" +#include "JSOESStandardDerivatives.h" #include "JSOESTextureFloat.h" #include "JSWebGLBuffer.h" #include "JSFloat32Array.h" @@ -50,6 +51,7 @@ #include "JSUint8Array.h" #include "JSWebKitCSSMatrix.h" #include "NotImplemented.h" +#include "OESStandardDerivatives.h" #include "OESTextureFloat.h" #include "WebGLBuffer.h" #include "Float32Array.h" @@ -173,6 +175,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten switch (extension->getName()) { case WebGLExtension::WebKitLoseContextName: return toJS(exec, globalObject, static_cast<WebKitLoseContext*>(extension)); + case WebGLExtension::OESStandardDerivativesName: + return toJS(exec, globalObject, static_cast<OESStandardDerivatives*>(extension)); case WebGLExtension::OESTextureFloatName: return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension)); } diff --git a/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp b/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp index c280d98..cc6986a 100644 --- a/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp +++ b/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp @@ -42,11 +42,11 @@ using namespace JSC; namespace WebCore { -JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line) +JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition) : m_debuggerCallFrame(debuggerCallFrame) , m_caller(caller) , m_sourceID(sourceID) - , m_line(line) + , m_textPosition(textPosition) , m_isValid(true) { } diff --git a/Source/WebCore/bindings/js/JavaScriptCallFrame.h b/Source/WebCore/bindings/js/JavaScriptCallFrame.h index c23a43d..74e0a70 100644 --- a/Source/WebCore/bindings/js/JavaScriptCallFrame.h +++ b/Source/WebCore/bindings/js/JavaScriptCallFrame.h @@ -33,14 +33,15 @@ #include <wtf/Forward.h> #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> +#include <wtf/text/TextPosition.h> namespace WebCore { class JavaScriptCallFrame : public RefCounted<JavaScriptCallFrame> { public: - static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line) + static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition) { - return adoptRef(new JavaScriptCallFrame(debuggerCallFrame, caller, sourceID, line)); + return adoptRef(new JavaScriptCallFrame(debuggerCallFrame, caller, sourceID, textPosition)); } void invalidate() @@ -54,11 +55,13 @@ public: JavaScriptCallFrame* caller(); intptr_t sourceID() const { return m_sourceID; } - int line() const { return m_line; } - void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int line) + int line() const { return m_textPosition.m_line.oneBasedInt(); } + int column() const { return m_textPosition.m_column.oneBasedInt(); } + + void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, const TextPosition1& textPosition) { m_debuggerCallFrame = debuggerCallFrame; - m_line = line; + m_textPosition = textPosition; m_sourceID = sourceID; m_isValid = true; } @@ -72,12 +75,12 @@ public: JSC::JSValue evaluate(const JSC::UString& script, JSC::JSValue& exception) const; private: - JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line); + JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1&); JSC::DebuggerCallFrame m_debuggerCallFrame; RefPtr<JavaScriptCallFrame> m_caller; intptr_t m_sourceID; - int m_line; + TextPosition1 m_textPosition; bool m_isValid; }; diff --git a/Source/WebCore/bindings/js/ScheduledAction.h b/Source/WebCore/bindings/js/ScheduledAction.h index 6c9d0ba..59ad6fc 100644 --- a/Source/WebCore/bindings/js/ScheduledAction.h +++ b/Source/WebCore/bindings/js/ScheduledAction.h @@ -41,7 +41,8 @@ namespace WebCore { * time interval, either once or repeatedly. Used for window.setTimeout() * and window.setInterval() */ - class ScheduledAction : public Noncopyable { + class ScheduledAction { + WTF_MAKE_NONCOPYABLE(ScheduledAction); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<ScheduledAction> create(JSC::ExecState*, DOMWrapperWorld* isolatedWorld); diff --git a/Source/WebCore/bindings/js/ScriptCachedFrameData.h b/Source/WebCore/bindings/js/ScriptCachedFrameData.h index 15c23c5..5f691d9 100644 --- a/Source/WebCore/bindings/js/ScriptCachedFrameData.h +++ b/Source/WebCore/bindings/js/ScriptCachedFrameData.h @@ -40,7 +40,8 @@ namespace WebCore { class DOMWindow; class DOMWrapperWorld; - class ScriptCachedFrameData : public Noncopyable { + class ScriptCachedFrameData { + WTF_MAKE_NONCOPYABLE(ScriptCachedFrameData); WTF_MAKE_FAST_ALLOCATED; typedef HashMap< RefPtr<DOMWrapperWorld>, JSC::ProtectedPtr<JSDOMWindow> > JSDOMWindowSet; public: diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.cpp b/Source/WebCore/bindings/js/ScriptDebugServer.cpp index 9845277..b516f6d 100644 --- a/Source/WebCore/bindings/js/ScriptDebugServer.cpp +++ b/Source/WebCore/bindings/js/ScriptDebugServer.cpp @@ -48,7 +48,7 @@ #include "ScrollView.h" #include "Widget.h" #include <debugger/DebuggerCallFrame.h> -#include <parser/SourceCode.h> +#include <parser/SourceProvider.h> #include <runtime/JSLock.h> #include <wtf/text/StringConcatenate.h> #include <wtf/MainThread.h> @@ -282,23 +282,25 @@ void ScriptDebugServer::dispatchDidContinue(ScriptDebugListener* listener) listener->didContinue(); } -void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, ScriptWorldType worldType) +void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, ScriptWorldType worldType) { - String sourceID = ustringToString(JSC::UString::number(source.provider()->asID())); - String url = ustringToString(source.provider()->url()); - String data = ustringToString(JSC::UString(source.data(), source.length())); + String sourceID = ustringToString(JSC::UString::number(sourceProvider->asID())); + String url = ustringToString(sourceProvider->url()); + String data = ustringToString(JSC::UString(sourceProvider->data(), sourceProvider->length())); + int lineOffset = sourceProvider->startPosition().m_line.convertAsZeroBasedInt(); + int columnOffset = sourceProvider->startPosition().m_column.convertAsZeroBasedInt(); Vector<ScriptDebugListener*> copy; copyToVector(listeners, copy); for (size_t i = 0; i < copy.size(); ++i) - copy[i]->didParseSource(sourceID, url, data, source.firstLine() - 1, source.firstColumn() - 1, worldType); + copy[i]->didParseSource(sourceID, url, data, lineOffset, columnOffset, worldType); } -void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, const SourceCode& source, int errorLine, const String& errorMessage) +void ScriptDebugServer::dispatchFailedToParseSource(const ListenerSet& listeners, SourceProvider* sourceProvider, int errorLine, const String& errorMessage) { - String url = ustringToString(source.provider()->url()); - String data = ustringToString(JSC::UString(source.data(), source.length())); - int firstLine = source.firstLine(); + String url = ustringToString(sourceProvider->url()); + String data = ustringToString(JSC::UString(sourceProvider->data(), sourceProvider->length())); + int firstLine = sourceProvider->startPosition().m_line.oneBasedInt(); Vector<ScriptDebugListener*> copy; copyToVector(listeners, copy); @@ -335,7 +337,7 @@ void ScriptDebugServer::detach(JSGlobalObject* globalObject) Debugger::detach(globalObject); } -void ScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode& source, int errorLine, const UString& errorMessage) +void ScriptDebugServer::sourceParsed(ExecState* exec, SourceProvider* sourceProvider, int errorLine, const UString& errorMessage) { if (m_callingListeners) return; @@ -353,9 +355,9 @@ void ScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode& source, if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) { ASSERT(!pageListeners->isEmpty()); if (isError) - dispatchFailedToParseSource(*pageListeners, source, errorLine, ustringToString(errorMessage)); + dispatchFailedToParseSource(*pageListeners, sourceProvider, errorLine, ustringToString(errorMessage)); else - dispatchDidParseSource(*pageListeners, source, worldType); + dispatchDidParseSource(*pageListeners, sourceProvider, worldType); } m_callingListeners = false; @@ -440,6 +442,24 @@ void ScriptDebugServer::setJavaScriptPaused(FrameView* view, bool paused) } } +void ScriptDebugServer::createCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) +{ + TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base()); + m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition); + pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); +} + +void ScriptDebugServer::updateCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) +{ + ASSERT(m_currentCallFrame); + if (!m_currentCallFrame) + return; + + TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base()); + m_currentCallFrame->update(debuggerCallFrame, sourceID, textPosition); + pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); +} + void ScriptDebugServer::pauseIfNeeded(Page* page) { if (m_paused) @@ -480,24 +500,14 @@ void ScriptDebugServer::pauseIfNeeded(Page* page) void ScriptDebugServer::callEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) { - if (m_paused) - return; - - m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + if (!m_paused) + createCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::atStatement(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) { - if (m_paused) - return; - - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + if (!m_paused) + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) @@ -505,12 +515,7 @@ void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame, if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); // detach may have been called during pauseIfNeeded if (!m_currentCallFrame) @@ -527,24 +532,16 @@ void ScriptDebugServer::exception(const DebuggerCallFrame& debuggerCallFrame, in if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - if (m_pauseOnExceptionsState == PauseOnAllExceptions || (m_pauseOnExceptionsState == PauseOnUncaughtExceptions && !hasHandler)) m_pauseOnNextStatement = true; - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::willExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) { - if (m_paused) - return; - - m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + if (!m_paused) + createCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) @@ -552,12 +549,7 @@ void ScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerCallF if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); // Treat stepping over the end of a program like stepping out. if (m_currentCallFrame == m_pauseOnCallFrame) @@ -570,13 +562,8 @@ void ScriptDebugServer::didReachBreakpoint(const DebuggerCallFrame& debuggerCall if (m_paused) return; - ASSERT(m_currentCallFrame); - if (!m_currentCallFrame) - return; - m_pauseOnNextStatement = true; - m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber); - pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); + updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber); } void ScriptDebugServer::recompileAllJSFunctionsSoon() diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.h b/Source/WebCore/bindings/js/ScriptDebugServer.h index 81cd9ac..bde4736 100644 --- a/Source/WebCore/bindings/js/ScriptDebugServer.h +++ b/Source/WebCore/bindings/js/ScriptDebugServer.h @@ -56,7 +56,8 @@ class PageGroup; class ScriptDebugListener; class JavaScriptCallFrame; -class ScriptDebugServer : JSC::Debugger, public Noncopyable { +class ScriptDebugServer : JSC::Debugger { + WTF_MAKE_NONCOPYABLE(ScriptDebugServer); WTF_MAKE_FAST_ALLOCATED; public: static ScriptDebugServer& shared(); @@ -115,14 +116,16 @@ private: void dispatchFunctionToListeners(const ListenerSet& listeners, JavaScriptExecutionCallback callback); void dispatchDidPause(ScriptDebugListener*); void dispatchDidContinue(ScriptDebugListener*); - void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, enum ScriptWorldType); - void dispatchFailedToParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, int errorLine, const String& errorMessage); + void dispatchDidParseSource(const ListenerSet& listeners, JSC::SourceProvider*, enum ScriptWorldType); + void dispatchFailedToParseSource(const ListenerSet& listeners, JSC::SourceProvider*, int errorLine, const String& errorMessage); + void createCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); + void updateCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); void pauseIfNeeded(Page*); virtual void detach(JSC::JSGlobalObject*); - virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMsg); + virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const JSC::UString& errorMsg); virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int firstLine); virtual void returnEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); diff --git a/Source/WebCore/bindings/js/ScriptProfiler.h b/Source/WebCore/bindings/js/ScriptProfiler.h index 05e7a25..d4dd606 100644 --- a/Source/WebCore/bindings/js/ScriptProfiler.h +++ b/Source/WebCore/bindings/js/ScriptProfiler.h @@ -32,11 +32,11 @@ #include "ScriptProfile.h" #include "ScriptState.h" -#include <wtf/Noncopyable.h> namespace WebCore { -class ScriptProfiler : public Noncopyable { +class ScriptProfiler { + WTF_MAKE_NONCOPYABLE(ScriptProfiler); public: static void start(ScriptState* state, const String& title); static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); diff --git a/Source/WebCore/bindings/js/ScriptSourceCode.h b/Source/WebCore/bindings/js/ScriptSourceCode.h index 6cf3987..373db31 100644 --- a/Source/WebCore/bindings/js/ScriptSourceCode.h +++ b/Source/WebCore/bindings/js/ScriptSourceCode.h @@ -43,8 +43,8 @@ namespace WebCore { class ScriptSourceCode { public: ScriptSourceCode(const String& source, const KURL& url = KURL(), const TextPosition1& startPosition = TextPosition1::minimumPosition()) - : m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string())) - , m_code(m_provider, startPosition) + : m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string(), startPosition)) + , m_code(m_provider, startPosition.m_line.oneBasedInt()) , m_url(url) { } diff --git a/Source/WebCore/bindings/js/ScriptSourceProvider.h b/Source/WebCore/bindings/js/ScriptSourceProvider.h index de4e307..3a5d579 100644 --- a/Source/WebCore/bindings/js/ScriptSourceProvider.h +++ b/Source/WebCore/bindings/js/ScriptSourceProvider.h @@ -34,8 +34,8 @@ namespace WebCore { class ScriptSourceProvider : public JSC::SourceProvider { public: - ScriptSourceProvider(const JSC::UString& url) - : SourceProvider(url) + ScriptSourceProvider(const JSC::UString& url, JSC::SourceProviderCache* cache = 0) + : SourceProvider(url, cache) { } diff --git a/Source/WebCore/bindings/js/ScriptState.h b/Source/WebCore/bindings/js/ScriptState.h index 0c08611..e19c0c8 100644 --- a/Source/WebCore/bindings/js/ScriptState.h +++ b/Source/WebCore/bindings/js/ScriptState.h @@ -52,7 +52,8 @@ class Page; // For now, the separation is purely by convention. typedef JSC::ExecState ScriptState; -class ScriptStateProtectedPtr : public Noncopyable { +class ScriptStateProtectedPtr { + WTF_MAKE_NONCOPYABLE(ScriptStateProtectedPtr); public: explicit ScriptStateProtectedPtr(ScriptState*); ~ScriptStateProtectedPtr(); diff --git a/Source/WebCore/bindings/js/StringSourceProvider.h b/Source/WebCore/bindings/js/StringSourceProvider.h index 478c1d1..e23fe5c 100644 --- a/Source/WebCore/bindings/js/StringSourceProvider.h +++ b/Source/WebCore/bindings/js/StringSourceProvider.h @@ -37,20 +37,26 @@ namespace WebCore { class StringSourceProvider : public ScriptSourceProvider { public: - static PassRefPtr<StringSourceProvider> create(const String& source, const String& url) { return adoptRef(new StringSourceProvider(source, url)); } + static PassRefPtr<StringSourceProvider> create(const String& source, const String& url, const TextPosition1& startPosition = TextPosition1::minimumPosition()) + { + return adoptRef(new StringSourceProvider(source, url, startPosition)); + } + virtual TextPosition1 startPosition() const { return m_startPosition; } JSC::UString getRange(int start, int end) const { return JSC::UString(m_source.characters() + start, end - start); } const UChar* data() const { return m_source.characters(); } int length() const { return m_source.length(); } const String& source() const { return m_source; } private: - StringSourceProvider(const String& source, const String& url) + StringSourceProvider(const String& source, const String& url, const TextPosition1& startPosition) : ScriptSourceProvider(stringToUString(url)) + , m_startPosition(startPosition) , m_source(source) { } + TextPosition1 m_startPosition; String m_source; }; diff --git a/Source/WebCore/bindings/js/WebCoreJSClientData.h b/Source/WebCore/bindings/js/WebCoreJSClientData.h index 5d03328..6e2d7be 100644 --- a/Source/WebCore/bindings/js/WebCoreJSClientData.h +++ b/Source/WebCore/bindings/js/WebCoreJSClientData.h @@ -24,17 +24,18 @@ #include "DOMWrapperWorld.h" #include "DOMObjectHashTableMap.h" -#include <wtf/Noncopyable.h> #include <wtf/HashSet.h> #include <wtf/RefPtr.h> namespace WebCore { -class WebCoreJSClientData : public JSC::JSGlobalData::ClientData, public Noncopyable { +class WebCoreJSClientData : public JSC::JSGlobalData::ClientData { + WTF_MAKE_NONCOPYABLE(WebCoreJSClientData); WTF_MAKE_FAST_ALLOCATED; friend class JSGlobalDataWorldIterator; friend void initNormalWorldClientData(JSC::JSGlobalData*); public: + WebCoreJSClientData() { } virtual ~WebCoreJSClientData() { ASSERT(m_worldSet.contains(m_normalWorld.get())); diff --git a/Source/WebCore/bindings/js/WorkerScriptController.h b/Source/WebCore/bindings/js/WorkerScriptController.h index be7da4d..4578913 100644 --- a/Source/WebCore/bindings/js/WorkerScriptController.h +++ b/Source/WebCore/bindings/js/WorkerScriptController.h @@ -31,7 +31,6 @@ #include <runtime/Protect.h> #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> #include <wtf/Threading.h> namespace JSC { @@ -45,7 +44,8 @@ namespace WebCore { class ScriptValue; class WorkerContext; - class WorkerScriptController : public Noncopyable { + class WorkerScriptController { + WTF_MAKE_NONCOPYABLE(WorkerScriptController); WTF_MAKE_FAST_ALLOCATED; public: WorkerScriptController(WorkerContext*); ~WorkerScriptController(); diff --git a/Source/WebCore/bindings/objc/DOM.mm b/Source/WebCore/bindings/objc/DOM.mm index 44bd653..1c24de6 100644 --- a/Source/WebCore/bindings/objc/DOM.mm +++ b/Source/WebCore/bindings/objc/DOM.mm @@ -131,7 +131,6 @@ static void createElementClassMap() addElementClass(HTMLNames::preTag, [DOMHTMLPreElement class]); addElementClass(HTMLNames::qTag, [DOMHTMLQuoteElement class]); addElementClass(HTMLNames::scriptTag, [DOMHTMLScriptElement class]); - addElementClass(HTMLNames::keygenTag, [DOMHTMLSelectElement class]); addElementClass(HTMLNames::selectTag, [DOMHTMLSelectElement class]); addElementClass(HTMLNames::styleTag, [DOMHTMLStyleElement class]); addElementClass(HTMLNames::tableTag, [DOMHTMLTableElement class]); diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm index 1863d8f..ed76d08 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -518,7 +518,7 @@ my @eventSignalNames = ( # User Interface Event types "focus", "blur", # Basic Event types - "load", "unload", "abort", "error", "select", "change", "submit", "reset", + "load", "unload", "abort", "error", "select", "change", "formchange", "submit", "reset", "resize", "scroll", # Mouse Event types "click", "dblclick", "mousedown", "mouseup", @@ -540,7 +540,7 @@ my @eventSignalNames = ( # Animations "webkitanimationend", "webkitanimationstart", "webkitanimationiteration", # Other - "contextmenu", "input", "invalid", "search", "selectstart"); + "contextmenu", "input", "forminput", "invalid", "search", "selectstart"); sub GenerateProperties { my ($object, $interfaceName, $dataNode) = @_; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm index cff51e9..abef04e 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -1721,9 +1721,9 @@ sub GenerateImplementation push(@implContent, " JSDOMGlobalObject* globalObject = castedThis->globalObject();\n"); } push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(thisObject)->impl());\n"); - if ($interfaceName eq "WorkerContext" and $name eq "onerror") { - $implIncludes{"JSWorkerContextErrorHandler.h"} = 1; - push(@implContent, " imp->set$implSetterFunctionName(createJSWorkerContextErrorHandler(exec, value, thisObject));\n"); + if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerContext")) and $name eq "onerror") { + $implIncludes{"JSErrorHandler.h"} = 1; + push(@implContent, " imp->set$implSetterFunctionName(createJSErrorHandler(exec, value, thisObject));\n"); } else { push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener)); } diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm index f50e74a..7d36db1 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -1001,6 +1001,10 @@ END $implIncludes{"V8EventListenerList.h"} = 1; $implIncludes{"V8WorkerContextErrorHandler.h"} = 1; push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)"); + } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->name eq "onerror") { + $implIncludes{"V8EventListenerList.h"} = 1; + $implIncludes{"V8WindowErrorHandler.h"} = 1; + push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WindowErrorHandler>(value, true)"); } else { push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)"); } @@ -2397,9 +2401,13 @@ END push(@args, " ${paramName}Handle"); } - push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); - push(@implContent, join(",\n", @args)); - push(@implContent, "\n };\n\n"); + if (scalar(@args) > 0) { + push(@implContent, "\n v8::Handle<v8::Value> argv[] = {\n"); + push(@implContent, join(",\n", @args)); + push(@implContent, "\n };\n\n"); + } else { + push(@implContent, "\n v8::Handle<v8::Value> *argv = 0;\n\n"); + } push(@implContent, " bool callbackReturnValue = false;\n"); push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); push(@implContent, "}\n"); diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp index a58da40..62ebc3c 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp @@ -83,6 +83,14 @@ WebDOMTestCallback::~WebDOMTestCallback() m_impl = 0; } +bool WebDOMTestCallback::callbackWithNoParam() +{ + if (!impl()) + return false; + + return impl()->callbackWithNoParam(); +} + bool WebDOMTestCallback::callbackWithClass1Param(const WebDOMClass1& class1Param) { if (!impl()) diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h index 91ff787..7a077e2 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h @@ -46,6 +46,7 @@ public: WebDOMTestCallback& operator=(const WebDOMTestCallback&); virtual ~WebDOMTestCallback(); + bool callbackWithNoParam(); bool callbackWithClass1Param(const WebDOMClass1& class1Param); bool callbackWithClass2Param(const WebDOMClass2& class2Param, const WebDOMString& strArg); int callbackWithNonBoolReturnType(const WebDOMClass3& class3Param); diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp index 9c8fa59..054dc38 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -39,8 +39,9 @@ #include "webkit/WebKitDOMClass3Private.h" #include "webkit/WebKitDOMTestCallback.h" #include "webkit/WebKitDOMTestCallbackPrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { @@ -57,6 +58,16 @@ WebKitDOMTestCallback* kit(WebCore::TestCallback* obj) } // namespace WebKit // gboolean +webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback * item = WebKit::core(self); + gboolean res = item->callbackWithNoParam(); + return res; +} + +gboolean webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param) { g_return_val_if_fail(self, 0); diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h index 4f0ac91..6049c79 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h @@ -47,6 +47,9 @@ WEBKIT_API GType webkit_dom_test_callback_get_type (void); WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self); + +WEBKIT_API gboolean webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param); WEBKIT_API gboolean diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp index b68340b..7086c80 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -33,8 +33,9 @@ #include "gobject/ConvertToUTF8String.h" #include "webkit/WebKitDOMTestInterface.h" #include "webkit/WebKitDOMTestInterfacePrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp index 93d0bde..5946ec0 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp @@ -31,8 +31,9 @@ #include "gobject/ConvertToUTF8String.h" #include "webkit/WebKitDOMTestMediaQueryListListener.h" #include "webkit/WebKitDOMTestMediaQueryListListenerPrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp index 6c94d94..44d58d4 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -38,8 +38,9 @@ #include "webkit/WebKitDOMSerializedScriptValuePrivate.h" #include "webkit/WebKitDOMTestObj.h" #include "webkit/WebKitDOMTestObjPrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" #include "webkitmarshal.h" -#include "webkitprivate.h" namespace WebKit { diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp index 069b8ae..1f48ee9 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -56,6 +56,23 @@ JSTestCallback::~JSTestCallback() // Functions +bool JSTestCallback::callbackWithNoParam() +{ + if (!canInvokeCallback()) + return true; + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + ExecState* exec = m_data->globalObject()->globalExec(); + MarkedArgumentBuffer args; + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + bool JSTestCallback::callbackWithClass1Param(Class1* class1Param) { if (!canInvokeCallback()) diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h index ae91a6c..ba3559c 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -40,6 +40,7 @@ public: virtual ~JSTestCallback(); // Functions + virtual bool callbackWithNoParam(); virtual bool callbackWithClass1Param(Class1* class1Param); virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp index 8e71df1..684f587 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -166,6 +166,7 @@ JSValue jsTestInterfaceConstructor(ExecState* exec, JSValue slotBase, const Iden JSTestInterface* domObject = static_cast<JSTestInterface*>(asObject(slotBase)); return JSTestInterface::getConstructor(exec, domObject->globalObject()); } + JSValue JSTestInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { return getDOMConstructor<JSTestInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp index e505ed2..f1c09b5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp @@ -162,6 +162,7 @@ JSValue jsTestMediaQueryListListenerConstructor(ExecState* exec, JSValue slotBas JSTestMediaQueryListListener* domObject = static_cast<JSTestMediaQueryListListener*>(asObject(slotBase)); return JSTestMediaQueryListListener::getConstructor(exec, domObject->globalObject()); } + JSValue JSTestMediaQueryListListener::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { return getDOMConstructor<JSTestMediaQueryListListenerConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index c4c77ee..9d446a2 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -607,6 +607,7 @@ JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase)); return JSTestObj::getConstructor(exec, domObject->globalObject()); } + void JSTestObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { lookupPut<JSTestObj, Base>(exec, propertyName, value, &JSTestObjTable, this, slot); diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h index 1213c6f..08c30b7 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h @@ -36,6 +36,7 @@ @class NSString; @interface DOMTestCallback : DOMObject +- (BOOL)callbackWithNoParam; - (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param; - (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg; - (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param; diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm index e941eda..c4be39d 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm @@ -79,6 +79,12 @@ [super finalize]; } +- (BOOL)callbackWithNoParam +{ + WebCore::JSMainThreadNullState state; + return IMPL->callbackWithNoParam(); +} + - (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param { WebCore::JSMainThreadNullState state; diff --git a/Source/WebCore/bindings/scripts/test/TestCallback.idl b/Source/WebCore/bindings/scripts/test/TestCallback.idl index 25db4c6..9679a5a 100644 --- a/Source/WebCore/bindings/scripts/test/TestCallback.idl +++ b/Source/WebCore/bindings/scripts/test/TestCallback.idl @@ -33,6 +33,7 @@ module test { Conditional=DATABASE, Callback ] TestCallback { + boolean callbackWithNoParam(); boolean callbackWithClass1Param(in Class1 class1Param); boolean callbackWithClass2Param(in Class2 class2Param, in DOMString strArg); long callbackWithNonBoolReturnType(in Class3 class3Param); diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp index c286c24..36a5ca2 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -48,6 +48,26 @@ V8TestCallback::~V8TestCallback() // Functions +bool V8TestCallback::callbackWithNoParam() +{ + if (!canInvokeCallback()) + return true; + + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + + v8::Handle<v8::Value> *argv = 0; + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 0, argv, callbackReturnValue, scriptExecutionContext()); +} + bool V8TestCallback::callbackWithClass1Param(Class1* class1Param) { if (!canInvokeCallback()) diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h index a105d75..8ff8c26 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -45,6 +45,7 @@ public: virtual ~V8TestCallback(); // Functions + virtual bool callbackWithNoParam(); virtual bool callbackWithClass1Param(Class1* class1Param); virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 7a759a3..4298756 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -260,7 +260,7 @@ static v8::Handle<v8::Value> reflectedUnsignedIntegralAttrAttrGetter(v8::Local<v { INC_STATS("DOM.TestObj.reflectedUnsignedIntegralAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8::Integer::NewFromUnsigned(imp->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)); + return v8::Integer::NewFromUnsigned(std::max(0, imp->getIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr))); } static void reflectedUnsignedIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/Source/WebCore/bindings/v8/DOMData.h b/Source/WebCore/bindings/v8/DOMData.h index 78edf92..b042606 100644 --- a/Source/WebCore/bindings/v8/DOMData.h +++ b/Source/WebCore/bindings/v8/DOMData.h @@ -43,7 +43,8 @@ namespace WebCore { // thread. The DOMData for the main thread and the DOMData for child threads // use different subclasses. // - class DOMData : public Noncopyable { + class DOMData { + WTF_MAKE_NONCOPYABLE(DOMData); public: DOMData(); virtual ~DOMData(); diff --git a/Source/WebCore/bindings/v8/DOMDataStore.cpp b/Source/WebCore/bindings/v8/DOMDataStore.cpp index 0d37dc0..5393bd9 100644 --- a/Source/WebCore/bindings/v8/DOMDataStore.cpp +++ b/Source/WebCore/bindings/v8/DOMDataStore.cpp @@ -148,11 +148,13 @@ void DOMDataStore::weakActiveDOMObjectCallback(v8::Persistent<v8::Value> v8Objec DOMData::handleWeakObject(DOMDataStore::ActiveDOMObjectMap, v8::Persistent<v8::Object>::Cast(v8Object), domObject); } -void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* domObject) +void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> value, void* domObject) { ASSERT(WTF::isMainThread()); Node* node = static_cast<Node*>(domObject); + // Node wrappers must be JS objects. + v8::Persistent<v8::Object> v8Object = v8::Persistent<v8::Object>::Cast(value); WTF::MutexLocker locker(DOMDataStore::allStoresMutex()); DOMDataList& list = DOMDataStore::allStores(); @@ -171,7 +173,7 @@ void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* do node->deref(); // Nobody overrides Node::deref so it's safe } -bool DOMDataStore::IntrusiveDOMWrapperMap::removeIfPresent(Node* obj, v8::Persistent<v8::Data> value) +bool DOMDataStore::IntrusiveDOMWrapperMap::removeIfPresent(Node* obj, v8::Persistent<v8::Object> value) { ASSERT(obj); v8::Persistent<v8::Object>* entry = obj->wrapper(); diff --git a/Source/WebCore/bindings/v8/DOMDataStore.h b/Source/WebCore/bindings/v8/DOMDataStore.h index a1051dd..dbead9c 100644 --- a/Source/WebCore/bindings/v8/DOMDataStore.h +++ b/Source/WebCore/bindings/v8/DOMDataStore.h @@ -149,7 +149,8 @@ namespace WebCore { // This class doesn't manage the lifetime of the store. The data store // lifetime is managed by subclasses. // - class DOMDataStore : public Noncopyable { + class DOMDataStore { + WTF_MAKE_NONCOPYABLE(DOMDataStore); public: enum DOMWrapperMapType { DOMNodeMap, @@ -190,7 +191,7 @@ namespace WebCore { m_table.visit(store, visitor); } - virtual bool removeIfPresent(Node* key, v8::Persistent<v8::Data> value); + virtual bool removeIfPresent(Node*, v8::Persistent<v8::Object>); virtual void clear() { diff --git a/Source/WebCore/bindings/v8/DebuggerScript.js b/Source/WebCore/bindings/v8/DebuggerScript.js index 8c9d98e..eb9de2f 100644 --- a/Source/WebCore/bindings/v8/DebuggerScript.js +++ b/Source/WebCore/bindings/v8/DebuggerScript.js @@ -201,8 +201,10 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) var script = func.script(); var sourceID = script && script.id(); - // Get line number. - var line = DebuggerScript._v8ToWebkitLineNumber(frameMirror.sourceLine()); + // Get location. + var location = frameMirror.sourceLocation(); + var line = DebuggerScript._v8ToWebkitLineNumber(location.line); + var column = DebuggerScript._v8ToWebkitLineNumber(location.column); // Get this object. var thisObject = frameMirror.details_.receiver(); @@ -250,6 +252,7 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) return { "sourceID": sourceID, "line": line, + "column": column, "functionName": functionName, "type": "function", "thisObject": thisObject, diff --git a/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp b/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp index 20bf378..5bb436f 100644 --- a/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp +++ b/Source/WebCore/bindings/v8/JavaScriptCallFrame.cpp @@ -80,6 +80,16 @@ int JavaScriptCallFrame::line() const return 0; } +int JavaScriptCallFrame::column() const +{ + v8::HandleScope handleScope; + v8::Context::Scope contextScope(m_debuggerContext.get()); + v8::Handle<v8::Value> result = m_callFrame.get()->Get(v8String("column")); + if (result->IsInt32()) + return result->Int32Value(); + return 0; +} + String JavaScriptCallFrame::functionName() const { v8::HandleScope handleScope; diff --git a/Source/WebCore/bindings/v8/JavaScriptCallFrame.h b/Source/WebCore/bindings/v8/JavaScriptCallFrame.h index 95a0510..2d14593 100644 --- a/Source/WebCore/bindings/v8/JavaScriptCallFrame.h +++ b/Source/WebCore/bindings/v8/JavaScriptCallFrame.h @@ -51,6 +51,7 @@ public: int sourceID() const; int line() const; + int column() const; String functionName() const; v8::Handle<v8::Value> scopeChain() const; diff --git a/Source/WebCore/bindings/v8/ScriptCachedFrameData.h b/Source/WebCore/bindings/v8/ScriptCachedFrameData.h index 1aa1f62..f08265b 100644 --- a/Source/WebCore/bindings/v8/ScriptCachedFrameData.h +++ b/Source/WebCore/bindings/v8/ScriptCachedFrameData.h @@ -67,7 +67,8 @@ namespace WebCore { class Frame; class DOMWindow; -class ScriptCachedFrameData : public Noncopyable { +class ScriptCachedFrameData { + WTF_MAKE_NONCOPYABLE(ScriptCachedFrameData); public: ScriptCachedFrameData(Frame*); ~ScriptCachedFrameData() { } diff --git a/Source/WebCore/bindings/v8/ScriptDebugServer.h b/Source/WebCore/bindings/v8/ScriptDebugServer.h index 40dd5fc..8fa723f 100644 --- a/Source/WebCore/bindings/v8/ScriptDebugServer.h +++ b/Source/WebCore/bindings/v8/ScriptDebugServer.h @@ -48,7 +48,8 @@ namespace WebCore { class Page; class ScriptDebugListener; -class ScriptDebugServer : public Noncopyable { +class ScriptDebugServer { + WTF_MAKE_NONCOPYABLE(ScriptDebugServer); public: static ScriptDebugServer& shared(); diff --git a/Source/WebCore/bindings/v8/ScriptProfiler.h b/Source/WebCore/bindings/v8/ScriptProfiler.h index b75a054..e0969e1 100644 --- a/Source/WebCore/bindings/v8/ScriptProfiler.h +++ b/Source/WebCore/bindings/v8/ScriptProfiler.h @@ -36,13 +36,13 @@ #include "ScriptProfile.h" #include "ScriptState.h" -#include <wtf/Noncopyable.h> namespace WebCore { class InspectorObject; -class ScriptProfiler : public Noncopyable { +class ScriptProfiler { + WTF_MAKE_NONCOPYABLE(ScriptProfiler); public: static void start(ScriptState* state, const String& title); static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); diff --git a/Source/WebCore/bindings/v8/ScriptState.h b/Source/WebCore/bindings/v8/ScriptState.h index 11813b0..0fecee8 100644 --- a/Source/WebCore/bindings/v8/ScriptState.h +++ b/Source/WebCore/bindings/v8/ScriptState.h @@ -42,7 +42,8 @@ class Frame; class Node; class Page; -class ScriptState : public Noncopyable { +class ScriptState { + WTF_MAKE_NONCOPYABLE(ScriptState); public: bool hadException() { return !m_exception.IsEmpty(); } void setException(v8::Local<v8::Value> exception) @@ -79,7 +80,8 @@ public: ~EmptyScriptState() { } }; -class ScriptStateProtectedPtr : public Noncopyable { +class ScriptStateProtectedPtr { + WTF_MAKE_NONCOPYABLE(ScriptStateProtectedPtr); public: ScriptStateProtectedPtr() : m_scriptState(0) { } ScriptStateProtectedPtr(ScriptState* scriptState) : m_scriptState(scriptState) diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp index 6ac4a65..666e619 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp @@ -128,7 +128,8 @@ private: // Writer is responsible for serializing primitive types and storing // information used to reconstruct composite types. -class Writer : Noncopyable { +class Writer { + WTF_MAKE_NONCOPYABLE(Writer); public: Writer() : m_position(0) @@ -377,7 +378,8 @@ public: } private: - class StateBase : public Noncopyable { + class StateBase { + WTF_MAKE_NONCOPYABLE(StateBase); public: virtual ~StateBase() { } @@ -1129,12 +1131,18 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() return adoptRef(new SerializedScriptValue()); } -SerializedScriptValue* SerializedScriptValue::nullValue() +SerializedScriptValue* SerializedScriptValue::nullValue() { DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (SerializedScriptValue::create())); return nullValue.get(); } +SerializedScriptValue* SerializedScriptValue::undefinedValue() +{ + DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, undefinedValue, (SerializedScriptValue::create(v8::Undefined()))); + return undefinedValue.get(); +} + PassRefPtr<SerializedScriptValue> SerializedScriptValue::release() { RefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_data, WireData)); diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.h b/Source/WebCore/bindings/v8/SerializedScriptValue.h index b534a57..ead9511 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.h +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.h @@ -52,8 +52,9 @@ public: static PassRefPtr<SerializedScriptValue> createFromWire(String data); static PassRefPtr<SerializedScriptValue> create(String data); static PassRefPtr<SerializedScriptValue> create(); - - static SerializedScriptValue* nullValue(); + + static SerializedScriptValue* nullValue(); + static SerializedScriptValue* undefinedValue(); PassRefPtr<SerializedScriptValue> release(); diff --git a/Source/WebCore/bindings/v8/V8ConsoleMessage.cpp b/Source/WebCore/bindings/v8/V8ConsoleMessage.cpp deleted file mode 100644 index e6871fd..0000000 --- a/Source/WebCore/bindings/v8/V8ConsoleMessage.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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" -#include "V8ConsoleMessage.h" - -#include "Console.h" -#include "DOMWindow.h" -#include "Frame.h" -#include "OwnPtr.h" -#include "Page.h" -#include "ScriptCallStack.h" -#include "ScriptCallStackFactory.h" -#include "V8Binding.h" -#include "V8Proxy.h" - -namespace WebCore { - -Vector<V8ConsoleMessage>* V8ConsoleMessage::m_delayedMessages = 0; - -V8ConsoleMessage::V8ConsoleMessage(const String& string, const String& sourceID, unsigned lineNumber) - : m_string(string) - , m_sourceID(sourceID) - , m_lineNumber(lineNumber) -{ -} - -void V8ConsoleMessage::dispatchNow(Page* page) -{ - dispatchNow(page, 0); -} - -void V8ConsoleMessage::dispatchLater() -{ - if (!m_delayedMessages) { - // Allocate a vector for the delayed messages. Will be - // deallocated when the delayed messages are processed - // in processDelayed(). - m_delayedMessages = new Vector<V8ConsoleMessage>(); - } - - m_delayedMessages->append(*this); -} - -void V8ConsoleMessage::processDelayed() -{ - if (!m_delayedMessages) - return; - - // Take ownership of the delayed vector to avoid re-entrancy issues. - OwnPtr<Vector<V8ConsoleMessage> > delayedMessages(m_delayedMessages); - m_delayedMessages = 0; - - // If we have a delayed vector it cannot be empty. - ASSERT(!delayedMessages->isEmpty()); - - // Add the delayed messages to the page of the active - // context. If that for some bizarre reason does not - // exist, we clear the list of delayed messages to avoid - // posting messages. We still deallocate the vector. - Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); - if (!frame) - return; - Page* page = frame->page(); - if (!page) - return; - - // Iterate through all the delayed messages and add them - // to the console. - const int size = delayedMessages->size(); - for (int i = 0; i < size; ++i) - delayedMessages->at(i).dispatchNow(page); -} - -void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data) -{ - // Use the frame where JavaScript is called from. - Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); - if (!frame) - return; - Page* page = frame->page(); - if (!page) - return; - - v8::Handle<v8::String> errorMessageString = message->Get(); - ASSERT(!errorMessageString.IsEmpty()); - String errorMessage = toWebCoreString(errorMessageString); - - v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); - RefPtr<ScriptCallStack> callStack; - // Currently stack trace is only collected when inspector is open. - if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) - callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture); - - v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); - bool useURL = resourceName.IsEmpty() || !resourceName->IsString(); - String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName); - V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber()); - consoleMessage.dispatchNow(page, callStack); -} - -void V8ConsoleMessage::dispatchNow(Page* page, PassRefPtr<ScriptCallStack> callStack) -{ - ASSERT(page); - - // Process any delayed messages to make sure that messages - // appear in the right order in the console. - processDelayed(); - - Console* console = page->mainFrame()->domWindow()->console(); - MessageType messageType = callStack ? UncaughtExceptionMessageType : LogMessageType; - console->addMessage(JSMessageSource, messageType, ErrorMessageLevel, m_string, m_lineNumber, m_sourceID, callStack); -} - -} // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8ConsoleMessage.h b/Source/WebCore/bindings/v8/V8ConsoleMessage.h deleted file mode 100644 index 97de24f..0000000 --- a/Source/WebCore/bindings/v8/V8ConsoleMessage.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - */ - -#ifndef V8ConsoleMessage_h -#define V8ConsoleMessage_h - -#include "PlatformString.h" -#include <v8.h> -#include <wtf/PassOwnPtr.h> -#include <wtf/Vector.h> - -namespace WebCore { - - class Page; - class ScriptCallStack; - - // V8ConsoleMessage encapsulates everything needed to - // log messages originating from JavaScript to the console. - class V8ConsoleMessage { - public: - V8ConsoleMessage(const String& string, const String& sourceID, unsigned lineNumber); - - // Add a message to the console. May end up calling JavaScript code - // indirectly through the inspector so only call this function when - // it is safe to do allocations. - void dispatchNow(Page*); - - // Add a message to the console but delay the reporting until it - // is safe to do so: Either when we leave JavaScript execution or - // when adding other console messages. The primary purpose of this - // method is to avoid calling into V8 to handle console messages - // when the VM is in a state that does not support GCs or allocations. - // Delayed messages are always reported in the page corresponding - // to the active context. - void dispatchLater(); - - // Process any delayed messages. May end up calling JavaScript code - // indirectly through the inspector so only call this function when - // it is safe to do allocations. - static void processDelayed(); - - // Convenience class for ensuring that delayed messages in the - // ConsoleMessageManager are processed quickly. - class Scope { - public: - Scope() { V8ConsoleMessage::processDelayed(); } - ~Scope() { V8ConsoleMessage::processDelayed(); } - }; - - // Callback from V8. - static void handler(v8::Handle<v8::Message>, v8::Handle<v8::Value> data); - - private: - const String m_string; - const String m_sourceID; - const unsigned m_lineNumber; - - void dispatchNow(Page*, PassRefPtr<ScriptCallStack>); - - // All delayed messages are stored in this vector. If the vector - // is 0, there are no delayed messages. - static Vector<V8ConsoleMessage>* m_delayedMessages; - }; - -} // namespace WebCore - -#endif // V8ConsoleMessage_h diff --git a/Source/WebCore/bindings/v8/V8DOMMap.h b/Source/WebCore/bindings/v8/V8DOMMap.h index c2b5a9d..51d933a 100644 --- a/Source/WebCore/bindings/v8/V8DOMMap.h +++ b/Source/WebCore/bindings/v8/V8DOMMap.h @@ -60,7 +60,7 @@ namespace WebCore { virtual void set(KeyType* obj, v8::Persistent<ValueType> wrapper) = 0; virtual bool contains(KeyType* obj) = 0; virtual void visit(DOMDataStore* store, Visitor* visitor) = 0; - virtual bool removeIfPresent(KeyType* key, v8::Persistent<v8::Data> value) = 0; + virtual bool removeIfPresent(KeyType*, v8::Persistent<ValueType>) = 0; virtual void clear() = 0; v8::WeakReferenceCallback weakReferenceCallback() { return m_weakReferenceCallback; } @@ -105,7 +105,7 @@ namespace WebCore { handle.Clear(); } - bool removeIfPresent(KeyType* key, v8::Persistent<v8::Data> value) + bool removeIfPresent(KeyType* key, v8::Persistent<ValueType> value) { typename HashMap<KeyType*, ValueType*>::iterator it = m_map.find(key); if (it == m_map.end() || it->second != *value) diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp index 9918577..f53e1b7 100644 --- a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp +++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp @@ -39,12 +39,13 @@ #include "FrameLoaderClient.h" #include "Page.h" #include "PageGroup.h" +#include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" #include "ScriptController.h" #include "StorageNamespace.h" #include "V8Binding.h" #include "V8BindingState.h" #include "V8Collection.h" -#include "V8ConsoleMessage.h" #include "V8DOMMap.h" #include "V8DOMWindow.h" #include "V8Document.h" @@ -88,12 +89,36 @@ static void reportFatalErrorInV8(const char* location, const char* message) // FIXME: clean up V8Proxy and disable JavaScript. int memoryUsageMB = -1; #if PLATFORM(CHROMIUM) - memoryUsageMB = ChromiumBridge::actualMemoryUsageMB(); + memoryUsageMB = PlatformBridge::actualMemoryUsageMB(); #endif printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, location, memoryUsageMB); handleFatalErrorInV8(); } +static void v8UncaughtExceptionHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data) +{ + // Use the frame where JavaScript is called from. + Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); + if (!frame) + return; + + v8::Handle<v8::String> errorMessageString = message->Get(); + ASSERT(!errorMessageString.IsEmpty()); + String errorMessage = toWebCoreString(errorMessageString); + + v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); + RefPtr<ScriptCallStack> callStack; + // Currently stack trace is only collected when inspector is open. + if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) + callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture); + + v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); + bool useURL = resourceName.IsEmpty() || !resourceName->IsString(); + Document* document = frame->document(); + String resourceNameString = useURL ? document->url() : toWebCoreString(resourceName); + document->reportException(errorMessage, message->GetLineNumber(), resourceNameString, callStack); +} + // Returns the owner frame pointer of a DOM wrapper object. It only works for // these DOM objects requiring cross-domain access check. static Frame* getTargetFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data) @@ -121,7 +146,7 @@ static void reportUnsafeJavaScriptAccess(v8::Local<v8::Object> host, v8::AccessT { Frame* target = getTargetFrame(host, data); if (target) - V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportLater); + V8Proxy::reportUnsafeAccessTo(target); } PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame) @@ -270,7 +295,7 @@ bool V8DOMWindowShell::initContextIfNeeded() v8::V8::SetGlobalGCPrologueCallback(&V8GCController::gcPrologue); v8::V8::SetGlobalGCEpilogueCallback(&V8GCController::gcEpilogue); - v8::V8::AddMessageListener(&V8ConsoleMessage::handler); + v8::V8::AddMessageListener(&v8UncaughtExceptionHandler); v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess); diff --git a/Source/WebCore/bindings/v8/V8EventListener.h b/Source/WebCore/bindings/v8/V8EventListener.h index fb6c0bc..bcf7213 100644 --- a/Source/WebCore/bindings/v8/V8EventListener.h +++ b/Source/WebCore/bindings/v8/V8EventListener.h @@ -54,8 +54,7 @@ namespace WebCore { v8::Local<v8::Function> getListenerFunction(ScriptExecutionContext*); - private: - virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); + virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8NPUtils.cpp b/Source/WebCore/bindings/v8/V8NPUtils.cpp index 250ee5b..dccdb15 100644 --- a/Source/WebCore/bindings/v8/V8NPUtils.cpp +++ b/Source/WebCore/bindings/v8/V8NPUtils.cpp @@ -63,9 +63,14 @@ void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject* owner, NP VOID_TO_NPVARIANT(*result); else if (object->IsString()) { v8::String::Utf8Value utf8(object); +<<<<<<< HEAD int length = utf8.length() + 1; char* utf8Chars = reinterpret_cast<char*>(malloc(length)); memcpy(utf8Chars, *utf8, length); +======= + char* utf8Chars = reinterpret_cast<char*>(malloc(utf8.length())); + memcpy(utf8Chars, *utf8, utf8.length()); +>>>>>>> WebKit.org at r76408 STRINGN_TO_NPVARIANT(utf8Chars, utf8.length(), *result); } else if (object->IsObject()) { DOMWindow* window = V8Proxy::retrieveWindow(V8Proxy::currentContext()); diff --git a/Source/WebCore/bindings/v8/V8Proxy.cpp b/Source/WebCore/bindings/v8/V8Proxy.cpp index 5eaba00..831a6ef 100644 --- a/Source/WebCore/bindings/v8/V8Proxy.cpp +++ b/Source/WebCore/bindings/v8/V8Proxy.cpp @@ -50,7 +50,6 @@ #include "V8Binding.h" #include "V8BindingState.h" #include "V8Collection.h" -#include "V8ConsoleMessage.h" #include "V8DOMCoreException.h" #include "V8DOMMap.h" #include "V8DOMWindow.h" @@ -139,21 +138,22 @@ typedef HashMap<int, v8::FunctionTemplate*> FunctionTemplateMap; bool AllowAllocation::m_current = false; +static void addMessageToConsole(Page* page, const String& message, const String& sourceID, unsigned lineNumber) +{ + ASSERT(page); + Console* console = page->mainFrame()->domWindow()->console(); + console->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, lineNumber, sourceID); +} + void logInfo(Frame* frame, const String& message, const String& url) { Page* page = frame->page(); if (!page) return; - V8ConsoleMessage consoleMessage(message, url, 0); - consoleMessage.dispatchNow(page); + addMessageToConsole(page, message, url, 0); } -enum DelayReporting { - ReportLater, - ReportNow -}; - -void V8Proxy::reportUnsafeAccessTo(Frame* target, DelayReporting delay) +void V8Proxy::reportUnsafeAccessTo(Frame* target) { ASSERT(target); Document* targetDocument = target->document(); @@ -174,20 +174,11 @@ void V8Proxy::reportUnsafeAccessTo(Frame* target, DelayReporting delay) // Build a console message with fake source ID and line number. const String kSourceID = ""; const int kLineNumber = 1; - V8ConsoleMessage message(str, kSourceID, kLineNumber); - if (delay == ReportNow) { - // NOTE: Safari prints the message in the target page, but it seems like - // it should be in the source page. Even for delayed messages, we put it in - // the source page; see V8ConsoleMessage::processDelayed(). - message.dispatchNow(source->page()); - } else { - ASSERT(delay == ReportLater); - // We cannot safely report the message eagerly, because this may cause - // allocations and GCs internally in V8 and we cannot handle that at this - // point. Therefore we delay the reporting. - message.dispatchLater(); - } + // NOTE: Safari prints the message in the target page, but it seems like + // it should be in the source page. Even for delayed messages, we put it in + // the source page. + addMessageToConsole(source->page(), str, kSourceID, kLineNumber); } static void handleFatalErrorInV8() @@ -440,8 +431,6 @@ v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, b // Run the script and keep track of the current recursion depth. v8::Local<v8::Value> result; { - V8ConsoleMessage::Scope scope; - // See comment in V8Proxy::callFunction. m_frame->keepAlive(); @@ -477,8 +466,6 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8 V8GCController::checkMemoryUsage(); v8::Local<v8::Value> result; { - V8ConsoleMessage::Scope scope; - if (m_recursion >= kMaxRecursionDepth) { v8::Local<v8::String> code = v8::String::New("throw new RangeError('Maximum call stack size exceeded.')"); if (code.IsEmpty()) @@ -545,8 +532,6 @@ v8::Local<v8::Value> V8Proxy::newInstance(v8::Handle<v8::Function> constructor, // V8Proxy::callFunction. v8::Local<v8::Value> result; { - V8ConsoleMessage::Scope scope; - // See comment in V8Proxy::callFunction. m_frame->keepAlive(); @@ -808,11 +793,6 @@ v8::Handle<v8::Value> V8Proxy::checkNewLegal(const v8::Arguments& args) return args.This(); } -void V8Proxy::processConsoleMessages() -{ - V8ConsoleMessage::processDelayed(); -} - void V8Proxy::registerExtensionWithV8(v8::Extension* extension) { // If the extension exists in our list, it was already registered with V8. diff --git a/Source/WebCore/bindings/v8/V8Proxy.h b/Source/WebCore/bindings/v8/V8Proxy.h index 34e80e1..746d8f8 100644 --- a/Source/WebCore/bindings/v8/V8Proxy.h +++ b/Source/WebCore/bindings/v8/V8Proxy.h @@ -132,12 +132,6 @@ namespace WebCore { GeneralError }; - // When to report errors. - enum DelayReporting { - ReportLater, - ReportNow - }; - explicit V8Proxy(Frame*); ~V8Proxy(); @@ -271,9 +265,6 @@ namespace WebCore { template <typename T> static v8::Handle<v8::Value> constructDOMObjectWithScriptExecutionContext(const v8::Arguments&, WrapperTypeInfo*); - // Process any pending JavaScript console messages. - static void processConsoleMessages(); - v8::Local<v8::Context> context(); v8::Local<v8::Context> mainWorldContext(); @@ -294,7 +285,7 @@ namespace WebCore { static const V8Extensions& extensions() { return m_extensions; } // Report an unsafe attempt to access the given frame on the console. - static void reportUnsafeAccessTo(Frame* target, DelayReporting delay); + static void reportUnsafeAccessTo(Frame* target); private: void didLeaveScriptContext(); diff --git a/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp b/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp new file mode 100644 index 0000000..4203ad5 --- /dev/null +++ b/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp @@ -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. + */ + +#include "config.h" + +#include "V8WindowErrorHandler.h" + +#include "ErrorEvent.h" +#include "V8Binding.h" + +namespace WebCore { + +V8WindowErrorHandler::V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext) + : V8EventListener(listener, isInline, worldContext) +{ +} + +v8::Local<v8::Value> V8WindowErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event) +{ + if (!event->isErrorEvent()) + return V8EventListener::callListenerFunction(context, jsEvent, event); + + ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); + v8::Local<v8::Object> listener = getListenerObject(context); + v8::Local<v8::Value> returnValue; + if (!listener.IsEmpty() && listener->IsFunction()) { + v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener); + v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global(); + v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message()), v8String(errorEvent->filename()), v8::Integer::New(errorEvent->lineno()) }; + returnValue = callFunction->Call(thisValue, 3, parameters); + if (!returnValue.IsEmpty() && returnValue->IsBoolean() && !returnValue->BooleanValue()) + event->preventDefault(); + } + return returnValue; +} + +} // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8WindowErrorHandler.h b/Source/WebCore/bindings/v8/V8WindowErrorHandler.h new file mode 100644 index 0000000..493a9bf --- /dev/null +++ b/Source/WebCore/bindings/v8/V8WindowErrorHandler.h @@ -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. + */ + +#ifndef V8WindowErrorHandler_h +#define V8WindowErrorHandler_h + +#include "V8EventListener.h" +#include <v8.h> +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class V8WindowErrorHandler : public V8EventListener { +public: + static PassRefPtr<V8WindowErrorHandler> create(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext) + { + return adoptRef(new V8WindowErrorHandler(listener, isInline, worldContext)); + } + +private: + V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext); + + virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); +}; + +} // namespace WebCore + +#endif // V8WindowErrorHandler_h diff --git a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp index cefb2fa..aef892a 100644 --- a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp +++ b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp @@ -37,10 +37,10 @@ #include "DedicatedWorkerContext.h" #include "Event.h" +#include "ScriptCallStack.h" #include "SharedWorker.h" #include "SharedWorkerContext.h" #include "V8Binding.h" -#include "V8ConsoleMessage.h" #include "V8DOMMap.h" #include "V8DedicatedWorkerContext.h" #include "V8Proxy.h" @@ -72,7 +72,7 @@ static void v8MessageHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Val String errorMessage = toWebCoreString(message->Get()); int lineNumber = message->GetLineNumber(); String sourceURL = toWebCoreString(message->GetScriptResourceName()); - context->reportException(errorMessage, lineNumber, sourceURL); + context->reportException(errorMessage, lineNumber, sourceURL, 0); } isReportingException = false; diff --git a/Source/WebCore/bindings/v8/WorkerScriptController.cpp b/Source/WebCore/bindings/v8/WorkerScriptController.cpp index b56d383..42e02e6 100644 --- a/Source/WebCore/bindings/v8/WorkerScriptController.cpp +++ b/Source/WebCore/bindings/v8/WorkerScriptController.cpp @@ -34,11 +34,10 @@ #include "WorkerScriptController.h" -#include <v8.h> - +#include "DOMTimer.h" +#include "ScriptCallStack.h" #include "ScriptSourceCode.h" #include "ScriptValue.h" -#include "DOMTimer.h" #include "V8DOMMap.h" #include "V8Proxy.h" #include "V8WorkerContext.h" @@ -46,6 +45,7 @@ #include "WorkerContextExecutionProxy.h" #include "WorkerObjectProxy.h" #include "WorkerThread.h" +#include <v8.h> namespace WebCore { @@ -80,7 +80,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, if (exception) *exception = state.exception; else - m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL); + m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL, 0); } return result; diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp index 9e89ce8..3d64edd 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp @@ -59,7 +59,10 @@ static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8:: { v8::Local<v8::Uint32> index = argument->ToArrayIndex(); if (index.IsEmpty()) { - v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(argument->ToString())); + v8::Local<v8::String> asString = argument->ToString(); + if (asString.IsEmpty()) + return v8::Handle<v8::Value>(); + v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(asString)); if (result.IsEmpty()) return v8::Undefined(); diff --git a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 70df7c1..7fdfc55 100644 --- a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -48,6 +48,7 @@ #include "V8Int16Array.h" #include "V8Int32Array.h" #include "V8Int8Array.h" +#include "V8OESStandardDerivatives.h" #include "V8OESTextureFloat.h" #include "V8Proxy.h" #include "V8Uint16Array.h" @@ -160,6 +161,9 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 case WebGLExtension::WebKitLoseContextName: extensionObject = toV8(static_cast<WebKitLoseContext*>(extension)); break; + case WebGLExtension::OESStandardDerivativesName: + extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension)); + break; case WebGLExtension::OESTextureFloatName: extensionObject = toV8(static_cast<OESTextureFloat*>(extension)); break; diff --git a/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp b/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp index 891272c..e00e35b 100644 --- a/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp +++ b/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp @@ -81,7 +81,7 @@ Frame* State<V8Binding>::firstFrame() void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target) { - V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportNow); + V8Proxy::reportUnsafeAccessTo(target); } bool State<V8Binding>::processingUserGesture() diff --git a/Source/WebCore/bridge/Bridge.h b/Source/WebCore/bridge/Bridge.h index 50efc64..00d6f36 100644 --- a/Source/WebCore/bridge/Bridge.h +++ b/Source/WebCore/bridge/Bridge.h @@ -28,14 +28,15 @@ #define Bridge_h #include "BridgeJSC.h" -#include <wtf/Noncopyable.h> namespace JSC { namespace Bindings { -class Method : public Noncopyable { +class Method { + WTF_MAKE_NONCOPYABLE(Method); WTF_MAKE_FAST_ALLOCATED; public: + Method() { } virtual int numParameters() const = 0; virtual ~Method() { } diff --git a/Source/WebCore/bridge/IdentifierRep.h b/Source/WebCore/bridge/IdentifierRep.h index 99bae0b..8646e92 100644 --- a/Source/WebCore/bridge/IdentifierRep.h +++ b/Source/WebCore/bridge/IdentifierRep.h @@ -33,7 +33,8 @@ namespace WebCore { -class IdentifierRep : public FastAllocBase { +class IdentifierRep { + WTF_MAKE_FAST_ALLOCATED; public: static IdentifierRep* get(int); static IdentifierRep* get(const char*); diff --git a/Source/WebCore/bridge/jsc/BridgeJSC.h b/Source/WebCore/bridge/jsc/BridgeJSC.h index 96974d9..ebcfaad 100644 --- a/Source/WebCore/bridge/jsc/BridgeJSC.h +++ b/Source/WebCore/bridge/jsc/BridgeJSC.h @@ -59,8 +59,10 @@ public: virtual ~Field() { } }; -class Class : public Noncopyable { +class Class { + WTF_MAKE_NONCOPYABLE(Class); WTF_MAKE_FAST_ALLOCATED; public: + Class() { } virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0; virtual Field* fieldNamed(const Identifier&, Instance*) const = 0; virtual JSValue fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); } @@ -125,7 +127,8 @@ private: WeakGCPtr<RuntimeObject> m_runtimeObject; }; -class Array : public Noncopyable { +class Array { + WTF_MAKE_NONCOPYABLE(Array); public: Array(PassRefPtr<RootObject>); virtual ~Array(); diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp index fde4a4e..b6b9ebe 100644 --- a/Source/WebCore/css/CSSGradientValue.cpp +++ b/Source/WebCore/css/CSSGradientValue.cpp @@ -230,58 +230,68 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend // We can't just push this logic down into the platform-specific Gradient code, // because we have to know the extent of the gradient, and possible move the end points. if (m_repeating && numStops > 1) { - float maxExtent = 1; - - // Radial gradients may need to extend further than the endpoints, because they have - // to repeat out to the corners of the box. - if (isRadialGradient()) { - if (!computedGradientLength) { - FloatSize gradientSize(gradientStart - gradientEnd); - gradientLength = gradientSize.diagonalLength(); - } - - if (maxLengthForRepeat > gradientLength) - maxExtent = maxLengthForRepeat / gradientLength; - } + // If the difference in the positions of the first and last color-stops is 0, + // the gradient defines a solid-color image with the color of the last color-stop in the rule. + float gradientRange = stops[numStops - 1].offset - stops[0].offset; + if (!gradientRange) { + stops.first().offset = 0; + stops.first().color = stops.last().color; + stops.shrink(1); + numStops = 1; + } else { + float maxExtent = 1; - size_t originalNumStops = numStops; - size_t originalFirstStopIndex = 0; + // Radial gradients may need to extend further than the endpoints, because they have + // to repeat out to the corners of the box. + if (isRadialGradient()) { + if (!computedGradientLength) { + FloatSize gradientSize(gradientStart - gradientEnd); + gradientLength = gradientSize.diagonalLength(); + } + + if (maxLengthForRepeat > gradientLength) + maxExtent = maxLengthForRepeat / gradientLength; + } - // Work backwards from the first, adding stops until we get one before 0. - float firstOffset = stops[0].offset; - if (firstOffset > 0) { - float currOffset = firstOffset; - size_t srcStopOrdinal = originalNumStops - 1; - - while (true) { - GradientStop newStop = stops[originalFirstStopIndex + srcStopOrdinal]; - newStop.offset = currOffset; - stops.prepend(newStop); - ++originalFirstStopIndex; - if (currOffset < 0) - break; + size_t originalNumStops = numStops; + size_t originalFirstStopIndex = 0; - if (srcStopOrdinal) - currOffset -= stops[originalFirstStopIndex + srcStopOrdinal].offset - stops[originalFirstStopIndex + srcStopOrdinal - 1].offset; - srcStopOrdinal = (srcStopOrdinal + originalNumStops - 1) % originalNumStops; + // Work backwards from the first, adding stops until we get one before 0. + float firstOffset = stops[0].offset; + if (firstOffset > 0) { + float currOffset = firstOffset; + size_t srcStopOrdinal = originalNumStops - 1; + + while (true) { + GradientStop newStop = stops[originalFirstStopIndex + srcStopOrdinal]; + newStop.offset = currOffset; + stops.prepend(newStop); + ++originalFirstStopIndex; + if (currOffset < 0) + break; + + if (srcStopOrdinal) + currOffset -= stops[originalFirstStopIndex + srcStopOrdinal].offset - stops[originalFirstStopIndex + srcStopOrdinal - 1].offset; + srcStopOrdinal = (srcStopOrdinal + originalNumStops - 1) % originalNumStops; + } } - } - - // Work forwards from the end, adding stops until we get one after 1. - float lastOffset = stops[stops.size() - 1].offset; - if (lastOffset < maxExtent) { - float currOffset = lastOffset; - size_t srcStopOrdinal = 0; - - while (true) { - GradientStop newStop = stops[srcStopOrdinal]; - newStop.offset = currOffset; - stops.append(newStop); - if (currOffset > maxExtent) - break; - if (srcStopOrdinal < originalNumStops - 1) - currOffset += stops[originalFirstStopIndex + srcStopOrdinal + 1].offset - stops[originalFirstStopIndex + srcStopOrdinal].offset; - srcStopOrdinal = (srcStopOrdinal + 1) % originalNumStops; + + // Work forwards from the end, adding stops until we get one after 1. + float lastOffset = stops[stops.size() - 1].offset; + if (lastOffset < maxExtent) { + float currOffset = lastOffset; + size_t srcStopOrdinal = 0; + + while (true) { + GradientStop newStop = stops[srcStopOrdinal]; + newStop.offset = currOffset; + stops.append(newStop); + if (currOffset > maxExtent) + break; + if (srcStopOrdinal < originalNumStops - 1) + currOffset += stops[originalFirstStopIndex + srcStopOrdinal + 1].offset - stops[originalFirstStopIndex + srcStopOrdinal].offset; + srcStopOrdinal = (srcStopOrdinal + 1) % originalNumStops; + } } } } diff --git a/Source/WebCore/css/CSSImageValue.h b/Source/WebCore/css/CSSImageValue.h index 833d7fe..174f1ed 100644 --- a/Source/WebCore/css/CSSImageValue.h +++ b/Source/WebCore/css/CSSImageValue.h @@ -32,6 +32,7 @@ class StyleCachedImage; class StyleImage; class CSSImageValue : public CSSPrimitiveValue, private CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<CSSImageValue> create() { return adoptRef(new CSSImageValue); } static PassRefPtr<CSSImageValue> create(const String& url) { return adoptRef(new CSSImageValue(url)); } diff --git a/Source/WebCore/css/CSSImportRule.h b/Source/WebCore/css/CSSImportRule.h index 943d53e..3f44f5b 100644 --- a/Source/WebCore/css/CSSImportRule.h +++ b/Source/WebCore/css/CSSImportRule.h @@ -34,6 +34,7 @@ class CachedCSSStyleSheet; class MediaList; class CSSImportRule : public CSSRule, private CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<CSSImportRule> create(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaList> media) { diff --git a/Source/WebCore/css/CSSMutableStyleDeclaration.h b/Source/WebCore/css/CSSMutableStyleDeclaration.h index f7d8ca9..35f1cc4 100644 --- a/Source/WebCore/css/CSSMutableStyleDeclaration.h +++ b/Source/WebCore/css/CSSMutableStyleDeclaration.h @@ -135,6 +135,8 @@ public: bool useStrictParsing() const { return m_strictParsing; } void addSubresourceStyleURLs(ListHashSet<KURL>&); + + bool propertiesEqual(const CSSMutableStyleDeclaration* o) const { return m_properties == o->m_properties; } protected: CSSMutableStyleDeclaration(CSSRule* parentRule); diff --git a/Source/WebCore/css/CSSNamespace.h b/Source/WebCore/css/CSSNamespace.h index 6225c36..92638f2 100644 --- a/Source/WebCore/css/CSSNamespace.h +++ b/Source/WebCore/css/CSSNamespace.h @@ -26,7 +26,9 @@ namespace WebCore { - struct CSSNamespace : Noncopyable { + struct CSSNamespace { + WTF_MAKE_NONCOPYABLE(CSSNamespace); WTF_MAKE_FAST_ALLOCATED; + public: AtomicString prefix; AtomicString uri; OwnPtr<CSSNamespace> parent; diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index fd5841f..9142e67 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -1965,7 +1965,8 @@ void CSSParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval) static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& cssValue) { - if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox || parserValue->id == CSSValueWebkitText) { + if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox + || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueWebkitText) { cssValue = CSSPrimitiveValue::createIdentifier(parserValue->id); return true; } diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h index 496a21a..d326812 100644 --- a/Source/WebCore/css/CSSParser.h +++ b/Source/WebCore/css/CSSParser.h @@ -340,7 +340,8 @@ namespace WebCore { int cssPropertyID(const String&); int cssValueKeywordID(const CSSParserString&); - class ShorthandScope : public FastAllocBase { + class ShorthandScope { + WTF_MAKE_FAST_ALLOCATED; public: ShorthandScope(CSSParser* parser, int propId) : m_parser(parser) { diff --git a/Source/WebCore/css/CSSParserValues.h b/Source/WebCore/css/CSSParserValues.h index 993ae28..996e783 100644 --- a/Source/WebCore/css/CSSParserValues.h +++ b/Source/WebCore/css/CSSParserValues.h @@ -59,7 +59,8 @@ struct CSSParserValue { PassRefPtr<CSSValue> createCSSValue(); }; -class CSSParserValueList : public FastAllocBase { +class CSSParserValueList { + WTF_MAKE_FAST_ALLOCATED; public: CSSParserValueList() : m_current(0) @@ -83,7 +84,9 @@ private: Vector<CSSParserValue, 4> m_values; }; -struct CSSParserFunction : FastAllocBase { +struct CSSParserFunction { + WTF_MAKE_FAST_ALLOCATED; +public: CSSParserString name; OwnPtr<CSSParserValueList> args; }; diff --git a/Source/WebCore/css/CSSProperty.h b/Source/WebCore/css/CSSProperty.h index 106171d..10e593c 100644 --- a/Source/WebCore/css/CSSProperty.h +++ b/Source/WebCore/css/CSSProperty.h @@ -29,7 +29,8 @@ namespace WebCore { -class CSSProperty : public FastAllocBase { +class CSSProperty { + WTF_MAKE_FAST_ALLOCATED; public: CSSProperty(int propID, PassRefPtr<CSSValue> value, bool important = false, int shorthandID = 0, bool implicit = false) : m_id(propID) diff --git a/Source/WebCore/css/CSSSelector.cpp b/Source/WebCore/css/CSSSelector.cpp index 400dd40..ca3814a 100644 --- a/Source/WebCore/css/CSSSelector.cpp +++ b/Source/WebCore/css/CSSSelector.cpp @@ -37,8 +37,10 @@ namespace WebCore { using namespace HTMLNames; -class CSSSelectorBag : public Noncopyable { +class CSSSelectorBag { + WTF_MAKE_NONCOPYABLE(CSSSelectorBag); public: + CSSSelectorBag() { } ~CSSSelectorBag() { ASSERT(isEmpty()); diff --git a/Source/WebCore/css/CSSSelector.h b/Source/WebCore/css/CSSSelector.h index 1101eed..b930353 100644 --- a/Source/WebCore/css/CSSSelector.h +++ b/Source/WebCore/css/CSSSelector.h @@ -33,7 +33,8 @@ namespace WebCore { class CSSSelectorBag; // this class represents a selector for a StyleRule - class CSSSelector : public Noncopyable { + class CSSSelector { + WTF_MAKE_NONCOPYABLE(CSSSelector); WTF_MAKE_FAST_ALLOCATED; public: CSSSelector() : m_relation(Descendant) @@ -278,6 +279,7 @@ namespace WebCore { return m_match == PseudoElement; } bool isUnknownPseudoElement() const; + bool isSiblingSelector() const; Relation relation() const { return static_cast<Relation>(m_relation); } @@ -305,7 +307,9 @@ namespace WebCore { unsigned specificityForPage() const; void extractPseudoType() const; - struct RareData : Noncopyable { + struct RareData { + WTF_MAKE_NONCOPYABLE(RareData); WTF_MAKE_FAST_ALLOCATED; + public: RareData(PassOwnPtr<CSSSelector> tagHistory) : m_a(0) , m_b(0) @@ -350,6 +354,24 @@ inline bool CSSSelector::isUnknownPseudoElement() const return m_match == PseudoElement && m_pseudoType == PseudoUnknown; } +inline bool CSSSelector::isSiblingSelector() const +{ + PseudoType type = pseudoType(); + return m_relation == DirectAdjacent + || m_relation == IndirectAdjacent + || type == PseudoEmpty + || type == PseudoFirstChild + || type == PseudoFirstOfType + || type == PseudoLastChild + || type == PseudoLastOfType + || type == PseudoOnlyChild + || type == PseudoOnlyOfType + || type == PseudoNthChild + || type == PseudoNthOfType + || type == PseudoNthLastChild + || type == PseudoNthLastOfType; +} + } // namespace WebCore #endif // CSSSelector_h diff --git a/Source/WebCore/css/CSSSelectorList.h b/Source/WebCore/css/CSSSelectorList.h index 7adc6b9..abd9bc8 100644 --- a/Source/WebCore/css/CSSSelectorList.h +++ b/Source/WebCore/css/CSSSelectorList.h @@ -27,11 +27,11 @@ #define CSSSelectorList_h #include "CSSSelector.h" -#include <wtf/Noncopyable.h> namespace WebCore { -class CSSSelectorList : public Noncopyable { +class CSSSelectorList { + WTF_MAKE_NONCOPYABLE(CSSSelectorList); WTF_MAKE_FAST_ALLOCATED; public: CSSSelectorList() : m_selectorArray(0) { } ~CSSSelectorList(); diff --git a/Source/WebCore/css/CSSStyleSelector.cpp b/Source/WebCore/css/CSSStyleSelector.cpp index b98b90d..5a21615 100644 --- a/Source/WebCore/css/CSSStyleSelector.cpp +++ b/Source/WebCore/css/CSSStyleSelector.cpp @@ -352,7 +352,8 @@ if (id == propID) { \ return; \ } -class CSSRuleData : public Noncopyable { +class CSSRuleData { + WTF_MAKE_NONCOPYABLE(CSSRuleData); public: CSSRuleData(unsigned pos, CSSStyleRule* r, CSSSelector* sel, CSSRuleData* prev = 0) : m_position(pos) @@ -380,7 +381,8 @@ private: CSSRuleData* m_next; }; -class CSSRuleDataList : public Noncopyable { +class CSSRuleDataList { + WTF_MAKE_NONCOPYABLE(CSSRuleDataList); public: CSSRuleDataList(unsigned pos, CSSStyleRule* rule, CSSSelector* sel) : m_first(new CSSRuleData(pos, rule, sel)) @@ -400,8 +402,8 @@ public: } } - CSSRuleData* first() { return m_first; } - CSSRuleData* last() { return m_last; } + CSSRuleData* first() const { return m_first; } + CSSRuleData* last() const { return m_last; } void append(unsigned pos, CSSStyleRule* rule, CSSSelector* sel) { m_last = new CSSRuleData(pos, rule, sel, m_last); } @@ -410,7 +412,8 @@ private: CSSRuleData* m_last; }; -class CSSRuleSet : public Noncopyable { +class CSSRuleSet { + WTF_MAKE_NONCOPYABLE(CSSRuleSet); public: CSSRuleSet(); ~CSSRuleSet(); @@ -425,6 +428,8 @@ public: void addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map, CSSStyleRule* rule, CSSSelector* sel); + void collectIdsAndSiblingRules(HashSet<AtomicStringImpl*>& ids, OwnPtr<CSSRuleSet>& siblingRules) const; + CSSRuleDataList* getIDRules(AtomicStringImpl* key) { return m_idRules.get(key); } CSSRuleDataList* getClassRules(AtomicStringImpl* key) { return m_classRules.get(key); } CSSRuleDataList* getTagRules(AtomicStringImpl* key) { return m_tagRules.get(key); } @@ -448,6 +453,8 @@ static CSSRuleSet* defaultQuirksStyle; static CSSRuleSet* defaultPrintStyle; static CSSRuleSet* defaultViewSourceStyle; static CSSStyleSheet* simpleDefaultStyleSheet; + +static CSSRuleSet* siblingRulesInDefaultStyle; RenderStyle* CSSStyleSelector::s_styleNotYetAvailable; @@ -459,11 +466,31 @@ static void loadSimpleDefaultStyle(); // FIXME: It would be nice to use some mechanism that guarantees this is in sync with the real UA stylesheet. static const char* simpleUserAgentStyleSheet = "html,body,div{display:block}body{margin:8px}div:focus,span:focus{outline:auto 5px -webkit-focus-ring-color}a:-webkit-any-link{color:-webkit-link;text-decoration:underline}a:-webkit-any-link:active{color:-webkit-activelink}"; -static bool elementCanUseSimpleDefaultStyle(Element* e) +static inline bool elementCanUseSimpleDefaultStyle(Element* e) { return e->hasTagName(htmlTag) || e->hasTagName(bodyTag) || e->hasTagName(divTag) || e->hasTagName(spanTag) || e->hasTagName(brTag) || e->hasTagName(aTag); } +static inline void collectSiblingRulesInDefaultStyle() +{ + OwnPtr<CSSRuleSet> siblingRules; + HashSet<AtomicStringImpl*> ids; + defaultStyle->collectIdsAndSiblingRules(ids, siblingRules); + ASSERT(ids.isEmpty()); + delete siblingRulesInDefaultStyle; + siblingRulesInDefaultStyle = siblingRules.leakPtr(); +} + +static inline void assertNoSiblingRulesInDefaultStyle() +{ +#ifndef NDEBUG + if (siblingRulesInDefaultStyle) + return; + collectSiblingRulesInDefaultStyle(); + ASSERT(!siblingRulesInDefaultStyle); +#endif +} + static const MediaQueryEvaluator& screenEval() { DEFINE_STATIC_LOCAL(const MediaQueryEvaluator, staticScreenEval, ("screen")); @@ -549,6 +576,16 @@ CSSStyleSelector::CSSStyleSelector(Document* document, StyleSheetList* styleShee if (sheet->isCSSStyleSheet() && !sheet->disabled()) m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(sheet), *m_medium, this); } + + // Collect all ids and rules using sibling selectors (:first-child and similar) + // in the current set of stylesheets. Style sharing code uses this information to reject + // sharing candidates. + // Usually there are no sibling rules in the default style but the MathML sheet has some. + if (siblingRulesInDefaultStyle) + siblingRulesInDefaultStyle->collectIdsAndSiblingRules(m_idsInRules, m_siblingRules); + m_authorStyle->collectIdsAndSiblingRules(m_idsInRules, m_siblingRules); + if (m_userStyle) + m_userStyle->collectIdsAndSiblingRules(m_idsInRules, m_siblingRules); if (document->renderer() && document->renderer()->style()) document->renderer()->style()->font().update(fontSelector()); @@ -944,40 +981,52 @@ static const unsigned cStyleSearchThreshold = 10; Node* CSSStyleSelector::locateCousinList(Element* parent, unsigned depth) const { - if (parent && parent->isStyledElement()) { - StyledElement* p = static_cast<StyledElement*>(parent); - if (!p->inlineStyleDecl() && !p->hasID()) { - Node* r = p->previousSibling(); - unsigned subcount = 0; - RenderStyle* st = p->renderStyle(); - while (r) { - if (r->renderStyle() == st) - return r->lastChild(); - if (subcount++ == cStyleSearchThreshold) - return 0; - r = r->previousSibling(); - } - if (!r && depth < cStyleSearchThreshold) - r = locateCousinList(parent->parentElement(), depth + 1); - while (r) { - if (r->renderStyle() == st) - return r->lastChild(); - if (subcount++ == cStyleSearchThreshold) - return 0; - r = r->previousSibling(); - } - } + if (!parent || !parent->isStyledElement()) + return 0; + StyledElement* p = static_cast<StyledElement*>(parent); + if (p->inlineStyleDecl()) + return 0; + if (p->hasID() && m_idsInRules.contains(p->idForStyleResolution().impl())) + return 0; + Node* r = p->previousSibling(); + unsigned subcount = 0; + RenderStyle* st = p->renderStyle(); + while (r) { + if (r->renderStyle() == st) + return r->lastChild(); + if (subcount++ == cStyleSearchThreshold) + return 0; + r = r->previousSibling(); + } + if (!r && depth < cStyleSearchThreshold) + r = locateCousinList(parent->parentElement(), depth + 1); + while (r) { + if (r->renderStyle() == st) + return r->lastChild(); + if (subcount++ == cStyleSearchThreshold) + return 0; + r = r->previousSibling(); } return 0; } +bool CSSStyleSelector::matchesSiblingRules() +{ + int firstSiblingRule = -1, lastSiblingRule = -1; + matchRules(m_siblingRules.get(), firstSiblingRule, lastSiblingRule, false); + if (m_matchedDecls.isEmpty()) + return false; + m_matchedDecls.clear(); + return true; +} + bool CSSStyleSelector::canShareStyleWithElement(Node* n) const { if (n->isStyledElement()) { StyledElement* s = static_cast<StyledElement*>(n); RenderStyle* style = s->renderStyle(); if (style && !style->unique() && - (s->tagQName() == m_element->tagQName()) && !s->hasID() && + (s->tagQName() == m_element->tagQName()) && (s->hasClass() == m_element->hasClass()) && !s->inlineStyleDecl() && (s->hasMappedAttributes() == m_styledElement->hasMappedAttributes()) && (s->isLink() == m_element->isLink()) && @@ -992,6 +1041,10 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* n) const (s->fastGetAttribute(langAttr) == m_element->fastGetAttribute(langAttr)) && (s->fastGetAttribute(readonlyAttr) == m_element->fastGetAttribute(readonlyAttr)) && (s->fastGetAttribute(cellpaddingAttr) == m_element->fastGetAttribute(cellpaddingAttr))) { + + if (s->hasID() && m_idsInRules.contains(s->idForStyleResolution().impl())) + return 0; + bool isControl = s->isFormControlElement(); if (isControl != m_element->isFormControlElement()) return false; @@ -1062,32 +1115,46 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* n) const } return false; } - -ALWAYS_INLINE RenderStyle* CSSStyleSelector::locateSharedStyle() const + +inline Node* CSSStyleSelector::findSiblingForStyleSharing(Node* node, unsigned& count) const { - if (m_styledElement && !m_styledElement->inlineStyleDecl() && !m_styledElement->hasID() && !m_styledElement->document()->usesSiblingRules()) { - // Check previous siblings. - unsigned count = 0; - Node* n; - for (n = m_element->previousSibling(); n && !n->isElementNode(); n = n->previousSibling()) { } - while (n) { - if (canShareStyleWithElement(n)) - return n->renderStyle(); - if (count++ == cStyleSearchThreshold) - return 0; - for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling()) { } - } - if (!n) - n = locateCousinList(m_element->parentElement()); - while (n) { - if (canShareStyleWithElement(n)) - return n->renderStyle(); - if (count++ == cStyleSearchThreshold) - return 0; - for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling()) { } - } + for (; node; node = node->previousSibling()) { + if (!node->isElementNode()) + continue; + if (canShareStyleWithElement(node)) + break; + if (count++ == cStyleSearchThreshold) + return 0; } - return 0; + return node; +} + +ALWAYS_INLINE RenderStyle* CSSStyleSelector::locateSharedStyle() +{ + if (!m_styledElement || !m_parentStyle) + return 0; + // If the element has inline style it is probably unique. + if (m_styledElement->inlineStyleDecl()) + return 0; + // Ids stop style sharing if they show up in the stylesheets. + if (m_styledElement->hasID() && m_idsInRules.contains(m_styledElement->idForStyleResolution().impl())) + return 0; + // Check previous siblings. + unsigned count = 0; + Node* shareNode = findSiblingForStyleSharing(m_styledElement->previousSibling(), count); + if (!shareNode) { + Node* cousinList = locateCousinList(m_styledElement->parentElement()); + shareNode = findSiblingForStyleSharing(cousinList, count); + if (!shareNode) + return 0; + } + // Can't share if sibling rules apply. This is checked at the end as it should rarely fail. + if (matchesSiblingRules()) + return 0; + // Tracking child index requires unique style for each node. This may get set by the sibling rule match above. + if (m_parentStyle->childrenAffectedByPositionalRules()) + return 0; + return shareNode->renderStyle(); } void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule) @@ -1180,12 +1247,12 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl } initElement(e); + initForStyleResolve(e, defaultParent); if (allowSharing) { RenderStyle* sharedStyle = locateSharedStyle(); if (sharedStyle) return sharedStyle; } - initForStyleResolve(e, defaultParent); // Compute our style allowing :visited to match first. RefPtr<RenderStyle> visitedStyle; @@ -1227,6 +1294,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl #if ENABLE(FULLSCREEN_API) loadFullScreenRulesIfNeeded(e->document()); #endif + assertNoSiblingRulesInDefaultStyle(); } #if ENABLE(SVG) @@ -1237,6 +1305,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* svgSheet = parseUASheet(svgUserAgentStyleSheet, sizeof(svgUserAgentStyleSheet)); defaultStyle->addRulesFromSheet(svgSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(svgSheet, printEval()); + assertNoSiblingRulesInDefaultStyle(); } #endif @@ -1248,6 +1317,8 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* mathMLSheet = parseUASheet(mathmlUserAgentStyleSheet, sizeof(mathmlUserAgentStyleSheet)); defaultStyle->addRulesFromSheet(mathMLSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(mathMLSheet, printEval()); + // There are some sibling rules here. + collectSiblingRulesInDefaultStyle(); } #endif @@ -1259,6 +1330,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* wmlSheet = parseUASheet(wmlUserAgentStyleSheet, sizeof(wmlUserAgentStyleSheet)); defaultStyle->addRulesFromSheet(wmlSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(wmlSheet, printEval()); + assertNoSiblingRulesInDefaultStyle(); } #endif @@ -1270,6 +1342,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* mediaControlsSheet = parseUASheet(mediaRules); defaultStyle->addRulesFromSheet(mediaControlsSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(mediaControlsSheet, printEval()); + assertNoSiblingRulesInDefaultStyle(); } #endif @@ -2794,7 +2867,7 @@ bool CSSStyleSelector::SelectorChecker::checkScrollbarPseudoClass(CSSSelector* s return false; } case CSSSelector::PseudoCornerPresent: - return scrollbar->client()->scrollbarCornerPresent(); + return scrollbar->scrollableArea()->scrollbarCornerPresent(); default: return false; } @@ -2927,6 +3000,47 @@ void CSSRuleSet::addStyleRule(CSSStyleRule* rule) } } +static void collectIdsAndSiblingRulesFromList(HashSet<AtomicStringImpl*>& ids, OwnPtr<CSSRuleSet>& siblingRules, const CSSRuleDataList* rules) +{ + for (CSSRuleData* data = rules->first(); data; data = data->next()) { + bool foundSiblingSelector = false; + for (CSSSelector* selector = data->selector(); selector; selector = selector->tagHistory()) { + if (selector->m_match == CSSSelector::Id && !selector->m_value.isEmpty()) + ids.add(selector->m_value.impl()); + if (CSSSelector* simpleSelector = selector->simpleSelector()) { + ASSERT(!simpleSelector->simpleSelector()); + if (simpleSelector->m_match == CSSSelector::Id && !simpleSelector->m_value.isEmpty()) + ids.add(simpleSelector->m_value.impl()); + } + if (selector->isSiblingSelector()) + foundSiblingSelector = true; + } + if (foundSiblingSelector) { + if (!siblingRules) + siblingRules = adoptPtr(new CSSRuleSet); + siblingRules->addRule(data->rule(), data->selector()); + } + } +} + +void CSSRuleSet::collectIdsAndSiblingRules(HashSet<AtomicStringImpl*>& ids, OwnPtr<CSSRuleSet>& siblingRules) const +{ + AtomRuleMap::const_iterator end = m_idRules.end(); + for (AtomRuleMap::const_iterator it = m_idRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + end = m_classRules.end(); + for (AtomRuleMap::const_iterator it = m_classRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + end = m_tagRules.end(); + for (AtomRuleMap::const_iterator it = m_tagRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + end = m_pseudoRules.end(); + for (AtomRuleMap::const_iterator it = m_pseudoRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + if (m_universalRules) + collectIdsAndSiblingRulesFromList(ids, siblingRules, m_universalRules.get()); +} + // ------------------------------------------------------------------------------------- // this is mostly boring stuff on how to apply a certain rule to the renderstyle... diff --git a/Source/WebCore/css/CSSStyleSelector.h b/Source/WebCore/css/CSSStyleSelector.h index b57ba13..e035af2 100644 --- a/Source/WebCore/css/CSSStyleSelector.h +++ b/Source/WebCore/css/CSSStyleSelector.h @@ -69,7 +69,8 @@ class StyledElement; class WebKitCSSKeyframeRule; class WebKitCSSKeyframesRule; -class MediaQueryResult : public Noncopyable { +class MediaQueryResult { + WTF_MAKE_NONCOPYABLE(MediaQueryResult); WTF_MAKE_FAST_ALLOCATED; public: MediaQueryResult(const MediaQueryExp& expr, bool result) : m_expression(expr) @@ -82,7 +83,8 @@ public: }; // This class selects a RenderStyle for a given element based on a collection of stylesheets. - class CSSStyleSelector : public Noncopyable { + class CSSStyleSelector { + WTF_MAKE_NONCOPYABLE(CSSStyleSelector); WTF_MAKE_FAST_ALLOCATED; public: CSSStyleSelector(Document*, StyleSheetList* authorSheets, CSSStyleSheet* mappedElementSheet, CSSStyleSheet* pageUserSheet, const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets, @@ -108,8 +110,10 @@ public: private: void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO); void initElement(Element*); - ALWAYS_INLINE RenderStyle* locateSharedStyle() const; + RenderStyle* locateSharedStyle(); + bool matchesSiblingRules(); Node* locateCousinList(Element* parent, unsigned depth = 1) const; + Node* findSiblingForStyleSharing(Node*, unsigned& count) const; bool canShareStyleWithElement(Node*) const; RenderStyle* style() const { return m_style.get(); } @@ -197,6 +201,9 @@ public: OwnPtr<CSSRuleSet> m_authorStyle; OwnPtr<CSSRuleSet> m_userStyle; + + OwnPtr<CSSRuleSet> m_siblingRules; + HashSet<AtomicStringImpl*> m_idsInRules; bool m_hasUAAppearance; BorderData m_borderData; @@ -209,7 +216,8 @@ public: public: static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; } - class SelectorChecker : public Noncopyable { + class SelectorChecker { + WTF_MAKE_NONCOPYABLE(SelectorChecker); public: SelectorChecker(Document*, bool strictParsing); diff --git a/Source/WebCore/css/MediaQuery.h b/Source/WebCore/css/MediaQuery.h index 281009b..a638ac9 100644 --- a/Source/WebCore/css/MediaQuery.h +++ b/Source/WebCore/css/MediaQuery.h @@ -37,7 +37,8 @@ namespace WebCore { class MediaQueryExp; -class MediaQuery : public Noncopyable { +class MediaQuery { + WTF_MAKE_NONCOPYABLE(MediaQuery); WTF_MAKE_FAST_ALLOCATED; public: enum Restrictor { Only, Not, None diff --git a/Source/WebCore/css/MediaQueryEvaluator.h b/Source/WebCore/css/MediaQueryEvaluator.h index 00ac394..07c4d0d 100644 --- a/Source/WebCore/css/MediaQueryEvaluator.h +++ b/Source/WebCore/css/MediaQueryEvaluator.h @@ -49,7 +49,8 @@ class MediaQueryExp; * the device characteristics are not known. This can be used to prune the loading * of stylesheets to only those which are probable to match. */ -class MediaQueryEvaluator : public Noncopyable { +class MediaQueryEvaluator { + WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); WTF_MAKE_FAST_ALLOCATED; public: /** Creates evaluator which evaluates only simple media queries * Evaluator returns true for "all", and returns value of \mediaFeatureResult diff --git a/Source/WebCore/css/MediaQueryExp.h b/Source/WebCore/css/MediaQueryExp.h index 72d3fff..7e4d477 100644 --- a/Source/WebCore/css/MediaQueryExp.h +++ b/Source/WebCore/css/MediaQueryExp.h @@ -38,7 +38,8 @@ namespace WebCore { class CSSParserValueList; -class MediaQueryExp : public FastAllocBase { +class MediaQueryExp { + WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<MediaQueryExp> create(const AtomicString& mediaFeature, CSSParserValueList* values); ~MediaQueryExp(); diff --git a/Source/WebCore/css/WebKitCSSMatrix.cpp b/Source/WebCore/css/WebKitCSSMatrix.cpp index 7d60f8c..14f6b4e 100644 --- a/Source/WebCore/css/WebKitCSSMatrix.cpp +++ b/Source/WebCore/css/WebKitCSSMatrix.cpp @@ -32,7 +32,6 @@ #include "CSSPropertyNames.h" #include "CSSValueKeywords.h" #include "ExceptionCode.h" -#include "RenderStyle.h" #include <wtf/MathExtras.h> namespace WebCore { diff --git a/Source/WebCore/css/mediaControlsQt.css b/Source/WebCore/css/mediaControlsQt.css index 4ea444c..871a5b8 100644 --- a/Source/WebCore/css/mediaControlsQt.css +++ b/Source/WebCore/css/mediaControlsQt.css @@ -32,7 +32,21 @@ audio { width: 400px; } -audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { +audio::-webkit-media-controls-panel { + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-align: end; + -webkit-user-select: none; + position: absolute; + bottom: 0; + width: 100%; + z-index: 0; + overflow: visible; + height: 100%; + text-align: right; +} + +video::-webkit-media-controls-panel { display: -webkit-box; -webkit-box-orient: horizontal; -webkit-box-align: end; @@ -50,25 +64,61 @@ video:-webkit-full-page-media::-webkit-media-controls-panel { bottom: 0px; } -audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { +audio::-webkit-media-controls-mute-button { width: 12px; height: 12px; padding: 6px; margin: 5px 5px 5px 3px; } -audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { +video::-webkit-media-controls-mute-button { + width: 12px; + height: 12px; + padding: 6px; + margin: 5px 5px 5px 3px; +} + +audio::-webkit-media-controls-play-button { width: 9px; height: 12px; padding: 6px 12px 6px 11px; margin: 5px 3px 5px 5px; } -audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls-timeline-container { +video::-webkit-media-controls-play-button { + width: 9px; + height: 12px; + padding: 6px 12px 6px 11px; + margin: 5px 3px 5px 5px; +} + +audio::-webkit-media-controls-timeline-container { + height: 34px; +} + +video::-webkit-media-controls-timeline-container { height: 34px; } -audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { +audio::-webkit-media-controls-current-time-display { + -webkit-appearance: media-current-time-display; + -webkit-user-select: none; + display: inline-block; + height: 12px; + padding: 6px; + margin: 5px 3px; + + overflow: hidden; + cursor: default; + + text-align: center; + font-size: 10px; + font-family: Verdana; + font-weight: bold; + color: white; +} + +video::-webkit-media-controls-current-time-display { -webkit-appearance: media-current-time-display; -webkit-user-select: none; display: inline-block; @@ -86,24 +136,41 @@ audio::-webkit-media-controls-current-time-display, video::-webkit-media-control color: white; } -audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display { +audio::-webkit-media-controls-time-remaining-display { + display: none; +} + +video::-webkit-media-controls-time-remaining-display { display: none; } -audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { +audio::-webkit-media-controls-timeline { height: 12px; padding: 6px 8px; margin: 5px 3px; } -audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container { +video::-webkit-media-controls-timeline { + height: 12px; + padding: 6px 8px; + margin: 5px 3px; +} + +audio::-webkit-media-controls-volume-slider-container { + -webkit-appearance: media-volume-slider-container; + position: absolute; + height: 103px; + width: 24px; +} + +video::-webkit-media-controls-volume-slider-container { -webkit-appearance: media-volume-slider-container; position: absolute; height: 103px; width: 24px; } -audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volume-slider { +audio::-webkit-media-controls-volume-slider { -webkit-appearance: media-volume-slider; display: inline; position: absolute; @@ -114,27 +181,62 @@ audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volum margin: 0 0 3px 0; } -audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { +video::-webkit-media-controls-volume-slider { + -webkit-appearance: media-volume-slider; + display: inline; + position: absolute; + + width: 12px; + padding: 6px; + height: 88px; + margin: 0 0 3px 0; +} + +audio::-webkit-media-controls-seek-back-button { + display: none; +} + +video::-webkit-media-controls-seek-back-button { + display: none; +} + +audio::-webkit-media-controls-seek-forward-button { + display: none; +} + +video::-webkit-media-controls-seek-forward-button { + display: none; +} + +audio::-webkit-media-controls-fullscreen-button { + display: none; +} + +video::-webkit-media-controls-fullscreen-button { + display: none; +} + +audio::-webkit-media-controls-rewind-button { display: none; } -audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button { +video::-webkit-media-controls-rewind-button { display: none; } -audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button { +audio::-webkit-media-controls-return-to-realtime-button { display: none; } -audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewind-button { +video::-webkit-media-controls-return-to-realtime-button { display: none; } -audio::-webkit-media-controls-return-to-realtime-button, video::-webkit-media-controls-return-to-realtime-button { +audio::-webkit-media-controls-toggle-closed-captions-button { display: none; } -audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button { +video::-webkit-media-controls-toggle-closed-captions-button { display: none; } diff --git a/Source/WebCore/css/mediaControlsQtFullscreen.css b/Source/WebCore/css/mediaControlsQtFullscreen.css index d191331..35cbf75 100644 --- a/Source/WebCore/css/mediaControlsQtFullscreen.css +++ b/Source/WebCore/css/mediaControlsQtFullscreen.css @@ -21,26 +21,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -audio { - height: 34px; - width: 400px; -} - -audio::-webkit-media-controls-panel { - display: -webkit-box; - -webkit-box-orient: horizontal; - -webkit-box-align: end; - -webkit-user-select: none; - position: absolute; - bottom: 0; - width: 100%; - z-index: 0; - overflow: visible; - height: 100%; - text-align: right; -} - video::-webkit-media-controls-panel { /* The control panel is only play button for full screen */ display: -webkit-box; @@ -54,24 +34,10 @@ video:-webkit-full-page-media::-webkit-media-controls-panel { display: none; } -audio::-webkit-media-controls-mute-button { - width: 12px; - height: 12px; - padding: 6px; - margin: 5px 5px 5px 3px; -} - video::-webkit-media-controls-mute-button { display: none; } -audio::-webkit-media-controls-play-button { - width: 9px; - height: 12px; - padding: 6px 12px 6px 11px; - margin: 5px 3px 5px 5px; -} - video::-webkit-media-controls-play-button { display: -webkit-box; -webkit-box-align: center; @@ -81,110 +47,55 @@ video::-webkit-media-controls-play-button { padding: 20px; } -audio::-webkit-media-controls-timeline-container { - height: 34px; -} - video::-webkit-media-controls-timeline-container { display: none; } -audio::-webkit-media-controls-current-time-display { - -webkit-appearance: media-current-time-display; - -webkit-user-select: none; - display: inline-block; - height: 12px; - padding: 6px; - margin: 5px 3px; - - overflow: hidden; - cursor: default; - - text-align: center; - font-size: 10px; - font-family: Verdana; - font-weight: bold; - color: white; -} - video::-webkit-media-controls-current-time-display { -webkit-appearance: media-current-time-display; -webkit-user-select: none; display: none; } -audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display { +video::-webkit-media-controls-time-remaining-display { display: none; } -audio::-webkit-media-controls-timeline { - height: 12px; - padding: 6px 8px; - margin: 5px 3px; -} - video::-webkit-media-controls-timeline { display: none; } -audio::-webkit-media-controls-volume-slider-container { - -webkit-appearance: media-volume-slider-container; - position: absolute; - height: 103px; - width: 24px; -} - video::-webkit-media-controls-volume-slider-container { -webkit-appearance: media-volume-slider-container; display: none; } -audio::-webkit-media-controls-volume-slider { - -webkit-appearance: media-volume-slider; - display: inline; - position: absolute; - - width: 12px; - padding: 6px; - height: 88px; - margin: 0 0 3px 0; -} - video::-webkit-media-controls-volume-slider { -webkit-appearance: media-volume-slider; display: none; } -audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { +video::-webkit-media-controls-seek-back-button { display: none; } -audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button { +video::-webkit-media-controls-seek-forward-button { display: none; } -audio::-webkit-media-controls-fullscreen-button { - position: absolute; - top: 0px; - right: 0px; - width: 12px; - height: 12px; - padding: 6px; - margin: 5px 5px 5px 3px; -} - video::-webkit-media-controls-fullscreen-button { display: none; } -audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewind-button { +video::-webkit-media-controls-rewind-button { display: none; } -audio::-webkit-media-controls-return-to-realtime-button, video::-webkit-media-controls-return-to-realtime-button { +video::-webkit-media-controls-return-to-realtime-button { display: none; } -audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button { +video::-webkit-media-controls-toggle-closed-captions-button { display: none; } + diff --git a/Source/WebCore/dom/AsyncScriptRunner.h b/Source/WebCore/dom/AsyncScriptRunner.h index 2326f67..6a75323 100644 --- a/Source/WebCore/dom/AsyncScriptRunner.h +++ b/Source/WebCore/dom/AsyncScriptRunner.h @@ -39,7 +39,8 @@ class Document; class PendingScript; class ScriptElement; -class AsyncScriptRunner : public Noncopyable { +class AsyncScriptRunner { + WTF_MAKE_NONCOPYABLE(AsyncScriptRunner); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<AsyncScriptRunner> create(Document* document) { return new AsyncScriptRunner(document); } ~AsyncScriptRunner(); diff --git a/Source/WebCore/dom/DOMStringMap.h b/Source/WebCore/dom/DOMStringMap.h index 86a22b0..772a700 100644 --- a/Source/WebCore/dom/DOMStringMap.h +++ b/Source/WebCore/dom/DOMStringMap.h @@ -35,7 +35,8 @@ namespace WebCore { class Element; typedef int ExceptionCode; -class DOMStringMap : public Noncopyable { +class DOMStringMap { + WTF_MAKE_NONCOPYABLE(DOMStringMap); WTF_MAKE_FAST_ALLOCATED; public: virtual ~DOMStringMap(); diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index 1787b52..0bdd603 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -119,6 +119,7 @@ #include "RenderTextControl.h" #include "RenderView.h" #include "RenderWidget.h" +#include "ScriptCallStack.h" #include "ScriptController.h" #include "ScriptElement.h" #include "ScriptEventListener.h" @@ -220,6 +221,10 @@ #include "RenderFullScreen.h" #endif +#if ENABLE(REQUEST_ANIMATION_FRAME) +#include "RequestAnimationFrameCallback.h" +#endif + using namespace std; using namespace WTF; using namespace Unicode; @@ -441,6 +446,9 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) , m_directionSetOnDocumentElement(false) , m_writingModeSetOnDocumentElement(false) +#if ENABLE(REQUEST_ANIMATION_FRAME) + , m_nextRequestAnimationFrameCallbackId(0) +#endif { m_document = this; @@ -1330,7 +1338,7 @@ PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y) if (visiblePosition.isNull()) return 0; - Position rangeCompliantPosition = rangeCompliantEquivalent(visiblePosition); + Position rangeCompliantPosition = visiblePosition.deepEquivalent().parentAnchoredEquivalent(); return Range::create(this, rangeCompliantPosition, rangeCompliantPosition); } @@ -2347,6 +2355,17 @@ KURL Document::virtualCompleteURL(const String& url) const return completeURL(url); } +EventTarget* Document::errorEventTarget() +{ + return domWindow(); +} + +void Document::logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack) +{ + MessageType messageType = callStack ? UncaughtExceptionMessageType : LogMessageType; + addMessage(JSMessageSource, messageType, ErrorMessageLevel, errorMessage, lineNumber, sourceURL, callStack); +} + void Document::setURL(const KURL& url) { const KURL& newURL = url.isEmpty() ? blankURL() : url; @@ -4735,18 +4754,15 @@ void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl) m_haveExplicitlyDisabledDNSPrefetch = true; } -void Document::reportException(const String& errorMessage, int lineNumber, const String& sourceURL) -{ - addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, errorMessage, lineNumber, sourceURL); -} - -void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL) +void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack) { if (DOMWindow* window = domWindow()) - window->console()->addMessage(source, type, level, message, lineNumber, sourceURL); + window->console()->addMessage(source, type, level, message, lineNumber, sourceURL, callStack); } -struct PerformTaskContext : Noncopyable { +struct PerformTaskContext { + WTF_MAKE_NONCOPYABLE(PerformTaskContext); WTF_MAKE_FAST_ALLOCATED; +public: PerformTaskContext(PassRefPtr<DocumentWeakReference> documentReference, PassOwnPtr<ScriptExecutionContext::Task> task) : documentReference(documentReference) , task(task) @@ -5004,6 +5020,86 @@ void Document::loadEventDelayTimerFired(Timer<Document>*) frame()->loader()->checkCompleted(); } +#if ENABLE(REQUEST_ANIMATION_FRAME) +int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e) +{ + if (!m_requestAnimationFrameCallbacks) + m_requestAnimationFrameCallbacks = new RequestAnimationFrameCallbackList; + int id = m_nextRequestAnimationFrameCallbackId++; + callback->m_firedOrCancelled = false; + callback->m_id = id; + callback->m_element = e; + m_requestAnimationFrameCallbacks->append(callback); + if (FrameView* v = view()) + v->scheduleAnimation(); + return id; +} + +void Document::webkitCancelRequestAnimationFrame(int id) +{ + if (!m_requestAnimationFrameCallbacks) + return; + for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size(); ++i) { + if (m_requestAnimationFrameCallbacks->at(i)->m_id == id) { + m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled = true; + m_requestAnimationFrameCallbacks->remove(i); + return; + } + } +} + +void Document::serviceScriptedAnimations() +{ + if (!m_requestAnimationFrameCallbacks) + return; + // We want to run the callback for all elements in the document that have registered + // for a callback and that are visible. Running the callbacks can cause new callbacks + // to be registered, existing callbacks to be cancelled, and elements to gain or lose + // visibility so this code has to iterate carefully. + + // FIXME: Currently, this code doesn't do any visibility tests beyond checking display: + + // First, generate a list of callbacks to consider. Callbacks registered from this point + // on are considered only for the "next" frame, not this one. + RequestAnimationFrameCallbackList callbacks(*m_requestAnimationFrameCallbacks); + + // Firing the callback may cause the visibility of other elements to change. To avoid + // missing any callbacks, we keep iterating through the list of candiate callbacks and firing + // them until nothing new becomes visible. + bool firedCallback; + do { + firedCallback = false; + // A previous iteration may have invalidated style (or layout). Update styles for each iteration + // for now since all we check is the existence of a renderer. + updateStyleIfNeeded(); + for (size_t i = 0; i < callbacks.size(); ++i) { + RequestAnimationFrameCallback* callback = callbacks[i].get(); + if (!callback->m_firedOrCancelled && (!callback->m_element || callback->m_element->renderer())) { + callback->m_firedOrCancelled = true; + callback->handleEvent(); + firedCallback = true; + callbacks.remove(i); + break; + } + } + } while (firedCallback); + + // Remove any callbacks we fired from the list of pending callbacks. + for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size();) { + if (m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled) + m_requestAnimationFrameCallbacks->remove(i); + else + ++i; + } + + // In most cases we expect this list to be empty, so no need to keep around the vector's inline buffer. + if (!m_requestAnimationFrameCallbacks->size()) + m_requestAnimationFrameCallbacks.clear(); + else if (FrameView* v = view()) + v->scheduleAnimation(); +} +#endif + #if ENABLE(TOUCH_EVENTS) PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const { diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h index e70063a..c9c8d38 100644 --- a/Source/WebCore/dom/Document.h +++ b/Source/WebCore/dom/Document.h @@ -146,6 +146,10 @@ class Touch; class TouchList; #endif +#if ENABLE(REQUEST_ANIMATION_FRAME) +class RequestAnimationFrameCallback; +#endif + typedef int ExceptionCode; class FormElementKey { @@ -249,6 +253,8 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(dragstart); DEFINE_ATTRIBUTE_EVENT_LISTENER(drag); DEFINE_ATTRIBUTE_EVENT_LISTENER(dragend); + DEFINE_ATTRIBUTE_EVENT_LISTENER(formchange); + DEFINE_ATTRIBUTE_EVENT_LISTENER(forminput); DEFINE_ATTRIBUTE_EVENT_LISTENER(input); DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid); DEFINE_ATTRIBUTE_EVENT_LISTENER(keydown); @@ -942,8 +948,7 @@ public: bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; } void parseDNSPrefetchControlHeader(const String&); - virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL); - virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL); + virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); virtual void postTask(PassOwnPtr<Task>); // Executes the task on context's thread asynchronously. #if USE(JSC) @@ -1083,8 +1088,17 @@ public: const DocumentTiming* timing() const { return &m_documentTiming; } +#if ENABLE(REQUEST_ANIMATION_FRAME) + int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*); + void webkitCancelRequestAnimationFrame(int id); + void serviceScriptedAnimations(); +#endif + bool mayCauseFlashOfUnstyledContent() const; + virtual EventTarget* errorEventTarget(); + virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); + void initDNSPrefetch(); protected: @@ -1408,6 +1422,12 @@ private: DocumentTiming m_documentTiming; RefPtr<MediaQueryMatcher> m_mediaQueryMatcher; + +#if ENABLE(REQUEST_ANIMATION_FRAME) + typedef Vector<RefPtr<RequestAnimationFrameCallback> > RequestAnimationFrameCallbackList; + OwnPtr<RequestAnimationFrameCallbackList> m_requestAnimationFrameCallbacks; + int m_nextRequestAnimationFrameCallbackId; +#endif }; inline bool Document::DocumentOrderedMap::contains(AtomicStringImpl* id) const diff --git a/Source/WebCore/dom/Document.idl b/Source/WebCore/dom/Document.idl index 8d7a71b..c215df0 100644 --- a/Source/WebCore/dom/Document.idl +++ b/Source/WebCore/dom/Document.idl @@ -266,6 +266,8 @@ module core { attribute [DontEnum] EventListener ondrop; attribute [DontEnum] EventListener onerror; attribute [DontEnum] EventListener onfocus; + attribute [DontEnum] EventListener onformchange; + attribute [DontEnum] EventListener onforminput; attribute [DontEnum] EventListener oninput; attribute [DontEnum] EventListener oninvalid; attribute [DontEnum] EventListener onkeydown; @@ -288,8 +290,6 @@ module core { // attribute [DontEnum] EventListener ondurationchange; // attribute [DontEnum] EventListener onemptied; // attribute [DontEnum] EventListener onended; - // attribute [DontEnum] EventListener onformchange; - // attribute [DontEnum] EventListener onforminput; // attribute [DontEnum] EventListener onloadeddata; // attribute [DontEnum] EventListener onloadedmetadata; // attribute [DontEnum] EventListener onloadstart; diff --git a/Source/WebCore/dom/DocumentMarkerController.h b/Source/WebCore/dom/DocumentMarkerController.h index 83177fc..2dc2b9e 100644 --- a/Source/WebCore/dom/DocumentMarkerController.h +++ b/Source/WebCore/dom/DocumentMarkerController.h @@ -38,8 +38,10 @@ class IntRect; class Node; class Range; -class DocumentMarkerController : public Noncopyable { +class DocumentMarkerController { + WTF_MAKE_NONCOPYABLE(DocumentMarkerController); WTF_MAKE_FAST_ALLOCATED; public: + DocumentMarkerController() { } ~DocumentMarkerController() { detach(); } void detach(); diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp index 5d91db7..276a409 100644 --- a/Source/WebCore/dom/Element.cpp +++ b/Source/WebCore/dom/Element.cpp @@ -75,6 +75,7 @@ PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu Element::~Element() { + removeShadowRoot(); if (m_attributeMap) m_attributeMap->detachFromElement(); } @@ -1100,7 +1101,7 @@ void Element::recalcStyle(StyleChange change) Node* Element::shadowRoot() { - return hasRareData() ? rareData()->m_shadowRoot.get() : 0; + return hasRareData() ? rareData()->m_shadowRoot : 0; } void Element::setShadowRoot(PassRefPtr<Node> node) @@ -1109,11 +1110,12 @@ void Element::setShadowRoot(PassRefPtr<Node> node) // about compromising DOM tree integrity (eg. node being a parent of this). However, // once we implement XBL2, we will have to add integrity checks here. removeShadowRoot(); + RefPtr<Node> newRoot = node; if (!newRoot) return; - ensureRareData()->m_shadowRoot = newRoot; + ensureRareData()->m_shadowRoot = newRoot.get(); newRoot->setShadowHost(this); } @@ -1122,7 +1124,9 @@ void Element::removeShadowRoot() if (!hasRareData()) return; - if (RefPtr<Node> oldRoot = rareData()->m_shadowRoot.release()) { + ElementRareData* data = rareData(); + if (RefPtr<Node> oldRoot = data->m_shadowRoot) { + data->m_shadowRoot = 0; document()->removeFocusedNodeOfSubtree(oldRoot.get()); oldRoot->setShadowHost(0); if (oldRoot->inDocument()) diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h index 5e6c047..4510478 100644 --- a/Source/WebCore/dom/Element.h +++ b/Source/WebCore/dom/Element.h @@ -63,6 +63,8 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(dragstart); DEFINE_ATTRIBUTE_EVENT_LISTENER(drag); DEFINE_ATTRIBUTE_EVENT_LISTENER(dragend); + DEFINE_ATTRIBUTE_EVENT_LISTENER(formchange); + DEFINE_ATTRIBUTE_EVENT_LISTENER(forminput); DEFINE_ATTRIBUTE_EVENT_LISTENER(input); DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid); DEFINE_ATTRIBUTE_EVENT_LISTENER(keydown); diff --git a/Source/WebCore/dom/Element.idl b/Source/WebCore/dom/Element.idl index 7cb63c2..652a75b 100644 --- a/Source/WebCore/dom/Element.idl +++ b/Source/WebCore/dom/Element.idl @@ -153,6 +153,8 @@ module core { attribute [DontEnum] EventListener ondrop; attribute [DontEnum] EventListener onerror; attribute [DontEnum] EventListener onfocus; + attribute [DontEnum] EventListener onformchange; + attribute [DontEnum] EventListener onforminput; attribute [DontEnum] EventListener oninput; attribute [DontEnum] EventListener oninvalid; attribute [DontEnum] EventListener onkeydown; @@ -174,8 +176,6 @@ module core { // attribute [DontEnum] EventListener ondurationchange; // attribute [DontEnum] EventListener onemptied; // attribute [DontEnum] EventListener onended; - // attribute [DontEnum] EventListener onformchange; - // attribute [DontEnum] EventListener onforminput; // attribute [DontEnum] EventListener onloadeddata; // attribute [DontEnum] EventListener onloadedmetadata; // attribute [DontEnum] EventListener onloadstart; diff --git a/Source/WebCore/dom/ElementRareData.h b/Source/WebCore/dom/ElementRareData.h index f7f30bb..818a2c2 100644 --- a/Source/WebCore/dom/ElementRareData.h +++ b/Source/WebCore/dom/ElementRareData.h @@ -33,6 +33,7 @@ namespace WebCore { class ElementRareData : public NodeRareData { public: ElementRareData(); + virtual ~ElementRareData(); void resetComputedStyle(); @@ -41,7 +42,7 @@ public: IntSize m_minimumSizeForResizing; RefPtr<RenderStyle> m_computedStyle; - RefPtr<Node> m_shadowRoot; + Node* m_shadowRoot; OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap; OwnPtr<ClassList> m_classList; @@ -54,9 +55,15 @@ inline IntSize defaultMinimumSizeForResizing() inline ElementRareData::ElementRareData() : m_minimumSizeForResizing(defaultMinimumSizeForResizing()) + , m_shadowRoot(0) { } +inline ElementRareData::~ElementRareData() +{ + ASSERT(!m_shadowRoot); +} + inline void ElementRareData::resetComputedStyle() { m_computedStyle.clear(); diff --git a/Source/WebCore/dom/ErrorEvent.cpp b/Source/WebCore/dom/ErrorEvent.cpp index 2627d01..c598836 100644 --- a/Source/WebCore/dom/ErrorEvent.cpp +++ b/Source/WebCore/dom/ErrorEvent.cpp @@ -30,8 +30,6 @@ #include "config.h" -#if ENABLE(WORKERS) - #include "ErrorEvent.h" #include "EventNames.h" @@ -72,5 +70,3 @@ bool ErrorEvent::isErrorEvent() const } } // namespace WebCore - -#endif // ENABLE(WORKERS) diff --git a/Source/WebCore/dom/ErrorEvent.h b/Source/WebCore/dom/ErrorEvent.h index f81530a..719ca2d 100644 --- a/Source/WebCore/dom/ErrorEvent.h +++ b/Source/WebCore/dom/ErrorEvent.h @@ -31,8 +31,6 @@ #ifndef ErrorEvent_h #define ErrorEvent_h -#if ENABLE(WORKERS) - #include "Event.h" #include "PlatformString.h" @@ -69,6 +67,4 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(WORKERS) - #endif // ErrorEvent_h diff --git a/Source/WebCore/dom/Event.cpp b/Source/WebCore/dom/Event.cpp index 0a1538b..0e11c69 100644 --- a/Source/WebCore/dom/Event.cpp +++ b/Source/WebCore/dom/Event.cpp @@ -204,12 +204,10 @@ bool Event::isIDBSuccessEvent() const } #endif -#if ENABLE(WORKERS) bool Event::isErrorEvent() const { return false; } -#endif #if ENABLE(TOUCH_EVENTS) bool Event::isTouchEvent() const @@ -265,7 +263,7 @@ bool Event::fromUserGesture() // other accepted events || type == eventNames().selectEvent || type == eventNames().changeEvent || type == eventNames().focusEvent || type == eventNames().blurEvent - || type == eventNames().submitEvent; + || type == eventNames().submitEvent || type == eventNames().formchangeEvent; } bool Event::storesResultAsString() const diff --git a/Source/WebCore/dom/Event.h b/Source/WebCore/dom/Event.h index 8562cad..45b879d 100644 --- a/Source/WebCore/dom/Event.h +++ b/Source/WebCore/dom/Event.h @@ -24,13 +24,13 @@ #ifndef Event_h #define Event_h +#include "Clipboard.h" #include "DOMTimeStamp.h" #include <wtf/RefCounted.h> #include <wtf/text/AtomicString.h> namespace WebCore { - class Clipboard; class EventTarget; class Event : public RefCounted<Event> { @@ -132,9 +132,7 @@ namespace WebCore { #if ENABLE(WEB_AUDIO) virtual bool isAudioProcessingEvent() const; #endif -#if ENABLE(WORKERS) virtual bool isErrorEvent() const; -#endif #if ENABLE(TOUCH_EVENTS) virtual bool isTouchEvent() const; #endif diff --git a/Source/WebCore/dom/EventNames.h b/Source/WebCore/dom/EventNames.h index d19f043..3b52838 100644 --- a/Source/WebCore/dom/EventNames.h +++ b/Source/WebCore/dom/EventNames.h @@ -66,6 +66,8 @@ namespace WebCore { macro(focus) \ macro(focusin) \ macro(focusout) \ + macro(formchange) \ + macro(forminput) \ macro(hashchange) \ macro(input) \ macro(invalid) \ @@ -182,7 +184,8 @@ namespace WebCore { \ // end of DOM_EVENT_NAMES_FOR_EACH - class EventNames : public Noncopyable { + class EventNames { + WTF_MAKE_NONCOPYABLE(EventNames); WTF_MAKE_FAST_ALLOCATED; int dummy; // Needed to make initialization macro work. // Private to prevent accidental call to EventNames() instead of eventNames() EventNames(); diff --git a/Source/WebCore/dom/EventTarget.h b/Source/WebCore/dom/EventTarget.h index ddcb663..81eeb7f 100644 --- a/Source/WebCore/dom/EventTarget.h +++ b/Source/WebCore/dom/EventTarget.h @@ -83,7 +83,9 @@ namespace WebCore { typedef Vector<RegisteredEventListener, 1> EventListenerVector; typedef HashMap<AtomicString, EventListenerVector*> EventListenerMap; - struct EventTargetData : Noncopyable { + struct EventTargetData { + WTF_MAKE_NONCOPYABLE(EventTargetData); WTF_MAKE_FAST_ALLOCATED; + public: EventTargetData(); ~EventTargetData(); diff --git a/Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h b/Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h index 9d1835a..26f7fd0 100644 --- a/Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h +++ b/Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h @@ -27,11 +27,11 @@ #define IgnoreDestructiveWriteCountIncrementer_h #include "Document.h" -#include <wtf/Noncopyable.h> namespace WebCore { -class IgnoreDestructiveWriteCountIncrementer : public Noncopyable { +class IgnoreDestructiveWriteCountIncrementer { + WTF_MAKE_NONCOPYABLE(IgnoreDestructiveWriteCountIncrementer); public: explicit IgnoreDestructiveWriteCountIncrementer(Document* document) : m_count(document ? &document->m_ignoreDestructiveWriteCount : 0) diff --git a/Source/WebCore/dom/InputElement.cpp b/Source/WebCore/dom/InputElement.cpp index 37211d8..db89c16 100644 --- a/Source/WebCore/dom/InputElement.cpp +++ b/Source/WebCore/dom/InputElement.cpp @@ -140,7 +140,7 @@ void InputElement::setValueFromRenderer(InputElementData& data, InputElement* in // Input event is fired by the Node::defaultEventHandler for editable controls. if (!inputElement->isTextField()) - element->dispatchEvent(Event::create(eventNames().inputEvent, true, false)); + element->dispatchInputEvents(); notifyFormStateChanged(element); } diff --git a/Source/WebCore/dom/MessagePortChannel.h b/Source/WebCore/dom/MessagePortChannel.h index f308a29..07668a4 100644 --- a/Source/WebCore/dom/MessagePortChannel.h +++ b/Source/WebCore/dom/MessagePortChannel.h @@ -55,7 +55,8 @@ namespace WebCore { // MessagePortChannel is a platform-independent interface to the remote side of a message channel. // It acts as a wrapper around the platform-dependent PlatformMessagePortChannel implementation which ensures that the platform-dependent close() method is invoked before destruction. - class MessagePortChannel : public Noncopyable { + class MessagePortChannel { + WTF_MAKE_NONCOPYABLE(MessagePortChannel); WTF_MAKE_FAST_ALLOCATED; public: static void createChannel(PassRefPtr<MessagePort>, PassRefPtr<MessagePort>); @@ -78,7 +79,8 @@ namespace WebCore { // Returns true if the proxy currently contains messages for this port. bool hasPendingActivity(); - class EventData : public Noncopyable { + class EventData { + WTF_MAKE_NONCOPYABLE(EventData); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<EventData> create(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>); diff --git a/Source/WebCore/dom/NamedNodeMap.cpp b/Source/WebCore/dom/NamedNodeMap.cpp index bc56f7e..0e2861e 100644 --- a/Source/WebCore/dom/NamedNodeMap.cpp +++ b/Source/WebCore/dom/NamedNodeMap.cpp @@ -359,6 +359,8 @@ bool NamedNodeMap::mappedMapsEquivalent(const NamedNodeMap* otherMap) const Attribute* otherAttr = otherMap->getAttributeItem(attr->name()); if (!otherAttr || attr->value() != otherAttr->value()) return false; + if (!attr->decl()->propertiesEqual(otherAttr->decl())) + return false; } } return true; diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp index 1998c8c..275e370 100644 --- a/Source/WebCore/dom/Node.cpp +++ b/Source/WebCore/dom/Node.cpp @@ -497,6 +497,7 @@ Element* Node::shadowHost() const void Node::setShadowHost(Element* host) { + ASSERT(!parentNode()); if (host) setFlag(IsShadowRootFlag); else @@ -3037,6 +3038,16 @@ void Node::dispatchBlurEvent() dispatchEvent(Event::create(eventNames().blurEvent, false, false)); } +void Node::dispatchChangeEvents() +{ + dispatchEvent(Event::create(eventNames().changeEvent, true, false)); +} + +void Node::dispatchInputEvents() +{ + dispatchEvent(Event::create(eventNames().inputEvent, true, false)); +} + bool Node::disabled() const { return false; @@ -3094,7 +3105,7 @@ void Node::defaultEventHandler(Event* event) if (Frame* frame = document()->frame()) frame->eventHandler()->defaultWheelEventHandler(startNode, wheelEvent); } else if (event->type() == eventNames().webkitEditableContentChangedEvent) { - dispatchEvent(Event::create(eventNames().inputEvent, true, false)); + dispatchInputEvents(); } } diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h index bc33e22..546b223 100644 --- a/Source/WebCore/dom/Node.h +++ b/Source/WebCore/dom/Node.h @@ -553,6 +553,8 @@ public: virtual void dispatchFocusEvent(); virtual void dispatchBlurEvent(); + virtual void dispatchChangeEvents(); + virtual void dispatchInputEvents(); // Perform the default action for an event. virtual void defaultEventHandler(Event*); diff --git a/Source/WebCore/dom/NodeRareData.h b/Source/WebCore/dom/NodeRareData.h index ab208d2..7350f80 100644 --- a/Source/WebCore/dom/NodeRareData.h +++ b/Source/WebCore/dom/NodeRareData.h @@ -34,7 +34,9 @@ namespace WebCore { -struct NodeListsNodeData : Noncopyable { +struct NodeListsNodeData { + WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED; +public: typedef HashSet<DynamicNodeList*> NodeListSet; NodeListSet m_listsWithCaches; @@ -67,7 +69,8 @@ private: } }; -class NodeRareData : public Noncopyable { +class NodeRareData { + WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; public: NodeRareData() : m_tabIndex(0) diff --git a/Source/WebCore/dom/Position.cpp b/Source/WebCore/dom/Position.cpp index be175aa..6749ca9 100644 --- a/Source/WebCore/dom/Position.cpp +++ b/Source/WebCore/dom/Position.cpp @@ -146,6 +146,27 @@ int Position::computeOffsetInContainerNode() const return 0; } +// Neighbor-anchored positions are invalid DOM positions, so they need to be +// fixed up before handing them off to the Range object. +Position Position::parentAnchoredEquivalent() const +{ + if (!m_anchorNode) + return Position(); + + // FIXME: This should only be necessary for legacy positions, but is also needed for positions before and after Tables + if (m_offset <= 0) { + if (m_anchorNode->parentNode() && (editingIgnoresContent(m_anchorNode.get()) || isTableElement(m_anchorNode.get()))) + return positionInParentBeforeNode(m_anchorNode.get()); + return Position(m_anchorNode, 0, PositionIsOffsetInAnchor); + } + if (!m_anchorNode->offsetInCharacters() && static_cast<unsigned>(m_offset) == m_anchorNode->childNodeCount() + && (editingIgnoresContent(m_anchorNode.get()) || isTableElement(m_anchorNode.get()))) { + return positionInParentAfterNode(m_anchorNode.get()); + } + + return Position(containerNode(), computeOffsetInContainerNode(), PositionIsOffsetInAnchor); +} + Node* Position::computeNodeBeforePosition() const { if (!m_anchorNode) diff --git a/Source/WebCore/dom/Position.h b/Source/WebCore/dom/Position.h index 4d3b5fe..8b41736 100644 --- a/Source/WebCore/dom/Position.h +++ b/Source/WebCore/dom/Position.h @@ -80,6 +80,7 @@ public: // will return img->parentNode() and img->nodeIndex() from these functions. Node* containerNode() const; // NULL for a before/after position anchored to a node with no parent int computeOffsetInContainerNode() const; // O(n) for before/after-anchored positions, O(1) for parent-anchored positions + Position parentAnchoredEquivalent() const; // Convenience method for DOM positions that also fixes up some positions for editing // Inline O(1) access for Positions which callers know to be parent-anchored int offsetInContainerNode() const @@ -179,7 +180,7 @@ private: RefPtr<Node> m_anchorNode; // m_offset can be the offset inside m_anchorNode, or if editingIgnoresContent(m_anchorNode) // returns true, then other places in editing will treat m_offset == 0 as "before the anchor" - // and m_offset > 0 as "after the anchor node". See rangeCompliantEquivalent for more info. + // and m_offset > 0 as "after the anchor node". See parentAnchoredEquivalent for more info. int m_offset; unsigned m_anchorType : 2; bool m_isLegacyEditingPosition : 1; diff --git a/Source/WebCore/dom/QualifiedName.h b/Source/WebCore/dom/QualifiedName.h index 34fc069..cb95f20 100644 --- a/Source/WebCore/dom/QualifiedName.h +++ b/Source/WebCore/dom/QualifiedName.h @@ -32,7 +32,8 @@ struct QualifiedNameComponents { StringImpl* m_namespace; }; -class QualifiedName : public FastAllocBase { +class QualifiedName { + WTF_MAKE_FAST_ALLOCATED; public: class QualifiedNameImpl : public RefCounted<QualifiedNameImpl> { public: diff --git a/Source/WebCore/platform/ScrollbarClient.cpp b/Source/WebCore/dom/RequestAnimationFrameCallback.h index 2f81a93..819e495 100644 --- a/Source/WebCore/platform/ScrollbarClient.cpp +++ b/Source/WebCore/dom/RequestAnimationFrameCallback.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2010, Google Inc. All rights reserved. - * + * Copyright (C) 2011 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 @@ -14,7 +14,7 @@ * * 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 @@ -28,30 +28,26 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "ScrollbarClient.h" +#ifndef RequestAnimationFrameCallback_h +#define RequestAnimationFrameCallback_h -#include "ScrollAnimator.h" +#include "Element.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> namespace WebCore { -ScrollbarClient::ScrollbarClient() - : m_scrollAnimator(ScrollAnimator::create(this)) -{ -} +class RequestAnimationFrameCallback : public RefCounted<RequestAnimationFrameCallback> { +public: + virtual ~RequestAnimationFrameCallback() { } + virtual bool handleEvent() = 0; -ScrollbarClient::~ScrollbarClient() -{ -} + RefPtr<Element> m_element; + int m_id; + bool m_firedOrCancelled; +}; -bool ScrollbarClient::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier) -{ - return m_scrollAnimator->scroll(orientation, granularity, step, multiplier); } -void ScrollbarClient::setScrollPositionAndStopAnimation(ScrollbarOrientation orientation, float pos) -{ - m_scrollAnimator->setScrollPositionAndStopAnimation(orientation, pos); -} +#endif // RequestAnimationFrameCallback_h -} // namespace WebCore diff --git a/Source/WebCore/dom/RequestAnimationFrameCallback.idl b/Source/WebCore/dom/RequestAnimationFrameCallback.idl new file mode 100644 index 0000000..8d232e5 --- /dev/null +++ b/Source/WebCore/dom/RequestAnimationFrameCallback.idl @@ -0,0 +1,37 @@ +/* + * 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. + */ + +module core { + interface [ + Callback=FunctionOnly,Conditional=REQUEST_ANIMATION_FRAME + ] RequestAnimationFrameCallback{ + boolean handleEvent(); + }; +} diff --git a/Source/WebCore/dom/ScriptElement.h b/Source/WebCore/dom/ScriptElement.h index 07c59db..5250f3e 100644 --- a/Source/WebCore/dom/ScriptElement.h +++ b/Source/WebCore/dom/ScriptElement.h @@ -32,6 +32,7 @@ class ScriptElement; class ScriptSourceCode; class ScriptElement : private CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: ScriptElement(Element*, bool createdByParser, bool isEvaluated); virtual ~ScriptElement(); diff --git a/Source/WebCore/dom/ScriptExecutionContext.cpp b/Source/WebCore/dom/ScriptExecutionContext.cpp index bfda17b..9fdf85e 100644 --- a/Source/WebCore/dom/ScriptExecutionContext.cpp +++ b/Source/WebCore/dom/ScriptExecutionContext.cpp @@ -33,14 +33,19 @@ #include "Database.h" #include "DatabaseTask.h" #include "DatabaseThread.h" +#include "ErrorEvent.h" +#include "EventListener.h" +#include "EventTarget.h" #include "FileThread.h" #include "MessagePort.h" +#include "ScriptCallStack.h" #include "SecurityOrigin.h" #include "ThreadableBlobRegistry.h" #include "WorkerContext.h" #include "WorkerThread.h" #include <wtf/MainThread.h> #include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> #if USE(JSC) #include "JSDOMWindow.h" @@ -61,9 +66,26 @@ public: } }; +class ScriptExecutionContext::PendingException { + WTF_MAKE_NONCOPYABLE(PendingException); +public: + PendingException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack) + : m_errorMessage(errorMessage) + , m_lineNumber(lineNumber) + , m_sourceURL(sourceURL) + , m_callStack(callStack) + { + } + String m_errorMessage; + int m_lineNumber; + String m_sourceURL; + RefPtr<ScriptCallStack> m_callStack; +}; + ScriptExecutionContext::ScriptExecutionContext() + : m_inDispatchErrorEvent(false) #if ENABLE(DATABASE) - : m_hasOpenDatabases(false) + , m_hasOpenDatabases(false) #endif { } @@ -243,6 +265,43 @@ void ScriptExecutionContext::setSecurityOrigin(PassRefPtr<SecurityOrigin> securi m_securityOrigin = securityOrigin; } +void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack) +{ + if (m_inDispatchErrorEvent) { + if (!m_pendingExceptions) + m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >()); + m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, sourceURL, callStack))); + return; + } + + // First report the original exception and only then all the nested ones. + if (!dispatchErrorEvent(errorMessage, lineNumber, sourceURL)) + logExceptionToConsole(errorMessage, lineNumber, sourceURL, callStack); + + if (!m_pendingExceptions) + return; + + for (size_t i = 0; i < m_pendingExceptions->size(); i++) { + PendingException* e = m_pendingExceptions->at(i).get(); + logExceptionToConsole(e->m_errorMessage, e->m_lineNumber, e->m_sourceURL, e->m_callStack); + } + m_pendingExceptions.clear(); +} + +bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL) +{ + EventTarget* target = errorEventTarget(); + if (!target) + return false; + + ASSERT(!m_inDispatchErrorEvent); + m_inDispatchErrorEvent = true; + RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(errorMessage, sourceURL, lineNumber); + target->dispatchEvent(errorEvent); + m_inDispatchErrorEvent = false; + return errorEvent->defaultPrevented(); +} + void ScriptExecutionContext::addTimeout(int timeoutId, DOMTimer* timer) { ASSERT(!m_timeouts.contains(timeoutId)); diff --git a/Source/WebCore/dom/ScriptExecutionContext.h b/Source/WebCore/dom/ScriptExecutionContext.h index e473a4b..b57b75a 100644 --- a/Source/WebCore/dom/ScriptExecutionContext.h +++ b/Source/WebCore/dom/ScriptExecutionContext.h @@ -33,6 +33,8 @@ #include <wtf/Forward.h> #include <wtf/HashMap.h> #include <wtf/HashSet.h> +#include <wtf/Noncopyable.h> +#include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> @@ -52,11 +54,14 @@ namespace WebCore { class DatabaseThread; #endif class DOMTimer; + class EventListener; + class EventTarget; #if ENABLE(BLOB) || ENABLE(FILE_SYSTEM) class FileThread; #endif class MessagePort; class SecurityOrigin; + class ScriptCallStack; class ScriptExecutionContext { public: @@ -85,8 +90,8 @@ namespace WebCore { SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } - virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0; - virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL) = 0; + void reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); + virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) = 0; // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked. bool canSuspendActiveDOMObjects(); @@ -110,8 +115,10 @@ namespace WebCore { void ref() { refScriptExecutionContext(); } void deref() { derefScriptExecutionContext(); } - class Task : public Noncopyable { + class Task { + WTF_MAKE_NONCOPYABLE(Task); WTF_MAKE_FAST_ALLOCATED; public: + Task() { } virtual ~Task(); virtual void performTask(ScriptExecutionContext*) = 0; // Certain tasks get marked specially so that they aren't discarded, and are executed, when the context is shutting down its message queue. @@ -148,6 +155,10 @@ namespace WebCore { virtual const KURL& virtualURL() const = 0; virtual KURL virtualCompleteURL(const String&) const = 0; + virtual EventTarget* errorEventTarget() = 0; + virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) = 0; + bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL); + void closeMessagePorts(); RefPtr<SecurityOrigin> m_securityOrigin; @@ -165,6 +176,10 @@ namespace WebCore { virtual void refScriptExecutionContext() = 0; virtual void derefScriptExecutionContext() = 0; + bool m_inDispatchErrorEvent; + class PendingException; + OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions; + #if ENABLE(DATABASE) RefPtr<DatabaseThread> m_databaseThread; bool m_hasOpenDatabases; // This never changes back to false, even after the database thread is closed. diff --git a/Source/WebCore/dom/SpaceSplitString.h b/Source/WebCore/dom/SpaceSplitString.h index 826e6bd..6eb893c 100644 --- a/Source/WebCore/dom/SpaceSplitString.h +++ b/Source/WebCore/dom/SpaceSplitString.h @@ -28,7 +28,8 @@ namespace WebCore { - class SpaceSplitStringData : public Noncopyable { + class SpaceSplitStringData { + WTF_MAKE_NONCOPYABLE(SpaceSplitStringData); WTF_MAKE_FAST_ALLOCATED; public: SpaceSplitStringData(const String& string, bool shouldFoldCase) : m_string(string), m_shouldFoldCase(shouldFoldCase), m_createdVector(false) diff --git a/Source/WebCore/dom/TextEvent.cpp b/Source/WebCore/dom/TextEvent.cpp index 68ed4b2..b7bd1c8 100644 --- a/Source/WebCore/dom/TextEvent.cpp +++ b/Source/WebCore/dom/TextEvent.cpp @@ -31,21 +31,12 @@ namespace WebCore { -TextEvent::InputType TextEvent::selectInputType(bool isLineBreak, bool isBackTab) -{ - if (isLineBreak) - return TextEvent::InputTypeLineBreak; - if (isBackTab) - return TextEvent::InputTypeBackTab; - return TextEvent::InputTypeKeyboard; -} - PassRefPtr<TextEvent> TextEvent::create() { return adoptRef(new TextEvent); } -PassRefPtr<TextEvent> TextEvent::create(PassRefPtr<AbstractView> view, const String& data, TextEvent::InputType inputType) +PassRefPtr<TextEvent> TextEvent::create(PassRefPtr<AbstractView> view, const String& data, TextEventInputType inputType) { return adoptRef(new TextEvent(view, data, inputType)); } @@ -62,17 +53,17 @@ PassRefPtr<TextEvent> TextEvent::createForFragmentPaste(PassRefPtr<AbstractView> PassRefPtr<TextEvent> TextEvent::createForDrop(PassRefPtr<AbstractView> view, const String& data) { - return adoptRef(new TextEvent(view, data, TextEvent::InputTypeDrop)); + return adoptRef(new TextEvent(view, data, TextEventInputDrop)); } TextEvent::TextEvent() - : m_inputType(TextEvent::InputTypeKeyboard) + : m_inputType(TextEventInputKeyboard) , m_shouldSmartReplace(false) , m_shouldMatchStyle(false) { } -TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, InputType inputType) +TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, TextEventInputType inputType) : UIEvent(eventNames().textInputEvent, true, true, view, 0) , m_inputType(inputType) , m_data(data) @@ -85,7 +76,7 @@ TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, InputTyp TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, PassRefPtr<DocumentFragment> pastingFragment, bool shouldSmartReplace, bool shouldMatchStyle) : UIEvent(eventNames().textInputEvent, true, true, view, 0) - , m_inputType(TextEvent::InputTypePaste) + , m_inputType(TextEventInputPaste) , m_data(data) , m_pastingFragment(pastingFragment) , m_shouldSmartReplace(shouldSmartReplace) diff --git a/Source/WebCore/dom/TextEvent.h b/Source/WebCore/dom/TextEvent.h index f1d24e9..d770d38 100644 --- a/Source/WebCore/dom/TextEvent.h +++ b/Source/WebCore/dom/TextEvent.h @@ -28,23 +28,16 @@ #define TextEvent_h #include "DocumentFragment.h" +#include "TextEventInputType.h" #include "UIEvent.h" namespace WebCore { class TextEvent : public UIEvent { public: - enum InputType { - InputTypeKeyboard, // any newline characters in the text are line breaks only, not paragraph separators. - InputTypeLineBreak, // any tab characters in the text are backtabs. - InputTypeBackTab, - InputTypePaste, - InputTypeDrop, - }; - static InputType selectInputType(bool isLineBreak, bool isBackTab); static PassRefPtr<TextEvent> create(); - static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView> view, const String& data, InputType = InputTypeKeyboard); + static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView>, const String& data, TextEventInputType = TextEventInputKeyboard); static PassRefPtr<TextEvent> createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace); static PassRefPtr<TextEvent> createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle); static PassRefPtr<TextEvent> createForDrop(PassRefPtr<AbstractView> view, const String& data); @@ -57,10 +50,10 @@ namespace WebCore { virtual bool isTextEvent() const; - bool isLineBreak() const { return m_inputType == InputTypeLineBreak; } - bool isBackTab() const { return m_inputType == InputTypeBackTab; } - bool isPaste() const { return m_inputType == InputTypePaste; } - bool isDrop() const { return m_inputType == InputTypeDrop; } + bool isLineBreak() const { return m_inputType == TextEventInputLineBreak; } + bool isBackTab() const { return m_inputType == TextEventInputBackTab; } + bool isPaste() const { return m_inputType == TextEventInputPaste; } + bool isDrop() const { return m_inputType == TextEventInputDrop; } bool shouldSmartReplace() const { return m_shouldSmartReplace; } bool shouldMatchStyle() const { return m_shouldMatchStyle; } @@ -69,11 +62,11 @@ namespace WebCore { private: TextEvent(); - TextEvent(PassRefPtr<AbstractView>, const String& data, InputType = InputTypeKeyboard); + TextEvent(PassRefPtr<AbstractView>, const String& data, TextEventInputType = TextEventInputKeyboard); TextEvent(PassRefPtr<AbstractView>, const String& data, PassRefPtr<DocumentFragment>, bool shouldSmartReplace, bool shouldMatchStyle); - InputType m_inputType; + TextEventInputType m_inputType; String m_data; RefPtr<DocumentFragment> m_pastingFragment; diff --git a/Source/WebCore/dom/TextEventInputType.h b/Source/WebCore/dom/TextEventInputType.h new file mode 100644 index 0000000..2522ec4 --- /dev/null +++ b/Source/WebCore/dom/TextEventInputType.h @@ -0,0 +1,41 @@ +/* + * 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 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 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 TextEventInputType_h +#define TextEventInputType_h + +namespace WebCore { + +enum TextEventInputType { + TextEventInputKeyboard, // any newline characters in the text are line breaks only, not paragraph separators. + TextEventInputLineBreak, // any tab characters in the text are backtabs. + TextEventInputBackTab, + TextEventInputPaste, + TextEventInputDrop, +}; + +} // namespace WebCore + +#endif // TextEventInputType_h diff --git a/Source/WebCore/dom/TransformSource.h b/Source/WebCore/dom/TransformSource.h index f97afcf..63dc78a 100644 --- a/Source/WebCore/dom/TransformSource.h +++ b/Source/WebCore/dom/TransformSource.h @@ -33,7 +33,8 @@ namespace WebCore { typedef void* PlatformTransformSource; #endif - class TransformSource : public Noncopyable { + class TransformSource { + WTF_MAKE_NONCOPYABLE(TransformSource); WTF_MAKE_FAST_ALLOCATED; public: TransformSource(const PlatformTransformSource& source); ~TransformSource(); diff --git a/Source/WebCore/dom/UserGestureIndicator.h b/Source/WebCore/dom/UserGestureIndicator.h index 17ea319..b1ed96b 100644 --- a/Source/WebCore/dom/UserGestureIndicator.h +++ b/Source/WebCore/dom/UserGestureIndicator.h @@ -36,7 +36,8 @@ enum ProcessingUserGestureState { DefinitelyNotProcessingUserGesture }; -class UserGestureIndicator : public Noncopyable { +class UserGestureIndicator { + WTF_MAKE_NONCOPYABLE(UserGestureIndicator); public: static bool processingUserGesture() { return s_processingUserGesture == DefinitelyProcessingUserGesture; } static ProcessingUserGestureState getUserGestureState() { return s_processingUserGesture; } diff --git a/Source/WebCore/dom/UserTypingGestureIndicator.h b/Source/WebCore/dom/UserTypingGestureIndicator.h index 6c71079..21f4c7e 100644 --- a/Source/WebCore/dom/UserTypingGestureIndicator.h +++ b/Source/WebCore/dom/UserTypingGestureIndicator.h @@ -34,7 +34,8 @@ namespace WebCore { class Frame; class Node; -class UserTypingGestureIndicator : public Noncopyable { +class UserTypingGestureIndicator { + WTF_MAKE_NONCOPYABLE(UserTypingGestureIndicator); public: static bool processingUserTypingGesture(); static Node* focusedElementAtGestureStart(); diff --git a/Source/WebCore/dom/XMLDocumentParser.h b/Source/WebCore/dom/XMLDocumentParser.h index 70628ed..2e305c8 100644 --- a/Source/WebCore/dom/XMLDocumentParser.h +++ b/Source/WebCore/dom/XMLDocumentParser.h @@ -180,6 +180,7 @@ namespace WebCore { #endif class XMLDocumentParser : public ScriptableDocumentParser, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<XMLDocumentParser> create(Document* document, FrameView* view) { diff --git a/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp b/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp index 0f6b4b4..10d6e0d 100644 --- a/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp +++ b/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp @@ -75,8 +75,10 @@ using namespace std; namespace WebCore { -class PendingCallbacks : public Noncopyable { +class PendingCallbacks { + WTF_MAKE_NONCOPYABLE(PendingCallbacks); public: + PendingCallbacks() { } ~PendingCallbacks() { deleteAllValues(m_callbacks); diff --git a/Source/WebCore/dom/XMLDocumentParserScope.h b/Source/WebCore/dom/XMLDocumentParserScope.h index 58e8a6b..f60471b 100644 --- a/Source/WebCore/dom/XMLDocumentParserScope.h +++ b/Source/WebCore/dom/XMLDocumentParserScope.h @@ -36,7 +36,8 @@ namespace WebCore { class CachedResourceLoader; - class XMLDocumentParserScope : public Noncopyable { + class XMLDocumentParserScope { + WTF_MAKE_NONCOPYABLE(XMLDocumentParserScope); public: XMLDocumentParserScope(CachedResourceLoader* cachedResourceLoader); ~XMLDocumentParserScope(); diff --git a/Source/WebCore/editing/ApplyStyleCommand.cpp b/Source/WebCore/editing/ApplyStyleCommand.cpp index 7227d7b..39350b9 100644 --- a/Source/WebCore/editing/ApplyStyleCommand.cpp +++ b/Source/WebCore/editing/ApplyStyleCommand.cpp @@ -569,8 +569,8 @@ void ApplyStyleCommand::applyBlockStyle(CSSMutableStyleDeclaration *style) // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoints. // Calculate start and end indices from the start of the tree that they're in. Node* scope = highestAncestor(visibleStart.deepEquivalent().node()); - RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(scope), rangeCompliantEquivalent(visibleStart.deepEquivalent())); - RefPtr<Range> endRange = Range::create(document(), firstPositionInNode(scope), rangeCompliantEquivalent(visibleEnd.deepEquivalent())); + RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); + RefPtr<Range> endRange = Range::create(document(), firstPositionInNode(scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); int startIndex = TextIterator::rangeLength(startRange.get(), true); int endIndex = TextIterator::rangeLength(endRange.get(), true); diff --git a/Source/WebCore/editing/CompositeEditCommand.cpp b/Source/WebCore/editing/CompositeEditCommand.cpp index 9e1dfca..552ed79 100644 --- a/Source/WebCore/editing/CompositeEditCommand.cpp +++ b/Source/WebCore/editing/CompositeEditCommand.cpp @@ -159,7 +159,7 @@ void CompositeEditCommand::insertNodeAt(PassRefPtr<Node> insertChild, const Posi ASSERT(isEditablePosition(editingPosition)); // For editing positions like [table, 0], insert before the table, // likewise for replaced elements, brs, etc. - Position p = rangeCompliantEquivalent(editingPosition); + Position p = editingPosition.parentAnchoredEquivalent(); Node* refChild = p.node(); int offset = p.deprecatedEditingOffset(); @@ -905,13 +905,13 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap startIndex = 0; if (startInParagraph) { - RefPtr<Range> startRange = Range::create(document(), rangeCompliantEquivalent(startOfParagraphToMove.deepEquivalent()), rangeCompliantEquivalent(visibleStart.deepEquivalent())); + RefPtr<Range> startRange = Range::create(document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleStart.deepEquivalent().parentAnchoredEquivalent()); startIndex = TextIterator::rangeLength(startRange.get(), true); } endIndex = 0; if (endInParagraph) { - RefPtr<Range> endRange = Range::create(document(), rangeCompliantEquivalent(startOfParagraphToMove.deepEquivalent()), rangeCompliantEquivalent(visibleEnd.deepEquivalent())); + RefPtr<Range> endRange = Range::create(document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); endIndex = TextIterator::rangeLength(endRange.get(), true); } } @@ -926,8 +926,8 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap Position end = endOfParagraphToMove.deepEquivalent().upstream(); // start and end can't be used directly to create a Range; they are "editing positions" - Position startRangeCompliant = rangeCompliantEquivalent(start); - Position endRangeCompliant = rangeCompliantEquivalent(end); + Position startRangeCompliant = start.parentAnchoredEquivalent(); + Position endRangeCompliant = end.parentAnchoredEquivalent(); RefPtr<Range> range = Range::create(document(), startRangeCompliant.node(), startRangeCompliant.deprecatedEditingOffset(), endRangeCompliant.node(), endRangeCompliant.deprecatedEditingOffset()); // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It @@ -974,7 +974,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap updateLayout(); } - RefPtr<Range> startToDestinationRange(Range::create(document(), firstPositionInNode(document()->documentElement()), rangeCompliantEquivalent(destination.deepEquivalent()))); + RefPtr<Range> startToDestinationRange(Range::create(document(), firstPositionInNode(document()->documentElement()), destination.deepEquivalent().parentAnchoredEquivalent())); destinationIndex = TextIterator::rangeLength(startToDestinationRange.get(), true); setEndingSelection(destination); diff --git a/Source/WebCore/editing/DeleteButtonController.h b/Source/WebCore/editing/DeleteButtonController.h index 1286c07..4d928c7 100644 --- a/Source/WebCore/editing/DeleteButtonController.h +++ b/Source/WebCore/editing/DeleteButtonController.h @@ -36,7 +36,8 @@ class HTMLElement; class RenderObject; class VisibleSelection; -class DeleteButtonController : public Noncopyable { +class DeleteButtonController { + WTF_MAKE_NONCOPYABLE(DeleteButtonController); WTF_MAKE_FAST_ALLOCATED; public: DeleteButtonController(Frame*); diff --git a/Source/WebCore/editing/DeleteSelectionCommand.cpp b/Source/WebCore/editing/DeleteSelectionCommand.cpp index 24c1968..3ba5ae9 100644 --- a/Source/WebCore/editing/DeleteSelectionCommand.cpp +++ b/Source/WebCore/editing/DeleteSelectionCommand.cpp @@ -111,9 +111,9 @@ void DeleteSelectionCommand::initializeStartEnd(Position& start, Position& end) // For HRs, we'll get a position at (HR,1) when hitting delete from the beginning of the previous line, or (HR,0) when forward deleting, // but in these cases, we want to delete it, so manually expand the selection if (start.node()->hasTagName(hrTag)) - start = Position(start.node(), 0); + start = positionBeforeNode(start.node()); else if (end.node()->hasTagName(hrTag)) - end = Position(end.node(), 1); + end = positionAfterNode(end.node()); // FIXME: This is only used so that moveParagraphs can avoid the bugs in special element expansion. if (!m_expandForSpecialElements) @@ -256,14 +256,14 @@ void DeleteSelectionCommand::initializePositionData() } } - // We must pass the positions through rangeCompliantEquivalent, since some editing positions + // We must pass call parentAnchoredEquivalent on the positions since some editing positions // that appear inside their nodes aren't really inside them. [hr, 0] is one example. - // FIXME: rangeComplaintEquivalent should eventually be moved into enclosing element getters + // FIXME: parentAnchoredEquivalent should eventually be moved into enclosing element getters // like the one below, since editing functions should obviously accept editing positions. // FIXME: Passing false to enclosingNodeOfType tells it that it's OK to return a non-editable // node. This was done to match existing behavior, but it seems wrong. - m_startBlock = enclosingNodeOfType(rangeCompliantEquivalent(m_downstreamStart), &isBlock, false); - m_endBlock = enclosingNodeOfType(rangeCompliantEquivalent(m_upstreamEnd), &isBlock, false); + m_startBlock = enclosingNodeOfType(m_downstreamStart.parentAnchoredEquivalent(), &isBlock, false); + m_endBlock = enclosingNodeOfType(m_upstreamEnd.parentAnchoredEquivalent(), &isBlock, false); } void DeleteSelectionCommand::saveTypingStyleState() @@ -315,10 +315,22 @@ static void updatePositionForNodeRemoval(Node* node, Position& position) { if (position.isNull()) return; - if (node->parentNode() == position.node() && node->nodeIndex() < (unsigned)position.deprecatedEditingOffset()) - position = Position(position.node(), position.deprecatedEditingOffset() - 1); - if (position.node() == node || position.node()->isDescendantOf(node)) - position = positionInParentBeforeNode(node); + switch (position.anchorType()) { + case Position::PositionIsOffsetInAnchor: + if (position.containerNode() == node->parentNode() && static_cast<unsigned>(position.offsetInContainerNode()) > node->nodeIndex()) + position.moveToOffset(position.offsetInContainerNode() - 1); + else if (node->contains(position.containerNode())) + position = positionInParentBeforeNode(node); + break; + case Position::PositionIsAfterAnchor: + if (node->contains(position.anchorNode())) + position = positionInParentAfterNode(node); + break; + case Position::PositionIsBeforeAnchor: + if (node->contains(position.anchorNode())) + position = positionInParentBeforeNode(node); + break; + } } void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node) @@ -362,7 +374,7 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node) updateLayout(); RenderObject *r = node->renderer(); if (r && r->isTableCell() && toRenderTableCell(r)->contentHeight() <= 0) - insertBlockPlaceholder(Position(node, 0)); + insertBlockPlaceholder(firstPositionInNode(node.get())); return; } @@ -381,12 +393,13 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node) static void updatePositionForTextRemoval(Node* node, int offset, int count, Position& position) { - if (position.node() == node) { - if (position.deprecatedEditingOffset() > offset + count) - position = Position(position.node(), position.deprecatedEditingOffset() - count); - else if (position.deprecatedEditingOffset() > offset) - position = Position(position.node(), offset); - } + if (position.anchorType() != Position::PositionIsOffsetInAnchor || position.containerNode() != node) + return; + + if (position.offsetInContainerNode() > offset + count) + position.moveToOffset(position.offsetInContainerNode() - count); + else if (position.offsetInContainerNode() > offset) + position.moveToOffset(offset); } void DeleteSelectionCommand::deleteTextFromNode(PassRefPtr<Text> node, unsigned offset, unsigned count) @@ -463,7 +476,7 @@ void DeleteSelectionCommand::handleGeneralDelete() // handle deleting all nodes that are completely selected while (node && node != m_downstreamEnd.node()) { - if (comparePositions(Position(node.get(), 0), m_downstreamEnd) >= 0) { + if (comparePositions(firstPositionInOrBeforeNode(node.get()), m_downstreamEnd) >= 0) { // traverseNextSibling just blew past the end position, so stop deleting node = 0; } else if (!m_downstreamEnd.node()->isDescendantOf(node.get())) { @@ -471,8 +484,9 @@ void DeleteSelectionCommand::handleGeneralDelete() // if we just removed a node from the end container, update end position so the // check above will work if (node->parentNode() == m_downstreamEnd.node()) { + ASSERT(m_downstreamEnd.deprecatedEditingOffset()); ASSERT(node->nodeIndex() < (unsigned)m_downstreamEnd.deprecatedEditingOffset()); - m_downstreamEnd = Position(m_downstreamEnd.node(), m_downstreamEnd.deprecatedEditingOffset() - 1); + m_downstreamEnd.moveToOffset(m_downstreamEnd.deprecatedEditingOffset() - 1); } removeNode(node.get()); node = nextNode.get(); @@ -513,7 +527,7 @@ void DeleteSelectionCommand::handleGeneralDelete() offset = n->nodeIndex() + 1; } removeChildrenInRange(m_downstreamEnd.node(), offset, m_downstreamEnd.deprecatedEditingOffset()); - m_downstreamEnd = Position(m_downstreamEnd.node(), offset); + m_downstreamEnd.moveToOffset(offset); } } } @@ -609,8 +623,8 @@ void DeleteSelectionCommand::mergeParagraphs() return; } - RefPtr<Range> range = Range::create(document(), rangeCompliantEquivalent(startOfParagraphToMove.deepEquivalent()), rangeCompliantEquivalent(endOfParagraphToMove.deepEquivalent())); - RefPtr<Range> rangeToBeReplaced = Range::create(document(), rangeCompliantEquivalent(mergeDestination.deepEquivalent()), rangeCompliantEquivalent(mergeDestination.deepEquivalent())); + RefPtr<Range> range = Range::create(document(), startOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent(), endOfParagraphToMove.deepEquivalent().parentAnchoredEquivalent()); + RefPtr<Range> rangeToBeReplaced = Range::create(document(), mergeDestination.deepEquivalent().parentAnchoredEquivalent(), mergeDestination.deepEquivalent().parentAnchoredEquivalent()); if (!document()->frame()->editor()->client()->shouldMoveRangeAfterDelete(range.get(), rangeToBeReplaced.get())) return; diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp index bea74d9..23b41ce 100644 --- a/Source/WebCore/editing/Editor.cpp +++ b/Source/WebCore/editing/Editor.cpp @@ -643,7 +643,7 @@ WritingDirection Editor::textDirectionForSelection(bool& hasNestedOrMultipleEmbe if (m_frame->selection()->isRange()) { end = m_frame->selection()->selection().end().upstream(); - Node* pastLast = Range::create(m_frame->document(), rangeCompliantEquivalent(position), rangeCompliantEquivalent(end))->pastLastNode(); + Node* pastLast = Range::create(m_frame->document(), position.parentAnchoredEquivalent(), end.parentAnchoredEquivalent())->pastLastNode(); for (Node* n = node; n && n != pastLast; n = n->traverseNextNode()) { if (!n->isStyledElement()) continue; @@ -1783,7 +1783,7 @@ void Editor::advanceToNextMisspelling(bool startBeforeSelection) if (position.isNull()) return; - Position rangeCompliantPosition = rangeCompliantEquivalent(position); + Position rangeCompliantPosition = position.parentAnchoredEquivalent(); spellingSearchRange->setStart(rangeCompliantPosition.node(), rangeCompliantPosition.deprecatedEditingOffset(), ec); startedWithSelection = false; // won't need to wrap } diff --git a/Source/WebCore/editing/EditorCommand.cpp b/Source/WebCore/editing/EditorCommand.cpp index 64993d5..9e5bf9f 100644 --- a/Source/WebCore/editing/EditorCommand.cpp +++ b/Source/WebCore/editing/EditorCommand.cpp @@ -477,7 +477,7 @@ static bool executeIndent(Frame* frame, Event*, EditorCommandSource, const Strin static bool executeInsertBacktab(Frame* frame, Event* event, EditorCommandSource, const String&) { - return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\t", event, false, true); + return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\t", event, TextEventInputBackTab); } static bool executeInsertHorizontalRule(Frame* frame, Event*, EditorCommandSource, const String& value) @@ -505,7 +505,7 @@ static bool executeInsertLineBreak(Frame* frame, Event* event, EditorCommandSour { switch (source) { case CommandFromMenuOrKeyBinding: - return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\n", event, true); + return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\n", event, TextEventInputLineBreak); case CommandFromDOM: case CommandFromDOMWithUserInterface: // Doesn't scroll to make the selection visible, or modify the kill ring. @@ -521,7 +521,7 @@ static bool executeInsertLineBreak(Frame* frame, Event* event, EditorCommandSour static bool executeInsertNewline(Frame* frame, Event* event, EditorCommandSource, const String&) { Frame* targetFrame = WebCore::targetFrame(frame, event); - return targetFrame->eventHandler()->handleTextInputEvent("\n", event, !targetFrame->editor()->canEditRichly()); + return targetFrame->eventHandler()->handleTextInputEvent("\n", event, targetFrame->editor()->canEditRichly() ? TextEventInputKeyboard : TextEventInputLineBreak); } static bool executeInsertNewlineInQuotedContent(Frame* frame, Event*, EditorCommandSource, const String&) @@ -544,7 +544,7 @@ static bool executeInsertParagraph(Frame* frame, Event*, EditorCommandSource, co static bool executeInsertTab(Frame* frame, Event* event, EditorCommandSource, const String&) { - return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\t", event, false, false); + return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\t", event); } static bool executeInsertText(Frame* frame, Event*, EditorCommandSource, const String& value) diff --git a/Source/WebCore/editing/IndentOutdentCommand.cpp b/Source/WebCore/editing/IndentOutdentCommand.cpp index 13d0f88..9d1adc1 100644 --- a/Source/WebCore/editing/IndentOutdentCommand.cpp +++ b/Source/WebCore/editing/IndentOutdentCommand.cpp @@ -134,11 +134,11 @@ void IndentOutdentCommand::outdentParagraph() } // The selection is inside a blockquote i.e. enclosingNode is a blockquote - VisiblePosition positionInEnclosingBlock = VisiblePosition(Position(enclosingNode, 0)); + VisiblePosition positionInEnclosingBlock = VisiblePosition(firstPositionInNode(enclosingNode)); // If the blockquote is inline, the start of the enclosing block coincides with // positionInEnclosingBlock. VisiblePosition startOfEnclosingBlock = (enclosingNode->renderer() && enclosingNode->renderer()->isInline()) ? positionInEnclosingBlock : startOfBlock(positionInEnclosingBlock); - VisiblePosition lastPositionInEnclosingBlock = VisiblePosition(Position(enclosingNode, enclosingNode->childNodeCount())); + VisiblePosition lastPositionInEnclosingBlock = VisiblePosition(lastPositionInNode(enclosingNode)); VisiblePosition endOfEnclosingBlock = endOfBlock(lastPositionInEnclosingBlock); if (visibleStartOfParagraph == startOfEnclosingBlock && visibleEndOfParagraph == endOfEnclosingBlock) { @@ -176,7 +176,7 @@ void IndentOutdentCommand::outdentParagraph() } RefPtr<Node> placeholder = createBreakElement(document()); insertNodeBefore(placeholder, splitBlockquoteNode); - moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visibleEndOfParagraph), VisiblePosition(Position(placeholder.get(), 0)), true); + moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visibleEndOfParagraph), positionBeforeNode(placeholder.get()), true); } // FIXME: We should merge this function with ApplyBlockElementCommand::formatSelection diff --git a/Source/WebCore/editing/InsertLineBreakCommand.cpp b/Source/WebCore/editing/InsertLineBreakCommand.cpp index 3070edf..af8f2fc 100644 --- a/Source/WebCore/editing/InsertLineBreakCommand.cpp +++ b/Source/WebCore/editing/InsertLineBreakCommand.cpp @@ -82,7 +82,7 @@ bool InsertLineBreakCommand::shouldUseBreakElement(const Position& insertionPos) // An editing position like [input, 0] actually refers to the position before // the input element, and in that case we need to check the input element's // parent's renderer. - Position p(rangeCompliantEquivalent(insertionPos)); + Position p(insertionPos.parentAnchoredEquivalent()); return p.node()->renderer() && !p.node()->renderer()->style()->preserveNewline(); } @@ -121,13 +121,13 @@ void InsertLineBreakCommand::doApply() if (needExtraLineBreak) insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert); - VisiblePosition endingPosition(Position(nodeToInsert.get(), 0)); + VisiblePosition endingPosition(positionBeforeNode(nodeToInsert.get())); setEndingSelection(VisibleSelection(endingPosition)); } else if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.node())) { insertNodeAt(nodeToInsert.get(), pos); // Insert an extra br or '\n' if the just inserted one collapsed. - if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0)))) + if (!isStartOfParagraph(positionBeforeNode(nodeToInsert.get()))) insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get()); setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM)); @@ -141,7 +141,7 @@ void InsertLineBreakCommand::doApply() Text* textNode = static_cast<Text*>(pos.node()); splitTextNode(textNode, pos.deprecatedEditingOffset()); insertNodeBefore(nodeToInsert, textNode); - Position endingPosition = Position(textNode, 0); + Position endingPosition = firstPositionInNode(textNode); // Handle whitespace that occurs after the split updateLayout(); @@ -156,7 +156,7 @@ void InsertLineBreakCommand::doApply() else { RefPtr<Text> nbspNode = document()->createTextNode(nonBreakingSpaceString()); insertNodeAt(nbspNode.get(), positionBeforeTextNode); - endingPosition = Position(nbspNode.get(), 0); + endingPosition = firstPositionInNode(nbspNode.get()); } } diff --git a/Source/WebCore/editing/InsertListCommand.cpp b/Source/WebCore/editing/InsertListCommand.cpp index bb3cd93..9348786 100644 --- a/Source/WebCore/editing/InsertListCommand.cpp +++ b/Source/WebCore/editing/InsertListCommand.cpp @@ -217,7 +217,7 @@ void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const Qu RefPtr<HTMLElement> newList = createHTMLElement(document(), listTag); insertNodeBefore(newList, listNode); - Node* firstChildInList = enclosingListChild(VisiblePosition(Position(listNode, 0)).deepEquivalent().node(), listNode.get()); + Node* firstChildInList = enclosingListChild(VisiblePosition(firstPositionInNode(listNode.get())).deepEquivalent().node(), listNode.get()); Node* outerBlock = firstChildInList->isBlockFlow() ? firstChildInList : listNode.get(); moveParagraphWithClones(firstPositionInNode(listNode.get()), lastPositionInNode(listNode.get()), newList.get(), outerBlock); @@ -302,7 +302,7 @@ void InsertListCommand::unlistifyParagraph(const VisiblePosition& originalStart, } else insertNodeAfter(nodeToInsert, listNode); - VisiblePosition insertionPoint = VisiblePosition(Position(placeholder.get(), 0)); + VisiblePosition insertionPoint = VisiblePosition(positionBeforeNode(placeholder.get())); moveParagraphs(start, end, insertionPoint, true); } @@ -345,7 +345,7 @@ PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio if (previousList) appendNode(listItemElement, previousList); else if (nextList) - insertNodeAt(listItemElement, Position(nextList, 0)); + insertNodeAt(listItemElement, positionBeforeNode(nextList)); else { // Create the list. listElement = createHTMLElement(document(), listTag); @@ -356,7 +356,7 @@ PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio // by a br or a '\n', will invalidate start and end. Insert // a placeholder and then recompute start and end. RefPtr<Node> placeholder = insertBlockPlaceholder(start.deepEquivalent()); - start = VisiblePosition(Position(placeholder.get(), 0)); + start = positionBeforeNode(placeholder.get()); end = start; } @@ -379,7 +379,7 @@ PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio start = startOfParagraph(originalStart); } - moveParagraph(start, end, VisiblePosition(Position(placeholder.get(), 0)), true); + moveParagraph(start, end, positionBeforeNode(placeholder.get()), true); if (listElement) return mergeWithNeighboringLists(listElement); diff --git a/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp b/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp index 1838382..1d50851 100644 --- a/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp +++ b/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp @@ -159,8 +159,8 @@ void InsertParagraphSeparatorCommand::doApply() affinity = endingSelection().affinity(); } - // FIXME: The rangeCompliantEquivalent conversion needs to be moved into enclosingBlock. - Node* startBlockNode = enclosingBlock(rangeCompliantEquivalent(insertionPosition).node()); + // FIXME: The parentAnchoredEquivalent conversion needs to be moved into enclosingBlock. + Node* startBlockNode = enclosingBlock(insertionPosition.parentAnchoredEquivalent().containerNode()); Position canonicalPos = VisiblePosition(insertionPosition).deepEquivalent(); Element* startBlock = static_cast<Element*>(startBlockNode); if (!startBlockNode @@ -242,7 +242,7 @@ void InsertParagraphSeparatorCommand::doApply() appendBlockPlaceholder(parent); - setEndingSelection(VisibleSelection(Position(parent.get(), 0), DOWNSTREAM)); + setEndingSelection(VisibleSelection(firstPositionInNode(parent.get()), DOWNSTREAM)); return; } @@ -378,7 +378,8 @@ void InsertParagraphSeparatorCommand::doApply() // Handle whitespace that occurs after the split if (splitText) { updateLayout(); - insertionPosition = Position(insertionPosition.node(), 0); + if (insertionPosition.anchorType() == Position::PositionIsOffsetInAnchor) + insertionPosition.moveToOffset(0); if (!insertionPosition.isRenderedCharacter()) { // Clear out all whitespace and insert one non-breaking space ASSERT(!insertionPosition.node()->renderer() || insertionPosition.node()->renderer()->style()->collapseWhiteSpace()); @@ -388,7 +389,7 @@ void InsertParagraphSeparatorCommand::doApply() } } - setEndingSelection(VisibleSelection(Position(blockToInsert.get(), 0), DOWNSTREAM)); + setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get()), DOWNSTREAM)); applyStyleAfterInsertion(startBlock); } diff --git a/Source/WebCore/editing/ReplaceSelectionCommand.cpp b/Source/WebCore/editing/ReplaceSelectionCommand.cpp index 044ce63..f47cb4e 100644 --- a/Source/WebCore/editing/ReplaceSelectionCommand.cpp +++ b/Source/WebCore/editing/ReplaceSelectionCommand.cpp @@ -62,7 +62,8 @@ enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment }; // --- ReplacementFragment helper class -class ReplacementFragment : public Noncopyable { +class ReplacementFragment { + WTF_MAKE_NONCOPYABLE(ReplacementFragment); public: ReplacementFragment(Document*, DocumentFragment*, bool matchStyle, const VisibleSelection&); @@ -568,7 +569,7 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const Node* sourceDocumentStyleSpan = topNode; RefPtr<Node> copiedRangeStyleSpan = sourceDocumentStyleSpan->firstChild(); - RefPtr<EditingStyle> styleAtInsertionPos = EditingStyle::create(rangeCompliantEquivalent(insertionPos)); + RefPtr<EditingStyle> styleAtInsertionPos = EditingStyle::create(insertionPos.parentAnchoredEquivalent()); String styleText = styleAtInsertionPos->style()->cssText(); // FIXME: This string comparison is a naive way of comparing two styles. diff --git a/Source/WebCore/editing/SelectionController.cpp b/Source/WebCore/editing/SelectionController.cpp index eca0711..fa0c32d 100644 --- a/Source/WebCore/editing/SelectionController.cpp +++ b/Source/WebCore/editing/SelectionController.cpp @@ -316,32 +316,45 @@ void SelectionController::willBeModified(EAlteration alter, SelectionDirection d Position start = m_selection.start(); Position end = m_selection.end(); + bool baseIsStart = true; + if (m_isDirectional) { // Make base and extent match start and end so we extend the user-visible selection. // This only matters for cases where base and extend point to different positions than // start and end (e.g. after a double-click to select a word). - if (m_selection.isBaseFirst()) { - m_selection.setBase(start); - m_selection.setExtent(end); - } else { - m_selection.setBase(end); - m_selection.setExtent(start); - } + if (m_selection.isBaseFirst()) + baseIsStart = true; + else + baseIsStart = false; } else { - // FIXME: This is probably not correct for right and left when the direction is RTL. switch (direction) { case DirectionRight: + if (directionOfEnclosingBlock() == LTR) + baseIsStart = true; + else + baseIsStart = false; + break; case DirectionForward: - m_selection.setBase(start); - m_selection.setExtent(end); + baseIsStart = true; break; case DirectionLeft: + if (directionOfEnclosingBlock() == LTR) + baseIsStart = false; + else + baseIsStart = true; + break; case DirectionBackward: - m_selection.setBase(end); - m_selection.setExtent(start); + baseIsStart = false; break; } } + if (baseIsStart) { + m_selection.setBase(start); + m_selection.setExtent(end); + } else { + m_selection.setBase(end); + m_selection.setExtent(start); + } } TextDirection SelectionController::directionOfEnclosingBlock() @@ -458,9 +471,12 @@ VisiblePosition SelectionController::modifyMovingRight(TextGranularity granulari VisiblePosition pos; switch (granularity) { case CharacterGranularity: - if (isRange()) - pos = VisiblePosition(m_selection.end(), m_selection.affinity()); - else + if (isRange()) { + if (directionOfEnclosingBlock() == LTR) + pos = VisiblePosition(m_selection.end(), m_selection.affinity()); + else + pos = VisiblePosition(m_selection.start(), m_selection.affinity()); + } else pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).right(true); break; case WordGranularity: @@ -612,7 +628,10 @@ VisiblePosition SelectionController::modifyMovingLeft(TextGranularity granularit switch (granularity) { case CharacterGranularity: if (isRange()) - pos = VisiblePosition(m_selection.start(), m_selection.affinity()); + if (directionOfEnclosingBlock() == LTR) + pos = VisiblePosition(m_selection.start(), m_selection.affinity()); + else + pos = VisiblePosition(m_selection.end(), m_selection.affinity()); else pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).left(true); break; diff --git a/Source/WebCore/editing/SelectionController.h b/Source/WebCore/editing/SelectionController.h index ee52187..3f805d3 100644 --- a/Source/WebCore/editing/SelectionController.h +++ b/Source/WebCore/editing/SelectionController.h @@ -48,7 +48,8 @@ class VisiblePosition; enum DirectionalityPolicy { MakeNonDirectionalSelection, MakeDirectionalSelection }; -class SelectionController : public Noncopyable { +class SelectionController { + WTF_MAKE_NONCOPYABLE(SelectionController); WTF_MAKE_FAST_ALLOCATED; public: enum EAlteration { AlterationMove, AlterationExtend }; enum CursorAlignOnScroll { AlignCursorOnScrollIfNeeded, diff --git a/Source/WebCore/editing/SpellChecker.h b/Source/WebCore/editing/SpellChecker.h index f6215d2..81bb519 100644 --- a/Source/WebCore/editing/SpellChecker.h +++ b/Source/WebCore/editing/SpellChecker.h @@ -54,7 +54,8 @@ private: int m_length; }; -class SpellChecker : public Noncopyable { +class SpellChecker { + WTF_MAKE_NONCOPYABLE(SpellChecker); public: explicit SpellChecker(Frame*, EditorClient*); ~SpellChecker(); diff --git a/Source/WebCore/editing/TextCheckingHelper.h b/Source/WebCore/editing/TextCheckingHelper.h index 227530f..8b5c691 100644 --- a/Source/WebCore/editing/TextCheckingHelper.h +++ b/Source/WebCore/editing/TextCheckingHelper.h @@ -72,7 +72,8 @@ private: mutable int m_checkingLength; }; -class TextCheckingHelper : public Noncopyable { +class TextCheckingHelper { + WTF_MAKE_NONCOPYABLE(TextCheckingHelper); public: TextCheckingHelper(EditorClient*, PassRefPtr<Range>); ~TextCheckingHelper(); diff --git a/Source/WebCore/editing/TextIterator.cpp b/Source/WebCore/editing/TextIterator.cpp index 7e41420..1fc7606 100644 --- a/Source/WebCore/editing/TextIterator.cpp +++ b/Source/WebCore/editing/TextIterator.cpp @@ -61,7 +61,8 @@ using namespace HTMLNames; // Case folding is also done if the CaseInsensitive option is specified. // Matches are further filtered if the AtWordStarts option is specified, although some // matches inside a word are permitted if TreatMedialCapitalAsWordStart is specified as well. -class SearchBuffer : public Noncopyable { +class SearchBuffer { + WTF_MAKE_NONCOPYABLE(SearchBuffer); public: SearchBuffer(const String& target, FindOptions); ~SearchBuffer(); @@ -1128,10 +1129,10 @@ void SimplifiedBackwardsTextIterator::advance() if (!next) { // Exit empty containers as we pass over them or containers // where [container, 0] is where we started iterating. - if (!m_handledNode && - canHaveChildrenForEditing(m_node) && - m_node->parentNode() && - (!m_node->lastChild() || (m_node == m_endNode && m_endOffset == 0))) { + if (!m_handledNode + && canHaveChildrenForEditing(m_node) + && m_node->parentNode() + && (!m_node->lastChild() || (m_node == m_endNode && !m_endOffset))) { exitNode(); if (m_positionNode) { m_handledNode = true; diff --git a/Source/WebCore/editing/VisiblePosition.cpp b/Source/WebCore/editing/VisiblePosition.cpp index adfead1..5999fa6 100644 --- a/Source/WebCore/editing/VisiblePosition.cpp +++ b/Source/WebCore/editing/VisiblePosition.cpp @@ -597,8 +597,8 @@ PassRefPtr<Range> makeRange(const VisiblePosition &start, const VisiblePosition if (start.isNull() || end.isNull()) return 0; - Position s = rangeCompliantEquivalent(start); - Position e = rangeCompliantEquivalent(end); + Position s = start.deepEquivalent().parentAnchoredEquivalent(); + Position e = end.deepEquivalent().parentAnchoredEquivalent(); return Range::create(s.node()->document(), s.node(), s.deprecatedEditingOffset(), e.node(), e.deprecatedEditingOffset()); } @@ -618,7 +618,7 @@ bool setStart(Range *r, const VisiblePosition &visiblePosition) { if (!r) return false; - Position p = rangeCompliantEquivalent(visiblePosition); + Position p = visiblePosition.deepEquivalent().parentAnchoredEquivalent(); int code = 0; r->setStart(p.node(), p.deprecatedEditingOffset(), code); return code == 0; @@ -628,7 +628,7 @@ bool setEnd(Range *r, const VisiblePosition &visiblePosition) { if (!r) return false; - Position p = rangeCompliantEquivalent(visiblePosition); + Position p = visiblePosition.deepEquivalent().parentAnchoredEquivalent(); int code = 0; r->setEnd(p.node(), p.deprecatedEditingOffset(), code); return code == 0; diff --git a/Source/WebCore/editing/VisibleSelection.cpp b/Source/WebCore/editing/VisibleSelection.cpp index 4037670..035afb8 100644 --- a/Source/WebCore/editing/VisibleSelection.cpp +++ b/Source/WebCore/editing/VisibleSelection.cpp @@ -121,8 +121,8 @@ PassRefPtr<Range> VisibleSelection::firstRange() const { if (isNone()) return 0; - Position start = rangeCompliantEquivalent(m_start); - Position end = rangeCompliantEquivalent(m_end); + Position start = m_start.parentAnchoredEquivalent(); + Position end = m_end.parentAnchoredEquivalent(); return Range::create(start.node()->document(), start, end); } @@ -146,7 +146,7 @@ PassRefPtr<Range> VisibleSelection::toNormalizedRange() const // If the selection is a caret, move the range start upstream. This helps us match // the conventions of text editors tested, which make style determinations based // on the character before the caret, if any. - s = rangeCompliantEquivalent(m_start.upstream()); + s = m_start.upstream().parentAnchoredEquivalent(); e = s; } else { // If the selection is a range, select the minimum range that encompasses the selection. @@ -170,8 +170,8 @@ PassRefPtr<Range> VisibleSelection::toNormalizedRange() const s = e; e = tmp; } - s = rangeCompliantEquivalent(s); - e = rangeCompliantEquivalent(e); + s = s.parentAnchoredEquivalent(); + e = e.parentAnchoredEquivalent(); } // VisibleSelections are supposed to always be valid. This constructor will ASSERT @@ -204,7 +204,7 @@ static PassRefPtr<Range> makeSearchRange(const Position& pos) RefPtr<Range> searchRange(Range::create(d)); ExceptionCode ec = 0; - Position start(rangeCompliantEquivalent(pos)); + Position start(pos.parentAnchoredEquivalent()); searchRange->selectNodeContents(boundary, ec); searchRange->setStart(start.node(), start.deprecatedEditingOffset(), ec); diff --git a/Source/WebCore/editing/htmlediting.cpp b/Source/WebCore/editing/htmlediting.cpp index d08ac2e..90db3ef 100644 --- a/Source/WebCore/editing/htmlediting.cpp +++ b/Source/WebCore/editing/htmlediting.cpp @@ -329,60 +329,12 @@ bool isBlock(const Node* node) // knowing about these kinds of special cases. Node* enclosingBlock(Node* node) { - return static_cast<Element*>(enclosingNodeOfType(Position(node, 0), isBlock)); -} - -// Internally editing uses "invalid" positions for historical reasons. For -// example, in <div><img /></div>, Editing might use (img, 1) for the position -// after <img>, but we have to convert that to (div, 1) before handing the -// position to a Range object. Ideally all internal positions should -// be "range compliant" for simplicity. -Position rangeCompliantEquivalent(const Position& pos) -{ - if (pos.isNull()) - return Position(); - - Node* node = pos.node(); - - if (pos.deprecatedEditingOffset() <= 0) { - if (node->parentNode() && (editingIgnoresContent(node) || isTableElement(node))) - return positionInParentBeforeNode(node); - return Position(node, 0); - } - - if (node->offsetInCharacters()) - return Position(node, min(node->maxCharacterOffset(), pos.deprecatedEditingOffset())); - - int maxCompliantOffset = node->childNodeCount(); - if (pos.deprecatedEditingOffset() > maxCompliantOffset) { - if (node->parentNode()) - return positionInParentAfterNode(node); - - // there is no other option at this point than to - // use the highest allowed position in the node - return Position(node, maxCompliantOffset); - } - - // Editing should never generate positions like this. - if ((pos.deprecatedEditingOffset() < maxCompliantOffset) && editingIgnoresContent(node)) { - ASSERT_NOT_REACHED(); - return node->parentNode() ? positionInParentBeforeNode(node) : Position(node, 0); - } - - if (pos.deprecatedEditingOffset() == maxCompliantOffset && (editingIgnoresContent(node) || isTableElement(node))) - return positionInParentAfterNode(node); - - return Position(pos); -} - -Position rangeCompliantEquivalent(const VisiblePosition& vpos) -{ - return rangeCompliantEquivalent(vpos.deepEquivalent()); + return static_cast<Element*>(enclosingNodeOfType(firstPositionInOrBeforeNode(node), isBlock)); } // This method is used to create positions in the DOM. It returns the maximum valid offset // in a node. It returns 1 for some elements even though they do not have children, which -// creates technically invalid DOM Positions. Be sure to call rangeCompliantEquivalent +// creates technically invalid DOM Positions. Be sure to call parentAnchoredEquivalent // on a Position before using it to create a DOM Range, or an exception will be thrown. int lastOffsetForEditing(const Node* node) { @@ -704,7 +656,7 @@ HTMLElement* enclosingList(Node* node) if (!node) return 0; - Node* root = highestEditableRoot(Position(node, 0)); + Node* root = highestEditableRoot(firstPositionInOrBeforeNode(node)); for (ContainerNode* n = node->parentNode(); n; n = n->parentNode()) { if (n->hasTagName(ulTag) || n->hasTagName(olTag)) @@ -722,7 +674,7 @@ HTMLElement* enclosingListChild(Node *node) return 0; // Check for a list item element, or for a node whose parent is a list element. Such a node // will appear visually as a list item (but without a list marker) - Node* root = highestEditableRoot(Position(node, 0)); + Node* root = highestEditableRoot(firstPositionInOrBeforeNode(node)); // FIXME: This function is inappropriately named if it starts with node instead of node->parentNode() for (Node* n = node; n && n->parentNode(); n = n->parentNode()) { @@ -1081,7 +1033,8 @@ int indexForVisiblePosition(const VisiblePosition& visiblePosition) if (visiblePosition.isNull()) return 0; Position p(visiblePosition.deepEquivalent()); - RefPtr<Range> range = Range::create(p.node()->document(), Position(p.node()->document(), 0), rangeCompliantEquivalent(p)); + RefPtr<Range> range = Range::create(p.node()->document(), firstPositionInNode(p.anchorNode()->document()->documentElement()), + p.parentAnchoredEquivalent()); return TextIterator::rangeLength(range.get(), true); } @@ -1104,11 +1057,11 @@ bool isNodeVisiblyContainedWithin(Node* node, const Range* selectedRange) return true; bool startIsVisuallySame = visiblePositionBeforeNode(node) == selectedRange->startPosition(); - if (startIsVisuallySame && comparePositions(Position(node->parentNode(), node->nodeIndex()+1), selectedRange->endPosition()) < 0) + if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node), selectedRange->endPosition()) < 0) return true; bool endIsVisuallySame = visiblePositionAfterNode(node) == selectedRange->endPosition(); - if (endIsVisuallySame && comparePositions(selectedRange->startPosition(), Position(node->parentNode(), node->nodeIndex())) < 0) + if (endIsVisuallySame && comparePositions(selectedRange->startPosition(), positionInParentBeforeNode(node)) < 0) return true; return startIsVisuallySame && endIsVisuallySame; @@ -1157,23 +1110,23 @@ VisibleSelection avoidIntersectionWithNode(const VisibleSelection& selection, No { if (selection.isNone()) return VisibleSelection(selection); - + VisibleSelection updatedSelection(selection); Node* base = selection.base().node(); Node* extent = selection.extent().node(); ASSERT(base); ASSERT(extent); - + if (base == node || base->isDescendantOf(node)) { ASSERT(node->parentNode()); - updatedSelection.setBase(Position(node->parentNode(), node->nodeIndex())); + updatedSelection.setBase(positionInParentBeforeNode(node)); } - + if (extent == node || extent->isDescendantOf(node)) { ASSERT(node->parentNode()); - updatedSelection.setExtent(Position(node->parentNode(), node->nodeIndex())); + updatedSelection.setExtent(positionInParentBeforeNode(node)); } - + return updatedSelection; } diff --git a/Source/WebCore/editing/htmlediting.h b/Source/WebCore/editing/htmlediting.h index 1f6b986..0208dfb 100644 --- a/Source/WebCore/editing/htmlediting.h +++ b/Source/WebCore/editing/htmlediting.h @@ -101,9 +101,6 @@ bool isNodeInTextFormControl(Node* node); // Functions returning Position -Position rangeCompliantEquivalent(const Position&); -Position rangeCompliantEquivalent(const VisiblePosition&); - Position nextCandidate(const Position&); Position previousCandidate(const Position&); diff --git a/Source/WebCore/editing/visible_units.cpp b/Source/WebCore/editing/visible_units.cpp index 7bb1515..3582aa9 100644 --- a/Source/WebCore/editing/visible_units.cpp +++ b/Source/WebCore/editing/visible_units.cpp @@ -57,8 +57,8 @@ static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch return VisiblePosition(); Document* d = boundary->document(); - Position start = rangeCompliantEquivalent(Position(boundary, 0)); - Position end = rangeCompliantEquivalent(pos); + Position start = Position(boundary, 0).parentAnchoredEquivalent(); + Position end = pos.parentAnchoredEquivalent(); RefPtr<Range> searchRange = Range::create(d); Vector<UChar, 1024> string; @@ -115,22 +115,18 @@ static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch ASSERT(!needMoreContext); } - if (it.atEnd() && next == 0) { - pos = it.range()->startPosition(); - } else if (next != 0) { - Node *node = it.range()->startContainer(ec); - if ((node->isTextNode() && static_cast<int>(next) <= node->maxCharacterOffset()) || (node->renderer() && node->renderer()->isBR() && !next)) - // The next variable contains a usable index into a text node - pos = Position(node, next); - else { - // Use the character iterator to translate the next value into a DOM position. - BackwardsCharacterIterator charIt(searchRange.get(), TextIteratorEndsAtEditingBoundary); - charIt.advance(string.size() - suffixLength - next); - pos = charIt.range()->endPosition(); - } - } + if (!next) + return VisiblePosition(it.atEnd() ? it.range()->startPosition() : pos, DOWNSTREAM); + + Node* node = it.range()->startContainer(ec); + if ((node->isTextNode() && static_cast<int>(next) <= node->maxCharacterOffset()) || (node->renderer() && node->renderer()->isBR() && !next)) + // The next variable contains a usable index into a text node + return VisiblePosition(Position(node, next), DOWNSTREAM); - return VisiblePosition(pos, DOWNSTREAM); + // Use the character iterator to translate the next value into a DOM position. + BackwardsCharacterIterator charIt(searchRange.get(), TextIteratorEndsAtEditingBoundary); + charIt.advance(string.size() - suffixLength - next); + return VisiblePosition(charIt.range()->endPosition(), DOWNSTREAM); } static VisiblePosition nextBoundary(const VisiblePosition& c, BoundarySearchFunction searchFunction) @@ -142,7 +138,7 @@ static VisiblePosition nextBoundary(const VisiblePosition& c, BoundarySearchFunc Document* d = boundary->document(); RefPtr<Range> searchRange(d->createRange()); - Position start(rangeCompliantEquivalent(pos)); + Position start(pos.parentAnchoredEquivalent()); Vector<UChar, 1024> string; unsigned prefixLength = 0; diff --git a/Source/WebCore/fileapi/FileThread.h b/Source/WebCore/fileapi/FileThread.h index d7aabf7..45205c4 100644 --- a/Source/WebCore/fileapi/FileThread.h +++ b/Source/WebCore/fileapi/FileThread.h @@ -54,7 +54,8 @@ public: bool start(); void stop(); - class Task : public Noncopyable { + class Task { + WTF_MAKE_NONCOPYABLE(Task); public: virtual ~Task() { } virtual void performTask() = 0; diff --git a/Source/WebCore/fileapi/LocalFileSystem.h b/Source/WebCore/fileapi/LocalFileSystem.h index b779a5f..12a7012 100644 --- a/Source/WebCore/fileapi/LocalFileSystem.h +++ b/Source/WebCore/fileapi/LocalFileSystem.h @@ -45,7 +45,8 @@ class FileSystemCallback; class ScriptExecutionContext; // Keeps per-process information and provides an entry point to open a file system. -class LocalFileSystem : public Noncopyable { +class LocalFileSystem { + WTF_MAKE_NONCOPYABLE(LocalFileSystem); public: // Returns a per-process instance of LocalFileSystem. // Note that LocalFileSystem::initializeLocalFileSystem must be called before diff --git a/Source/WebCore/fileapi/SyncCallbackHelper.h b/Source/WebCore/fileapi/SyncCallbackHelper.h index 25e6739..020ac49 100644 --- a/Source/WebCore/fileapi/SyncCallbackHelper.h +++ b/Source/WebCore/fileapi/SyncCallbackHelper.h @@ -58,7 +58,8 @@ class FileEntrySync; // A helper template for FileSystemSync implementation. template <typename SuccessCallback, typename ObserverType, typename CallbackArg, typename ResultType> -class SyncCallbackHelper : public Noncopyable { +class SyncCallbackHelper { + WTF_MAKE_NONCOPYABLE(SyncCallbackHelper); public: typedef SyncCallbackHelper<SuccessCallback, ObserverType, CallbackArg, ResultType> HelperType; SyncCallbackHelper(ObserverType* observer = 0) diff --git a/Source/WebCore/history/BackForwardController.h b/Source/WebCore/history/BackForwardController.h index e89e32b..12884ea 100644 --- a/Source/WebCore/history/BackForwardController.h +++ b/Source/WebCore/history/BackForwardController.h @@ -36,7 +36,8 @@ class BackForwardList; class HistoryItem; class Page; -class BackForwardController : public Noncopyable { +class BackForwardController { + WTF_MAKE_NONCOPYABLE(BackForwardController); WTF_MAKE_FAST_ALLOCATED; public: BackForwardController(Page*, PassRefPtr<BackForwardList>); ~BackForwardController(); diff --git a/Source/WebCore/history/CachedFrame.cpp b/Source/WebCore/history/CachedFrame.cpp index d21f958..ab6b4d6 100644 --- a/Source/WebCore/history/CachedFrame.cpp +++ b/Source/WebCore/history/CachedFrame.cpp @@ -30,6 +30,7 @@ #include "DocumentLoader.h" #include "ExceptionCode.h" #include "EventNames.h" +#include "FocusController.h" #include "Frame.h" #include "FrameLoaderClient.h" #include "FrameView.h" @@ -131,6 +132,9 @@ CachedFrame::CachedFrame(Frame* frame) ASSERT(m_documentLoader); ASSERT(m_view); + if (frame->page()->focusController()->focusedFrame() == frame) + frame->page()->focusController()->setFocusedFrame(frame->page()->mainFrame()); + // Active DOM objects must be suspended before we cached the frame script data m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive); m_cachedFrameScriptData = adoptPtr(new ScriptCachedFrameData(frame)); diff --git a/Source/WebCore/history/HistoryItem.cpp b/Source/WebCore/history/HistoryItem.cpp index f9e6c96..805d5aa 100644 --- a/Source/WebCore/history/HistoryItem.cpp +++ b/Source/WebCore/history/HistoryItem.cpp @@ -65,6 +65,8 @@ HistoryItem::HistoryItem() , m_visitCount(0) , m_itemSequenceNumber(generateSequenceNumber()) , m_documentSequenceNumber(generateSequenceNumber()) + , m_next(0) + , m_prev(0) { } @@ -80,6 +82,8 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, double ti , m_visitCount(0) , m_itemSequenceNumber(generateSequenceNumber()) , m_documentSequenceNumber(generateSequenceNumber()) + , m_next(0) + , m_prev(0) { iconDatabase()->retainIconForPageURL(m_urlString); } @@ -97,6 +101,8 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, const Str , m_visitCount(0) , m_itemSequenceNumber(generateSequenceNumber()) , m_documentSequenceNumber(generateSequenceNumber()) + , m_next(0) + , m_prev(0) { iconDatabase()->retainIconForPageURL(m_urlString); } @@ -115,6 +121,8 @@ HistoryItem::HistoryItem(const KURL& url, const String& target, const String& pa , m_visitCount(0) , m_itemSequenceNumber(generateSequenceNumber()) , m_documentSequenceNumber(generateSequenceNumber()) + , m_next(0) + , m_prev(0) { iconDatabase()->retainIconForPageURL(m_urlString); } @@ -168,6 +176,38 @@ PassRefPtr<HistoryItem> HistoryItem::copy() const return adoptRef(new HistoryItem(*this)); } +void HistoryItem::reset() +{ + iconDatabase()->releaseIconForPageURL(m_urlString); + + m_urlString = String(); + m_originalURLString = String(); + m_referrer = String(); + m_target = String(); + m_parent = String(); + m_title = String(); + m_displayTitle = String(); + + m_lastVisitedTime = 0; + m_lastVisitWasHTTPNonGet = false; + + m_lastVisitWasFailure = false; + m_isTargetItem = false; + m_visitCount = 0; + m_dailyVisitCounts.clear(); + m_weeklyVisitCounts.clear(); + + m_redirectURLs.clear(); + + m_itemSequenceNumber = generateSequenceNumber(); + + m_stateObject = 0; + m_documentSequenceNumber = generateSequenceNumber(); + + m_formData = 0; + m_formContentType = String(); +} + const String& HistoryItem::urlString() const { return m_urlString; diff --git a/Source/WebCore/history/HistoryItem.h b/Source/WebCore/history/HistoryItem.h index a4622c0..526cae2 100644 --- a/Source/WebCore/history/HistoryItem.h +++ b/Source/WebCore/history/HistoryItem.h @@ -88,6 +88,9 @@ public: PassRefPtr<HistoryItem> copy() const; + // Resets the HistoryItem to its initial state, as returned by create(). + void reset(); + void encodeBackForwardTree(Encoder&) const; static PassRefPtr<HistoryItem> decodeBackForwardTree(const String& urlString, const String& title, const String& originalURLString, Decoder&); @@ -148,7 +151,7 @@ public: void setDocumentSequenceNumber(long long number) { m_documentSequenceNumber = number; } long long documentSequenceNumber() const { return m_documentSequenceNumber; } - + void setFormInfoFromRequest(const ResourceRequest&); void setFormData(PassRefPtr<FormData>); void setFormContentType(const String&); @@ -262,11 +265,19 @@ private: OwnPtr<Vector<String> > m_redirectURLs; + // If two HistoryItems have the same item sequence number, then they are + // clones of one another. Traversing history from one such HistoryItem to + // another is a no-op. HistoryItem clones are created for parent and + // sibling frames when only a subframe navigates. int64_t m_itemSequenceNumber; + // If two HistoryItems have the same document sequence number, then they + // refer to the same instance of a document. Traversing history from one + // such HistoryItem to another preserves the document. + int64_t m_documentSequenceNumber; + // Support for HTML5 History RefPtr<SerializedScriptValue> m_stateObject; - int64_t m_documentSequenceNumber; // info used to repost form data RefPtr<FormData> m_formData; diff --git a/Source/WebCore/history/PageCache.h b/Source/WebCore/history/PageCache.h index 71ae5ad..912bd65 100644 --- a/Source/WebCore/history/PageCache.h +++ b/Source/WebCore/history/PageCache.h @@ -39,7 +39,8 @@ namespace WebCore { class HistoryItem; class Page; - class PageCache : public Noncopyable { + class PageCache { + WTF_MAKE_NONCOPYABLE(PageCache); WTF_MAKE_FAST_ALLOCATED; public: friend PageCache* pageCache(); diff --git a/Source/WebCore/html/CollectionCache.h b/Source/WebCore/html/CollectionCache.h index df1d1fa..8e4a066 100644 --- a/Source/WebCore/html/CollectionCache.h +++ b/Source/WebCore/html/CollectionCache.h @@ -29,7 +29,9 @@ namespace WebCore { class Element; -struct CollectionCache : FastAllocBase { +struct CollectionCache { + WTF_MAKE_FAST_ALLOCATED; +public: CollectionCache(); CollectionCache(const CollectionCache&); CollectionCache& operator=(const CollectionCache& other) diff --git a/Source/WebCore/html/DOMSettableTokenList.h b/Source/WebCore/html/DOMSettableTokenList.h index 2b711b4..8f6fd4e 100644 --- a/Source/WebCore/html/DOMSettableTokenList.h +++ b/Source/WebCore/html/DOMSettableTokenList.h @@ -35,6 +35,7 @@ namespace WebCore { class DOMSettableTokenList : public DOMTokenList, public RefCounted<DOMSettableTokenList> { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<DOMSettableTokenList> create() { diff --git a/Source/WebCore/html/DOMTokenList.h b/Source/WebCore/html/DOMTokenList.h index 5df2ede..0b75b66 100644 --- a/Source/WebCore/html/DOMTokenList.h +++ b/Source/WebCore/html/DOMTokenList.h @@ -27,15 +27,16 @@ #include "ExceptionCode.h" #include <wtf/text/AtomicString.h> -#include <wtf/Noncopyable.h> #include <wtf/Vector.h> namespace WebCore { class Element; -class DOMTokenList : public Noncopyable { +class DOMTokenList { + WTF_MAKE_NONCOPYABLE(DOMTokenList); WTF_MAKE_FAST_ALLOCATED; public: + DOMTokenList() { } virtual ~DOMTokenList() {}; virtual void ref() = 0; diff --git a/Source/WebCore/html/FormAssociatedElement.h b/Source/WebCore/html/FormAssociatedElement.h index 873bdf4..ebefdc6 100644 --- a/Source/WebCore/html/FormAssociatedElement.h +++ b/Source/WebCore/html/FormAssociatedElement.h @@ -46,6 +46,7 @@ public: virtual bool isFormControlElement() const = 0; virtual bool isEnumeratable() const = 0; + virtual bool isResettable() const = 0; const AtomicString& name() const { return formControlName(); } diff --git a/Source/WebCore/html/HTMLAreaElement.cpp b/Source/WebCore/html/HTMLAreaElement.cpp index dc87ef6..ac4c865 100644 --- a/Source/WebCore/html/HTMLAreaElement.cpp +++ b/Source/WebCore/html/HTMLAreaElement.cpp @@ -22,6 +22,7 @@ #include "config.h" #include "HTMLAreaElement.h" +#include "AffineTransform.h" #include "Attribute.h" #include "Frame.h" #include "HTMLImageElement.h" diff --git a/Source/WebCore/html/HTMLAttributeNames.in b/Source/WebCore/html/HTMLAttributeNames.in index 513e44f..eac9a73 100644 --- a/Source/WebCore/html/HTMLAttributeNames.in +++ b/Source/WebCore/html/HTMLAttributeNames.in @@ -177,6 +177,8 @@ onerror onfocus onfocusin onfocusout +onformchange +onforminput onhashchange oninput oninvalid diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp index f286749..0fdb7b2 100644 --- a/Source/WebCore/html/HTMLCanvasElement.cpp +++ b/Source/WebCore/html/HTMLCanvasElement.cpp @@ -406,6 +406,11 @@ void HTMLCanvasElement::createImageBuffer() const m_imageBuffer->context()->scale(FloatSize(size.width() / unscaledSize.width(), size.height() / unscaledSize.height())); m_imageBuffer->context()->setShadowsIgnoreTransforms(true); m_imageBuffer->context()->setImageInterpolationQuality(DefaultInterpolationQuality); + +#if USE(JSC) + if (hasCachedDOMNodeWrapperUnchecked(document(), const_cast<HTMLCanvasElement*>(this))) + scriptExecutionContext()->globalData()->heap.reportExtraMemoryCost(m_imageBuffer->dataSize()); +#endif } GraphicsContext* HTMLCanvasElement::drawingContext() const @@ -446,8 +451,7 @@ AffineTransform HTMLCanvasElement::baseTransform() const AffineTransform transform; if (size.width() && size.height()) transform.scaleNonUniform(size.width() / unscaledSize.width(), size.height() / unscaledSize.height()); - transform.multiply(m_imageBuffer->baseTransform()); - return transform; + return m_imageBuffer->baseTransform() * transform; } } diff --git a/Source/WebCore/html/HTMLElement.cpp b/Source/WebCore/html/HTMLElement.cpp index af3115c..b7eca06 100644 --- a/Source/WebCore/html/HTMLElement.cpp +++ b/Source/WebCore/html/HTMLElement.cpp @@ -190,6 +190,10 @@ void HTMLElement::parseMappedAttribute(Attribute* attr) setAttributeEventListener(eventNames().focusinEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == onfocusoutAttr) { setAttributeEventListener(eventNames().focusoutEvent, createAttributeEventListener(this, attr)); + } else if (attr->name() == onformchangeAttr) { + setAttributeEventListener(eventNames().formchangeEvent, createAttributeEventListener(this, attr)); + } else if (attr->name() == onforminputAttr) { + setAttributeEventListener(eventNames().forminputEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == onblurAttr) { setAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == onkeydownAttr) { @@ -685,19 +689,18 @@ bool HTMLElement::isContentRichlyEditable() const String HTMLElement::contentEditable() const { - if (!renderer()) - return "false"; - - switch (renderer()->style()->userModify()) { - case READ_WRITE: - return "true"; - case READ_ONLY: - return "false"; - case READ_WRITE_PLAINTEXT_ONLY: - return "plaintext-only"; - default: - return "inherit"; - } + const AtomicString& value = fastGetAttribute(contenteditableAttr); + + if (value.isNull()) + return "inherit"; + if (value.isEmpty() || equalIgnoringCase(value, "true")) + return "true"; + if (equalIgnoringCase(value, "false")) + return "false"; + if (equalIgnoringCase(value, "plaintext-only")) + return "plaintext-only"; + + return "inherit"; } void HTMLElement::setContentEditable(Attribute* attr) @@ -726,14 +729,16 @@ void HTMLElement::setContentEditable(Attribute* attr) } } -void HTMLElement::setContentEditable(const String &enabled) +void HTMLElement::setContentEditable(const String& enabled, ExceptionCode& ec) { - if (enabled == "inherit") { - ExceptionCode ec; + if (equalIgnoringCase(enabled, "true")) + setAttribute(contenteditableAttr, "true", ec); + else if (equalIgnoringCase(enabled, "false")) + setAttribute(contenteditableAttr, "false", ec); + else if (equalIgnoringCase(enabled, "inherit")) removeAttribute(contenteditableAttr, ec); - } else - setAttribute(contenteditableAttr, enabled.isEmpty() ? "true" : enabled); + ec = SYNTAX_ERR; } bool HTMLElement::draggable() const @@ -837,6 +842,40 @@ HTMLFormElement* HTMLElement::virtualForm() const return findFormAncestor(); } +HTMLFormElement* HTMLElement::shadowAncestorOwnerForm() +{ + Node* ancestorNode = shadowAncestorNode(); + if (!ancestorNode) + return form(); + + if (!ancestorNode->isHTMLElement()) + return 0; + HTMLElement* ancestorHTML = static_cast<HTMLElement*>(ancestorNode); + if (!ancestorHTML) + return 0; + return ancestorHTML->form(); +} + +void HTMLElement::dispatchChangeEvents() +{ + RefPtr<HTMLElement> protector(this); + RefPtr<HTMLFormElement> ownerForm(shadowAncestorOwnerForm()); + + Node::dispatchChangeEvents(); + if (ownerForm) + ownerForm->dispatchFormChange(); +} + +void HTMLElement::dispatchInputEvents() +{ + RefPtr<HTMLElement> protector(this); + RefPtr<HTMLFormElement> ownerForm(shadowAncestorOwnerForm()); + + Node::dispatchInputEvents(); + if (ownerForm) + ownerForm->dispatchFormInput(); +} + } // namespace WebCore #ifndef NDEBUG diff --git a/Source/WebCore/html/HTMLElement.h b/Source/WebCore/html/HTMLElement.h index a64db2c..ad84f5d 100644 --- a/Source/WebCore/html/HTMLElement.h +++ b/Source/WebCore/html/HTMLElement.h @@ -61,7 +61,7 @@ public: virtual bool isContentRichlyEditable() const; String contentEditable() const; - void setContentEditable(const String&); + void setContentEditable(const String&, ExceptionCode&); virtual bool draggable() const; void setDraggable(bool); @@ -84,6 +84,9 @@ public: HTMLFormElement* findFormAncestor() const; + virtual void dispatchChangeEvents(); + virtual void dispatchInputEvents(); + protected: HTMLElement(const QualifiedName& tagName, Document*); @@ -101,6 +104,8 @@ private: Node* insertAdjacent(const String& where, Node* newChild, ExceptionCode&); PassRefPtr<DocumentFragment> textToFragment(const String&, ExceptionCode&); + + HTMLFormElement* shadowAncestorOwnerForm(); }; inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document* document) diff --git a/Source/WebCore/html/HTMLElement.idl b/Source/WebCore/html/HTMLElement.idl index 77423fc..cd400c4 100644 --- a/Source/WebCore/html/HTMLElement.idl +++ b/Source/WebCore/html/HTMLElement.idl @@ -59,7 +59,8 @@ module html { readonly attribute HTMLCollection children; - attribute [ConvertNullToNullString] DOMString contentEditable; + attribute [ConvertNullToNullString] DOMString contentEditable + setter raises(DOMException); readonly attribute boolean isContentEditable; attribute boolean spellcheck; diff --git a/Source/WebCore/html/HTMLFormControlElement.cpp b/Source/WebCore/html/HTMLFormControlElement.cpp index b3ad7c8..bb42dfd 100644 --- a/Source/WebCore/html/HTMLFormControlElement.cpp +++ b/Source/WebCore/html/HTMLFormControlElement.cpp @@ -178,7 +178,12 @@ void HTMLFormControlElement::setName(const AtomicString& value) void HTMLFormControlElement::dispatchFormControlChangeEvent() { - dispatchEvent(Event::create(eventNames().changeEvent, true, false)); + HTMLElement::dispatchChangeEvents(); +} + +void HTMLFormControlElement::dispatchFormControlInputEvent() +{ + HTMLElement::dispatchInputEvents(); } void HTMLFormControlElement::setDisabled(bool b) diff --git a/Source/WebCore/html/HTMLFormControlElement.h b/Source/WebCore/html/HTMLFormControlElement.h index 8403b84..c88905c 100644 --- a/Source/WebCore/html/HTMLFormControlElement.h +++ b/Source/WebCore/html/HTMLFormControlElement.h @@ -53,12 +53,14 @@ public: virtual void setFormControlValueMatchesRenderer(bool b) { m_valueMatchesRenderer = b; } virtual void dispatchFormControlChangeEvent(); + virtual void dispatchFormControlInputEvent(); virtual bool disabled() const { return m_disabled; } void setDisabled(bool); virtual bool isFocusable() const; virtual bool isEnumeratable() const { return false; } + virtual bool isResettable() const { return false; } // Determines whether or not a control will be automatically focused. virtual bool autofocus() const; diff --git a/Source/WebCore/html/HTMLFormElement.cpp b/Source/WebCore/html/HTMLFormElement.cpp index c896bbf..d778601 100644 --- a/Source/WebCore/html/HTMLFormElement.cpp +++ b/Source/WebCore/html/HTMLFormElement.cpp @@ -590,6 +590,39 @@ bool HTMLFormElement::checkValidity() return controls.isEmpty(); } +void HTMLFormElement::broadcastFormEvent(const AtomicString& eventName) +{ + RefPtr<HTMLFormElement> protector(this); + // Copy m_associatedElements because event handlers called from + // formElement->dispatchEvent() might change m_associatedElements. + Vector<RefPtr<FormAssociatedElement> > elements; + elements.reserveCapacity(m_associatedElements.size()); + for (unsigned i = 0; i < m_associatedElements.size(); ++i) { + if (!m_associatedElements[i]->isResettable()) + continue; + elements.append(m_associatedElements[i]); + } + + for (unsigned i = 0; i < elements.size(); ++i) { + // We can assume a resettable control is always a HTMLFormControlElement. + // FIXME: We should handle resettable non-HTMLFormControlElements maybe in the future. + ASSERT(elements[i]->isFormControlElement()); + HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(elements[i].get()); + if (!formElement->dispatchEvent(Event::create(eventName, false, false))) + continue; + } +} + +void HTMLFormElement::dispatchFormInput() +{ + broadcastFormEvent(eventNames().forminputEvent); +} + +void HTMLFormElement::dispatchFormChange() +{ + broadcastFormEvent(eventNames().formchangeEvent); +} + void HTMLFormElement::collectUnhandledInvalidControls(Vector<RefPtr<FormAssociatedElement> >& unhandledInvalidControls) { RefPtr<HTMLFormElement> protector(this); diff --git a/Source/WebCore/html/HTMLFormElement.h b/Source/WebCore/html/HTMLFormElement.h index bd087b8..7d7f4f8 100644 --- a/Source/WebCore/html/HTMLFormElement.h +++ b/Source/WebCore/html/HTMLFormElement.h @@ -114,6 +114,9 @@ public: const Vector<FormAssociatedElement*>& associatedElements() const { return m_associatedElements; } + void dispatchFormInput(); + void dispatchFormChange(); + private: HTMLFormElement(const QualifiedName&, Document*); @@ -144,6 +147,8 @@ private: // event was not canceled to the specified vector. void collectUnhandledInvalidControls(Vector<RefPtr<FormAssociatedElement> >&); + void broadcastFormEvent(const AtomicString&); + friend class HTMLFormCollection; typedef HashMap<RefPtr<AtomicStringImpl>, RefPtr<HTMLFormControlElement> > AliasMap; diff --git a/Source/WebCore/html/HTMLFormElement.idl b/Source/WebCore/html/HTMLFormElement.idl index e9759e2..3e9e46d 100644 --- a/Source/WebCore/html/HTMLFormElement.idl +++ b/Source/WebCore/html/HTMLFormElement.idl @@ -43,6 +43,9 @@ module html { #endif void reset(); boolean checkValidity(); + + void dispatchFormInput(); + void dispatchFormChange(); }; } diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp index c7a1a86..637e831 100644 --- a/Source/WebCore/html/HTMLInputElement.cpp +++ b/Source/WebCore/html/HTMLInputElement.cpp @@ -1048,6 +1048,12 @@ void HTMLInputElement::defaultEventHandler(Event* evt) return; } + if (evt->isMouseEvent() && evt->type() == eventNames().mousedownEvent) { + m_inputType->handleMouseDownEvent(static_cast<MouseEvent*>(evt)); + if (evt->defaultHandled()) + return; + } + m_inputType->forwardEvent(evt); if (!callBaseClassEarly && !evt->defaultHandled()) @@ -1391,7 +1397,7 @@ void HTMLInputElement::stepUpFromRenderer(int n) if (m_inputType->isRangeControl()) dispatchFormControlChangeEvent(); else - dispatchEvent(Event::create(eventNames().inputEvent, true, false)); + dispatchFormControlInputEvent(); } } diff --git a/Source/WebCore/html/HTMLInputElement.h b/Source/WebCore/html/HTMLInputElement.h index eb30de0..403248c 100644 --- a/Source/WebCore/html/HTMLInputElement.h +++ b/Source/WebCore/html/HTMLInputElement.h @@ -211,6 +211,7 @@ private: virtual bool isKeyboardFocusable(KeyboardEvent*) const; virtual bool isMouseFocusable() const; virtual bool isEnumeratable() const; + virtual bool isResettable() const { return true; } virtual void updateFocusAppearance(bool restorePreviousSelection); virtual void aboutToUnload(); virtual bool shouldUseInputMethod() const; diff --git a/Source/WebCore/html/HTMLKeygenElement.h b/Source/WebCore/html/HTMLKeygenElement.h index 80f94b5..3dc4ad2 100644 --- a/Source/WebCore/html/HTMLKeygenElement.h +++ b/Source/WebCore/html/HTMLKeygenElement.h @@ -32,14 +32,16 @@ class HTMLKeygenElement : public HTMLSelectElement { public: static PassRefPtr<HTMLKeygenElement> create(const QualifiedName&, Document*, HTMLFormElement*); + virtual bool willValidate() const { return false; } + private: HTMLKeygenElement(const QualifiedName&, Document*, HTMLFormElement*); + virtual bool isResettable() const { return true; } + virtual const AtomicString& formControlType() const; virtual void parseMappedAttribute(Attribute*); virtual bool appendFormData(FormDataList&, bool); - - virtual bool willValidate() const { return false; } virtual bool isOptionalFormControl() const { return false; } AtomicString m_challenge; diff --git a/Source/WebCore/html/HTMLKeygenElement.idl b/Source/WebCore/html/HTMLKeygenElement.idl new file mode 100644 index 0000000..c34a925 --- /dev/null +++ b/Source/WebCore/html/HTMLKeygenElement.idl @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011 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. + */ + +module html { + + interface HTMLKeygenElement : HTMLElement { + attribute [Reflect] boolean autofocus; + attribute [Reflect] DOMString challenge; + attribute [Reflect] boolean disabled; + readonly attribute HTMLFormElement form; + attribute [Reflect] DOMString keytype; + attribute DOMString name; + + readonly attribute DOMString type; + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error); + + readonly attribute NodeList labels; + }; + +} diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index 43d53f5..be478b3 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -544,6 +544,7 @@ void HTMLMediaElement::prepareForLoad() refreshCachedTime(); m_paused = true; m_seeking = false; + invalidateCachedTime(); scheduleEvent(eventNames().emptiedEvent); } @@ -1001,6 +1002,7 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state) if (m_autoplaying && m_paused && autoplay()) { m_paused = false; + invalidateCachedTime(); scheduleEvent(eventNames().playEvent); scheduleEvent(eventNames().playingEvent); } @@ -1310,6 +1312,7 @@ void HTMLMediaElement::setPlaybackRate(float rate) if (m_playbackRate != rate) { m_playbackRate = rate; + invalidateCachedTime(); scheduleEvent(eventNames().ratechangeEvent); } if (m_player && potentiallyPlaying() && m_player->rate() != rate) @@ -1414,6 +1417,7 @@ void HTMLMediaElement::playInternal() if (m_paused) { m_paused = false; + invalidateCachedTime(); scheduleEvent(eventNames().playEvent); if (m_readyState <= HAVE_CURRENT_DATA) @@ -1901,6 +1905,7 @@ void HTMLMediaElement::mediaPlayerRateChanged(MediaPlayer*) // Stash the rate in case the one we tried to set isn't what the engine is // using (eg. it can't handle the rate we set) m_playbackRate = m_player->rate(); + invalidateCachedTime(); endProcessingMediaPlayerCallback(); } diff --git a/Source/WebCore/html/HTMLObjectElement.h b/Source/WebCore/html/HTMLObjectElement.h index ff773f1..cc8a03c 100644 --- a/Source/WebCore/html/HTMLObjectElement.h +++ b/Source/WebCore/html/HTMLObjectElement.h @@ -50,6 +50,7 @@ public: virtual bool isFormControlElement() const { return false; } virtual bool isEnumeratable() const { return true; } + virtual bool isResettable() const { return false; } virtual bool appendFormData(FormDataList&, bool); // Implementations of constraint validation API. diff --git a/Source/WebCore/html/HTMLOutputElement.h b/Source/WebCore/html/HTMLOutputElement.h index 83ecee2..4c5c684 100644 --- a/Source/WebCore/html/HTMLOutputElement.h +++ b/Source/WebCore/html/HTMLOutputElement.h @@ -56,6 +56,7 @@ private: virtual void parseMappedAttribute(Attribute*); virtual const AtomicString& formControlType() const; virtual bool isEnumeratable() const { return true; } + virtual bool isResettable() const { return true; } virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); virtual void reset(); diff --git a/Source/WebCore/html/HTMLParserQuirks.h b/Source/WebCore/html/HTMLParserQuirks.h index 50de710..3bf22a4 100644 --- a/Source/WebCore/html/HTMLParserQuirks.h +++ b/Source/WebCore/html/HTMLParserQuirks.h @@ -27,13 +27,13 @@ #define HTMLParserQuirks_h #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> namespace WebCore { class Node; -class HTMLParserQuirks : public Noncopyable { +class HTMLParserQuirks { + WTF_MAKE_NONCOPYABLE(HTMLParserQuirks); public: HTMLParserQuirks() { } virtual ~HTMLParserQuirks() { } diff --git a/Source/WebCore/html/HTMLSelectElement.h b/Source/WebCore/html/HTMLSelectElement.h index a22df02..42e8963 100644 --- a/Source/WebCore/html/HTMLSelectElement.h +++ b/Source/WebCore/html/HTMLSelectElement.h @@ -107,6 +107,7 @@ private: virtual bool canStartSelection() const { return false; } virtual bool isEnumeratable() const { return true; } + virtual bool isResettable() const { return true; } virtual bool saveFormControlState(String& value) const; virtual void restoreFormControlState(const String&); diff --git a/Source/WebCore/html/HTMLTagNames.in b/Source/WebCore/html/HTMLTagNames.in index 4153f5c..f5ff077 100644 --- a/Source/WebCore/html/HTMLTagNames.in +++ b/Source/WebCore/html/HTMLTagNames.in @@ -71,7 +71,7 @@ input constructorNeedsFormElement ins interfaceName=HTMLModElement isindex interfaceName=HTMLIsIndexElement, constructorNeedsFormElement kbd interfaceName=HTMLElement -keygen JSInterfaceName=HTMLSelectElement, constructorNeedsFormElement +keygen constructorNeedsFormElement label layer interfaceName=HTMLElement legend constructorNeedsFormElement diff --git a/Source/WebCore/html/HTMLTextAreaElement.h b/Source/WebCore/html/HTMLTextAreaElement.h index 669fcd8..21b5880 100644 --- a/Source/WebCore/html/HTMLTextAreaElement.h +++ b/Source/WebCore/html/HTMLTextAreaElement.h @@ -80,6 +80,7 @@ private: virtual void defaultEventHandler(Event*); virtual bool isEnumeratable() const { return true; } + virtual bool isResettable() const { return true; } virtual const AtomicString& formControlType() const; diff --git a/Source/WebCore/html/InputType.cpp b/Source/WebCore/html/InputType.cpp index 729f204..2f8d414 100644 --- a/Source/WebCore/html/InputType.cpp +++ b/Source/WebCore/html/InputType.cpp @@ -305,6 +305,10 @@ void InputType::handleClickEvent(MouseEvent*) { } +void InputType::handleMouseDownEvent(MouseEvent*) +{ +} + void InputType::handleDOMActivateEvent(Event*) { } diff --git a/Source/WebCore/html/InputType.h b/Source/WebCore/html/InputType.h index 0d1f6b8..e6ceb96 100644 --- a/Source/WebCore/html/InputType.h +++ b/Source/WebCore/html/InputType.h @@ -33,6 +33,7 @@ #define InputType_h #include <wtf/Forward.h> +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> @@ -56,17 +57,18 @@ class WheelEvent; typedef int ExceptionCode; struct ClickHandlingState { + WTF_MAKE_FAST_ALLOCATED; +public: bool checked; bool indeterminate; RefPtr<HTMLInputElement> checkedRadioButton; - - WTF_MAKE_FAST_ALLOCATED }; // An InputType object represents the type-specific part of an HTMLInputElement. // Do not expose instances of InputType and classes derived from it to classes // other than HTMLInputElement. -class InputType : public Noncopyable { +class InputType { + WTF_MAKE_NONCOPYABLE(InputType); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<InputType> create(HTMLInputElement*, const String&); static PassOwnPtr<InputType> createText(HTMLInputElement*); @@ -153,6 +155,7 @@ public: // Event handlers virtual void handleClickEvent(MouseEvent*); + virtual void handleMouseDownEvent(MouseEvent*); virtual PassOwnPtr<ClickHandlingState> willDispatchClick(); virtual void didDispatchClick(Event*, const ClickHandlingState&); virtual void handleDOMActivateEvent(Event*); diff --git a/Source/WebCore/html/RangeInputType.cpp b/Source/WebCore/html/RangeInputType.cpp index 7d0a38c..e9ac295 100644 --- a/Source/WebCore/html/RangeInputType.cpp +++ b/Source/WebCore/html/RangeInputType.cpp @@ -36,6 +36,8 @@ #include "HTMLNames.h" #include "HTMLParserIdioms.h" #include "KeyboardEvent.h" +#include "MouseEvent.h" +#include "PlatformMouseEvent.h" #include "RenderSlider.h" #include "SliderThumbElement.h" #include "StepRange.h" @@ -141,6 +143,15 @@ double RangeInputType::stepScaleFactor() const return rangeStepScaleFactor; } +void RangeInputType::handleMouseDownEvent(MouseEvent* event) +{ + if (event->button() != LeftButton || event->target() != element()) + return; + + if (SliderThumbElement* thumb = toSliderThumbElement(element()->shadowRoot())) + thumb->dragFrom(event->absoluteLocation()); +} + void RangeInputType::handleKeydownEvent(KeyboardEvent* event) { const String& key = event->keyIdentifier(); @@ -181,6 +192,7 @@ void RangeInputType::handleKeydownEvent(KeyboardEvent* event) event->setDefaultHandled(); } +<<<<<<< HEAD void RangeInputType::forwardEvent(Event* event) { if (element()->renderer() @@ -193,6 +205,8 @@ void RangeInputType::forwardEvent(Event* event) toRenderSlider(element()->renderer())->forwardEvent(event); } +======= +>>>>>>> WebKit.org at r76408 void RangeInputType::createShadowSubtree() { element()->setShadowRoot(SliderThumbElement::create(element()->document())); diff --git a/Source/WebCore/html/RangeInputType.h b/Source/WebCore/html/RangeInputType.h index 57eb299..15d224d 100644 --- a/Source/WebCore/html/RangeInputType.h +++ b/Source/WebCore/html/RangeInputType.h @@ -55,8 +55,8 @@ private: virtual double stepBase() const; virtual double defaultStep() const; virtual double stepScaleFactor() const; + virtual void handleMouseDownEvent(MouseEvent*); virtual void handleKeydownEvent(KeyboardEvent*); - virtual void forwardEvent(Event*); virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; virtual void createShadowSubtree(); virtual double parseToDouble(const String&, double) const; diff --git a/Source/WebCore/html/StepRange.h b/Source/WebCore/html/StepRange.h index ce044ea..2fa1393 100644 --- a/Source/WebCore/html/StepRange.h +++ b/Source/WebCore/html/StepRange.h @@ -28,7 +28,8 @@ namespace WebCore { class HTMLInputElement; -class StepRange : public Noncopyable { +class StepRange { + WTF_MAKE_NONCOPYABLE(StepRange); public: bool hasStep; double step; diff --git a/Source/WebCore/html/ValidationMessage.h b/Source/WebCore/html/ValidationMessage.h index 5fa1f96..7cd0cbb 100644 --- a/Source/WebCore/html/ValidationMessage.h +++ b/Source/WebCore/html/ValidationMessage.h @@ -42,7 +42,8 @@ namespace WebCore { class FormAssociatedElement; class HTMLElement; -class ValidationMessage : public Noncopyable { +class ValidationMessage { + WTF_MAKE_NONCOPYABLE(ValidationMessage); public: static PassOwnPtr<ValidationMessage> create(FormAssociatedElement*); ~ValidationMessage(); diff --git a/Source/WebCore/html/ValidityState.h b/Source/WebCore/html/ValidityState.h index e140c49..4a96488 100644 --- a/Source/WebCore/html/ValidityState.h +++ b/Source/WebCore/html/ValidityState.h @@ -29,7 +29,8 @@ namespace WebCore { -class ValidityState : public Noncopyable { +class ValidityState { + WTF_MAKE_NONCOPYABLE(ValidityState); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<ValidityState> create(FormAssociatedElement* control) { diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext.h b/Source/WebCore/html/canvas/CanvasRenderingContext.h index a25e8a1..a143596 100644 --- a/Source/WebCore/html/canvas/CanvasRenderingContext.h +++ b/Source/WebCore/html/canvas/CanvasRenderingContext.h @@ -41,7 +41,8 @@ class HTMLVideoElement; class KURL; class WebGLObject; -class CanvasRenderingContext : public Noncopyable { +class CanvasRenderingContext { + WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); WTF_MAKE_FAST_ALLOCATED; public: CanvasRenderingContext(HTMLCanvasElement*); virtual ~CanvasRenderingContext() { } diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 62c5793..e029128 100644 --- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -57,6 +57,7 @@ #include "Settings.h" #include "StrokeStyleApplier.h" #include "TextMetrics.h" +#include "TextRun.h" #if ENABLE(ACCELERATED_2D_CANVAS) #include "Chrome.h" @@ -170,7 +171,7 @@ void CanvasRenderingContext2D::reset() m_path.clear(); #if ENABLE(ACCELERATED_2D_CANVAS) if (GraphicsContext* c = drawingContext()) { - if (m_context3D) { + if (m_context3D && m_drawingBuffer) { m_drawingBuffer->reset(IntSize(canvas()->width(), canvas()->height())); c->setSharedGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), IntSize(canvas()->width(), canvas()->height())); } @@ -537,7 +538,7 @@ void CanvasRenderingContext2D::transform(float m11, float m12, float m21, float return; AffineTransform transform(m11, m12, m21, m22, dx, dy); - AffineTransform newTransform = transform * state().m_transform; + AffineTransform newTransform = state().m_transform * transform; if (!newTransform.isInvertible()) { state().m_invertibleCTM = false; return; @@ -562,7 +563,7 @@ void CanvasRenderingContext2D::setTransform(float m11, float m12, float m21, flo return; c->concatCTM(c->getCTM().inverse()); c->concatCTM(canvas()->baseTransform()); - state().m_transform.multiply(ctm.inverse()); + state().m_transform = ctm.inverse() * state().m_transform; m_path.transform(ctm); state().m_invertibleCTM = true; @@ -1895,7 +1896,7 @@ void CanvasRenderingContext2D::paintRenderingResultsToCanvas() #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING) PlatformLayer* CanvasRenderingContext2D::platformLayer() const { - return m_drawingBuffer->platformLayer(); + return m_drawingBuffer ? m_drawingBuffer->platformLayer() : 0; } #endif diff --git a/Source/WebCore/html/canvas/CheckedInt.h b/Source/WebCore/html/canvas/CheckedInt.h index 861e8e6..b83ac19 100644 --- a/Source/WebCore/html/canvas/CheckedInt.h +++ b/Source/WebCore/html/canvas/CheckedInt.h @@ -60,29 +60,93 @@ namespace CheckedInt_internal { struct unsupported_type {}; -template<typename T> struct integer_type_manually_recorded_info -{ - enum { is_supported = 0 }; - typedef unsupported_type twice_bigger_type; -}; +template<typename T> struct integer_type_manually_recorded_info; -#define CHECKEDINT_REGISTER_SUPPORTED_TYPE(T,_twice_bigger_type) \ +#define CHECKEDINT_REGISTER_SUPPORTED_TYPE(T,_twice_bigger_type,_unsigned_type) \ template<> struct integer_type_manually_recorded_info<T> \ { \ enum { is_supported = 1 }; \ typedef _twice_bigger_type twice_bigger_type; \ - static void TYPE_NOT_SUPPORTED_BY_CheckedInt() {} \ + typedef _unsigned_type unsigned_type; \ }; -CHECKEDINT_REGISTER_SUPPORTED_TYPE(int8_t, int16_t) -CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint8_t, uint16_t) -CHECKEDINT_REGISTER_SUPPORTED_TYPE(int16_t, int32_t) -CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint16_t, uint32_t) -CHECKEDINT_REGISTER_SUPPORTED_TYPE(int32_t, int64_t) -CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint32_t, uint64_t) -CHECKEDINT_REGISTER_SUPPORTED_TYPE(int64_t, unsupported_type) -CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint64_t, unsupported_type) +// Type Twice Bigger Type Unsigned Type +CHECKEDINT_REGISTER_SUPPORTED_TYPE(int8_t, int16_t, uint8_t) +CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint8_t, uint16_t, uint8_t) +CHECKEDINT_REGISTER_SUPPORTED_TYPE(int16_t, int32_t, uint16_t) +CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint16_t, uint32_t, uint16_t) +CHECKEDINT_REGISTER_SUPPORTED_TYPE(int32_t, int64_t, uint32_t) +CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint32_t, uint64_t, uint32_t) +CHECKEDINT_REGISTER_SUPPORTED_TYPE(int64_t, unsupported_type, uint64_t) +CHECKEDINT_REGISTER_SUPPORTED_TYPE(uint64_t, unsupported_type, uint64_t) + +// now implement the fallback for standard types like int, long, ... +// the difficulty is that they may or may not be equal to one of the above types, and/or +// to each other. This is why any attempt to handle at once PRInt8... types and standard types +// is bound to fail. +template<typename T> +struct is_standard_integer_type { enum { value = 0 }; }; + +template<> +struct is_standard_integer_type<char> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<unsigned char> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<short> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<unsigned short> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<int> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<unsigned int> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<long> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<unsigned long> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<long long> { enum { value = 1 }; }; +template<> +struct is_standard_integer_type<unsigned long long> { enum { value = 1 }; }; + +template<int size, bool is_signed> +struct explicitly_sized_integer_type {}; + +template<> +struct explicitly_sized_integer_type<1, true> { typedef int8_t type; }; +template<> +struct explicitly_sized_integer_type<1, false> { typedef uint8_t type; }; +template<> +struct explicitly_sized_integer_type<2, true> { typedef int16_t type; }; +template<> +struct explicitly_sized_integer_type<2, false> { typedef uint16_t type; }; +template<> +struct explicitly_sized_integer_type<4, true> { typedef int32_t type; }; +template<> +struct explicitly_sized_integer_type<4, false> { typedef uint32_t type; }; +template<> +struct explicitly_sized_integer_type<8, true> { typedef int64_t type; }; +template<> +struct explicitly_sized_integer_type<8, false> { typedef uint64_t type; }; + +template<typename T> struct integer_type_manually_recorded_info +{ + enum { + is_supported = is_standard_integer_type<T>::value, + size = sizeof(T), + is_signed = (T(-1) > T(0)) ? 0 : 1 + }; + typedef typename explicitly_sized_integer_type<size, is_signed>::type explicit_sized_type; + typedef integer_type_manually_recorded_info<explicit_sized_type> base; + typedef typename base::twice_bigger_type twice_bigger_type; + typedef typename base::unsigned_type unsigned_type; +}; + +template<typename T, bool is_supported = integer_type_manually_recorded_info<T>::is_supported> +struct TYPE_NOT_SUPPORTED_BY_CheckedInt {}; + +template<typename T> +struct TYPE_NOT_SUPPORTED_BY_CheckedInt<T, true> { static void run() {} }; /*** Step 2: record some info about a given integer type, @@ -348,8 +412,7 @@ protected: template<typename U> CheckedInt(const U& value, bool isValid) : mValue(value), mIsValid(isValid) { - CheckedInt_internal::integer_type_manually_recorded_info<T> - ::TYPE_NOT_SUPPORTED_BY_CheckedInt(); + CheckedInt_internal::TYPE_NOT_SUPPORTED_BY_CheckedInt<T>::run(); } public: @@ -366,15 +429,13 @@ public: : mValue(value), mIsValid(CheckedInt_internal::is_in_range<T>(value)) { - CheckedInt_internal::integer_type_manually_recorded_info<T> - ::TYPE_NOT_SUPPORTED_BY_CheckedInt(); + CheckedInt_internal::TYPE_NOT_SUPPORTED_BY_CheckedInt<T>::run(); } /** Constructs a valid checked integer with uninitialized value */ CheckedInt() : mIsValid(1) { - CheckedInt_internal::integer_type_manually_recorded_info<T> - ::TYPE_NOT_SUPPORTED_BY_CheckedInt(); + CheckedInt_internal::TYPE_NOT_SUPPORTED_BY_CheckedInt<T>::run(); } /** \returns the actual value */ diff --git a/Source/WebCore/html/canvas/OESStandardDerivatives.cpp b/Source/WebCore/html/canvas/OESStandardDerivatives.cpp new file mode 100644 index 0000000..25aae2f --- /dev/null +++ b/Source/WebCore/html/canvas/OESStandardDerivatives.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011 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 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" + +#if ENABLE(3D_CANVAS) + +#include "OESStandardDerivatives.h" + +namespace WebCore { + +OESStandardDerivatives::OESStandardDerivatives() : WebGLExtension() +{ +} + +OESStandardDerivatives::~OESStandardDerivatives() +{ +} + +WebGLExtension::ExtensionName OESStandardDerivatives::getName() const +{ + return OESStandardDerivativesName; +} + +PassRefPtr<OESStandardDerivatives> OESStandardDerivatives::create() +{ + return adoptRef(new OESStandardDerivatives); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/Source/WebCore/html/canvas/OESStandardDerivatives.h b/Source/WebCore/html/canvas/OESStandardDerivatives.h new file mode 100644 index 0000000..c74e24f --- /dev/null +++ b/Source/WebCore/html/canvas/OESStandardDerivatives.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011 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 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. + */ + +#ifndef OESStandardDerivatives_h +#define OESStandardDerivatives_h + +#include "WebGLExtension.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class OESStandardDerivatives : public WebGLExtension { +public: + static PassRefPtr<OESStandardDerivatives> create(); + + virtual ~OESStandardDerivatives(); + virtual ExtensionName getName() const; + +private: + OESStandardDerivatives(); +}; + +} // namespace WebCore + +#endif // OESStandardDerivatives_h diff --git a/Source/WebCore/html/canvas/OESStandardDerivatives.idl b/Source/WebCore/html/canvas/OESStandardDerivatives.idl new file mode 100644 index 0000000..a9d1dd6 --- /dev/null +++ b/Source/WebCore/html/canvas/OESStandardDerivatives.idl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2011 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 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. + */ + +module html { + interface [Conditional=3D_CANVAS, OmitConstructor, DontCheckEnums] OESStandardDerivatives { + const unsigned int FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B; + }; +} diff --git a/Source/WebCore/html/canvas/TypedArrayBase.h b/Source/WebCore/html/canvas/TypedArrayBase.h index 2bef6f0..a828620 100644 --- a/Source/WebCore/html/canvas/TypedArrayBase.h +++ b/Source/WebCore/html/canvas/TypedArrayBase.h @@ -60,7 +60,12 @@ class TypedArrayBase : public ArrayBufferView { return m_length; } - protected: + virtual unsigned byteLength() const + { + return m_length * sizeof(T); + } + +protected: TypedArrayBase(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length) : ArrayBufferView(buffer, byteOffset) , m_length(length) @@ -110,13 +115,6 @@ class TypedArrayBase : public ArrayBufferView { // We do not want to have to access this via a virtual function in subclasses, // which is why it is protected rather than private. unsigned m_length; - - private: - // Overridden from ArrayBufferView. - virtual unsigned byteLength() const - { - return m_length * sizeof(T); - } }; } // namespace WebCore diff --git a/Source/WebCore/html/canvas/WebGLBuffer.cpp b/Source/WebCore/html/canvas/WebGLBuffer.cpp index 4566bfa..849472b 100644 --- a/Source/WebCore/html/canvas/WebGLBuffer.cpp +++ b/Source/WebCore/html/canvas/WebGLBuffer.cpp @@ -61,9 +61,9 @@ bool WebGLBuffer::associateBufferDataImpl(ArrayBuffer* array, GC3Dintptr byteOff return false; if (array && byteLength) { - CheckedInt<int32_t> checkedOffset(byteOffset); - CheckedInt<int32_t> checkedLength(byteLength); - CheckedInt<int32_t> checkedMax = checkedOffset + checkedLength; + CheckedInt<GC3Dintptr> checkedOffset(byteOffset); + CheckedInt<GC3Dsizeiptr> checkedLength(byteLength); + CheckedInt<GC3Dintptr> checkedMax = checkedOffset + checkedLength; if (!checkedMax.valid() || checkedMax.value() > static_cast<int32_t>(array->byteLength())) return false; } @@ -124,11 +124,11 @@ bool WebGLBuffer::associateBufferSubDataImpl(GC3Dintptr offset, ArrayBuffer* arr return false; if (byteLength) { - CheckedInt<int32_t> checkedBufferOffset(offset); - CheckedInt<int32_t> checkedArrayOffset(arrayByteOffset); - CheckedInt<int32_t> checkedLength(byteLength); - CheckedInt<int32_t> checkedArrayMax = checkedArrayOffset + checkedLength; - CheckedInt<int32_t> checkedBufferMax = checkedBufferOffset + checkedLength; + CheckedInt<GC3Dintptr> checkedBufferOffset(offset); + CheckedInt<GC3Dintptr> checkedArrayOffset(arrayByteOffset); + CheckedInt<GC3Dsizeiptr> checkedLength(byteLength); + CheckedInt<GC3Dintptr> checkedArrayMax = checkedArrayOffset + checkedLength; + CheckedInt<GC3Dintptr> checkedBufferMax = checkedBufferOffset + checkedLength; if (!checkedArrayMax.valid() || checkedArrayMax.value() > static_cast<int32_t>(array->byteLength()) || !checkedBufferMax.valid() || checkedBufferMax.value() > m_byteLength) return false; } diff --git a/Source/WebCore/html/canvas/WebGLExtension.h b/Source/WebCore/html/canvas/WebGLExtension.h index f2d6b7b..d135c18 100644 --- a/Source/WebCore/html/canvas/WebGLExtension.h +++ b/Source/WebCore/html/canvas/WebGLExtension.h @@ -36,6 +36,7 @@ public: enum ExtensionName { WebKitLoseContextName, OESTextureFloatName, + OESStandardDerivativesName, }; virtual ~WebGLExtension(); diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp index c445e2b..a3b9699 100644 --- a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp +++ b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp @@ -44,6 +44,7 @@ #include "ImageData.h" #include "IntSize.h" #include "NotImplemented.h" +#include "OESStandardDerivatives.h" #include "OESTextureFloat.h" #include "RenderBox.h" #include "RenderLayer.h" @@ -62,6 +63,7 @@ #include <wtf/ByteArray.h> #include <wtf/OwnArrayPtr.h> #include <wtf/PassOwnArrayPtr.h> +#include <wtf/text/StringBuilder.h> namespace WebCore { @@ -101,12 +103,11 @@ namespace { // Return true if a character belongs to the ASCII subset as defined in // GLSL ES 1.0 spec section 3.1. - // We make exceptions for " ' `. bool validateCharacter(unsigned char c) { // Printing characters are valid except " $ ` @ \ ' DEL. if (c >= 32 && c <= 126 - && c != '$' && c != '@' && c != '\\') + && c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && c != '\'') return true; // Horizontal tab, line feed, vertical tab, form feed, carriage return // are also valid. @@ -115,6 +116,189 @@ namespace { return false; } + // Strips comments from shader text. This allows non-ASCII characters + // to be used in comments without potentially breaking OpenGL + // implementations not expecting characters outside the GLSL ES set. + class StripComments { + public: + StripComments(const String& str) + : m_parseState(BeginningOfLine) + , m_sourceString(str) + , m_length(str.length()) + , m_position(0) + { + parse(); + } + + String result() + { + return m_builder.toString(); + } + + private: + bool hasMoreCharacters() + { + return (m_position < m_length); + } + + void parse() + { + while (hasMoreCharacters()) { + process(current()); + // process() might advance the position. + if (hasMoreCharacters()) + advance(); + } + } + + void process(UChar); + + bool peek(UChar& character) + { + if (m_position + 1 >= m_length) + return false; + character = m_sourceString[m_position + 1]; + return true; + } + + UChar current() + { + ASSERT(m_position < m_length); + return m_sourceString[m_position]; + } + + void advance() + { + ++m_position; + } + + bool isNewline(UChar character) + { + // Don't attempt to canonicalize newline related characters. + return (character == '\n' || character == '\r'); + } + + void emit(UChar character) + { + m_builder.append(character); + } + + enum ParseState { + // Have not seen an ASCII non-whitespace character yet on + // this line. Possible that we might see a preprocessor + // directive. + BeginningOfLine, + + // Have seen at least one ASCII non-whitespace character + // on this line. + MiddleOfLine, + + // Handling a preprocessor directive. Passes through all + // characters up to the end of the line. Disables comment + // processing. + InPreprocessorDirective, + + // Handling a single-line comment. The comment text is + // replaced with a single space. + InSingleLineComment, + + // Handling a multi-line comment. Newlines are passed + // through to preserve line numbers. + InMultiLineComment + }; + + ParseState m_parseState; + String m_sourceString; + unsigned m_length; + unsigned m_position; + StringBuilder m_builder; + }; + + void StripComments::process(UChar c) + { + if (isNewline(c)) { + // No matter what state we are in, pass through newlines + // so we preserve line numbers. + emit(c); + + if (m_parseState != InMultiLineComment) + m_parseState = BeginningOfLine; + + return; + } + + UChar temp = 0; + switch (m_parseState) { + case BeginningOfLine: + if (WTF::isASCIISpace(c)) { + emit(c); + break; + } + + if (c == '#') { + m_parseState = InPreprocessorDirective; + emit(c); + break; + } + + // Transition to normal state and re-handle character. + m_parseState = MiddleOfLine; + process(c); + break; + + case MiddleOfLine: + if (c == '/' && peek(temp)) { + if (temp == '/') { + m_parseState = InSingleLineComment; + emit(' '); + advance(); + break; + } + + if (temp == '*') { + m_parseState = InMultiLineComment; + // Emit the comment start in case the user has + // an unclosed comment and we want to later + // signal an error. + emit('/'); + emit('*'); + advance(); + break; + } + } + + emit(c); + break; + + case InPreprocessorDirective: + // No matter what the character is, just pass it + // through. Do not parse comments in this state. This + // might not be the right thing to do long term, but it + // should handle the #error preprocessor directive. + emit(c); + break; + + case InSingleLineComment: + // The newline code at the top of this function takes care + // of resetting our state when we get out of the + // single-line comment. Swallow all other characters. + break; + + case InMultiLineComment: + if (c == '*' && peek(temp) && temp == '/') { + emit('*'); + emit('/'); + m_parseState = MiddleOfLine; + advance(); + break; + } + + // Swallow all other characters. Unclear whether we may + // want or need to just emit a space per character to try + // to preserve column numbers for debugging purposes. + break; + } + } } // namespace anonymous class WebGLStateRestorer { @@ -1574,6 +1758,14 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name) if (isContextLost()) return 0; + if (equalIgnoringCase(name, "OES_standard_derivatives") + && m_context->getExtensions()->supports("GL_OES_standard_derivatives")) { + if (!m_oesStandardDerivatives) { + m_context->getExtensions()->ensureEnabled("GL_OES_standard_derivatives"); + m_oesStandardDerivatives = OESStandardDerivatives::create(); + } + return m_oesStandardDerivatives.get(); + } if (equalIgnoringCase(name, "OES_texture_float") && m_context->getExtensions()->supports("GL_OES_texture_float")) { if (!m_oesTextureFloat) { @@ -1581,7 +1773,8 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name) m_oesTextureFloat = OESTextureFloat::create(); } return m_oesTextureFloat.get(); - } else if (equalIgnoringCase(name, "WEBKIT_lose_context")) { + } + if (equalIgnoringCase(name, "WEBKIT_lose_context")) { if (!m_webkitLoseContext) m_webkitLoseContext = WebKitLoseContext::create(this); return m_webkitLoseContext.get(); @@ -1823,6 +2016,11 @@ WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode& return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GraphicsContext3D::VERSION) + ")"); case GraphicsContext3D::VIEWPORT: return getWebGLIntArrayParameter(pname); + case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives + if (m_oesStandardDerivatives) + return getUnsignedLongParameter(Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES); + m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); + return WebGLGetInfo(); default: m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); return WebGLGetInfo(); @@ -1990,6 +2188,8 @@ Vector<String> WebGLRenderingContext::getSupportedExtensions() Vector<String> result; if (m_context->getExtensions()->supports("GL_OES_texture_float")) result.append("OES_texture_float"); + if (m_context->getExtensions()->supports("GL_OES_standard_derivatives")) + result.append("OES_standard_derivatives"); result.append("WEBKIT_lose_context"); return result; } @@ -2234,7 +2434,17 @@ void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode) { if (isContextLost()) return; - if (target != GraphicsContext3D::GENERATE_MIPMAP_HINT) { + bool isValid = false; + switch (target) { + case GraphicsContext3D::GENERATE_MIPMAP_HINT: + isValid = true; + break; + case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives + if (m_oesStandardDerivatives) + isValid = true; + break; + } + if (!isValid) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); return; } @@ -2547,9 +2757,10 @@ void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri UNUSED_PARAM(ec); if (isContextLost() || !validateWebGLObject(shader)) return; - if (!validateString(string)) + String stringWithoutComments = StripComments(string).result(); + if (!validateString(stringWithoutComments)) return; - m_context->shaderSource(objectOrZero(shader), string); + m_context->shaderSource(objectOrZero(shader), stringWithoutComments); cleanupAfterGraphicsCall(false); } @@ -4352,11 +4563,16 @@ void WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation() int WebGLRenderingContext::getNumberOfExtensions() { - return (m_webkitLoseContext ? 1 : 0) + (m_oesTextureFloat ? 1 : 0); + return (m_oesStandardDerivatives ? 1 : 0) + (m_webkitLoseContext ? 1 : 0) + (m_oesTextureFloat ? 1 : 0); } WebGLExtension* WebGLRenderingContext::getExtensionNumber(int i) { + if (m_oesStandardDerivatives) { + if (!i) + return m_oesStandardDerivatives.get(); + --i; + } if (m_webkitLoseContext) { if (!i) return m_webkitLoseContext.get(); diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.h b/Source/WebCore/html/canvas/WebGLRenderingContext.h index d9b738c..01b5438 100644 --- a/Source/WebCore/html/canvas/WebGLRenderingContext.h +++ b/Source/WebCore/html/canvas/WebGLRenderingContext.h @@ -57,6 +57,7 @@ class HTMLVideoElement; class ImageBuffer; class ImageData; class IntSize; +class OESStandardDerivatives; class OESTextureFloat; class WebGLRenderingContext : public CanvasRenderingContext { @@ -452,6 +453,7 @@ public: // Enabled extension objects. RefPtr<OESTextureFloat> m_oesTextureFloat; + RefPtr<OESStandardDerivatives> m_oesStandardDerivatives; RefPtr<WebKitLoseContext> m_webkitLoseContext; // Helpers for getParameter and others diff --git a/Source/WebCore/html/parser/CSSPreloadScanner.h b/Source/WebCore/html/parser/CSSPreloadScanner.h index 7ac282f..fae95a1 100644 --- a/Source/WebCore/html/parser/CSSPreloadScanner.h +++ b/Source/WebCore/html/parser/CSSPreloadScanner.h @@ -35,7 +35,8 @@ namespace WebCore { class Document; class HTMLToken; -class CSSPreloadScanner : public Noncopyable { +class CSSPreloadScanner { + WTF_MAKE_NONCOPYABLE(CSSPreloadScanner); public: CSSPreloadScanner(Document*); diff --git a/Source/WebCore/html/parser/HTMLConstructionSite.h b/Source/WebCore/html/parser/HTMLConstructionSite.h index 8b09bf5..5a4a65d 100644 --- a/Source/WebCore/html/parser/HTMLConstructionSite.h +++ b/Source/WebCore/html/parser/HTMLConstructionSite.h @@ -40,7 +40,8 @@ class AtomicHTMLToken; class Document; class Element; -class HTMLConstructionSite : public Noncopyable { +class HTMLConstructionSite { + WTF_MAKE_NONCOPYABLE(HTMLConstructionSite); public: HTMLConstructionSite(Document*, FragmentScriptingPermission, bool isParsingFragment); ~HTMLConstructionSite(); @@ -89,7 +90,8 @@ public: HTMLFormElement* form() const { return m_form.get(); } PassRefPtr<HTMLFormElement> takeForm(); - class RedirectToFosterParentGuard : public Noncopyable { + class RedirectToFosterParentGuard { + WTF_MAKE_NONCOPYABLE(RedirectToFosterParentGuard); public: RedirectToFosterParentGuard(HTMLConstructionSite& tree) : m_tree(tree) diff --git a/Source/WebCore/html/parser/HTMLDocumentParser.h b/Source/WebCore/html/parser/HTMLDocumentParser.h index 80ca727..f925269 100644 --- a/Source/WebCore/html/parser/HTMLDocumentParser.h +++ b/Source/WebCore/html/parser/HTMLDocumentParser.h @@ -50,6 +50,7 @@ class ScriptController; class ScriptSourceCode; class HTMLDocumentParser : public ScriptableDocumentParser, HTMLScriptRunnerHost, CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<HTMLDocumentParser> create(HTMLDocument* document, bool reportErrors) { diff --git a/Source/WebCore/html/parser/HTMLElementStack.h b/Source/WebCore/html/parser/HTMLElementStack.h index 8a8e160..ad8b941 100644 --- a/Source/WebCore/html/parser/HTMLElementStack.h +++ b/Source/WebCore/html/parser/HTMLElementStack.h @@ -39,12 +39,14 @@ class QualifiedName; // NOTE: The HTML5 spec uses a backwards (grows downward) stack. We're using // more standard (grows upwards) stack terminology here. -class HTMLElementStack : public Noncopyable { +class HTMLElementStack { + WTF_MAKE_NONCOPYABLE(HTMLElementStack); WTF_MAKE_FAST_ALLOCATED; public: HTMLElementStack(); ~HTMLElementStack(); - class ElementRecord : public Noncopyable { + class ElementRecord { + WTF_MAKE_NONCOPYABLE(ElementRecord); public: ~ElementRecord(); // Public for ~PassOwnPtr() diff --git a/Source/WebCore/html/parser/HTMLFormattingElementList.h b/Source/WebCore/html/parser/HTMLFormattingElementList.h index aca05bb..f75fa50 100644 --- a/Source/WebCore/html/parser/HTMLFormattingElementList.h +++ b/Source/WebCore/html/parser/HTMLFormattingElementList.h @@ -35,7 +35,8 @@ namespace WebCore { class Element; // This may end up merged into HTMLElementStack. -class HTMLFormattingElementList : public Noncopyable { +class HTMLFormattingElementList { + WTF_MAKE_NONCOPYABLE(HTMLFormattingElementList); public: HTMLFormattingElementList(); ~HTMLFormattingElementList(); diff --git a/Source/WebCore/html/parser/HTMLInputStream.h b/Source/WebCore/html/parser/HTMLInputStream.h index 1bfbaf9..d95ec31 100644 --- a/Source/WebCore/html/parser/HTMLInputStream.h +++ b/Source/WebCore/html/parser/HTMLInputStream.h @@ -47,7 +47,8 @@ namespace WebCore { // m_last is a pointer to the last of the afterInsertionPoint strings. // The network adds data at the end of the InputStream, which appends // them to the "last" string. -class HTMLInputStream : public Noncopyable { +class HTMLInputStream { + WTF_MAKE_NONCOPYABLE(HTMLInputStream); public: HTMLInputStream() : m_last(&m_first) @@ -129,7 +130,8 @@ private: SegmentedString* m_last; }; -class InsertionPointRecord : public Noncopyable { +class InsertionPointRecord { + WTF_MAKE_NONCOPYABLE(InsertionPointRecord); public: explicit InsertionPointRecord(HTMLInputStream& inputStream) : m_inputStream(&inputStream) diff --git a/Source/WebCore/html/parser/HTMLMetaCharsetParser.h b/Source/WebCore/html/parser/HTMLMetaCharsetParser.h index c3136f5..45fbaf7 100644 --- a/Source/WebCore/html/parser/HTMLMetaCharsetParser.h +++ b/Source/WebCore/html/parser/HTMLMetaCharsetParser.h @@ -36,7 +36,8 @@ namespace WebCore { class HTMLTokenizer; class TextCodec; -class HTMLMetaCharsetParser : public Noncopyable { +class HTMLMetaCharsetParser { + WTF_MAKE_NONCOPYABLE(HTMLMetaCharsetParser); public: static PassOwnPtr<HTMLMetaCharsetParser> create() { return adoptPtr(new HTMLMetaCharsetParser()); } diff --git a/Source/WebCore/html/parser/HTMLParserScheduler.h b/Source/WebCore/html/parser/HTMLParserScheduler.h index 3a20b2b..c415c62 100644 --- a/Source/WebCore/html/parser/HTMLParserScheduler.h +++ b/Source/WebCore/html/parser/HTMLParserScheduler.h @@ -28,14 +28,14 @@ #include "Timer.h" #include <wtf/CurrentTime.h> -#include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> namespace WebCore { class HTMLDocumentParser; -class HTMLParserScheduler : public Noncopyable { +class HTMLParserScheduler { + WTF_MAKE_NONCOPYABLE(HTMLParserScheduler); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<HTMLParserScheduler> create(HTMLDocumentParser* parser) { diff --git a/Source/WebCore/html/parser/HTMLPreloadScanner.h b/Source/WebCore/html/parser/HTMLPreloadScanner.h index 94a90e6..bed77fe 100644 --- a/Source/WebCore/html/parser/HTMLPreloadScanner.h +++ b/Source/WebCore/html/parser/HTMLPreloadScanner.h @@ -30,7 +30,6 @@ #include "CSSPreloadScanner.h" #include "HTMLToken.h" #include "SegmentedString.h" -#include <wtf/Noncopyable.h> namespace WebCore { @@ -39,7 +38,8 @@ class HTMLToken; class HTMLTokenizer; class SegmentedString; -class HTMLPreloadScanner : public Noncopyable { +class HTMLPreloadScanner { + WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); WTF_MAKE_FAST_ALLOCATED; public: HTMLPreloadScanner(Document*); diff --git a/Source/WebCore/html/parser/HTMLScriptRunner.h b/Source/WebCore/html/parser/HTMLScriptRunner.h index 6cf74d8..986f7bd 100644 --- a/Source/WebCore/html/parser/HTMLScriptRunner.h +++ b/Source/WebCore/html/parser/HTMLScriptRunner.h @@ -29,7 +29,6 @@ #include "PendingScript.h" #include <wtf/Deque.h> #include <wtf/text/TextPosition.h> -#include <wtf/Noncopyable.h> #include <wtf/PassRefPtr.h> namespace WebCore { @@ -42,7 +41,8 @@ class Frame; class HTMLScriptRunnerHost; class ScriptSourceCode; -class HTMLScriptRunner : public Noncopyable { +class HTMLScriptRunner { + WTF_MAKE_NONCOPYABLE(HTMLScriptRunner); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<HTMLScriptRunner> create(Document* document, HTMLScriptRunnerHost* host) { diff --git a/Source/WebCore/html/parser/HTMLToken.h b/Source/WebCore/html/parser/HTMLToken.h index 42cddb8..1cbc151 100644 --- a/Source/WebCore/html/parser/HTMLToken.h +++ b/Source/WebCore/html/parser/HTMLToken.h @@ -27,13 +27,13 @@ #define HTMLToken_h #include "NamedNodeMap.h" -#include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> namespace WebCore { -class HTMLToken : public Noncopyable { +class HTMLToken { + WTF_MAKE_NONCOPYABLE(HTMLToken); WTF_MAKE_FAST_ALLOCATED; public: enum Type { Uninitialized, @@ -313,7 +313,8 @@ private: // want to end up with a cleaner interface between the two classes. friend class AtomicHTMLToken; - class DoctypeData : public Noncopyable { + class DoctypeData { + WTF_MAKE_NONCOPYABLE(DoctypeData); public: DoctypeData() : m_hasPublicIdentifier(false) @@ -352,7 +353,8 @@ private: // FIXME: This class should eventually be named HTMLToken once we move the // exiting HTMLToken to be internal to the HTMLTokenizer. -class AtomicHTMLToken : public Noncopyable { +class AtomicHTMLToken { + WTF_MAKE_NONCOPYABLE(AtomicHTMLToken); public: AtomicHTMLToken(HTMLToken& token) : m_type(token.type()) diff --git a/Source/WebCore/html/parser/HTMLTokenizer.h b/Source/WebCore/html/parser/HTMLTokenizer.h index f16b049..fa45cb2 100644 --- a/Source/WebCore/html/parser/HTMLTokenizer.h +++ b/Source/WebCore/html/parser/HTMLTokenizer.h @@ -39,7 +39,8 @@ class Element; class Frame; class HTMLToken; -class HTMLTokenizer : public Noncopyable { +class HTMLTokenizer { + WTF_MAKE_NONCOPYABLE(HTMLTokenizer); WTF_MAKE_FAST_ALLOCATED; public: enum State { DataState, @@ -172,7 +173,8 @@ public: private: // http://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-stream - class InputStreamPreprocessor : public Noncopyable { + class InputStreamPreprocessor { + WTF_MAKE_NONCOPYABLE(InputStreamPreprocessor); public: InputStreamPreprocessor(HTMLTokenizer* tokenizer) : m_tokenizer(tokenizer) diff --git a/Source/WebCore/html/parser/HTMLTreeBuilder.cpp b/Source/WebCore/html/parser/HTMLTreeBuilder.cpp index 02713e5..97cee13 100644 --- a/Source/WebCore/html/parser/HTMLTreeBuilder.cpp +++ b/Source/WebCore/html/parser/HTMLTreeBuilder.cpp @@ -241,7 +241,8 @@ HTMLFormElement* closestFormAncestor(Element* element) } // namespace -class HTMLTreeBuilder::ExternalCharacterTokenBuffer : public Noncopyable { +class HTMLTreeBuilder::ExternalCharacterTokenBuffer { + WTF_MAKE_NONCOPYABLE(ExternalCharacterTokenBuffer); public: explicit ExternalCharacterTokenBuffer(AtomicHTMLToken& token) : m_current(token.characters().data()) @@ -2342,7 +2343,8 @@ void HTMLTreeBuilder::reprocessEndTag(AtomicHTMLToken& token) processEndTag(token); } -class HTMLTreeBuilder::FakeInsertionMode : public Noncopyable { +class HTMLTreeBuilder::FakeInsertionMode { + WTF_MAKE_NONCOPYABLE(FakeInsertionMode); public: FakeInsertionMode(HTMLTreeBuilder* treeBuilder, InsertionMode mode) : m_treeBuilder(treeBuilder) diff --git a/Source/WebCore/html/parser/HTMLTreeBuilder.h b/Source/WebCore/html/parser/HTMLTreeBuilder.h index 17b77b7..309ac6f 100644 --- a/Source/WebCore/html/parser/HTMLTreeBuilder.h +++ b/Source/WebCore/html/parser/HTMLTreeBuilder.h @@ -51,7 +51,8 @@ class HTMLDocument; class Node; class HTMLDocumentParser; -class HTMLTreeBuilder : public Noncopyable { +class HTMLTreeBuilder { + WTF_MAKE_NONCOPYABLE(HTMLTreeBuilder); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<HTMLTreeBuilder> create(HTMLDocumentParser* parser, HTMLDocument* document, bool reportErrors, bool usePreHTML5ParserQuirks) { @@ -204,7 +205,8 @@ private: void processForeignContentUsingInBodyModeAndResetMode(AtomicHTMLToken& token); void resetForeignInsertionMode(); - class FragmentParsingContext : public Noncopyable { + class FragmentParsingContext { + WTF_MAKE_NONCOPYABLE(FragmentParsingContext); public: FragmentParsingContext(); FragmentParsingContext(DocumentFragment*, Element* contextElement, FragmentScriptingPermission); diff --git a/Source/WebCore/html/parser/NestingLevelIncrementer.h b/Source/WebCore/html/parser/NestingLevelIncrementer.h index c597876..8155635 100644 --- a/Source/WebCore/html/parser/NestingLevelIncrementer.h +++ b/Source/WebCore/html/parser/NestingLevelIncrementer.h @@ -28,7 +28,8 @@ namespace WebCore { -class NestingLevelIncrementer : public Noncopyable { +class NestingLevelIncrementer { + WTF_MAKE_NONCOPYABLE(NestingLevelIncrementer); public: explicit NestingLevelIncrementer(unsigned& nestingLevel) : m_nestingLevel(&nestingLevel) diff --git a/Source/WebCore/html/shadow/SliderThumbElement.cpp b/Source/WebCore/html/shadow/SliderThumbElement.cpp index d598da9..ad93261 100644 --- a/Source/WebCore/html/shadow/SliderThumbElement.cpp +++ b/Source/WebCore/html/shadow/SliderThumbElement.cpp @@ -35,9 +35,15 @@ #include "Event.h" #include "Frame.h" +#include "HTMLInputElement.h" +#include "HTMLParserIdioms.h" #include "MouseEvent.h" #include "RenderSlider.h" #include "RenderTheme.h" +#include "StepRange.h" +#include <wtf/MathExtras.h> + +using namespace std; #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) #include "TouchEvent.h" @@ -52,7 +58,6 @@ public: virtual void layout(); }; - RenderSliderThumb::RenderSliderThumb(Node* node) : RenderBlock(node) { @@ -84,6 +89,70 @@ RenderObject* SliderThumbElement::createRenderer(RenderArena* arena, RenderStyle return new (arena) RenderSliderThumb(this); } +void SliderThumbElement::dragFrom(const IntPoint& point) +{ + setPosition(point); + startDragging(); +} + +void SliderThumbElement::setPosition(const IntPoint& point) +{ + HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost()); + ASSERT(input); + + if (!input->renderer() || !renderer()) + return; + + IntPoint offset = roundedIntPoint(input->renderer()->absoluteToLocal(point, false, true)); + RenderStyle* sliderStyle = input->renderer()->style(); + bool isVertical = sliderStyle->appearance() == SliderVerticalPart || sliderStyle->appearance() == MediaVolumeSliderPart; + + int trackSize; + int position; + int currentPosition; + if (isVertical) { + trackSize = input->renderBox()->contentHeight() - renderBox()->height(); + position = offset.y() - renderBox()->height() / 2; + currentPosition = renderBox()->y() - input->renderBox()->contentBoxRect().y(); + } else { + trackSize = input->renderBox()->contentWidth() - renderBox()->width(); + position = offset.x() - renderBox()->width() / 2; + currentPosition = renderBox()->x() - input->renderBox()->contentBoxRect().x(); + } + position = max(0, min(position, trackSize)); + if (position == currentPosition) + return; + + StepRange range(input); + double fraction = static_cast<double>(position) / trackSize; + if (isVertical) + fraction = 1 - fraction; + double value = range.clampValue(range.valueFromProportion(fraction)); + + // FIXME: This is no longer being set from renderer. Consider updating the method name. + input->setValueFromRenderer(serializeForNumberType(value)); + renderer()->setNeedsLayout(true); + input->dispatchFormControlChangeEvent(); +} + +void SliderThumbElement::startDragging() +{ + if (Frame* frame = document()->frame()) { + frame->eventHandler()->setCapturingMouseEventsNode(this); + m_inDragMode = true; + } +} + +void SliderThumbElement::stopDragging() +{ + if (!m_inDragMode) + return; + + if (Frame* frame = document()->frame()) + frame->eventHandler()->setCapturingMouseEventsNode(0); + m_inDragMode = false; +} + void SliderThumbElement::defaultEventHandler(Event* event) { if (!event->isMouseEvent() @@ -99,6 +168,7 @@ void SliderThumbElement::defaultEventHandler(Event* event) bool isLeftButton = mouseEvent->button() == LeftButton; const AtomicString& eventType = event->type(); +<<<<<<< HEAD if (eventType == eventNames().mousedownEvent && isLeftButton #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) || eventType == eventNames().touchstartEvent @@ -164,6 +234,18 @@ void SliderThumbElement::defaultEventHandler(Event* event) return; } } +======= + if (eventType == eventNames().mousedownEvent && isLeftButton) { + startDragging(); + return; + } else if (eventType == eventNames().mouseupEvent && isLeftButton) { + stopDragging(); + return; + } else if (eventType == eventNames().mousemoveEvent) { + if (m_inDragMode) + setPosition(mouseEvent->absoluteLocation()); + return; +>>>>>>> WebKit.org at r76408 } HTMLDivElement::defaultEventHandler(event); diff --git a/Source/WebCore/html/shadow/SliderThumbElement.h b/Source/WebCore/html/shadow/SliderThumbElement.h index 7219186..1f1c869 100644 --- a/Source/WebCore/html/shadow/SliderThumbElement.h +++ b/Source/WebCore/html/shadow/SliderThumbElement.h @@ -50,6 +50,7 @@ public: bool inDragMode() const { return m_inDragMode; } + void dragFrom(const IntPoint&); virtual void defaultEventHandler(Event*); virtual void detach(); virtual AtomicString shadowPseudoId() const; @@ -57,6 +58,9 @@ public: private: SliderThumbElement(Document*); virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + void startDragging(); + void stopDragging(); + void setPosition(const IntPoint&); FloatPoint m_offsetToThumb; bool m_inDragMode; diff --git a/Source/WebCore/inspector/CodeGeneratorInspector.pm b/Source/WebCore/inspector/CodeGeneratorInspector.pm index b7be15e..e215a91 100644 --- a/Source/WebCore/inspector/CodeGeneratorInspector.pm +++ b/Source/WebCore/inspector/CodeGeneratorInspector.pm @@ -13,61 +13,70 @@ my %typeTransform; $typeTransform{"ApplicationCache"} = { "forward" => "InspectorApplicationCacheAgent", "header" => "InspectorApplicationCacheAgent.h", - "domainAccessor" => "m_inspectorController->m_applicationCacheAgent", + "domainAccessor" => "m_inspectorAgent->applicationCacheAgent()", }; $typeTransform{"CSS"} = { "forward" => "InspectorCSSAgent", "header" => "InspectorCSSAgent.h", - "domainAccessor" => "m_inspectorController->m_cssAgent", + "domainAccessor" => "m_inspectorAgent->cssAgent()", }; $typeTransform{"Console"} = { "forward" => "InspectorConsoleAgent", "header" => "InspectorConsoleAgent.h", - "domainAccessor" => "m_inspectorController->m_consoleAgent", + "domainAccessor" => "m_inspectorAgent->consoleAgent()", }; $typeTransform{"Debugger"} = { "forward" => "InspectorDebuggerAgent", "header" => "InspectorDebuggerAgent.h", - "domainAccessor" => "m_inspectorController->m_debuggerAgent", + "domainAccessor" => "m_inspectorAgent->debuggerAgent()", }; $typeTransform{"BrowserDebugger"} = { "forward" => "InspectorBrowserDebuggerAgent", "header" => "InspectorBrowserDebuggerAgent.h", - "domainAccessor" => "m_inspectorController->m_browserDebuggerAgent", + "domainAccessor" => "m_inspectorAgent->browserDebuggerAgent()", }; $typeTransform{"Database"} = { "forward" => "InspectorDatabaseAgent", "header" => "InspectorDatabaseAgent.h", - "domainAccessor" => "m_inspectorController->m_databaseAgent", + "domainAccessor" => "m_inspectorAgent->databaseAgent()", }; $typeTransform{"DOM"} = { "forward" => "InspectorDOMAgent", "header" => "InspectorDOMAgent.h", - "domainAccessor" => "m_inspectorController->m_domAgent", + "domainAccessor" => "m_inspectorAgent->domAgent()", }; $typeTransform{"DOMStorage"} = { "forward" => "InspectorDOMStorageAgent", "header" => "InspectorDOMStorageAgent.h", - "domainAccessor" => "m_inspectorController->m_domStorageAgent", + "domainAccessor" => "m_inspectorAgent->domStorageAgent()", }; $typeTransform{"FileSystem"} = { "forward" => "InspectorFileSystemAgent", "header" => "InspectorFileSystemAgent.h", - "domainAccessor" => "m_inspectorController->m_fileSystemAgent", + "domainAccessor" => "m_inspectorAgent->fileSystemAgent()", +}; +$typeTransform{"InjectedScript"} = { + "forwardHeader" => "InjectedScriptHost.h", + "domainAccessor" => "m_inspectorAgent->injectedScriptAgent()", }; $typeTransform{"Inspector"} = { - "forwardHeader" => "InspectorController.h", - "domainAccessor" => "m_inspectorController", + "forwardHeader" => "InspectorController.h", # FIXME: Temporary solution until extracting the real InspectorAgent from InspectorController. + "domainAccessor" => "m_inspectorAgent", }; $typeTransform{"Network"} = { "forward" => "InspectorResourceAgent", "header" => "InspectorResourceAgent.h", - "domainAccessor" => "m_inspectorController->m_resourceAgent", + "domainAccessor" => "m_inspectorAgent->resourceAgent()", }; $typeTransform{"Profiler"} = { "forward" => "InspectorProfilerAgent", "header" => "InspectorProfilerAgent.h", - "domainAccessor" => "m_inspectorController->m_profilerAgent", + "domainAccessor" => "m_inspectorAgent->profilerAgent()", +}; +$typeTransform{"Runtime"} = { + "forward" => "InspectorRuntimeAgent", + "header" => "InspectorRuntimeAgent.h", + "domainAccessor" => "m_inspectorAgent->runtimeAgent()", }; $typeTransform{"Frontend"} = { @@ -87,7 +96,8 @@ $typeTransform{"Object"} = { "defaultValue" => "InspectorObject::create()", "forward" => "InspectorObject", "header" => "InspectorValues.h", - "JSONType" => "Object" + "JSONType" => "Object", + "JSType" => "object" }; $typeTransform{"Array"} = { "param" => "PassRefPtr<InspectorArray>", @@ -95,7 +105,8 @@ $typeTransform{"Array"} = { "defaultValue" => "InspectorArray::create()", "forward" => "InspectorArray", "header" => "InspectorValues.h", - "JSONType" => "Array" + "JSONType" => "Array", + "JSType" => "object" }; $typeTransform{"Value"} = { "param" => "PassRefPtr<InspectorValue>", @@ -103,16 +114,18 @@ $typeTransform{"Value"} = { "defaultValue" => "InspectorValue::null()", "forward" => "InspectorValue", "header" => "InspectorValues.h", - "JSONType" => "Value" + "JSONType" => "Value", + "JSType" => "" }; $typeTransform{"String"} = { "param" => "const String&", "variable" => "String", "return" => "String", "defaultValue" => "\"\"", - "forwardHeader" => "wtf/Forward.h", + "forwardHeader" => "PlatformString.h", "header" => "PlatformString.h", - "JSONType" => "String" + "JSONType" => "String", + "JSType" => "string" }; $typeTransform{"long"} = { "param" => "long", @@ -120,7 +133,8 @@ $typeTransform{"long"} = { "defaultValue" => "0", "forward" => "", "header" => "", - "JSONType" => "Number" + "JSONType" => "Number", + "JSType" => "number" }; $typeTransform{"int"} = { "param" => "int", @@ -129,6 +143,7 @@ $typeTransform{"int"} = { "forward" => "", "header" => "", "JSONType" => "Number", + "JSType" => "number" }; $typeTransform{"unsigned long"} = { "param" => "unsigned long", @@ -136,7 +151,8 @@ $typeTransform{"unsigned long"} = { "defaultValue" => "0u", "forward" => "", "header" => "", - "JSONType" => "Number" + "JSONType" => "Number", + "JSType" => "number" }; $typeTransform{"unsigned int"} = { "param" => "unsigned int", @@ -144,7 +160,8 @@ $typeTransform{"unsigned int"} = { "defaultValue" => "0u", "forward" => "", "header" => "", - "JSONType" => "Number" + "JSONType" => "Number", + "JSType" => "number" }; $typeTransform{"double"} = { "param" => "double", @@ -152,7 +169,8 @@ $typeTransform{"double"} = { "defaultValue" => "0.0", "forward" => "", "header" => "", - "JSONType" => "Number" + "JSONType" => "Number", + "JSType" => "number" }; $typeTransform{"boolean"} = { "param" => "bool", @@ -160,7 +178,8 @@ $typeTransform{"boolean"} = { "defaultValue" => "false", "forward" => "", "header" => "", - "JSONType" => "Boolean" + "JSONType" => "Boolean", + "JSType" => "boolean" }; $typeTransform{"void"} = { "forward" => "", @@ -250,12 +269,13 @@ sub GenerateInterface $backendClassName = $className . "BackendDispatcher"; $backendJSStubName = $className . "BackendStub"; my @backendHead; - push(@backendHead, " ${backendClassName}(InspectorController* inspectorController) : m_inspectorController(inspectorController) { }"); + push(@backendHead, " typedef InspectorController InspectorAgent;"); # FIXME: Temporary substitution until extracting InspectorAgent from InspectorController. + push(@backendHead, " ${backendClassName}(InspectorAgent* inspectorAgent) : m_inspectorAgent(inspectorAgent) { }"); push(@backendHead, " void reportProtocolError(const long callId, const String& errorText) const;"); push(@backendHead, " void dispatch(const String& message);"); push(@backendHead, " static bool getCommandName(const String& message, String* result);"); $backendConstructor = join("\n", @backendHead); - $backendFooter = " InspectorController* m_inspectorController;"; + $backendFooter = " InspectorAgent* m_inspectorAgent;"; $backendTypes{"Inspector"} = 1; $backendTypes{"InspectorClient"} = 1; $backendTypes{"PassRefPtr"} = 1; @@ -392,7 +412,7 @@ sub generateBackendFunction } push(@function, " // use InspectorFrontend as a marker of WebInspector availability"); - push(@function, " if ((callId || protocolErrors->length()) && m_inspectorController->hasFrontend()) {"); + push(@function, " if ((callId || protocolErrors->length()) && m_inspectorAgent->hasFrontend()) {"); push(@function, " RefPtr<InspectorObject> responseMessage = InspectorObject::create();"); push(@function, " responseMessage->setNumber(\"seq\", callId);"); push(@function, " responseMessage->setString(\"domain\", \"$domain\");"); @@ -407,7 +427,7 @@ sub generateBackendFunction push(@function, " responseMessage->setObject(\"data\", responseData);"); push(@function, " }"); } - push(@function, " m_inspectorController->inspectorClient()->sendMessageToFrontend(responseMessage->toJSONString());"); + push(@function, " m_inspectorAgent->inspectorClient()->sendMessageToFrontend(responseMessage->toJSONString());"); push(@function, " }"); @@ -428,7 +448,7 @@ void ${backendClassName}::reportProtocolError(const long callId, const String& e RefPtr<InspectorArray> errors = InspectorArray::create(); errors->pushString(errorText); message->setArray("errors", errors); - m_inspectorController->inspectorClient()->sendMessageToFrontend(message->toJSONString()); + m_inspectorAgent->inspectorClient()->sendMessageToFrontend(message->toJSONString()); } EOF return split("\n", $reportProtocolError); @@ -567,7 +587,7 @@ sub generateBackendStubJS foreach my $function (@backendFunctions) { my $name = $function->signature->name; my $domain = $function->signature->extendedAttributes->{"domain"}; - my $argumentNames = join(",", map("\"" . $_->name . "\": \"" . lc($typeTransform{$_->type}->{"JSONType"}) . "\"", grep($_->direction eq "in", @{$function->parameters}))); + my $argumentNames = join(",", map("\"" . $_->name . "\": \"" . $typeTransform{$_->type}->{"JSType"} . "\"", grep($_->direction eq "in", @{$function->parameters}))); push(@JSStubs, " this._registerDelegate('{" . "\"seq\": 0, " . "\"domain\": \"$domain\", " . @@ -625,7 +645,7 @@ InspectorBackendStub.prototype = { return; } var value = args.shift(); - if (typeof value !== request.arguments[key]) { + if (request.arguments[key] && typeof value !== request.arguments[key]) { console.error("Protocol Error: Invalid type of argument '%s' for 'InspectorBackend.%s' call. It should be '%s' but it is '%s'.", key, request.command, request.arguments[key], typeof value); return; } diff --git a/Source/WebCore/inspector/ConsoleMessage.h b/Source/WebCore/inspector/ConsoleMessage.h index 310aa8e..7c3348b 100644 --- a/Source/WebCore/inspector/ConsoleMessage.h +++ b/Source/WebCore/inspector/ConsoleMessage.h @@ -46,7 +46,8 @@ class ScriptCallFrame; class ScriptCallStack; class ScriptValue; -class ConsoleMessage : public Noncopyable { +class ConsoleMessage { + WTF_MAKE_NONCOPYABLE(ConsoleMessage); WTF_MAKE_FAST_ALLOCATED; public: ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u); ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>); diff --git a/Source/WebCore/inspector/InjectedScript.cpp b/Source/WebCore/inspector/InjectedScript.cpp index 3f4d819..1969f34 100644 --- a/Source/WebCore/inspector/InjectedScript.cpp +++ b/Source/WebCore/inspector/InjectedScript.cpp @@ -44,21 +44,94 @@ InjectedScript::InjectedScript(ScriptObject injectedScriptObject) { } -void InjectedScript::dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException) +void InjectedScript::evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) { - ASSERT(!hasNoValue()); - if (!canAccessInspectedWindow()) { - *hadException = true; - return; - } + ScriptFunctionCall function(m_injectedScriptObject, "evaluate"); + function.appendArgument(expression); + function.appendArgument(objectGroup); + makeCall(function, result); +} - ScriptFunctionCall function(m_injectedScriptObject, "dispatch"); - function.appendArgument(methodName); - function.appendArgument(arguments); - *hadException = false; - ScriptValue resultValue = function.call(*hadException); - if (!*hadException) - *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); +void InjectedScript::evaluateOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "evaluateOnCallFrame"); + function.appendArgument(callFrameId->toJSONString()); + function.appendArgument(expression); + function.appendArgument(objectGroup); + makeCall(function, result); +} + +void InjectedScript::evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "evaluateOnSelf"); + function.appendArgument(functionBody); + function.appendArgument(argumentsArray->toJSONString()); + makeCall(function, result); +} + +void InjectedScript::getCompletions(const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "getCompletions"); + function.appendArgument(expression); + function.appendArgument(includeInspectorCommandLineAPI); + makeCall(function, result); +} + +void InjectedScript::getCompletionsOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "getCompletionsOnCallFrame"); + function.appendArgument(callFrameId->toJSONString()); + function.appendArgument(expression); + function.appendArgument(includeInspectorCommandLineAPI); + makeCall(function, result); +} + +void InjectedScript::getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "getProperties"); + String objectIdString = objectId->toJSONString(); + function.appendArgument(objectIdString); + function.appendArgument(ignoreHasOwnProperty); + function.appendArgument(abbreviate); + makeCall(function, result); +} + +void InjectedScript::pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "pushNodeToFrontend"); + function.appendArgument(objectId->toJSONString()); + makeCall(function, result); +} + +void InjectedScript::resolveNode(long nodeId, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "resolveNode"); + function.appendArgument(nodeId); + makeCall(function, result); +} + +void InjectedScript::getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "getNodeProperties"); + function.appendArgument(nodeId); + function.appendArgument(propertiesArray->toJSONString()); + makeCall(function, result); +} + +void InjectedScript::getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "getNodePrototypes"); + function.appendArgument(nodeId); + makeCall(function, result); +} + +void InjectedScript::setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result) +{ + ScriptFunctionCall function(m_injectedScriptObject, "getNodeProperties"); + function.appendArgument(objectId->toJSONString()); + function.appendArgument(propertyName); + function.appendArgument(expression); + makeCall(function, result); } #if ENABLE(JAVASCRIPT_DEBUGGER) @@ -91,11 +164,29 @@ void InjectedScript::releaseWrapperObjectGroup(const String& objectGroup) releaseFunction.appendArgument(objectGroup); releaseFunction.call(); } + bool InjectedScript::canAccessInspectedWindow() { return InjectedScriptHost::canAccessInspectedWindow(m_injectedScriptObject.scriptState()); } +void InjectedScript::makeCall(ScriptFunctionCall& function, RefPtr<InspectorValue>* result) +{ + if (hasNoValue() || !canAccessInspectedWindow()) { + *result = InspectorValue::null(); + return; + } + + bool hadException = false; + ScriptValue resultValue = function.call(hadException); + + ASSERT(!hadException); + if (!hadException) + *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState()); + else + *result = InspectorValue::null(); +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InjectedScript.h b/Source/WebCore/inspector/InjectedScript.h index f80cfb4..0a3f24b 100644 --- a/Source/WebCore/inspector/InjectedScript.h +++ b/Source/WebCore/inspector/InjectedScript.h @@ -36,10 +36,12 @@ #include <wtf/Forward.h> #include <wtf/Noncopyable.h> #include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> namespace WebCore { class InspectorValue; +class ScriptFunctionCall; class InjectedScript { public: @@ -48,10 +50,22 @@ public: bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); } - void dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException); + void evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); + void evaluateOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); + void evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result); + void getCompletions(const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result); + void getCompletionsOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result); + void getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result); + void pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result); + void resolveNode(long nodeId, RefPtr<InspectorValue>* result); + void getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result); + void getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result); + void setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result); + #if ENABLE(JAVASCRIPT_DEBUGGER) PassRefPtr<InspectorValue> callFrames(); #endif + PassRefPtr<InspectorValue> wrapForConsole(ScriptValue); void releaseWrapperObjectGroup(const String&); ScriptState* scriptState() const { return m_injectedScriptObject.scriptState(); } @@ -60,6 +74,9 @@ private: friend InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState*); explicit InjectedScript(ScriptObject); bool canAccessInspectedWindow(); + + void makeCall(ScriptFunctionCall&, RefPtr<InspectorValue>* result); + ScriptObject m_injectedScriptObject; }; diff --git a/Source/WebCore/inspector/InjectedScriptHost.cpp b/Source/WebCore/inspector/InjectedScriptHost.cpp index 3fd70e4..d67adaf 100644 --- a/Source/WebCore/inspector/InjectedScriptHost.cpp +++ b/Source/WebCore/inspector/InjectedScriptHost.cpp @@ -30,22 +30,21 @@ #include "config.h" #include "InjectedScriptHost.h" -#include "InjectedScriptSource.h" -#include "InspectorDatabaseAgent.h" -#include "InspectorDOMStorageAgent.h" #if ENABLE(INSPECTOR) - #include "Element.h" #include "Frame.h" #include "FrameLoader.h" #include "HTMLFrameOwnerElement.h" #include "InjectedScript.h" +#include "InjectedScriptSource.h" #include "InspectorClient.h" #include "InspectorConsoleAgent.h" #include "InspectorController.h" #include "InspectorDOMAgent.h" +#include "InspectorDOMStorageAgent.h" +#include "InspectorDatabaseAgent.h" #include "InspectorFrontend.h" #include "Pasteboard.h" @@ -81,6 +80,13 @@ InjectedScriptHost::~InjectedScriptHost() { } +void InjectedScriptHost::evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = injectedScriptForMainFrame(); + if (!injectedScript.hasNoValue()) + injectedScript.evaluateOnSelf(functionBody, argumentsArray, result); +} + void InjectedScriptHost::clearConsoleMessages() { if (m_inspectorController) @@ -124,23 +130,23 @@ long InjectedScriptHost::inspectedNode(unsigned long num) #if ENABLE(DATABASE) Database* InjectedScriptHost::databaseForId(long databaseId) { - if (m_inspectorController && m_inspectorController->m_databaseAgent) - return m_inspectorController->m_databaseAgent->databaseForId(databaseId); + if (m_inspectorController && m_inspectorController->databaseAgent()) + return m_inspectorController->databaseAgent()->databaseForId(databaseId); return 0; } void InjectedScriptHost::selectDatabase(Database* database) { - if (m_inspectorController && m_inspectorController->m_databaseAgent) - m_inspectorController->m_databaseAgent->selectDatabase(database); + if (m_inspectorController && m_inspectorController->databaseAgent()) + m_inspectorController->databaseAgent()->selectDatabase(database); } #endif #if ENABLE(DOM_STORAGE) void InjectedScriptHost::selectDOMStorage(Storage* storage) { - if (m_inspectorController && m_inspectorController->m_domStorageAgent) - m_inspectorController->m_domStorageAgent->selectDOMStorage(storage); + if (m_inspectorController && m_inspectorController->domStorageAgent()) + m_inspectorController->domStorageAgent()->selectDOMStorage(storage); } #endif @@ -149,6 +155,20 @@ InjectedScript InjectedScriptHost::injectedScriptForId(long id) return m_idToInjectedScript.get(id); } +InjectedScript InjectedScriptHost::injectedScriptForObjectId(InspectorObject* objectId) +{ + long injectedScriptId = 0; + bool success = objectId->getNumber("injectedScriptId", &injectedScriptId); + if (success) + return injectedScriptForId(injectedScriptId); + return InjectedScript(); +} + +InjectedScript InjectedScriptHost::injectedScriptForMainFrame() +{ + return injectedScriptFor(mainWorldScriptState(m_inspectorController->inspectedPage()->mainFrame())); +} + void InjectedScriptHost::discardInjectedScripts() { IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end(); @@ -174,14 +194,14 @@ InspectorDOMAgent* InjectedScriptHost::inspectorDOMAgent() { if (!m_inspectorController) return 0; - return m_inspectorController->m_domAgent.get(); + return m_inspectorController->domAgent(); } InspectorFrontend* InjectedScriptHost::frontend() { if (!m_inspectorController) return 0; - return m_inspectorController->m_frontend.get(); + return m_inspectorController->frontend(); } String InjectedScriptHost::injectedScriptSource() diff --git a/Source/WebCore/inspector/InjectedScriptHost.h b/Source/WebCore/inspector/InjectedScriptHost.h index e9c09aa..108f118 100644 --- a/Source/WebCore/inspector/InjectedScriptHost.h +++ b/Source/WebCore/inspector/InjectedScriptHost.h @@ -44,6 +44,7 @@ class Database; class InjectedScript; class InspectorDOMAgent; class InspectorFrontend; +class InspectorObject; class Node; class ScriptObject; class Storage; @@ -58,6 +59,9 @@ public: ~InjectedScriptHost(); + // Part of the protocol. + void evaluateOnSelf(const String& functionBody, PassRefPtr<InspectorArray> argumentsArray, RefPtr<InspectorValue>* result); + InspectorController* inspectorController() { return m_inspectorController; } void disconnectController() { m_inspectorController = 0; } @@ -84,6 +88,8 @@ public: pair<long, ScriptObject> injectScript(const String& source, ScriptState*); InjectedScript injectedScriptFor(ScriptState*); InjectedScript injectedScriptForId(long); + InjectedScript injectedScriptForObjectId(InspectorObject* objectId); + InjectedScript injectedScriptForMainFrame(); void discardInjectedScripts(); void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup); diff --git a/Source/WebCore/inspector/InjectedScriptSource.js b/Source/WebCore/inspector/InjectedScriptSource.js index 90797fb..3aa24a6 100644 --- a/Source/WebCore/inspector/InjectedScriptSource.js +++ b/Source/WebCore/inspector/InjectedScriptSource.js @@ -60,7 +60,9 @@ InjectedScript.prototype = { this._objectGroups[objectGroupName] = group; } group.push(id); - objectId = this._serializeObjectId(id, objectGroupName); + objectId = { injectedScriptId: injectedScriptId, + id: id, + groupName: objectGroupName }; } return InjectedScript.RemoteObject.fromObject(object, objectId, abbreviate); } catch (e) { @@ -68,18 +70,9 @@ InjectedScript.prototype = { } }, - _serializeObjectId: function(id, groupName) - { - return injectedScriptId + ":" + id + ":" + groupName; - }, - _parseObjectId: function(objectId) { - var tokens = objectId.split(":"); - var parsedObjectId = {}; - parsedObjectId.id = parseInt(tokens[1]); - parsedObjectId.groupName = tokens[2]; - return parsedObjectId; + return eval("(" + objectId + ")"); }, releaseWrapperObjectGroup: function(objectGroupName) @@ -103,26 +96,11 @@ InjectedScript.prototype = { return result; }, - getPrototypes: function(nodeId) - { - this.releaseWrapperObjectGroup("prototypes"); - var node = this._nodeForId(nodeId); - if (!node) - return false; - - var result = []; - var prototype = node; - do { - result.push(this._wrapObject(prototype, "prototypes")); - prototype = prototype.__proto__; - } while (prototype) - return result; - }, - getProperties: function(objectId, ignoreHasOwnProperty, abbreviate) { var parsedObjectId = this._parseObjectId(objectId); var object = this._objectForId(parsedObjectId); + if (!this._isDefined(object)) return false; var properties = []; @@ -208,29 +186,14 @@ InjectedScript.prototype = { return Object.keys(propertyNameSet); }, - getCompletions: function(expression, includeInspectorCommandLineAPI, callFrameId) + getCompletions: function(expression, includeInspectorCommandLineAPI) { var props = {}; try { - var expressionResult; - // Evaluate on call frame if call frame id is available. - if (typeof callFrameId === "number") { - var callFrame = this._callFrameForId(callFrameId); - if (!callFrame) - return props; - if (expression) - expressionResult = this._evaluateOn(callFrame.evaluate, callFrame, expression, true); - else { - // Evaluate into properties in scope of the selected call frame. - var scopeChain = callFrame.scopeChain; - for (var i = 0; i < scopeChain.length; ++i) - this._populatePropertyNames(scopeChain[i], props); - } - } else { - if (!expression) - expression = "this"; - expressionResult = this._evaluateOn(inspectedWindow.eval, inspectedWindow, expression, false); - } + if (!expression) + expression = "this"; + var expressionResult = this._evaluateOn(inspectedWindow.eval, inspectedWindow, expression, false); + if (typeof expressionResult === "object") this._populatePropertyNames(expressionResult, props); @@ -243,6 +206,34 @@ InjectedScript.prototype = { return props; }, + getCompletionsOnCallFrame: function(callFrameId, expression, includeInspectorCommandLineAPI) + { + var props = {}; + try { + var callFrame = this._callFrameForId(callFrameId); + if (!callFrame) + return props; + + if (expression) { + var expressionResult = this._evaluateOn(callFrame.evaluate, callFrame, expression, true); + if (typeof expressionResult === "object") + this._populatePropertyNames(expressionResult, props); + } else { + // Evaluate into properties in scope of the selected call frame. + var scopeChain = callFrame.scopeChain; + for (var i = 0; i < scopeChain.length; ++i) + this._populatePropertyNames(scopeChain[i], props); + } + + if (includeInspectorCommandLineAPI) { + for (var prop in this._commandLineAPI) + props[prop] = true; + } + } catch(e) { + } + return props; + }, + evaluate: function(expression, objectGroup) { return this._evaluateAndWrap(inspectedWindow.eval, inspectedWindow, expression, objectGroup, false); @@ -300,7 +291,7 @@ InjectedScript.prototype = { return result; }, - evaluateInCallFrame: function(callFrameId, code, objectGroup) + evaluateOnCallFrame: function(callFrameId, code, objectGroup) { var callFrame = this._callFrameForId(callFrameId); if (!callFrame) @@ -308,10 +299,12 @@ InjectedScript.prototype = { return this._evaluateAndWrap(callFrame.evaluate, callFrame, code, objectGroup, true); }, - _callFrameForId: function(id) + _callFrameForId: function(callFrameId) { + var parsedCallFrameId = eval("(" + callFrameId + ")"); + var ordinal = parsedCallFrameId.ordinal; var callFrame = InjectedScriptHost.currentCallFrame(); - while (--id >= 0 && callFrame) + while (--ordinal >= 0 && callFrame) callFrame = callFrame.caller; return callFrame; }, @@ -323,9 +316,9 @@ InjectedScript.prototype = { return InjectedScriptHost.nodeForId(nodeId); }, - _objectForId: function(parsedObjectId) + _objectForId: function(objectId) { - return this._idToWrappedObject[parsedObjectId.id]; + return this._idToWrappedObject[objectId.id]; }, resolveNode: function(nodeId) @@ -342,12 +335,29 @@ InjectedScript.prototype = { var node = this._nodeForId(nodeId); if (!node) return false; + properties = eval("(" + properties + ")"); var result = {}; for (var i = 0; i < properties.length; ++i) result[properties[i]] = node[properties[i]]; return result; }, + getNodePrototypes: function(nodeId) + { + this.releaseWrapperObjectGroup("prototypes"); + var node = this._nodeForId(nodeId); + if (!node) + return false; + + var result = []; + var prototype = node; + do { + result.push(this._wrapObject(prototype, "prototypes")); + prototype = prototype.__proto__; + } while (prototype) + return result; + }, + pushNodeToFrontend: function(objectId) { var parsedObjectId = this._parseObjectId(objectId); @@ -359,8 +369,8 @@ InjectedScript.prototype = { evaluateOnSelf: function(funcBody, args) { - var func = window.eval("(" + funcBody + ")"); - return func.apply(this, args || []); + var func = eval("(" + funcBody + ")"); + return func.apply(this, eval("(" + args + ")") || []); }, _isDefined: function(object) @@ -536,15 +546,15 @@ InjectedScript.RemoteObject.fromObject = function(object, objectId, abbreviate) } } -InjectedScript.CallFrameProxy = function(id, callFrame) +InjectedScript.CallFrameProxy = function(ordinal, callFrame) { - this.id = id; + this.id = { ordinal: ordinal, injectedScriptId: injectedScriptId }; this.type = callFrame.type; this.functionName = (this.type === "function" ? callFrame.functionName : ""); this.sourceID = callFrame.sourceID; this.line = callFrame.line; + this.column = callFrame.column; this.scopeChain = this._wrapScopeChain(callFrame); - this.worldId = injectedScriptId; } InjectedScript.CallFrameProxy.prototype = { diff --git a/Source/WebCore/inspector/Inspector.idl b/Source/WebCore/inspector/Inspector.idl index 6c2cc2e..79b33f6 100644 --- a/Source/WebCore/inspector/Inspector.idl +++ b/Source/WebCore/inspector/Inspector.idl @@ -36,13 +36,8 @@ module core { // generic Inspector's methods /////////////////////////////////////////////////////////////////////// - // HUGE FIXME: we need to expose InjectedScript methods here. Or document InjectedScript capabilities. - [domain=Inspector] void dispatchOnInjectedScript(in long injectedScriptId, in String methodName, in String arguments, out Value result, out boolean isException); [domain=Inspector] void addScriptToEvaluateOnLoad(in String scriptSource); [domain=Inspector] void removeAllScriptsToEvaluateOnLoad(); - [domain=Inspector] void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup); - [domain=Inspector] void getInspectorState(out Object state); - [domain=Inspector] void setMonitoringXHREnabled(in boolean enable, out boolean newState); [domain=Inspector] void reloadPage(); [domain=Inspector] void populateScriptObjects(); @@ -73,6 +68,22 @@ module core { [domain=Inspector] void deleteCookie(in String cookieName, in String domain); /////////////////////////////////////////////////////////////////////// + // Runtime + /////////////////////////////////////////////////////////////////////// + + [domain=Runtime] void evaluate(in String expression, in String objectGroup, out Value result); + [domain=Runtime] void getCompletions(in String expression, in boolean includeInspectorCommandLineAPI, out Value result); + [domain=Runtime] void getProperties(in Object objectId, in boolean ignoreHasOwnProperty, in boolean abbreviate, out Value result); + [domain=Runtime] void setPropertyValue(in Object objectId, in String propertyName, in String expression, out Value result); + [domain=Runtime] void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup); + + /////////////////////////////////////////////////////////////////////// + // Injected Script + /////////////////////////////////////////////////////////////////////// + + [domain=InjectedScript] void evaluateOnSelf(in String functionBody, in Array argumentsArray, out Value result); + + /////////////////////////////////////////////////////////////////////// // Console API /////////////////////////////////////////////////////////////////////// @@ -82,6 +93,8 @@ module core { [notify, domain=Console] void updateConsoleMessageRepeatCount(out unsigned long count); [domain=Console] void clearConsoleMessages(); [notify, domain=Console] void consoleMessagesCleared(); + [domain=Console] void setMonitoringXHREnabled(in boolean enabled); + [notify, domain=Console] void monitoringXHRStateChanged(out boolean enabled); /////////////////////////////////////////////////////////////////////// // Network API @@ -89,8 +102,8 @@ module core { [domain=Network] void cachedResources(out Object resources); [domain=Network] void resourceContent(in unsigned long frameId, in String url, in boolean base64Encode, out String content); - [notify, domain=Network] void frameDetachedFromParent(out unsigned long frameId); + [notify, domain=Network] void frameDetachedFromParent(out unsigned long frameId); [notify, domain=Network] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out Value callStack); [notify, domain=Network] void willSendRequest(out long identifier, out double time, out Object request, out Object redirectResponse); [notify, domain=Network] void markResourceAsCached(out long identifier); @@ -112,10 +125,11 @@ module core { // Database API /////////////////////////////////////////////////////////////////////// - [notify, domain=Database] void addDatabase(out Object database); - [notify, domain=Database] void selectDatabase(out int databaseId); [domain=Database] void getDatabaseTableNames(in long databaseId, out Array tableNames); [domain=Database] void executeSQL(in long databaseId, in String query, out boolean success, out long transactionId); + + [notify, domain=Database] void addDatabase(out Object database); + [notify, domain=Database] void selectDatabase(out int databaseId); [notify, domain=Database] void sqlTransactionSucceeded(out long transactionId, out Value columnNames, out Value values); [notify, domain=Database] void sqlTransactionFailed(out long transactionId, out Value sqlError); #endif @@ -177,6 +191,10 @@ module core { [domain=DOM] void performSearch(in String query, in boolean runSynchronously); [domain=DOM] void searchCanceled(); [domain=DOM] void pushNodeByPathToFrontend(in String path, out long nodeId); + [domain=DOM] void resolveNode(in long nodeId, out Value result); + [domain=DOM] void getNodeProperties(in long nodeId, in Array propertiesArray, out Value result); + [domain=DOM] void getNodePrototypes(in long nodeId, out Value result); + [domain=DOM] void pushNodeToFrontend(in Object objectId, out Value result); [notify, domain=DOM] void setDocument(out Value root); // FIXME: should be requested from the front-end as getDocument. [notify, domain=DOM] void attributesUpdated(out long id, out Array attributes); @@ -224,12 +242,12 @@ module core { [domain=Inspector] void enableDebugger(in boolean always); [domain=Inspector] void disableDebugger(in boolean always); - [domain=Inspector] void setStickyBreakpoints(in Object breakpoints); + [domain=Inspector] void setAllBrowserBreakpoints(in Object breakpoints); [notify, domain=Debugger] void debuggerWasEnabled(); [notify, domain=Debugger] void debuggerWasDisabled(); - [notify, domain=Debugger] void parsedScriptSource(out String sourceID, out String url, out int lineOffset, out int columnOffset, out int scriptWorldType); + [notify, domain=Debugger] void parsedScriptSource(out String sourceID, out String url, out int lineOffset, out int columnOffset, out int length, out int scriptWorldType); [notify, domain=Debugger] void failedToParseScriptSource(out String url, out String data, out int firstLine, out int errorLine, out String errorMessage); [domain=Debugger] void activateBreakpoints(); @@ -251,13 +269,16 @@ module core { [domain=Debugger] void pause(); [notify, domain=Debugger] void pausedScript(out Object details); [domain=Debugger] void resume(); - [notify, domain=Debugger] void resumedScript(); // FIXME: Make this out parameter fo resume if possible. - - [domain=Debugger] void setPauseOnExceptionsState(in long pauseOnExceptionsState, out long newState); + [notify, domain=Debugger] void resumedScript(); // FIXME: Make this out parameter of resume if possible. [domain=Debugger] void editScriptSource(in String sourceID, in String newContent, out boolean success, out String result, out Value newCallFrames); [domain=Debugger] void getScriptSource(in String sourceID, out String scriptSource); + [domain=Debugger] void setPauseOnExceptionsState(in long pauseOnExceptionsState, out long newState); + + [domain=Debugger] void evaluateOnCallFrame(in Object callFrameId, in String expression, in String objectGroup, out Value result); + [domain=Debugger] void getCompletionsOnCallFrame(in Object callFrameId, in String expression, in boolean includeInspectorCommandLineAPI, out Value result); + [notify, domain=Debugger] void breakpointResolved(out String breakpointId, out String sourceID, out unsigned int lineNumber, out String condition, out boolean enabled, out unsigned int originalLineNumber); #if defined(ENABLE_WORKERS) && ENABLE_WORKERS @@ -269,7 +290,7 @@ module core { // Profiler API /////////////////////////////////////////////////////////////////////// - [domain=Inspector] void enableProfiler(in boolean always); // FIXME: preferrable with Inspector domain, dispatched on backend. + [domain=Inspector] void enableProfiler(in boolean always); [domain=Inspector] void disableProfiler(in boolean always); [notify, domain=Profiler] void profilerWasEnabled(); [notify, domain=Profiler] void profilerWasDisabled(); diff --git a/Source/WebCore/inspector/InspectorApplicationCacheAgent.h b/Source/WebCore/inspector/InspectorApplicationCacheAgent.h index 3d9e494..ac0acbf 100644 --- a/Source/WebCore/inspector/InspectorApplicationCacheAgent.h +++ b/Source/WebCore/inspector/InspectorApplicationCacheAgent.h @@ -41,7 +41,8 @@ class InspectorObject; class InspectorValue; class ResourceResponse; -class InspectorApplicationCacheAgent : public Noncopyable { +class InspectorApplicationCacheAgent { + WTF_MAKE_NONCOPYABLE(InspectorApplicationCacheAgent); WTF_MAKE_FAST_ALLOCATED; public: InspectorApplicationCacheAgent(InspectorController* inspectorController, InspectorFrontend* frontend); ~InspectorApplicationCacheAgent() { } diff --git a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp index a33bacc..023dc49 100644 --- a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp +++ b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp @@ -71,9 +71,71 @@ InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent() { } +void InspectorBrowserDebuggerAgent::inspectedURLChanged(const KURL& url) +{ + m_eventListenerBreakpoints.clear(); + m_XHRBreakpoints.clear(); + m_hasXHRBreakpointWithEmptyURL = false; + + RefPtr<InspectorObject> allBreakpoints = m_inspectorController->state()->getObject(InspectorState::browserBreakpoints); + KURL urlCopy = url; + urlCopy.removeFragmentIdentifier(); + RefPtr<InspectorArray> breakpoints = allBreakpoints->getArray(urlCopy); + if (!breakpoints) + return; + for (unsigned i = 0; i < breakpoints->length(); ++i) + restoreStickyBreakpoint(breakpoints->get(i)->asObject()); +} + +void InspectorBrowserDebuggerAgent::restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint) +{ + DEFINE_STATIC_LOCAL(String, eventListenerBreakpointType, ("EventListener")); + DEFINE_STATIC_LOCAL(String, javaScriptBreakpointType, ("JS")); + DEFINE_STATIC_LOCAL(String, xhrBreakpointType, ("XHR")); + + if (!breakpoint) + return; + String type; + if (!breakpoint->getString("type", &type)) + return; + bool enabled; + if (!breakpoint->getBoolean("enabled", &enabled)) + return; + RefPtr<InspectorObject> condition = breakpoint->getObject("condition"); + if (!condition) + return; + + if (type == eventListenerBreakpointType) { + if (!enabled) + return; + String eventName; + if (!condition->getString("eventName", &eventName)) + return; + setEventListenerBreakpoint(eventName); + } else if (type == javaScriptBreakpointType && m_inspectorController->debuggerAgent()) { + String url; + if (!condition->getString("url", &url)) + return; + double lineNumber; + if (!condition->getNumber("lineNumber", &lineNumber)) + return; + String javaScriptCondition; + if (!condition->getString("condition", &javaScriptCondition)) + return; + m_inspectorController->debuggerAgent()->setStickyBreakpoint(url, static_cast<unsigned>(lineNumber), javaScriptCondition, enabled); + } else if (type == xhrBreakpointType) { + if (!enabled) + return; + String url; + if (!condition->getString("url", &url)) + return; + setXHRBreakpoint(url); + } +} + void InspectorBrowserDebuggerAgent::discardBindings() { - m_breakpoints.clear(); + m_domBreakpoints.clear(); } void InspectorBrowserDebuggerAgent::setEventListenerBreakpoint(const String& eventName) @@ -88,8 +150,8 @@ void InspectorBrowserDebuggerAgent::removeEventListenerBreakpoint(const String& void InspectorBrowserDebuggerAgent::didInsertDOMNode(Node* node) { - if (m_breakpoints.size()) { - uint32_t mask = m_breakpoints.get(InspectorDOMAgent::innerParentNode(node)); + if (m_domBreakpoints.size()) { + uint32_t mask = m_domBreakpoints.get(InspectorDOMAgent::innerParentNode(node)); uint32_t inheritableTypesMask = (mask | (mask >> domBreakpointDerivedTypeShift)) & inheritableDOMBreakpointTypesMask; if (inheritableTypesMask) updateSubtreeBreakpoints(node, inheritableTypesMask, true); @@ -98,16 +160,16 @@ void InspectorBrowserDebuggerAgent::didInsertDOMNode(Node* node) void InspectorBrowserDebuggerAgent::didRemoveDOMNode(Node* node) { - if (m_breakpoints.size()) { + if (m_domBreakpoints.size()) { // Remove subtree breakpoints. - m_breakpoints.remove(node); + m_domBreakpoints.remove(node); Vector<Node*> stack(1, InspectorDOMAgent::innerFirstChild(node)); do { Node* node = stack.last(); stack.removeLast(); if (!node) continue; - m_breakpoints.remove(node); + m_domBreakpoints.remove(node); stack.append(InspectorDOMAgent::innerFirstChild(node)); stack.append(InspectorDOMAgent::innerNextSibling(node)); } while (!stack.isEmpty()); @@ -116,12 +178,12 @@ void InspectorBrowserDebuggerAgent::didRemoveDOMNode(Node* node) void InspectorBrowserDebuggerAgent::setDOMBreakpoint(long nodeId, long type) { - Node* node = m_inspectorController->m_domAgent->nodeForId(nodeId); + Node* node = m_inspectorController->domAgent()->nodeForId(nodeId); if (!node) return; uint32_t rootBit = 1 << type; - m_breakpoints.set(node, m_breakpoints.get(node) | rootBit); + m_domBreakpoints.set(node, m_domBreakpoints.get(node) | rootBit); if (rootBit & inheritableDOMBreakpointTypesMask) { for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child)) updateSubtreeBreakpoints(child, rootBit, true); @@ -130,16 +192,16 @@ void InspectorBrowserDebuggerAgent::setDOMBreakpoint(long nodeId, long type) void InspectorBrowserDebuggerAgent::removeDOMBreakpoint(long nodeId, long type) { - Node* node = m_inspectorController->m_domAgent->nodeForId(nodeId); + Node* node = m_inspectorController->domAgent()->nodeForId(nodeId); if (!node) return; uint32_t rootBit = 1 << type; - uint32_t mask = m_breakpoints.get(node) & ~rootBit; + uint32_t mask = m_domBreakpoints.get(node) & ~rootBit; if (mask) - m_breakpoints.set(node, mask); + m_domBreakpoints.set(node, mask); else - m_breakpoints.remove(node); + m_domBreakpoints.remove(node); if ((rootBit & inheritableDOMBreakpointTypesMask) && !(mask & (rootBit << domBreakpointDerivedTypeShift))) { for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child)) @@ -149,7 +211,7 @@ void InspectorBrowserDebuggerAgent::removeDOMBreakpoint(long nodeId, long type) void InspectorBrowserDebuggerAgent::willInsertDOMNode(Node*, Node* parent) { - InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->debuggerAgent(); if (!debuggerAgent) return; @@ -163,7 +225,7 @@ void InspectorBrowserDebuggerAgent::willInsertDOMNode(Node*, Node* parent) void InspectorBrowserDebuggerAgent::willRemoveDOMNode(Node* node) { - InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->debuggerAgent(); if (!debuggerAgent) return; @@ -182,7 +244,7 @@ void InspectorBrowserDebuggerAgent::willRemoveDOMNode(Node* node) void InspectorBrowserDebuggerAgent::willModifyDOMAttr(Element* element) { - InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->debuggerAgent(); if (!debuggerAgent) return; @@ -202,7 +264,7 @@ void InspectorBrowserDebuggerAgent::descriptionForDOMEvent(Node* target, long br if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) { // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint. // Target node may be unknown to frontend, so we need to push it first. - long targetNodeId = m_inspectorController->m_domAgent->pushNodePathToFrontend(target); + long targetNodeId = m_inspectorController->domAgent()->pushNodePathToFrontend(target); ASSERT(targetNodeId); description->setNumber("targetNodeId", targetNodeId); @@ -210,7 +272,7 @@ void InspectorBrowserDebuggerAgent::descriptionForDOMEvent(Node* target, long br if (!insertion) breakpointOwner = InspectorDOMAgent::innerParentNode(target); ASSERT(breakpointOwner); - while (!(m_breakpoints.get(breakpointOwner) & (1 << breakpointType))) { + while (!(m_domBreakpoints.get(breakpointOwner) & (1 << breakpointType))) { breakpointOwner = InspectorDOMAgent::innerParentNode(breakpointOwner); ASSERT(breakpointOwner); } @@ -219,7 +281,7 @@ void InspectorBrowserDebuggerAgent::descriptionForDOMEvent(Node* target, long br description->setBoolean("insertion", insertion); } - long breakpointOwnerNodeId = m_inspectorController->m_domAgent->pushNodePathToFrontend(breakpointOwner); + long breakpointOwnerNodeId = m_inspectorController->domAgent()->pushNodePathToFrontend(breakpointOwner); ASSERT(breakpointOwnerNodeId); description->setNumber("nodeId", breakpointOwnerNodeId); description->setNumber("type", breakpointType); @@ -229,18 +291,18 @@ bool InspectorBrowserDebuggerAgent::hasBreakpoint(Node* node, long type) { uint32_t rootBit = 1 << type; uint32_t derivedBit = rootBit << domBreakpointDerivedTypeShift; - return m_breakpoints.get(node) & (rootBit | derivedBit); + return m_domBreakpoints.get(node) & (rootBit | derivedBit); } void InspectorBrowserDebuggerAgent::updateSubtreeBreakpoints(Node* node, uint32_t rootMask, bool set) { - uint32_t oldMask = m_breakpoints.get(node); + uint32_t oldMask = m_domBreakpoints.get(node); uint32_t derivedMask = rootMask << domBreakpointDerivedTypeShift; uint32_t newMask = set ? oldMask | derivedMask : oldMask & ~derivedMask; if (newMask) - m_breakpoints.set(node, newMask); + m_domBreakpoints.set(node, newMask); else - m_breakpoints.remove(node); + m_domBreakpoints.remove(node); uint32_t newRootMask = rootMask & ~newMask; if (!newRootMask) @@ -252,7 +314,7 @@ void InspectorBrowserDebuggerAgent::updateSubtreeBreakpoints(Node* node, uint32_ void InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous) { - InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->debuggerAgent(); if (!debuggerAgent) return; @@ -287,7 +349,7 @@ void InspectorBrowserDebuggerAgent::removeXHRBreakpoint(const String& url) void InspectorBrowserDebuggerAgent::willSendXMLHttpRequest(const String& url) { - InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->debuggerAgent(); if (!debuggerAgent) return; @@ -313,13 +375,6 @@ void InspectorBrowserDebuggerAgent::willSendXMLHttpRequest(const String& url) debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release()); } -void InspectorBrowserDebuggerAgent::clearForPageNavigation() -{ - m_eventListenerBreakpoints.clear(); - m_XHRBreakpoints.clear(); - m_hasXHRBreakpointWithEmptyURL = false; -} - } // namespace WebCore #endif // ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER) diff --git a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h index 537bda1..0ffa85c 100644 --- a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h +++ b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h @@ -46,9 +46,11 @@ namespace WebCore { class Element; class InspectorController; class InspectorObject; +class KURL; class Node; -class InspectorBrowserDebuggerAgent : public Noncopyable { +class InspectorBrowserDebuggerAgent { + WTF_MAKE_NONCOPYABLE(InspectorBrowserDebuggerAgent); public: static PassOwnPtr<InspectorBrowserDebuggerAgent> create(InspectorController* inspectorController) { @@ -57,6 +59,8 @@ public: virtual ~InspectorBrowserDebuggerAgent(); + void inspectedURLChanged(const KURL&); + // BrowserDebugger API for InspectorFrontend void setXHRBreakpoint(const String& url); void removeXHRBreakpoint(const String& url); @@ -74,17 +78,18 @@ public: void willSendXMLHttpRequest(const String& url); void pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous); - void clearForPageNavigation(); private: InspectorBrowserDebuggerAgent(InspectorController*); + void restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint); + void descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, InspectorObject* description); void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set); bool hasBreakpoint(Node*, long type); void discardBindings(); InspectorController* m_inspectorController; - HashMap<Node*, uint32_t> m_breakpoints; + HashMap<Node*, uint32_t> m_domBreakpoints; HashSet<String> m_eventListenerBreakpoints; HashSet<String> m_XHRBreakpoints; bool m_hasXHRBreakpointWithEmptyURL; diff --git a/Source/WebCore/inspector/InspectorCSSAgent.cpp b/Source/WebCore/inspector/InspectorCSSAgent.cpp index 725a26d..bacf741 100644 --- a/Source/WebCore/inspector/InspectorCSSAgent.cpp +++ b/Source/WebCore/inspector/InspectorCSSAgent.cpp @@ -349,6 +349,8 @@ void InspectorCSSAgent::addRule2(const long contextNodeId, const String& selecto return; InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(node->document(), true); + if (!inspectorStyleSheet) + return; CSSStyleRule* newRule = inspectorStyleSheet->addRule(selector); if (!newRule) return; @@ -447,8 +449,17 @@ InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen RefPtr<Element> styleElement = document->createElement("style", ec); if (!ec) styleElement->setAttribute("type", "text/css", ec); - if (!ec) - document->head()->appendChild(styleElement, ec); + if (!ec) { + ContainerNode* targetNode; + // HEAD is absent in ImageDocuments, for example. + if (document->head()) + targetNode = document->head(); + else if (document->body()) + targetNode = document->body(); + else + return 0; + targetNode->appendChild(styleElement, ec); + } if (ec) return 0; StyleSheetList* styleSheets = document->styleSheets(); diff --git a/Source/WebCore/inspector/InspectorConsoleAgent.cpp b/Source/WebCore/inspector/InspectorConsoleAgent.cpp index a543cb2..2c837f3 100644 --- a/Source/WebCore/inspector/InspectorConsoleAgent.cpp +++ b/Source/WebCore/inspector/InspectorConsoleAgent.cpp @@ -33,6 +33,7 @@ #include "InspectorController.h" #include "InspectorDOMAgent.h" #include "InspectorFrontend.h" +#include "InspectorSettings.h" #include "InspectorState.h" #include "ResourceError.h" #include "ResourceResponse.h" @@ -49,9 +50,8 @@ namespace WebCore { static const unsigned maximumConsoleMessages = 1000; static const unsigned expireConsoleMessagesStep = 100; -InspectorConsoleAgent::InspectorConsoleAgent(InspectorController* inspectorController, InspectorState* state) +InspectorConsoleAgent::InspectorConsoleAgent(InspectorController* inspectorController) : m_inspectorController(inspectorController) - , m_state(state) , m_frontend(0) , m_previousMessage(0) , m_expiredConsoleMessageCount(0) @@ -165,7 +165,7 @@ void InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest(const String& url, { if (!m_inspectorController->enabled()) return; - if (m_state->getBoolean(InspectorState::monitoringXHR)) + if (m_inspectorController->state()->getBoolean(InspectorState::monitoringXHR)) addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL); } @@ -191,11 +191,21 @@ void InspectorConsoleAgent::didFailLoading(unsigned long identifier, const Resou addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier)); } +void InspectorConsoleAgent::setMonitoringXHREnabled(bool enabled) +{ + m_inspectorController->state()->setBoolean(InspectorState::monitoringXHR, enabled); + m_inspectorController->settings()->setBoolean(InspectorSettings::MonitoringXHREnabled, enabled); + if (m_frontend) + m_frontend->monitoringXHRStateChanged(enabled); +} + void InspectorConsoleAgent::setConsoleMessagesEnabled(bool enabled) { - m_state->setBoolean(InspectorState::consoleMessagesEnabled, enabled); - if (!m_inspectorController->enabled()) + m_inspectorController->state()->setBoolean(InspectorState::consoleMessagesEnabled, enabled); + if (!enabled || !m_frontend) return; + + m_frontend->monitoringXHRStateChanged(m_inspectorController->state()->getBoolean(InspectorState::monitoringXHR)); if (m_expiredConsoleMessageCount) m_frontend->updateConsoleMessageExpiredCount(m_expiredConsoleMessageCount); unsigned messageCount = m_consoleMessages.size(); @@ -210,12 +220,12 @@ void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> console if (m_previousMessage && m_previousMessage->isEqual(consoleMessage.get())) { m_previousMessage->incrementCount(); - if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) + if (m_inspectorController->state()->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) m_previousMessage->updateRepeatCountInConsole(m_frontend); } else { m_previousMessage = consoleMessage.get(); m_consoleMessages.append(consoleMessage); - if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) + if (m_inspectorController->state()->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) m_previousMessage->addToFrontend(m_frontend, m_inspectorController->injectedScriptHost()); } diff --git a/Source/WebCore/inspector/InspectorConsoleAgent.h b/Source/WebCore/inspector/InspectorConsoleAgent.h index 97fcb3f..411f709 100644 --- a/Source/WebCore/inspector/InspectorConsoleAgent.h +++ b/Source/WebCore/inspector/InspectorConsoleAgent.h @@ -46,9 +46,10 @@ class ScriptArguments; class ScriptCallStack; class ScriptProfile; -class InspectorConsoleAgent : public Noncopyable { +class InspectorConsoleAgent { + WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent); public: - InspectorConsoleAgent(InspectorController*, InspectorState*); + InspectorConsoleAgent(InspectorController*); ~InspectorConsoleAgent(); void setConsoleMessagesEnabled(bool enabled, bool* newState); @@ -70,13 +71,13 @@ public: void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL); void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL); #endif + void setMonitoringXHREnabled(bool enabled); private: void setConsoleMessagesEnabled(bool); void addConsoleMessage(PassOwnPtr<ConsoleMessage>); InspectorController* m_inspectorController; - InspectorState* m_state; InspectorFrontend* m_frontend; ConsoleMessage* m_previousMessage; Vector<OwnPtr<ConsoleMessage> > m_consoleMessages; diff --git a/Source/WebCore/inspector/InspectorController.cpp b/Source/WebCore/inspector/InspectorController.cpp index 5a139b6..8533a5f 100644 --- a/Source/WebCore/inspector/InspectorController.cpp +++ b/Source/WebCore/inspector/InspectorController.cpp @@ -70,6 +70,7 @@ #include "InspectorInstrumentation.h" #include "InspectorProfilerAgent.h" #include "InspectorResourceAgent.h" +#include "InspectorRuntimeAgent.h" #include "InspectorSettings.h" #include "InspectorState.h" #include "InspectorTimelineAgent.h" @@ -95,6 +96,7 @@ #include "SharedBuffer.h" #include "TextEncoding.h" #include "TextIterator.h" +#include "TextRun.h" #include "UserGestureIndicator.h" #include "WindowFeatures.h" #include <wtf/text/StringConcatenate.h> @@ -140,7 +142,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client) , m_state(new InspectorState(client)) , m_inspectorBackendDispatcher(new InspectorBackendDispatcher(this)) , m_injectedScriptHost(InjectedScriptHost::create(this)) - , m_consoleAgent(new InspectorConsoleAgent(this, m_state.get())) + , m_consoleAgent(new InspectorConsoleAgent(this)) #if ENABLE(JAVASCRIPT_DEBUGGER) , m_attachDebuggerWhenShown(false) , m_profilerAgent(InspectorProfilerAgent::create(this)) @@ -156,10 +158,6 @@ InspectorController::~InspectorController() ASSERT(!m_client); ASSERT(!m_inspectedPage); ASSERT(!m_highlightedNode); - - releaseFrontendLifetimeAgents(); - - m_injectedScriptHost->disconnectController(); } void InspectorController::inspectedPageDestroyed() @@ -177,6 +175,9 @@ void InspectorController::inspectedPageDestroyed() ASSERT(m_inspectedPage); m_inspectedPage = 0; + releaseFrontendLifetimeAgents(); + m_injectedScriptHost->disconnectController(); + m_client->inspectorDestroyed(); m_client = 0; } @@ -213,15 +214,6 @@ bool InspectorController::searchingForNodeInPage() const return m_state->getBoolean(InspectorState::searchingForNode); } -void InspectorController::getInspectorState(RefPtr<InspectorObject>* state) -{ -#if ENABLE(JAVASCRIPT_DEBUGGER) - if (m_debuggerAgent) - m_state->setLong(InspectorState::pauseOnExceptionsState, m_debuggerAgent->pauseOnExceptionsState()); -#endif - *state = m_state->generateStateObjectForFrontend(); -} - void InspectorController::restoreInspectorStateFromCookie(const String& inspectorStateCookie) { m_state->restoreFromInspectorCookie(inspectorStateCookie); @@ -229,11 +221,13 @@ void InspectorController::restoreInspectorStateFromCookie(const String& inspecto if (!m_frontend) { connectFrontend(); m_frontend->frontendReused(); - m_frontend->inspectedURLChanged(m_inspectedPage->mainFrame()->loader()->url().string()); + m_frontend->inspectedURLChanged(inspectedURL().string()); m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); pushDataCollectedOffline(); } + m_resourceAgent = InspectorResourceAgent::restore(m_inspectedPage, m_state.get(), m_frontend.get()); + if (m_state->getBoolean(InspectorState::timelineProfilerEnabled)) startTimelineProfiler(); @@ -381,21 +375,13 @@ void InspectorController::setSearchingForNode(bool enabled, bool* newState) setSearchingForNode(enabled); } -void InspectorController::setMonitoringXHREnabled(bool enabled, bool* newState) -{ - *newState = enabled; - m_state->setBoolean(InspectorState::monitoringXHR, enabled); - m_settings->setBoolean(InspectorSettings::MonitoringXHREnabled, enabled); -} - void InspectorController::connectFrontend() { m_openingFrontend = false; releaseFrontendLifetimeAgents(); m_frontend = new InspectorFrontend(m_client); - m_domAgent = InspectorDOMAgent::create(m_frontend.get()); - m_resourceAgent = InspectorResourceAgent::create(m_inspectedPage, m_frontend.get()); - + m_domAgent = InspectorDOMAgent::create(m_injectedScriptHost.get(), m_frontend.get()); + m_runtimeAgent = InspectorRuntimeAgent::create(m_injectedScriptHost.get()); m_cssAgent->setDOMAgent(m_domAgent.get()); #if ENABLE(DATABASE) @@ -412,7 +398,7 @@ void InspectorController::connectFrontend() m_consoleAgent->setFrontend(m_frontend.get()); // Initialize Web Inspector title. - m_frontend->inspectedURLChanged(m_inspectedPage->mainFrame()->loader()->url().string()); + m_frontend->inspectedURLChanged(inspectedURL().string()); #if ENABLE(OFFLINE_WEB_APPLICATIONS) m_applicationCacheAgent = new InspectorApplicationCacheAgent(this, m_frontend.get()); @@ -501,9 +487,17 @@ void InspectorController::disconnectFrontend() m_extraHeaders.clear(); } +InspectorResourceAgent* InspectorController::resourceAgent() +{ + if (!m_resourceAgent && m_frontend) + m_resourceAgent = InspectorResourceAgent::create(m_inspectedPage, m_state.get(), m_frontend.get()); + return m_resourceAgent.get(); +} + void InspectorController::releaseFrontendLifetimeAgents() { m_resourceAgent.clear(); + m_runtimeAgent.clear(); // This should be invoked prior to m_domAgent destruction. m_cssAgent->setDOMAgent(0); @@ -607,7 +601,7 @@ void InspectorController::restoreProfiler(ProfilerRestoreAction action) if (!ScriptProfiler::isProfilerAlwaysEnabled() && m_settings->getBoolean(InspectorSettings::ProfilerAlwaysEnabled)) enableProfiler(); if (action == ProfilerRestoreResetAgent) - m_profilerAgent->resetState(); + m_profilerAgent->resetFrontendProfiles(); #endif } @@ -648,8 +642,7 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) if (m_debuggerAgent) { m_debuggerAgent->clearForPageNavigation(); if (m_browserDebuggerAgent) - m_browserDebuggerAgent->clearForPageNavigation(); - restoreStickyBreakpoints(); + m_browserDebuggerAgent->inspectedURLChanged(inspectedURL()); } #endif @@ -988,23 +981,11 @@ void InspectorController::didCloseWebSocket(unsigned long identifier) #endif // ENABLE(WEB_SOCKETS) #if ENABLE(JAVASCRIPT_DEBUGGER) -void InspectorController::addProfile(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL) -{ - if (!enabled()) - return; - m_profilerAgent->addProfile(prpProfile, lineNumber, sourceURL); -} - bool InspectorController::isRecordingUserInitiatedProfile() const { return m_profilerAgent->isRecordingUserInitiatedProfile(); } -String InspectorController::getCurrentUserInitiatedProfileName(bool incrementProfileNumber) -{ - return m_profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber); -} - void InspectorController::startUserInitiatedProfiling() { if (!enabled()) @@ -1067,7 +1048,7 @@ void InspectorController::enableDebugger(bool always) m_debuggerAgent = InspectorDebuggerAgent::create(this, m_frontend.get()); m_browserDebuggerAgent = InspectorBrowserDebuggerAgent::create(this); - restoreStickyBreakpoints(); + m_browserDebuggerAgent->inspectedURLChanged(inspectedURL()); m_frontend->debuggerWasEnabled(); } @@ -1097,95 +1078,12 @@ void InspectorController::resume() m_debuggerAgent->resume(); } -void InspectorController::setStickyBreakpoints(PassRefPtr<InspectorObject> breakpoints) +void InspectorController::setAllBrowserBreakpoints(PassRefPtr<InspectorObject> breakpoints) { - m_state->setObject(InspectorState::stickyBreakpoints, breakpoints); -} - -void InspectorController::restoreStickyBreakpoints() -{ - RefPtr<InspectorObject> allBreakpoints = m_state->getObject(InspectorState::stickyBreakpoints); - KURL url = m_inspectedPage->mainFrame()->loader()->url(); - url.removeFragmentIdentifier(); - RefPtr<InspectorArray> breakpoints = allBreakpoints->getArray(url); - if (!breakpoints) - return; - for (unsigned i = 0; i < breakpoints->length(); ++i) - restoreStickyBreakpoint(breakpoints->get(i)->asObject()); -} - -void InspectorController::restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint) -{ - DEFINE_STATIC_LOCAL(String, eventListenerBreakpointType, ("EventListener")); - DEFINE_STATIC_LOCAL(String, javaScriptBreakpointType, ("JS")); - DEFINE_STATIC_LOCAL(String, xhrBreakpointType, ("XHR")); - - if (!breakpoint) - return; - String type; - if (!breakpoint->getString("type", &type)) - return; - bool enabled; - if (!breakpoint->getBoolean("enabled", &enabled)) - return; - RefPtr<InspectorObject> condition = breakpoint->getObject("condition"); - if (!condition) - return; - - if (type == eventListenerBreakpointType && m_browserDebuggerAgent) { - if (!enabled) - return; - String eventName; - if (!condition->getString("eventName", &eventName)) - return; - m_browserDebuggerAgent->setEventListenerBreakpoint(eventName); - } else if (type == javaScriptBreakpointType && m_debuggerAgent) { - String url; - if (!condition->getString("url", &url)) - return; - double lineNumber; - if (!condition->getNumber("lineNumber", &lineNumber)) - return; - String javaScriptCondition; - if (!condition->getString("condition", &javaScriptCondition)) - return; - m_debuggerAgent->setStickyBreakpoint(url, static_cast<unsigned>(lineNumber), javaScriptCondition, enabled); - } else if (type == xhrBreakpointType && m_browserDebuggerAgent) { - if (!enabled) - return; - String url; - if (!condition->getString("url", &url)) - return; - m_browserDebuggerAgent->setXHRBreakpoint(url); - } + m_state->setObject(InspectorState::browserBreakpoints, breakpoints); } #endif -void InspectorController::dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException) -{ - if (!m_frontend) - return; - - // FIXME: explicitly pass injectedScriptId along with node id to the frontend. - bool injectedScriptIdIsNodeId = injectedScriptId <= 0; - - InjectedScript injectedScript; - if (injectedScriptIdIsNodeId) - injectedScript = injectedScriptForNodeId(-injectedScriptId); - else - injectedScript = injectedScriptHost()->injectedScriptForId(injectedScriptId); - - if (injectedScript.hasNoValue()) - return; - - injectedScript.dispatch(methodName, arguments, result, hadException); -} - -void InspectorController::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup) -{ - injectedScriptHost()->releaseWrapperObjectGroup(injectedScriptId, objectGroup); -} - void InspectorController::evaluateForTestInFrontend(long callId, const String& script) { if (m_frontend) @@ -1468,27 +1366,6 @@ void InspectorController::openInInspectedWindow(const String& url) newFrame->loader()->changeLocation(mainFrame->document()->securityOrigin(), newFrame->loader()->completeURL(url), "", false, false); } -InjectedScript InspectorController::injectedScriptForNodeId(long id) -{ - - Frame* frame = 0; - if (id) { - ASSERT(m_domAgent); - Node* node = m_domAgent->nodeForId(id); - if (node) { - Document* document = node->ownerDocument(); - if (document) - frame = document->frame(); - } - } else - frame = m_inspectedPage->mainFrame(); - - if (frame) - return m_injectedScriptHost->injectedScriptFor(mainWorldScriptState(frame)); - - return InjectedScript(); -} - void InspectorController::addScriptToEvaluateOnLoad(const String& source) { m_scriptsToEvaluateOnLoad.append(source); @@ -1504,6 +1381,11 @@ void InspectorController::setInspectorExtensionAPI(const String& source) m_inspectorExtensionAPI = source; } +KURL InspectorController::inspectedURL() const +{ + return m_inspectedPage->mainFrame()->loader()->url(); +} + void InspectorController::reloadPage() { // FIXME: Why do we set the user gesture indicator here? diff --git a/Source/WebCore/inspector/InspectorController.h b/Source/WebCore/inspector/InspectorController.h index 9cddc56..90a0300 100644 --- a/Source/WebCore/inspector/InspectorController.h +++ b/Source/WebCore/inspector/InspectorController.h @@ -72,6 +72,7 @@ class InspectorFrontendClient; class InspectorObject; class InspectorProfilerAgent; class InspectorResourceAgent; +class InspectorRuntimeAgent; class InspectorSettings; class InspectorState; class InspectorStorageAgent; @@ -104,7 +105,8 @@ class WebSocketHandshakeRequest; class WebSocketHandshakeResponse; #endif -class InspectorController : public Noncopyable { +class InspectorController { + WTF_MAKE_NONCOPYABLE(InspectorController); WTF_MAKE_FAST_ALLOCATED; public: static const char* const ConsolePanel; static const char* const ElementsPanel; @@ -123,6 +125,7 @@ public: bool enabled() const; Page* inspectedPage() const { return m_inspectedPage; } + KURL inspectedURL() const; void reloadPage(); void restoreInspectorStateFromCookie(const String& inspectorCookie); @@ -143,9 +146,35 @@ public: void connectFrontend(); void reuseFrontend(); void disconnectFrontend(); + InspectorFrontend* frontend() const { return m_frontend.get(); } + + InspectorResourceAgent* resourceAgent(); + + InspectorController* inspectorAgent() { return this; } + InspectorConsoleAgent* consoleAgent() { return m_consoleAgent.get(); } + InspectorCSSAgent* cssAgent() { return m_cssAgent.get(); } + InspectorDOMAgent* domAgent() { return m_domAgent.get(); } + InjectedScriptHost* injectedScriptAgent() { return m_injectedScriptHost.get(); } + InspectorRuntimeAgent* runtimeAgent() { return m_runtimeAgent.get(); } + InspectorTimelineAgent* timelineAgent() { return m_timelineAgent.get(); } +#if ENABLE(DATABASE) + InspectorDatabaseAgent* databaseAgent() { return m_databaseAgent.get(); } +#endif +#if ENABLE(DOM_STORAGE) + InspectorDOMStorageAgent* domStorageAgent() { return m_domStorageAgent.get(); } +#endif +#if ENABLE(FILE_SYSTEM) + InspectorFileSystemAgent* fileSystemAgent() { return m_fileSystemAgent.get(); } +#endif +#if ENABLE(JAVASCRIPT_DEBUGGER) + InspectorBrowserDebuggerAgent* browserDebuggerAgent() const { return m_browserDebuggerAgent.get(); } + InspectorDebuggerAgent* debuggerAgent() const { return m_debuggerAgent.get(); } + InspectorProfilerAgent* profilerAgent() const { return m_profilerAgent.get(); } +#endif +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + InspectorApplicationCacheAgent* applicationCacheAgent() { return m_applicationCacheAgent.get(); } +#endif - InspectorConsoleAgent* consoleAgent() const { return m_consoleAgent.get(); } - InspectorDOMAgent* domAgent() const { return m_domAgent.get(); } bool searchingForNodeInPage() const; void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); @@ -162,15 +191,10 @@ public: void startTimelineProfiler(); void stopTimelineProfiler(); - InspectorTimelineAgent* timelineAgent() { return m_timelineAgent.get(); } void getCookies(RefPtr<InspectorArray>* cookies, WTF::String* cookiesString); void deleteCookie(const String& cookieName, const String& domain); -#if ENABLE(OFFLINE_WEB_APPLICATIONS) - InspectorApplicationCacheAgent* applicationCacheAgent() { return m_applicationCacheAgent.get(); } -#endif - void mainResourceFiredLoadEvent(DocumentLoader*, const KURL&); void mainResourceFiredDOMContentEvent(DocumentLoader*, const KURL&); @@ -204,9 +228,7 @@ public: void drawElementTitle(GraphicsContext&, const IntRect& boundingBox, const FloatRect& overlayRect, WebCore::Settings*) const; #if ENABLE(JAVASCRIPT_DEBUGGER) - void addProfile(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL); bool isRecordingUserInitiatedProfile() const; - String getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false); void startProfiling() { startUserInitiatedProfiling(); } void startUserInitiatedProfiling(); void stopProfiling() { stopUserInitiatedProfiling(); } @@ -221,19 +243,12 @@ public: bool debuggerEnabled() const { return m_debuggerAgent; } void resume(); - void setStickyBreakpoints(PassRefPtr<InspectorObject> breakpoints); + void setAllBrowserBreakpoints(PassRefPtr<InspectorObject>); #endif - void setInjectedScriptSource(const String& source); - void dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException); - // Generic code called from custom implementations. - void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup); - void evaluateForTestInFrontend(long testCallId, const String& script); - InjectedScript injectedScriptForNodeId(long id); - void addScriptToEvaluateOnLoad(const String& source); void removeAllScriptsToEvaluateOnLoad(); void setInspectorExtensionAPI(const String& source); @@ -243,20 +258,22 @@ public: void setInspectorAttachedHeight(long height); long inspectorAttachedHeight() const; -private: - friend class InspectorBackend; - friend class InspectorBackendDispatcher; - friend class InspectorBrowserDebuggerAgent; - friend class InspectorInstrumentation; - friend class InjectedScriptHost; + InspectorState* state() { return m_state.get(); } + InspectorSettings* settings() { return m_settings.get(); } - void willSendRequest(ResourceRequest&); + // InspectorAgent API + void getInspectorState(RefPtr<InspectorObject>* state); + void setMonitoringXHREnabled(bool enabled, bool* newState); + void populateScriptObjects(); + // Following are used from InspectorBackend and internally. + void setSearchingForNode(bool enabled, bool* newState); + void didEvaluateForTestInFrontend(long callId, const String& jsonResult); + // InspectorInstrumentation API void ensureSettingsLoaded(); + void willSendRequest(ResourceRequest&); - void getInspectorState(RefPtr<InspectorObject>* state); - - void populateScriptObjects(); +private: void pushDataCollectedOffline(); void restoreDebugger(); enum ProfilerRestoreAction { @@ -267,27 +284,18 @@ private: void unbindAllResources(); void setSearchingForNode(bool enabled); - // Following are used from InspectorBackend and internally. - void setSearchingForNode(bool enabled, bool* newState); - - void setMonitoringXHREnabled(bool enabled, bool* newState); void releaseFrontendLifetimeAgents(); #if ENABLE(JAVASCRIPT_DEBUGGER) void toggleRecordButton(bool); - void restoreStickyBreakpoints(); - void restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint); #endif PassRefPtr<InspectorObject> buildObjectForCookie(const Cookie&); PassRefPtr<InspectorArray> buildArrayForCookies(ListHashSet<Cookie>&); void focusNode(); - bool isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl); - void didEvaluateForTestInFrontend(long callId, const String& jsonResult); - Page* m_inspectedPage; InspectorClient* m_client; OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient; @@ -318,6 +326,7 @@ private: RefPtr<Node> m_nodeToFocus; RefPtr<InspectorResourceAgent> m_resourceAgent; + OwnPtr<InspectorRuntimeAgent> m_runtimeAgent; #if ENABLE(DATABASE) typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap; @@ -341,7 +350,6 @@ private: bool m_attachDebuggerWhenShown; OwnPtr<InspectorDebuggerAgent> m_debuggerAgent; OwnPtr<InspectorBrowserDebuggerAgent> m_browserDebuggerAgent; - OwnPtr<InspectorProfilerAgent> m_profilerAgent; #endif OwnPtr<HTTPHeaderMap> m_extraHeaders; diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index 19ae30d..6e10f09 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -59,6 +59,7 @@ #include "FrameTree.h" #include "HTMLElement.h" #include "HTMLFrameOwnerElement.h" +#include "InjectedScriptHost.h" #include "InspectorFrontend.h" #include "MutationEvent.h" #include "Node.h" @@ -206,8 +207,9 @@ public: } -InspectorDOMAgent::InspectorDOMAgent(InspectorFrontend* frontend) +InspectorDOMAgent::InspectorDOMAgent(InjectedScriptHost* injectedScriptHost, InspectorFrontend* frontend) : EventListener(InspectorDOMAgentType) + , m_injectedScriptHost(injectedScriptHost) , m_frontend(frontend) , m_domListener(0) , m_lastNodeId(1) @@ -758,6 +760,34 @@ void InspectorDOMAgent::searchCanceled() m_searchResults.clear(); } +void InspectorDOMAgent::resolveNode(long nodeId, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = injectedScriptForNodeId(nodeId); + if (!injectedScript.hasNoValue()) + injectedScript.resolveNode(nodeId, result); +} + +void InspectorDOMAgent::getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = injectedScriptForNodeId(nodeId); + if (!injectedScript.hasNoValue()) + injectedScript.getNodeProperties(nodeId, propertiesArray, result); +} + +void InspectorDOMAgent::getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = injectedScriptForNodeId(nodeId); + if (!injectedScript.hasNoValue()) + injectedScript.getNodePrototypes(nodeId, result); +} + +void InspectorDOMAgent::pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(objectId.get()); + if (!injectedScript.hasNoValue()) + injectedScript.pushNodeToFrontend(objectId, result); +} + String InspectorDOMAgent::documentURLString(Document* document) const { if (!document || document->url().isNull()) @@ -1112,6 +1142,26 @@ void InspectorDOMAgent::pushNodeByPathToFrontend(const String& path, long* nodeI *nodeId = pushNodePathToFrontend(node); } +InjectedScript InspectorDOMAgent::injectedScriptForNodeId(long nodeId) +{ + Frame* frame = 0; + if (nodeId) { + Node* node = nodeForId(nodeId); + if (node) { + Document* document = node->ownerDocument(); + if (document) + frame = document->frame(); + } + } else + frame = mainFrameDocument()->frame(); + + if (frame) + return m_injectedScriptHost->injectedScriptFor(mainWorldScriptState(frame)); + + return InjectedScript(); +} + + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorDOMAgent.h b/Source/WebCore/inspector/InspectorDOMAgent.h index 97175fe..e4edf5d 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.h +++ b/Source/WebCore/inspector/InspectorDOMAgent.h @@ -32,6 +32,8 @@ #include "EventListener.h" #include "EventTarget.h" +#include "InjectedScript.h" +#include "InjectedScriptHost.h" #include "InspectorValues.h" #include "NodeList.h" #include "Timer.h" @@ -45,164 +47,168 @@ #include <wtf/text/AtomicString.h> namespace WebCore { - class ContainerNode; - class CSSRule; - class CSSRuleList; - class CSSStyleDeclaration; - class CSSStyleRule; - class CSSStyleSheet; - class CharacterData; - class Document; - class Element; - class Event; - class InspectorDOMAgent; - class InspectorFrontend; - class MatchJob; - class NameNodeMap; - class Node; - class Page; +class ContainerNode; +class CSSRule; +class CSSRuleList; +class CSSStyleDeclaration; +class CSSStyleRule; +class CSSStyleSheet; +class CharacterData; +class Document; +class Element; +class Event; +class InspectorDOMAgent; +class InspectorFrontend; +class MatchJob; +class NameNodeMap; +class Node; +class Page; #if ENABLE(INSPECTOR) - struct EventListenerInfo { - EventListenerInfo(Node* node, const AtomicString& eventType, const EventListenerVector& eventListenerVector) - : node(node) - , eventType(eventType) - , eventListenerVector(eventListenerVector) +struct EventListenerInfo { + EventListenerInfo(Node* node, const AtomicString& eventType, const EventListenerVector& eventListenerVector) + : node(node) + , eventType(eventType) + , eventListenerVector(eventListenerVector) + { + } + + Node* node; + const AtomicString eventType; + const EventListenerVector eventListenerVector; +}; + +class InspectorDOMAgent : public EventListener { +public: + struct DOMListener { + virtual ~DOMListener() { } - - Node* node; - const AtomicString eventType; - const EventListenerVector eventListenerVector; - }; - - class InspectorDOMAgent : public EventListener { - public: - struct DOMListener { - virtual ~DOMListener() - { - } - virtual void didRemoveDocument(Document*) = 0; - virtual void didRemoveDOMNode(Node*) = 0; - virtual void didModifyDOMAttr(Element*) = 0; - }; - - static PassRefPtr<InspectorDOMAgent> create(InspectorFrontend* frontend) - { - return adoptRef(new InspectorDOMAgent(frontend)); - } - - static const InspectorDOMAgent* cast(const EventListener* listener) - { - return listener->type() == InspectorDOMAgentType - ? static_cast<const InspectorDOMAgent*>(listener) - : 0; - } - - InspectorDOMAgent(InspectorFrontend* frontend); - ~InspectorDOMAgent(); - - void reset(); - - virtual bool operator==(const EventListener& other); - - // Methods called from the frontend for DOM nodes inspection. - void getChildNodes(long nodeId); - void setAttribute(long elementId, const String& name, const String& value, bool* success); - void removeAttribute(long elementId, const String& name, bool* success); - void removeNode(long nodeId, long* outNodeId); - void changeTagName(long nodeId, const String& tagName, long* newId); - void getOuterHTML(long nodeId, WTF::String* outerHTML); - void setOuterHTML(long nodeId, const String& outerHTML, long* newId); - void setTextNodeValue(long nodeId, const String& value, bool* success); - void getEventListenersForNode(long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray); - void addInspectedNode(long nodeId); - void performSearch(const String& whitespaceTrimmedQuery, bool runSynchronously); - void searchCanceled(); - bool shouldBreakOnNodeInsertion(Node* node, Node* parent, PassRefPtr<InspectorObject> details); - bool shouldBreakOnNodeRemoval(Node* node, PassRefPtr<InspectorObject> details); - bool shouldBreakOnAttributeModification(Element* element, PassRefPtr<InspectorObject> details); - - // Methods called from the InspectorInstrumentation. - void setDocument(Document* document); - void releaseDanglingNodes(); - - void didInsertDOMNode(Node*); - void didRemoveDOMNode(Node*); - void didModifyDOMAttr(Element*); - void characterDataModified(CharacterData*); - - Node* nodeForId(long nodeId); - long pushNodePathToFrontend(Node* node); - void pushChildNodesToFrontend(long nodeId); - void pushNodeByPathToFrontend(const String& path, long* nodeId); - long inspectedNode(unsigned long num); - void copyNode(long nodeId); - const ListHashSet<RefPtr<Document> >& documents() { return m_documents; } - void setDOMListener(DOMListener*); - - String documentURLString(Document* document) const; - - // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently. - // We also skip whitespace text nodes conditionally. Following methods encapsulate these specifics. - static Node* innerFirstChild(Node*); - static Node* innerNextSibling(Node*); - static Node* innerPreviousSibling(Node*); - static unsigned innerChildNodeCount(Node*); - static Node* innerParentNode(Node*); - static bool isWhitespace(Node*); - - private: - void startListeningFrameDocument(Node* frameOwnerNode); - void startListening(Document* document); - void stopListening(Document* document); - - virtual void handleEvent(ScriptExecutionContext*, Event* event); - - // Node-related methods. - typedef HashMap<RefPtr<Node>, long> NodeToIdMap; - long bind(Node* node, NodeToIdMap* nodesMap); - void unbind(Node* node, NodeToIdMap* nodesMap); - - bool pushDocumentToFrontend(); - - bool hasBreakpoint(Node* node, long type); - void updateSubtreeBreakpoints(Node* root, uint32_t rootMask, bool value); - void descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, PassRefPtr<InspectorObject> description); - - PassRefPtr<InspectorObject> buildObjectForNode(Node* node, int depth, NodeToIdMap* nodesMap); - PassRefPtr<InspectorArray> buildArrayForElementAttributes(Element* element); - PassRefPtr<InspectorArray> buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap); - PassRefPtr<InspectorObject> buildObjectForEventListener(const RegisteredEventListener& registeredEventListener, const AtomicString& eventType, Node* node); - - Document* mainFrameDocument() const; - - void onMatchJobsTimer(Timer<InspectorDOMAgent>*); - void reportNodesAsSearchResults(ListHashSet<Node*>& resultCollector); - - Node* nodeForPath(const String& path); - PassRefPtr<InspectorArray> toArray(const Vector<String>& data); - - void discardBindings(); - - InspectorFrontend* m_frontend; - DOMListener* m_domListener; - NodeToIdMap m_documentNodeToIdMap; - // Owns node mappings for dangling nodes. - Vector<NodeToIdMap*> m_danglingNodeToIdMaps; - HashMap<long, Node*> m_idToNode; - HashMap<long, NodeToIdMap*> m_idToNodesMap; - HashSet<long> m_childrenRequested; - long m_lastNodeId; - ListHashSet<RefPtr<Document> > m_documents; - Deque<MatchJob*> m_pendingMatchJobs; - Timer<InspectorDOMAgent> m_matchJobsTimer; - HashSet<RefPtr<Node> > m_searchResults; - Vector<long> m_inspectedNodes; + virtual void didRemoveDocument(Document*) = 0; + virtual void didRemoveDOMNode(Node*) = 0; + virtual void didModifyDOMAttr(Element*) = 0; }; -#endif + static PassRefPtr<InspectorDOMAgent> create(InjectedScriptHost* injectedScriptHost, InspectorFrontend* frontend) + { + return adoptRef(new InspectorDOMAgent(injectedScriptHost, frontend)); + } + + static const InspectorDOMAgent* cast(const EventListener* listener) + { + return listener->type() == InspectorDOMAgentType + ? static_cast<const InspectorDOMAgent*>(listener) + : 0; + } + + InspectorDOMAgent(InjectedScriptHost*, InspectorFrontend*); + ~InspectorDOMAgent(); + + void reset(); + + virtual bool operator==(const EventListener& other); + + // Methods called from the frontend for DOM nodes inspection. + void getChildNodes(long nodeId); + void setAttribute(long elementId, const String& name, const String& value, bool* success); + void removeAttribute(long elementId, const String& name, bool* success); + void removeNode(long nodeId, long* outNodeId); + void changeTagName(long nodeId, const String& tagName, long* newId); + void getOuterHTML(long nodeId, WTF::String* outerHTML); + void setOuterHTML(long nodeId, const String& outerHTML, long* newId); + void setTextNodeValue(long nodeId, const String& value, bool* success); + void getEventListenersForNode(long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray); + void addInspectedNode(long nodeId); + void performSearch(const String& whitespaceTrimmedQuery, bool runSynchronously); + void searchCanceled(); + void resolveNode(long nodeId, RefPtr<InspectorValue>* result); + void getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result); + void getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result); + void pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, RefPtr<InspectorValue>* result); + + // Methods called from the InspectorInstrumentation. + void setDocument(Document*); + void releaseDanglingNodes(); + + void didInsertDOMNode(Node*); + void didRemoveDOMNode(Node*); + void didModifyDOMAttr(Element*); + void characterDataModified(CharacterData*); + + Node* nodeForId(long nodeId); + long pushNodePathToFrontend(Node*); + void pushChildNodesToFrontend(long nodeId); + void pushNodeByPathToFrontend(const String& path, long* nodeId); + long inspectedNode(unsigned long num); + void copyNode(long nodeId); + const ListHashSet<RefPtr<Document> >& documents() { return m_documents; } + void setDOMListener(DOMListener*); + + String documentURLString(Document*) const; + + // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently. + // We also skip whitespace text nodes conditionally. Following methods encapsulate these specifics. + static Node* innerFirstChild(Node*); + static Node* innerNextSibling(Node*); + static Node* innerPreviousSibling(Node*); + static unsigned innerChildNodeCount(Node*); + static Node* innerParentNode(Node*); + static bool isWhitespace(Node*); + +private: + void startListeningFrameDocument(Node* frameOwnerNode); + void startListening(Document*); + void stopListening(Document*); + + virtual void handleEvent(ScriptExecutionContext*, Event*); + + // Node-related methods. + typedef HashMap<RefPtr<Node>, long> NodeToIdMap; + long bind(Node*, NodeToIdMap*); + void unbind(Node*, NodeToIdMap*); + + bool pushDocumentToFrontend(); + + bool hasBreakpoint(Node*, long type); + void updateSubtreeBreakpoints(Node* root, uint32_t rootMask, bool value); + void descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, PassRefPtr<InspectorObject> description); + + PassRefPtr<InspectorObject> buildObjectForNode(Node*, int depth, NodeToIdMap*); + PassRefPtr<InspectorArray> buildArrayForElementAttributes(Element*); + PassRefPtr<InspectorArray> buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap); + PassRefPtr<InspectorObject> buildObjectForEventListener(const RegisteredEventListener&, const AtomicString& eventType, Node*); + + Document* mainFrameDocument() const; + + void onMatchJobsTimer(Timer<InspectorDOMAgent>*); + void reportNodesAsSearchResults(ListHashSet<Node*>& resultCollector); + + Node* nodeForPath(const String& path); + PassRefPtr<InspectorArray> toArray(const Vector<String>& data); + + void discardBindings(); + + InjectedScript injectedScriptForNodeId(long nodeId); + + InjectedScriptHost* m_injectedScriptHost; + InspectorFrontend* m_frontend; + DOMListener* m_domListener; + NodeToIdMap m_documentNodeToIdMap; + // Owns node mappings for dangling nodes. + Vector<NodeToIdMap*> m_danglingNodeToIdMaps; + HashMap<long, Node*> m_idToNode; + HashMap<long, NodeToIdMap*> m_idToNodesMap; + HashSet<long> m_childrenRequested; + long m_lastNodeId; + ListHashSet<RefPtr<Document> > m_documents; + Deque<MatchJob*> m_pendingMatchJobs; + Timer<InspectorDOMAgent> m_matchJobsTimer; + HashSet<RefPtr<Node> > m_searchResults; + Vector<long> m_inspectedNodes; +}; + +#endif // ENABLE(INSPECTOR) } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorDebuggerAgent.cpp b/Source/WebCore/inspector/InspectorDebuggerAgent.cpp index 82c250a..acfbb6e 100644 --- a/Source/WebCore/inspector/InspectorDebuggerAgent.cpp +++ b/Source/WebCore/inspector/InspectorDebuggerAgent.cpp @@ -173,9 +173,18 @@ void InspectorDebuggerAgent::setPauseOnExceptionsState(long pauseState, long* ne *newState = ScriptDebugServer::shared().pauseOnExceptionsState(); } -long InspectorDebuggerAgent::pauseOnExceptionsState() +void InspectorDebuggerAgent::evaluateOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) { - return ScriptDebugServer::shared().pauseOnExceptionsState(); + InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptForObjectId(callFrameId.get()); + if (!injectedScript.hasNoValue()) + injectedScript.evaluateOnCallFrame(callFrameId, expression, objectGroup, result); +} + +void InspectorDebuggerAgent::getCompletionsOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptForObjectId(callFrameId.get()); + if (!injectedScript.hasNoValue()) + injectedScript.getCompletionsOnCallFrame(callFrameId, expression, includeInspectorCommandLineAPI, result); } void InspectorDebuggerAgent::clearForPageNavigation() @@ -202,7 +211,7 @@ PassRefPtr<InspectorValue> InspectorDebuggerAgent::currentCallFrames() void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String& url, const String& data, int lineOffset, int columnOffset, ScriptWorldType worldType) { // Don't send script content to the front end until it's really needed. - m_frontend->parsedScriptSource(sourceID, url, lineOffset, columnOffset, worldType); + m_frontend->parsedScriptSource(sourceID, url, lineOffset, columnOffset, data.length(), worldType); m_scriptIDToContent.set(sourceID, data); diff --git a/Source/WebCore/inspector/InspectorDebuggerAgent.h b/Source/WebCore/inspector/InspectorDebuggerAgent.h index 07d2ab9..4cb9f9c 100644 --- a/Source/WebCore/inspector/InspectorDebuggerAgent.h +++ b/Source/WebCore/inspector/InspectorDebuggerAgent.h @@ -31,6 +31,7 @@ #define InspectorDebuggerAgent_h #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) +#include "InjectedScript.h" #include "ScriptDebugListener.h" #include "ScriptState.h" #include <wtf/Forward.h> @@ -52,22 +53,22 @@ enum DebuggerEventType { NativeBreakpointDebuggerEventType }; -class InspectorDebuggerAgent : public ScriptDebugListener, public Noncopyable { +class InspectorDebuggerAgent : public ScriptDebugListener { + WTF_MAKE_NONCOPYABLE(InspectorDebuggerAgent); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<InspectorDebuggerAgent> create(InspectorController*, InspectorFrontend*); virtual ~InspectorDebuggerAgent(); static bool isDebuggerAlwaysEnabled(); + // Part of the protocol. void activateBreakpoints(); void deactivateBreakpoints(); void setStickyBreakpoint(const String& url, unsigned lineNumber, const String& condition, bool enabled); void setBreakpoint(const String& sourceID, unsigned lineNumber, const String& condition, bool enabled, String* breakpointId, unsigned int* actualLineNumber); void removeBreakpoint(const String& breakpointId); - void editScriptSource(const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames); void getScriptSource(const String& sourceID, String* scriptSource); - void schedulePauseOnNextStatement(DebuggerEventType type, PassRefPtr<InspectorValue> data); void cancelPauseOnNextStatement(); void breakProgram(DebuggerEventType type, PassRefPtr<InspectorValue> data); @@ -76,9 +77,9 @@ public: void stepOver(); void stepInto(); void stepOut(); - void setPauseOnExceptionsState(long pauseState, long* newState); - long pauseOnExceptionsState(); + void evaluateOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); + void getCompletionsOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result); void clearForPageNavigation(); diff --git a/Source/WebCore/inspector/InspectorFrontendClientLocal.h b/Source/WebCore/inspector/InspectorFrontendClientLocal.h index 9dcaa5a..19f6ad1 100644 --- a/Source/WebCore/inspector/InspectorFrontendClientLocal.h +++ b/Source/WebCore/inspector/InspectorFrontendClientLocal.h @@ -41,7 +41,8 @@ class InspectorController; class InspectorFrontendHost; class Page; -class InspectorFrontendClientLocal : public InspectorFrontendClient, public Noncopyable { +class InspectorFrontendClientLocal : public InspectorFrontendClient { + WTF_MAKE_NONCOPYABLE(InspectorFrontendClientLocal); WTF_MAKE_FAST_ALLOCATED; public: InspectorFrontendClientLocal(InspectorController*, Page*); virtual ~InspectorFrontendClientLocal(); diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp index aa941df..9ae97be 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.cpp +++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp @@ -93,17 +93,17 @@ void InspectorInstrumentation::inspectedPageDestroyedImpl(InspectorController* i void InspectorInstrumentation::willInsertDOMNodeImpl(InspectorController* inspectorController, Node* node, Node* parent) { #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->browserDebuggerAgent()) browserDebuggerAgent->willInsertDOMNode(node, parent); #endif } void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspectorController, Node* node) { - if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get()) + if (InspectorDOMAgent* domAgent = inspectorController->domAgent()) domAgent->didInsertDOMNode(node); #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->browserDebuggerAgent()) browserDebuggerAgent->didInsertDOMNode(node); #endif } @@ -111,7 +111,7 @@ void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspect void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node) { #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->browserDebuggerAgent()) browserDebuggerAgent->willRemoveDOMNode(node); #endif } @@ -119,24 +119,24 @@ void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspec void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node) { #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->browserDebuggerAgent()) browserDebuggerAgent->didRemoveDOMNode(node); #endif - if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get()) + if (InspectorDOMAgent* domAgent = inspectorController->domAgent()) domAgent->didRemoveDOMNode(node); } void InspectorInstrumentation::willModifyDOMAttrImpl(InspectorController* inspectorController, Element* element) { #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->browserDebuggerAgent()) browserDebuggerAgent->willModifyDOMAttr(element); #endif } void InspectorInstrumentation::didModifyDOMAttrImpl(InspectorController* inspectorController, Element* element) { - if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get()) + if (InspectorDOMAgent* domAgent = inspectorController->domAgent()) domAgent->didModifyDOMAttr(element); } @@ -152,14 +152,14 @@ bool InspectorInstrumentation::handleMousePressImpl(InspectorController* inspect void InspectorInstrumentation::characterDataModifiedImpl(InspectorController* inspectorController, CharacterData* characterData) { - if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get()) + if (InspectorDOMAgent* domAgent = inspectorController->domAgent()) domAgent->characterDataModified(characterData); } void InspectorInstrumentation::willSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url) { #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->browserDebuggerAgent()) browserDebuggerAgent->willSendXMLHttpRequest(url); #endif } @@ -433,7 +433,7 @@ void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorIns InspectorController* ic = cookie.first; if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) resourceAgent->didReceiveResponse(identifier, loader, response); - ic->m_consoleAgent->didReceiveResponse(identifier, response); + ic->consoleAgent()->didReceiveResponse(identifier, response); if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie)) timelineAgent->didReceiveResourceResponse(); } @@ -454,7 +454,7 @@ void InspectorInstrumentation::didFinishLoadingImpl(InspectorController* ic, uns void InspectorInstrumentation::didFailLoadingImpl(InspectorController* ic, unsigned long identifier, const ResourceError& error) { - ic->m_consoleAgent->didFailLoading(identifier, error); + ic->consoleAgent()->didFailLoading(identifier, error); if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(ic)) timelineAgent->didFinishLoadingResource(identifier, true, 0); if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) @@ -463,7 +463,7 @@ void InspectorInstrumentation::didFailLoadingImpl(InspectorController* ic, unsig void InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl(InspectorController* ic, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber) { - ic->m_consoleAgent->resourceRetrievedByXMLHttpRequest(url, sendURL, sendLineNumber); + ic->consoleAgent()->resourceRetrievedByXMLHttpRequest(url, sendURL, sendLineNumber); if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) resourceAgent->setInitialContent(identifier, sourceString, "XHR"); } @@ -549,9 +549,36 @@ void InspectorInstrumentation::consoleMarkTimelineImpl(InspectorController* insp #if ENABLE(JAVASCRIPT_DEBUGGER) void InspectorInstrumentation::addStartProfilingMessageToConsoleImpl(InspectorController* inspectorController, const String& title, unsigned lineNumber, const String& sourceURL) { - if (InspectorProfilerAgent* profilerAgent = inspectorController->m_profilerAgent.get()) + if (InspectorProfilerAgent* profilerAgent = inspectorController->profilerAgent()) profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, sourceURL); } + +void InspectorInstrumentation::addProfileImpl(InspectorController* inspectorController, RefPtr<ScriptProfile> profile, ScriptCallStack* callStack) +{ + if (InspectorProfilerAgent* profilerAgent = inspectorController->profilerAgent()) { + const ScriptCallFrame& lastCaller = callStack->at(0); + profilerAgent->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL()); + } +} + +bool InspectorInstrumentation::profilerEnabledImpl(InspectorController* inspectorController) +{ + if (!inspectorController->enabled()) + return false; + + InspectorProfilerAgent* profilerAgent = inspectorController->profilerAgent(); + if (!profilerAgent) + return false; + + return profilerAgent->enabled(); +} + +String InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(InspectorController* inspectorController, bool incrementProfileNumber) +{ + if (InspectorProfilerAgent* profilerAgent = inspectorController->profilerAgent()) + return profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber); + return ""; +} #endif #if ENABLE(DATABASE) @@ -624,7 +651,7 @@ bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorControl void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InspectorController* inspectorController, const String& categoryType, const String& eventName, bool synchronous) { #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->browserDebuggerAgent()) browserDebuggerAgent->pauseOnNativeEventIfNeeded(categoryType, eventName, synchronous); #endif } @@ -632,14 +659,14 @@ void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InspectorController* i void InspectorInstrumentation::cancelPauseOnNativeEvent(InspectorController* inspectorController) { #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get()) + if (InspectorDebuggerAgent* debuggerAgent = inspectorController->debuggerAgent()) debuggerAgent->cancelPauseOnNextStatement(); #endif } InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(InspectorController* inspectorController) { - return inspectorController->m_timelineAgent.get(); + return inspectorController->timelineAgent(); } InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const InspectorInstrumentationCookie& cookie) @@ -652,7 +679,7 @@ InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const In InspectorResourceAgent* InspectorInstrumentation::retrieveResourceAgent(InspectorController* ic) { - return ic->m_resourceAgent.get(); + return ic->resourceAgent(); } } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h index 28867cb..7a7ee43 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.h +++ b/Source/WebCore/inspector/InspectorInstrumentation.h @@ -139,6 +139,9 @@ public: #if ENABLE(JAVASCRIPT_DEBUGGER) static void addStartProfilingMessageToConsole(Page*, const String& title, unsigned lineNumber, const String& sourceURL); + static void addProfile(Page*, RefPtr<ScriptProfile>, ScriptCallStack*); + static bool profilerEnabled(Page*); + static String getCurrentUserInitiatedProfileName(Page*, bool incrementProfileNumber); #endif #if ENABLE(DATABASE) @@ -246,6 +249,9 @@ private: #if ENABLE(JAVASCRIPT_DEBUGGER) static void addStartProfilingMessageToConsoleImpl(InspectorController*, const String& title, unsigned lineNumber, const String& sourceURL); + static void addProfileImpl(InspectorController*, RefPtr<ScriptProfile>, ScriptCallStack*); + static bool profilerEnabledImpl(InspectorController*); + static String getCurrentUserInitiatedProfileNameImpl(InspectorController*, bool incrementProfileNumber); #endif #if ENABLE(DATABASE) @@ -881,6 +887,32 @@ inline void InspectorInstrumentation::addStartProfilingMessageToConsole(Page* pa addStartProfilingMessageToConsoleImpl(inspectorController, title, lineNumber, sourceURL); #endif } + +inline void InspectorInstrumentation::addProfile(Page* page, RefPtr<ScriptProfile> profile, ScriptCallStack* callStack) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + addProfileImpl(inspectorController, profile, callStack); +#endif +} + +inline bool InspectorInstrumentation::profilerEnabled(Page* page) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + return profilerEnabledImpl(inspectorController); +#endif + return false; +} + +inline String InspectorInstrumentation::getCurrentUserInitiatedProfileName(Page* page, bool incrementProfileNumber) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + return InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(inspectorController, incrementProfileNumber); +#endif + return ""; +} #endif #if ENABLE(INSPECTOR) @@ -936,6 +968,7 @@ inline InspectorController* InspectorInstrumentation::inspectorControllerWithFro } return 0; } + #endif } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorProfilerAgent.cpp b/Source/WebCore/inspector/InspectorProfilerAgent.cpp index da9b67d..8c4f28f 100644 --- a/Source/WebCore/inspector/InspectorProfilerAgent.cpp +++ b/Source/WebCore/inspector/InspectorProfilerAgent.cpp @@ -88,6 +88,8 @@ void InspectorProfilerAgent::addProfile(PassRefPtr<ScriptProfile> prpProfile, un void InspectorProfilerAgent::addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL) { + if (!m_frontend) + return; RefPtr<ScriptProfile> profile = prpProfile; String title = profile->title(); String message = makeString("Profile \"webkit-profile://", CPUProfileType, '/', encodeWithURLEscapeSequences(title), '#', String::number(profile->uid()), "\" finished."); @@ -96,6 +98,8 @@ void InspectorProfilerAgent::addProfileFinishedMessageToConsole(PassRefPtr<Scrip void InspectorProfilerAgent::addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL) { + if (!m_frontend) + return; String message = makeString("Profile \"webkit-profile://", CPUProfileType, '/', encodeWithURLEscapeSequences(title), "#0\" started."); m_inspectorController->consoleAgent()->addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); } @@ -211,7 +215,12 @@ void InspectorProfilerAgent::resetState() m_currentUserInitiatedProfileNumber = 1; m_nextUserInitiatedProfileNumber = 1; m_nextUserInitiatedHeapSnapshotNumber = 1; - if (m_frontend) + resetFrontendProfiles(); +} + +void InspectorProfilerAgent::resetFrontendProfiles() +{ + if (m_frontend && m_profiles.begin() == m_profiles.end()) m_frontend->resetProfiles(); } diff --git a/Source/WebCore/inspector/InspectorProfilerAgent.h b/Source/WebCore/inspector/InspectorProfilerAgent.h index e67848d..436ae51 100644 --- a/Source/WebCore/inspector/InspectorProfilerAgent.h +++ b/Source/WebCore/inspector/InspectorProfilerAgent.h @@ -47,7 +47,8 @@ class InspectorObject; class ScriptHeapSnapshot; class ScriptProfile; -class InspectorProfilerAgent : public Noncopyable { +class InspectorProfilerAgent { + WTF_MAKE_NONCOPYABLE(InspectorProfilerAgent); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<InspectorProfilerAgent> create(InspectorController*); virtual ~InspectorProfilerAgent(); @@ -65,6 +66,7 @@ public: bool isRecordingUserInitiatedProfile() { return m_recordingUserInitiatedProfile; } void removeProfile(const String& type, unsigned uid); void resetState(); + void resetFrontendProfiles(); void setFrontend(InspectorFrontend* frontend) { m_frontend = frontend; } void startUserInitiatedProfiling(); void stopUserInitiatedProfiling(bool ignoreProfile = false); diff --git a/Source/WebCore/inspector/InspectorResourceAgent.cpp b/Source/WebCore/inspector/InspectorResourceAgent.cpp index 6779790..029c79d 100644 --- a/Source/WebCore/inspector/InspectorResourceAgent.cpp +++ b/Source/WebCore/inspector/InspectorResourceAgent.cpp @@ -45,6 +45,7 @@ #include "HTMLNames.h" #include "HTTPHeaderMap.h" #include "InspectorFrontend.h" +#include "InspectorState.h" #include "InspectorValues.h" #include "KURL.h" #include "Page.h" @@ -66,6 +67,13 @@ namespace WebCore { +PassRefPtr<InspectorResourceAgent> InspectorResourceAgent::restore(Page* page, InspectorState* state, InspectorFrontend* frontend) +{ + if (state->getBoolean(InspectorState::resourceAgentEnabled)) + return create(page, state, frontend); + return 0; +} + bool InspectorResourceAgent::resourceContent(Frame* frame, const KURL& url, String* result) { if (!frame) @@ -281,6 +289,7 @@ static void populateObjectWithFrameResources(Frame* frame, PassRefPtr<InspectorO InspectorResourceAgent::~InspectorResourceAgent() { + m_state->setBoolean(InspectorState::resourceAgentEnabled, false); } void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader) @@ -476,10 +485,12 @@ void InspectorResourceAgent::resourceContent(unsigned long id, const String& url } } -InspectorResourceAgent::InspectorResourceAgent(Page* page, InspectorFrontend* frontend) +InspectorResourceAgent::InspectorResourceAgent(Page* page, InspectorState* state, InspectorFrontend* frontend) : m_page(page) + , m_state(state) , m_frontend(frontend) { + m_state->setBoolean(InspectorState::resourceAgentEnabled, true); } } // namespace WebCore diff --git a/Source/WebCore/inspector/InspectorResourceAgent.h b/Source/WebCore/inspector/InspectorResourceAgent.h index 1e77d58..6c2df24 100644 --- a/Source/WebCore/inspector/InspectorResourceAgent.h +++ b/Source/WebCore/inspector/InspectorResourceAgent.h @@ -49,8 +49,9 @@ class Document; class DocumentLoader; class Frame; class InspectorArray; -class InspectorObject; class InspectorFrontend; +class InspectorObject; +class InspectorState; class KURL; class Page; class ResourceError; @@ -65,11 +66,13 @@ class WebSocketHandshakeResponse; class InspectorResourceAgent : public RefCounted<InspectorResourceAgent> { public: - static PassRefPtr<InspectorResourceAgent> create(Page* page, InspectorFrontend* frontend) + static PassRefPtr<InspectorResourceAgent> create(Page* page, InspectorState* state, InspectorFrontend* frontend) { - return adoptRef(new InspectorResourceAgent(page, frontend)); + return adoptRef(new InspectorResourceAgent(page, state, frontend)); } + static PassRefPtr<InspectorResourceAgent> restore(Page*, InspectorState*, InspectorFrontend*); + static bool resourceContent(Frame*, const KURL&, String* result); static bool resourceContentBase64(Frame*, const KURL&, String* result); static PassRefPtr<SharedBuffer> resourceData(Frame*, const KURL&, String* textEncodingName); @@ -103,9 +106,10 @@ public: void resourceContent(unsigned long frameID, const String& url, bool base64Encode, String* content); private: - InspectorResourceAgent(Page* page, InspectorFrontend* frontend); + InspectorResourceAgent(Page* page, InspectorState*, InspectorFrontend* frontend); Page* m_page; + InspectorState* m_state; InspectorFrontend* m_frontend; }; diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.cpp b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp new file mode 100644 index 0000000..0502437 --- /dev/null +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2011 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 "InspectorRuntimeAgent.h" + +#if ENABLE(INSPECTOR) + +#include "InjectedScriptHost.h" +#include "InspectorValues.h" + +namespace WebCore { + +InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptHost* injectedScriptHost) + : m_injectedScriptHost(injectedScriptHost) +{ +} + +InspectorRuntimeAgent::~InspectorRuntimeAgent() { } + +void InspectorRuntimeAgent::evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForMainFrame(); + if (!injectedScript.hasNoValue()) + injectedScript.evaluate(expression, objectGroup, result); +} + +void InspectorRuntimeAgent::getCompletions(const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForMainFrame(); + if (!injectedScript.hasNoValue()) + injectedScript.getCompletions(expression, includeInspectorCommandLineAPI, result); +} + +void InspectorRuntimeAgent::getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(objectId.get()); + if (!injectedScript.hasNoValue()) + injectedScript.getProperties(objectId, ignoreHasOwnProperty, abbreviate, result); +} + +void InspectorRuntimeAgent::setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result) +{ + InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(objectId.get()); + if (!injectedScript.hasNoValue()) + injectedScript.setPropertyValue(objectId, propertyName, expression, result); +} + +void InspectorRuntimeAgent::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup) +{ + m_injectedScriptHost->releaseWrapperObjectGroup(injectedScriptId, objectGroup); +} + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.h b/Source/WebCore/inspector/InspectorRuntimeAgent.h new file mode 100644 index 0000000..3ac2eed --- /dev/null +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011 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 InspectorRuntimeAgent_h +#define InspectorRuntimeAgent_h + +#if ENABLE(INSPECTOR) + +#include "InjectedScript.h" +#include "PlatformString.h" + +#include <wtf/Noncopyable.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class InjectedScriptHost; +class InspectorObject; +class InspectorValue; + +class InspectorRuntimeAgent { + WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent); +public: + static PassOwnPtr<InspectorRuntimeAgent> create(InjectedScriptHost* injectedScriptHost) + { + return adoptPtr(new InspectorRuntimeAgent(injectedScriptHost)); + } + + ~InspectorRuntimeAgent(); + + // Part of the protocol. + void evaluate(const String& expression, const String& objectGroup, RefPtr<InspectorValue>* result); + void getCompletions(const String& expression, bool includeInspectorCommandLineAPI, RefPtr<InspectorValue>* result); + void getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result); + void setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result); + void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup); + +private: + InspectorRuntimeAgent(InjectedScriptHost*); + + InjectedScriptHost* m_injectedScriptHost; +}; + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) +#endif // InspectorRuntimeAgent_h diff --git a/Source/WebCore/inspector/InspectorState.cpp b/Source/WebCore/inspector/InspectorState.cpp index 1b74518..dba9e4d 100644 --- a/Source/WebCore/inspector/InspectorState.cpp +++ b/Source/WebCore/inspector/InspectorState.cpp @@ -39,15 +39,13 @@ InspectorState::InspectorState(InspectorClient* client) : m_client(client) { // Pure reload state - registerBoolean(userInitiatedProfiling, false, String()); - registerBoolean(timelineProfilerEnabled, false, String()); - registerBoolean(searchingForNode, false, String()); - registerObject(stickyBreakpoints, String()); - - // Should go away - registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled"); - registerBoolean(monitoringXHR, false, "monitoringXHREnabled"); - registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState"); + registerBoolean(userInitiatedProfiling, false); + registerBoolean(timelineProfilerEnabled, false); + registerBoolean(searchingForNode, false); + registerObject(browserBreakpoints); + registerBoolean(consoleMessagesEnabled, false); + registerBoolean(monitoringXHR, false); + registerBoolean(resourceAgentEnabled, false); } void InspectorState::restoreFromInspectorCookie(const String& json) @@ -70,16 +68,6 @@ void InspectorState::restoreFromInspectorCookie(const String& json) } } -PassRefPtr<InspectorObject> InspectorState::generateStateObjectForFrontend() -{ - RefPtr<InspectorObject> stateObject = InspectorObject::create(); - for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i) { - if (i->second.m_frontendAlias.length()) - stateObject->setValue(i->second.m_frontendAlias, i->second.m_value); - } - return stateObject.release(); -} - void InspectorState::updateCookie() { RefPtr<InspectorObject> cookieObject = InspectorObject::create(); @@ -139,31 +127,30 @@ void InspectorState::setObject(InspectorPropertyId id, PassRefPtr<InspectorObjec updateCookie(); } -void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias) +void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value) { - m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value), frontendAlias)); + m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value))); } -void InspectorState::registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias) +void InspectorState::registerString(InspectorPropertyId propertyId, const String& value) { - m_properties.set(propertyId, Property::create(InspectorString::create(value), frontendAlias)); + m_properties.set(propertyId, Property::create(InspectorString::create(value))); } -void InspectorState::registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias) +void InspectorState::registerLong(InspectorPropertyId propertyId, long value) { - m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias)); + m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value))); } -void InspectorState::registerObject(InspectorPropertyId propertyId, const String& frontendAlias) +void InspectorState::registerObject(InspectorPropertyId propertyId) { - m_properties.set(propertyId, Property::create(InspectorObject::create(), frontendAlias)); + m_properties.set(propertyId, Property::create(InspectorObject::create())); } -InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value, const String& frontendAlias) +InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value) { Property property; property.m_value = value; - property.m_frontendAlias = frontendAlias; return property; } diff --git a/Source/WebCore/inspector/InspectorState.h b/Source/WebCore/inspector/InspectorState.h index 3142c92..6e12673 100644 --- a/Source/WebCore/inspector/InspectorState.h +++ b/Source/WebCore/inspector/InspectorState.h @@ -47,45 +47,42 @@ public: monitoringXHR = 1, timelineProfilerEnabled, searchingForNode, - pauseOnExceptionsState, consoleMessagesEnabled, userInitiatedProfiling, - stickyBreakpoints, + browserBreakpoints, + resourceAgentEnabled, lastPropertyId }; InspectorState(InspectorClient* client); - PassRefPtr<InspectorObject> generateStateObjectForFrontend(); void restoreFromInspectorCookie(const String& jsonString); - String getFrontendAlias(InspectorPropertyId propertyId); - bool getBoolean(InspectorPropertyId propertyId); - String getString(InspectorPropertyId propertyId); - long getLong(InspectorPropertyId propertyId); - PassRefPtr<InspectorObject> getObject(InspectorPropertyId id); + bool getBoolean(InspectorPropertyId); + String getString(InspectorPropertyId); + long getLong(InspectorPropertyId); + PassRefPtr<InspectorObject> getObject(InspectorPropertyId); void setBoolean(InspectorPropertyId propertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value)); } void setString(InspectorPropertyId propertyId, const String& value) { setValue(propertyId, InspectorString::create(value)); } void setLong(InspectorPropertyId propertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value)); } - void setObject(InspectorPropertyId propertyId, PassRefPtr<InspectorObject> value); + void setObject(InspectorPropertyId, PassRefPtr<InspectorObject> value); private: void updateCookie(); - void setValue(InspectorPropertyId propertyId, PassRefPtr<InspectorValue> value); + void setValue(InspectorPropertyId, PassRefPtr<InspectorValue>); struct Property { - static Property create(PassRefPtr<InspectorValue> value, const String& frontendAlias); - String m_frontendAlias; + static Property create(PassRefPtr<InspectorValue> value); RefPtr<InspectorValue> m_value; }; typedef HashMap<long, Property> PropertyMap; PropertyMap m_properties; - void registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias); - void registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias); - void registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias); - void registerObject(InspectorPropertyId propertyId, const String& frontendAlias); + void registerBoolean(InspectorPropertyId, bool value); + void registerString(InspectorPropertyId, const String& value); + void registerLong(InspectorPropertyId, long value); + void registerObject(InspectorPropertyId); InspectorClient* m_client; }; diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.h b/Source/WebCore/inspector/InspectorTimelineAgent.h index 33e2737..cae5aad 100644 --- a/Source/WebCore/inspector/InspectorTimelineAgent.h +++ b/Source/WebCore/inspector/InspectorTimelineAgent.h @@ -70,7 +70,8 @@ enum TimelineRecordType { ScheduleResourceRequestTimelineRecordType = 20 }; -class InspectorTimelineAgent : ScriptGCEventListener, public Noncopyable { +class InspectorTimelineAgent : ScriptGCEventListener { + WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent); WTF_MAKE_FAST_ALLOCATED; public: InspectorTimelineAgent(InspectorFrontend* frontend); ~InspectorTimelineAgent(); diff --git a/Source/WebCore/inspector/InspectorValues.cpp b/Source/WebCore/inspector/InspectorValues.cpp index 89e9b7c..d1b8093 100644 --- a/Source/WebCore/inspector/InspectorValues.cpp +++ b/Source/WebCore/inspector/InspectorValues.cpp @@ -647,6 +647,14 @@ bool InspectorObject::getBoolean(const String& name, bool* output) const return value->asBoolean(output); } +bool InspectorObject::getNumber(const String& name, long* output) const +{ + RefPtr<InspectorValue> value = get(name); + if (!value) + return false; + return value->asNumber(output); +} + bool InspectorObject::getNumber(const String& name, double* output) const { RefPtr<InspectorValue> value = get(name); diff --git a/Source/WebCore/inspector/InspectorValues.h b/Source/WebCore/inspector/InspectorValues.h index 391372e..843f369 100644 --- a/Source/WebCore/inspector/InspectorValues.h +++ b/Source/WebCore/inspector/InspectorValues.h @@ -180,6 +180,7 @@ public: const_iterator find(const String& name) const; bool getBoolean(const String& name, bool* output) const; + bool getNumber(const String& name, long* output) const; bool getNumber(const String& name, double* output) const; bool getString(const String& name, String* output) const; PassRefPtr<InspectorObject> getObject(const String& name) const; diff --git a/Source/WebCore/inspector/JavaScriptCallFrame.idl b/Source/WebCore/inspector/JavaScriptCallFrame.idl index 225059d..db0e0a6 100644 --- a/Source/WebCore/inspector/JavaScriptCallFrame.idl +++ b/Source/WebCore/inspector/JavaScriptCallFrame.idl @@ -43,6 +43,7 @@ module inspector { readonly attribute JavaScriptCallFrame caller; readonly attribute long sourceID; readonly attribute long line; + readonly attribute long column; readonly attribute [CustomGetter] Array scopeChain; [Custom] unsigned short scopeType(in int scopeIndex); readonly attribute [CustomGetter] Object thisObject; diff --git a/Source/WebCore/inspector/front-end/AuditLauncherView.js b/Source/WebCore/inspector/front-end/AuditLauncherView.js index c140589..df16a41 100644 --- a/Source/WebCore/inspector/front-end/AuditLauncherView.js +++ b/Source/WebCore/inspector/front-end/AuditLauncherView.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2011 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 @@ -50,60 +50,38 @@ WebInspector.AuditLauncherView = function(runnerCallback) this._headerElement.className = "no-audits"; this._headerElement.textContent = WebInspector.UIString("No audits to run"); this._contentElement.appendChild(this._headerElement); + + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this); + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceFinished, this); } WebInspector.AuditLauncherView.prototype = { - get totalResources() + _resetResourceCount: function() { - return this._totalResources; + this._loadedResources = 0; + this._totalResources = 0; }, - set totalResources(x) + _onResourceStarted: function(event) { - if (this._totalResources === x) + var resource = event.data; + // Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway. + if (resource.type === WebInspector.Resource.Type.WebSocket) return; - this._totalResources = x; + ++this._totalResources; this._updateResourceProgress(); }, - get loadedResources() - { - return this._loadedResources; - }, - - set loadedResources(x) + _onResourceFinished: function(event) { - if (this._loadedResources === x) + var resource = event.data; + // See resorceStarted for details. + if (resource.type === WebInspector.Resource.Type.WebSocket) return; - this._loadedResources = x; + ++this._loadedResources; this._updateResourceProgress(); }, - _resetResourceCount: function() - { - this.loadedResources = 0; - this.totalResources = 0; - }, - - resourceStarted: function(resource) - { - // Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway. - if (resource.type !== WebInspector.Resource.Type.WebSocket) - ++this.totalResources; - }, - - resourceFinished: function(resource) - { - // See resorceStarted for details. - if (resource.type !== WebInspector.Resource.Type.WebSocket) - ++this.loadedResources; - }, - - reset: function() - { - this._resetResourceCount(); - }, - addCategory: function(category) { if (!this._sortedCategories.length) @@ -264,7 +242,7 @@ WebInspector.AuditLauncherView.prototype = { this._resourceProgressContainer.addStyleClass("hidden"); } else this._resourceProgressContainer.removeStyleClass("hidden"); - this._resourceProgressTextElement.textContent = WebInspector.UIString("Loading (%d of %d)", this.loadedResources, this.totalResources); + this._resourceProgressTextElement.textContent = WebInspector.UIString("Loading (%d of %d)", this._loadedResources, this._totalResources); }, _updateButton: function() diff --git a/Source/WebCore/inspector/front-end/AuditRules.js b/Source/WebCore/inspector/front-end/AuditRules.js index 7aa891f..c2bbcbb 100644 --- a/Source/WebCore/inspector/front-end/AuditRules.js +++ b/Source/WebCore/inspector/front-end/AuditRules.js @@ -65,7 +65,7 @@ WebInspector.AuditRules.getDomainToResourcesMap = function(resources, types, nee WebInspector.AuditRules.evaluateInTargetWindow = function(func, args, callback) { - InjectedScriptAccess.getDefault().evaluateOnSelf(func.toString(), args, callback); + InspectorBackend.evaluateOnSelf(func.toString(), args, callback); } @@ -721,7 +721,7 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = { return nodeIds; } - WebInspector.AuditRules.evaluateInTargetWindow(pushImageNodes, null, receivedImages); + WebInspector.AuditRules.evaluateInTargetWindow(pushImageNodes, [], receivedImages); } } @@ -797,7 +797,7 @@ WebInspector.AuditRules.CssInHeadRule.prototype = { return found ? urlToViolationsArray : null; } - WebInspector.AuditRules.evaluateInTargetWindow(routine, null, evalCallback); + WebInspector.AuditRules.evaluateInTargetWindow(routine, [], evalCallback); } } @@ -844,7 +844,7 @@ WebInspector.AuditRules.StylesScriptsOrderRule.prototype = { return [ lateStyleUrls, cssBeforeInlineCount ]; } - WebInspector.AuditRules.evaluateInTargetWindow(routine, null, evalCallback.bind(this)); + WebInspector.AuditRules.evaluateInTargetWindow(routine, [], evalCallback.bind(this)); } } diff --git a/Source/WebCore/inspector/front-end/AuditsPanel.js b/Source/WebCore/inspector/front-end/AuditsPanel.js index c639f47..f3cbfa7 100644 --- a/Source/WebCore/inspector/front-end/AuditsPanel.js +++ b/Source/WebCore/inspector/front-end/AuditsPanel.js @@ -96,16 +96,6 @@ WebInspector.AuditsPanel.prototype = { return this._auditCategoriesById; }, - resourceStarted: function(resource) - { - this._launcherView.resourceStarted(resource); - }, - - resourceFinished: function(resource) - { - this._launcherView.resourceFinished(resource); - }, - addCategory: function(category) { this.categoriesById[category.id] = category; @@ -246,11 +236,6 @@ WebInspector.AuditsPanel.prototype = { x.show(this.viewsContainerElement); }, - reset: function() - { - this._launcherView.reset(); - }, - attach: function() { WebInspector.Panel.prototype.attach.call(this); diff --git a/Source/WebCore/inspector/front-end/Breakpoint.js b/Source/WebCore/inspector/front-end/Breakpoint.js index e5e1768..aa600a7 100644 --- a/Source/WebCore/inspector/front-end/Breakpoint.js +++ b/Source/WebCore/inspector/front-end/Breakpoint.js @@ -37,7 +37,6 @@ WebInspector.Breakpoint = function(debuggerModel, breakpointId, sourceID, url, l this.sourceID = sourceID; this._enabled = enabled; this._condition = condition || ""; - this._hit = false; this._debuggerModel = debuggerModel; } @@ -60,52 +59,14 @@ WebInspector.Breakpoint.prototype = { return this._condition; }, - get hit() + get data() { - return this._hit; - }, - - set hit(hit) - { - this._hit = hit; - this.dispatchEventToListeners("hit-state-changed"); - }, - - click: function(event) - { - WebInspector.panels.scripts.showSourceLine(this.url, this.line); - }, - - compareTo: function(other) - { - if (this.url != other.url) - return this.url < other.url ? -1 : 1; - if (this.line != other.line) - return this.line < other.line ? -1 : 1; - return 0; - }, - - populateLabelElement: function(element) - { - function didGetSourceLine(text) - { - var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)"); - var labelElement = document.createTextNode(displayName + ":" + this.line); - element.appendChild(labelElement); - - var sourceTextElement = document.createElement("div"); - sourceTextElement.textContent = text; - sourceTextElement.className = "source-text monospace"; - element.appendChild(sourceTextElement); - } - var script = this._debuggerModel.scriptForSourceID(this.sourceID); - script.sourceLine(this.line, didGetSourceLine.bind(this)); + return { id: this.id, url: this.url, sourceID: this.sourceID, lineNumber: this.line, condition: this.condition }; }, remove: function() { this._debuggerModel.removeBreakpoint(this.id); - this.dispatchEventToListeners("removed"); this.removeAllListeners(); delete this._debuggerModel; } diff --git a/Source/WebCore/inspector/front-end/BreakpointManager.js b/Source/WebCore/inspector/front-end/BreakpointManager.js index 67ef112..d943d5b 100644 --- a/Source/WebCore/inspector/front-end/BreakpointManager.js +++ b/Source/WebCore/inspector/front-end/BreakpointManager.js @@ -34,7 +34,7 @@ WebInspector.BreakpointManager = function() var breakpoints = WebInspector.settings.findSettingForAllProjects("nativeBreakpoints"); for (var projectId in breakpoints) this._stickyBreakpoints[projectId] = this._validateBreakpoints(breakpoints[projectId]); - InspectorBackend.setStickyBreakpoints(this._stickyBreakpoints); + InspectorBackend.setAllBrowserBreakpoints(this._stickyBreakpoints); this._breakpoints = {}; this._domBreakpointsRestored = false; @@ -303,7 +303,7 @@ WebInspector.BreakpointManager.prototype = { WebInspector.settings.nativeBreakpoints = breakpoints; this._stickyBreakpoints[WebInspector.settings.projectId] = breakpoints; - InspectorBackend.setStickyBreakpoints(this._stickyBreakpoints); + InspectorBackend.setAllBrowserBreakpoints(this._stickyBreakpoints); }, _validateBreakpoints: function(persistentBreakpoints) diff --git a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js index 408c5ba..b237ca2 100644 --- a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js @@ -23,7 +23,213 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.BreakpointsSidebarPane = function(title) +WebInspector.JavaScriptBreakpointsSidebarPane = function(title) +{ + WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints")); + + this.listElement = document.createElement("ol"); + this.listElement.className = "breakpoint-list"; + + this.emptyElement = document.createElement("div"); + this.emptyElement.className = "info"; + this.emptyElement.textContent = WebInspector.UIString("No Breakpoints"); + + this.bodyElement.appendChild(this.emptyElement); + + this._items = {}; + + WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this); + WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointRemoved, this._breakpointRemoved, this); + WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); + WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this); + WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.ProjectChanged, this._projectChanged, this); +} + +WebInspector.JavaScriptBreakpointsSidebarPane.prototype = { + _breakpointAdded: function(event) + { + var breakpoint = event.data; + var breakpointId = breakpoint.id; + var data = breakpoint.data; + + var element = document.createElement("li"); + + var checkbox = document.createElement("input"); + checkbox.className = "checkbox-elem"; + checkbox.type = "checkbox"; + checkbox.checked = breakpoint.enabled; + checkbox.addEventListener("click", this._breakpointItemCheckboxClicked.bind(this, breakpointId), false); + element.appendChild(checkbox); + + var label = document.createElement("span"); + element.appendChild(label); + + element._data = data; + var currentElement = this.listElement.firstChild; + while (currentElement) { + if (currentElement._data && this._compareBreakpoints(currentElement._data, element._data) > 0) + break; + currentElement = currentElement.nextSibling; + } + this._addListElement(element, currentElement); + + element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this, breakpointId), true); + + this._setupBreakpointElement(data, element); + + var breakpointItem = {}; + breakpointItem.data = data; + breakpointItem.element = element; + breakpointItem.checkbox = checkbox; + this._items[breakpointId] = breakpointItem; + + if (!this.expanded) + this.expanded = true; + }, + + _breakpointRemoved: function(event) + { + var breakpointId = event.data; + var breakpointItem = this._items[breakpointId]; + if (breakpointItem) { + delete this._items[breakpointId]; + this._removeListElement(breakpointItem.element); + } + }, + + _breakpointEnableChanged: function(enabled, event) + { + var breakpointId = event.data; + var breakpointItem = this._items[breakpointId]; + if (breakpointItem) + breakpointItem.checkbox.checked = enabled; + }, + + _breakpointItemCheckboxClicked: function(breakpointId, event) + { + this._setBreakpointEnabled(breakpointId, event.target.checked); + + // Breakpoint element may have it's own click handler. + event.stopPropagation(); + }, + + _contextMenuEventFired: function(breakpointId, event) + { + var contextMenu = new WebInspector.ContextMenu(); + contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), this._removeBreakpoint.bind(this, breakpointId)); + contextMenu.show(event); + }, + + _debuggerPaused: function(event) + { + var breakpointId = this._breakpointIdForDebuggerPausedEvent(event.data); + if (!breakpointId) + return; + var breakpointItem = this._items[breakpointId]; + if (!breakpointItem) + return; + breakpointItem.element.addStyleClass("breakpoint-hit"); + this._lastHitBreakpointItem = breakpointItem; + }, + + _debuggerResumed: function() + { + if (this._lastHitBreakpointItem) { + this._lastHitBreakpointItem.element.removeStyleClass("breakpoint-hit"); + delete this._lastHitBreakpointItem; + } + }, + + _addListElement: function(element, beforeElement) + { + if (beforeElement) + this.listElement.insertBefore(element, beforeElement); + else { + if (!this.listElement.firstChild) { + this.bodyElement.removeChild(this.emptyElement); + this.bodyElement.appendChild(this.listElement); + } + this.listElement.appendChild(element); + } + }, + + _removeListElement: function(element) + { + this.listElement.removeChild(element); + if (!this.listElement.firstChild) { + this.bodyElement.removeChild(this.listElement); + this.bodyElement.appendChild(this.emptyElement); + } + }, + + _projectChanged: function() + { + this.listElement.removeChildren(); + if (this.listElement.parentElement) { + this.bodyElement.removeChild(this.listElement); + this.bodyElement.appendChild(this.emptyElement); + } + this._items = {}; + }, + + _compare: function(x, y) + { + if (x !== y) + return x < y ? -1 : 1; + return 0; + }, + + _compareBreakpoints: function(b1, b2) + { + return this._compare(b1.url, b2.url) || this._compare(b1.lineNumber, b2.lineNumber); + }, + + _setupBreakpointElement: function(data, element) + { + var displayName = data.url ? WebInspector.displayNameForURL(data.url) : WebInspector.UIString("(program)"); + var labelElement = document.createTextNode(displayName + ":" + data.lineNumber); + element.appendChild(labelElement); + + var sourceTextElement = document.createElement("div"); + sourceTextElement.className = "source-text monospace"; + element.appendChild(sourceTextElement); + + function didGetSourceLine(text) + { + sourceTextElement.textContent = text; + } + var script = WebInspector.debuggerModel.scriptForSourceID(data.sourceID); + script.sourceLine(data.lineNumber, didGetSourceLine.bind(this)); + + element.addStyleClass("cursor-pointer"); + var clickHandler = WebInspector.panels.scripts.showSourceLine.bind(WebInspector.panels.scripts, data.url, data.lineNumber); + element.addEventListener("click", clickHandler, false); + }, + + _breakpointIdForDebuggerPausedEvent: function(details) + { + var callFrame = details.callFrames[0]; + var breakpoint = WebInspector.debuggerModel.findBreakpoint(callFrame.sourceID, callFrame.line); + if (breakpoint) + return breakpoint.id; + }, + + _setBreakpointEnabled: function(breakpointId, enabled) + { + var breakpoint = WebInspector.debuggerModel.breakpointForId(breakpointId); + WebInspector.debuggerModel.removeBreakpoint(breakpointId); + WebInspector.debuggerModel.setBreakpoint(breakpoint.sourceID, breakpoint.line, enabled, breakpoint.condition); + }, + + _removeBreakpoint: function(breakpointId) + { + WebInspector.debuggerModel.removeBreakpoint(breakpointId); + } +} + +WebInspector.JavaScriptBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; + +WebInspector.NativeBreakpointsSidebarPane = function(title) { WebInspector.SidebarPane.call(this, title); @@ -39,7 +245,7 @@ WebInspector.BreakpointsSidebarPane = function(title) WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.ProjectChanged, this._projectChanged, this); } -WebInspector.BreakpointsSidebarPane.prototype = { +WebInspector.NativeBreakpointsSidebarPane.prototype = { addBreakpointItem: function(breakpointItem) { var element = breakpointItem.element; @@ -102,11 +308,11 @@ WebInspector.BreakpointsSidebarPane.prototype = { } } -WebInspector.BreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; +WebInspector.NativeBreakpointsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; WebInspector.XHRBreakpointsSidebarPane = function() { - WebInspector.BreakpointsSidebarPane.call(this, WebInspector.UIString("XHR Breakpoints")); + WebInspector.NativeBreakpointsSidebarPane.call(this, WebInspector.UIString("XHR Breakpoints")); function addButtonClicked(event) { @@ -123,7 +329,7 @@ WebInspector.XHRBreakpointsSidebarPane = function() WebInspector.XHRBreakpointsSidebarPane.prototype = { addBreakpointItem: function(breakpointItem) { - WebInspector.BreakpointsSidebarPane.prototype.addBreakpointItem.call(this, breakpointItem); + WebInspector.NativeBreakpointsSidebarPane.prototype.addBreakpointItem.call(this, breakpointItem); breakpointItem._labelElement.addEventListener("dblclick", this._startEditingBreakpoint.bind(this, breakpointItem), false); }, @@ -166,7 +372,7 @@ WebInspector.XHRBreakpointsSidebarPane.prototype = { } } -WebInspector.XHRBreakpointsSidebarPane.prototype.__proto__ = WebInspector.BreakpointsSidebarPane.prototype; +WebInspector.XHRBreakpointsSidebarPane.prototype.__proto__ = WebInspector.NativeBreakpointsSidebarPane.prototype; WebInspector.BreakpointItem = function(breakpoint) { diff --git a/Source/WebCore/inspector/front-end/CSSCompletions.js b/Source/WebCore/inspector/front-end/CSSCompletions.js index e8d7556..f60c297 100644 --- a/Source/WebCore/inspector/front-end/CSSCompletions.js +++ b/Source/WebCore/inspector/front-end/CSSCompletions.js @@ -44,7 +44,7 @@ WebInspector.CSSCompletions.prototype = { return []; var results = []; - while (this._values[firstIndex].indexOf(prefix) === 0) + while (firstIndex < this._values.length && this._values[firstIndex].indexOf(prefix) === 0) results.push(this._values[firstIndex++]); return results; }, diff --git a/Source/WebCore/inspector/front-end/CSSKeywordCompletions.js b/Source/WebCore/inspector/front-end/CSSKeywordCompletions.js new file mode 100755 index 0000000..ac62aff --- /dev/null +++ b/Source/WebCore/inspector/front-end/CSSKeywordCompletions.js @@ -0,0 +1,438 @@ +/* + * Copyright (C) 2011 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. + */ + +WebInspector.CSSKeywordCompletions = { + forProperty: function(propertyName) + { + var acceptedKeywords = ["initial"]; + if (propertyName in this._propertyKeywordMap) + acceptedKeywords = acceptedKeywords.concat(this._propertyKeywordMap[propertyName]); + if (propertyName in this._colorAwareProperties) + acceptedKeywords = acceptedKeywords.concat(WebInspector.CSSKeywordCompletions._colors); + if (propertyName in WebInspector.StylesSidebarPane.InheritedProperties) + acceptedKeywords.push("inherit"); + return new WebInspector.CSSCompletions(acceptedKeywords); + } +}; + +WebInspector.CSSKeywordCompletions._colors = [ + "aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", + "silver", "teal", "white", "yellow", "transparent", "currentcolor", "grey", "aliceblue", "antiquewhite", + "aquamarine", "azure", "beige", "bisque", "blanchedalmond", "blueviolet", "brown", "burlywood", "cadetblue", + "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", + "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", + "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkslategrey", + "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick", + "floralwhite", "forestgreen", "gainsboro", "ghostwhite", "gold", "goldenrod", "greenyellow", "honeydew", "hotpink", + "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", + "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink", + "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow", + "limegreen", "linen", "magenta", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", + "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", + "mistyrose", "moccasin", "navajowhite", "oldlace", "olivedrab", "orangered", "orchid", "palegoldenrod", "palegreen", + "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "rosybrown", + "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "skyblue", "slateblue", + "slategray", "slategrey", "snow", "springgreen", "steelblue", "tan", "thistle", "tomato", "turquoise", "violet", + "wheat", "whitesmoke", "yellowgreen" +], + +WebInspector.CSSKeywordCompletions._colorAwareProperties = [ + "background", "background-color", "border", "border-color", "border-top", "border-right", "border-bottom", + "border-left", "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", "color", + "outline", "outline-color", "text-line-through", "text-line-through-color", "text-overline", "text-overline-color", + "text-shadow", "text-underline", "text-underline-color", "-webkit-text-emphasis", "-webkit-text-emphasis-color" +].keySet(); + +WebInspector.CSSKeywordCompletions._propertyKeywordMap = { + "table-layout": [ + "auto", "fixed" + ], + "visibility": [ + "hidden", "visible", "collapse" + ], + "background-repeat": [ + "repeat", "repeat-x", "repeat-y", "no-repeat", "space", "round" + ], + "text-underline": [ + "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave" + ], + "content": [ + "list-item", "close-quote", "no-close-quote", "no-open-quote", "open-quote" + ], + "list-style-image": [ + "none" + ], + "clear": [ + "none", "left", "right", "both" + ], + "text-underline-mode": [ + "continuous", "skip-white-space" + ], + "overflow-x": [ + "hidden", "auto", "visible", "overlay", "scroll" + ], + "stroke-linejoin": [ + "round", "miter", "bevel" + ], + "baseline-shift": [ + "baseline", "sub", "super" + ], + "border-bottom-width": [ + "medium", "thick", "thin" + ], + "marquee-speed": [ + "normal", "slow", "fast" + ], + "margin-top-collapse": [ + "collapse", "separate", "discard" + ], + "max-height": [ + "none" + ], + "box-orient": [ + "horizontal", "vertical", "inline-axis", "block-axis" + ], + "font-stretch": [ + "normal", "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", + "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" + ], + "-webkit-color-correction": [ + "default", "srgb" + ], + "text-underline-style": [ + "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave" + ], + "text-overline-mode": [ + "continuous", "skip-white-space" + ], + "-webkit-background-composite": [ + "highlight", "clear", "copy", "source-over", "source-in", "source-out", "source-atop", "destination-over", + "destination-in", "destination-out", "destination-atop", "xor", "plus-darker", "plus-lighter" + ], + "border-left-width": [ + "medium", "thick", "thin" + ], + "-webkit-writing-mode": [ + "lr", "rl", "tb", "lr-tb", "rl-tb", "tb-rl", "horizontal-tb", "vertical-rl", "vertical-lr", "horizontal-bt" + ], + "text-line-through-mode": [ + "continuous", "skip-white-space" + ], + "border-collapse": [ + "collapse", "separate" + ], + "page-break-inside": [ + "auto", "avoid" + ], + "border-top-width": [ + "medium", "thick", "thin" + ], + "outline-color": [ + "invert" + ], + "text-line-through-style": [ + "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave" + ], + "outline-style": [ + "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double" + ], + "cursor": [ + "none", "copy", "auto", "crosshair", "default", "pointer", "move", "vertical-text", "cell", "context-menu", + "alias", "progress", "no-drop", "not-allowed", "-webkit-zoom-in", "-webkit-zoom-out", "e-resize", "ne-resize", + "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "ew-resize", "ns-resize", + "nesw-resize", "nwse-resize", "col-resize", "row-resize", "text", "wait", "help", "all-scroll", "-webkit-grab", + "-webkit-grabbing" + ], + "border-width": [ + "medium", "thick", "thin" + ], + "size": [ + "a3", "a4", "a5", "b4", "b5", "landscape", "ledger", "legal", "letter", "portrait" + ], + "background-size": [ + "contain", "cover" + ], + "direction": [ + "ltr", "rtl" + ], + "marquee-direction": [ + "left", "right", "auto", "reverse", "forwards", "backwards", "ahead", "up", "down" + ], + "enable-background": [ + "accumulate", "new" + ], + "float": [ + "none", "left", "right" + ], + "overflow-y": [ + "hidden", "auto", "visible", "overlay", "scroll" + ], + "margin-bottom-collapse": [ + "collapse", "separate", "discard" + ], + "box-reflect": [ + "left", "right", "above", "below" + ], + "overflow": [ + "hidden", "auto", "visible", "overlay", "scroll" + ], + "text-rendering": [ + "auto", "optimizespeed", "optimizelegibility", "geometricprecision" + ], + "text-align": [ + "-webkit-auto", "left", "right", "center", "justify", "-webkit-left", "-webkit-right", "-webkit-center" + ], + "list-style-position": [ + "outside", "inside" + ], + "margin-bottom": [ + "auto" + ], + "color-interpolation": [ + "linearrgb" + ], + "background-origin": [ + "border-box", "content-box", "padding-box" + ], + "word-wrap": [ + "normal", "break-word" + ], + "font-weight": [ + "normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900" + ], + "margin-before-collapse": [ + "collapse", "separate", "discard" + ], + "text-overline-width": [ + "normal", "medium", "auto", "thick", "thin" + ], + "text-transform": [ + "none", "capitalize", "uppercase", "lowercase" + ], + "border-right-style": [ + "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double" + ], + "border-left-style": [ + "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double" + ], + "-webkit-text-emphasis": [ + "circle", "filled", "open", "dot", "double-circle", "triangle", "sesame" + ], + "font-style": [ + "italic", "oblique", "normal" + ], + "speak": [ + "none", "normal", "spell-out", "digits", "literal-punctuation", "no-punctuation" + ], + "text-line-through": [ + "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave", "continuous", + "skip-white-space" + ], + "color-rendering": [ + "auto", "optimizespeed", "optimizequality" + ], + "list-style-type": [ + "none", "disc", "circle", "square", "decimal", "decimal-leading-zero", "arabic-indic", "binary", "bengali", + "cambodian", "khmer", "devanagari", "gujarati", "gurmukhi", "kannada", "lower-hexadecimal", "lao", "malayalam", + "mongolian", "myanmar", "octal", "oriya", "persian", "urdu", "telugu", "tibetan", "thai", "upper-hexadecimal", + "lower-roman", "upper-roman", "lower-greek", "lower-alpha", "lower-latin", "upper-alpha", "upper-latin", "afar", + "ethiopic-halehame-aa-et", "ethiopic-halehame-aa-er", "amharic", "ethiopic-halehame-am-et", "amharic-abegede", + "ethiopic-abegede-am-et", "cjk-earthly-branch", "cjk-heavenly-stem", "ethiopic", "ethiopic-halehame-gez", + "ethiopic-abegede", "ethiopic-abegede-gez", "hangul-consonant", "hangul", "lower-norwegian", "oromo", + "ethiopic-halehame-om-et", "sidama", "ethiopic-halehame-sid-et", "somali", "ethiopic-halehame-so-et", "tigre", + "ethiopic-halehame-tig", "tigrinya-er", "ethiopic-halehame-ti-er", "tigrinya-er-abegede", + "ethiopic-abegede-ti-er", "tigrinya-et", "ethiopic-halehame-ti-et", "tigrinya-et-abegede", + "ethiopic-abegede-ti-et", "upper-greek", "upper-norwegian", "asterisks", "footnotes", "hebrew", "armenian", + "lower-armenian", "upper-armenian", "georgian", "cjk-ideographic", "hiragana", "katakana", "hiragana-iroha", + "katakana-iroha" + ], + "-webkit-text-combine": [ + "none", "horizontal" + ], + "outline": [ + "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double" + ], + "font": [ + "caption", "icon", "menu", "message-box", "small-caption", "-webkit-mini-control", "-webkit-small-control", + "-webkit-control", "status-bar", "italic", "oblique", "small-caps", "normal", "bold", "bolder", "lighter", + "100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium", + "large", "x-large", "xx-large", "-webkit-xxx-large", "smaller", "larger", "serif", "sans-serif", "cursive", + "fantasy", "monospace", "-webkit-body" + ], + "dominant-baseline": [ + "middle", "auto", "central", "text-before-edge", "text-after-edge", "ideographic", "alphabetic", "hanging", + "mathematical", "use-script", "no-change", "reset-size" + ], + "display": [ + "none", "inline", "block", "list-item", "run-in", "compact", "inline-block", "table", "inline-table", + "table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group", + "table-column", "table-cell", "table-caption", "-webkit-box", "-webkit-inline-box", "-wap-marquee" + ], + "-webkit-text-emphasis-position": [ + "over", "under" + ], + "image-rendering": [ + "auto", "optimizespeed", "optimizequality" + ], + "alignment-baseline": [ + "baseline", "middle", "auto", "before-edge", "after-edge", "central", "text-before-edge", "text-after-edge", + "ideographic", "alphabetic", "hanging", "mathematical" + ], + "outline-width": [ + "medium", "thick", "thin" + ], + "text-line-through-width": [ + "normal", "medium", "auto", "thick", "thin" + ], + "box-align": [ + "baseline", "center", "stretch", "start", "end" + ], + "border-right-width": [ + "medium", "thick", "thin" + ], + "border-top-style": [ + "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double" + ], + "line-height": [ + "normal" + ], + "text-overflow": [ + "clip", "ellipsis" + ], + "box-direction": [ + "normal", "reverse" + ], + "margin-after-collapse": [ + "collapse", "separate", "discard" + ], + "page-break-before": [ + "left", "right", "auto", "always", "avoid" + ], + "-webkit-hyphens": [ + "none", "auto", "manual" + ], + "border-image": [ + "repeat", "stretch" + ], + "text-decoration": [ + "blink", "line-through", "overline", "underline" + ], + "position": [ + "absolute", "fixed", "relative", "static" + ], + "font-family": [ + "serif", "sans-serif", "cursive", "fantasy", "monospace", "-webkit-body" + ], + "text-overflow-mode": [ + "clip", "ellipsis" + ], + "border-bottom-style": [ + "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double" + ], + "unicode-bidi": [ + "normal", "bidi-override", "embed" + ], + "clip-rule": [ + "nonzero", "evenodd" + ], + "margin-left": [ + "auto" + ], + "margin-top": [ + "auto" + ], + "zoom": [ + "document", "reset" + ], + "text-overline-style": [ + "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave" + ], + "max-width": [ + "none" + ], + "empty-cells": [ + "hide", "show" + ], + "pointer-events": [ + "none", "all", "auto", "visible", "visiblepainted", "visiblefill", "visiblestroke", "painted", "fill", "stroke" + ], + "letter-spacing": [ + "normal" + ], + "background-clip": [ + "border-box", "content-box", "padding-box" + ], + "-webkit-font-smoothing": [ + "none", "auto", "antialiased", "subpixel-antialiased" + ], + "border": [ + "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double" + ], + "font-size": [ + "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "-webkit-xxx-large", "smaller", + "larger" + ], + "font-variant": [ + "small-caps", "normal" + ], + "vertical-align": [ + "baseline", "middle", "sub", "super", "text-top", "text-bottom", "top", "bottom", "-webkit-baseline-middle" + ], + "marquee-style": [ + "none", "scroll", "slide", "alternate" + ], + "white-space": [ + "normal", "nowrap", "pre", "pre-line", "pre-wrap" + ], + "text-underline-width": [ + "normal", "medium", "auto", "thick", "thin" + ], + "box-lines": [ + "single", "multiple" + ], + "page-break-after": [ + "left", "right", "auto", "always", "avoid" + ], + "clip-path": [ + "none" + ], + "margin": [ + "auto" + ], + "marquee-repetition": [ + "infinite" + ], + "margin-right": [ + "auto" + ], + "-webkit-text-emphasis-style": [ + "circle", "filled", "open", "dot", "double-circle", "triangle", "sesame" + ] +} diff --git a/Source/WebCore/inspector/front-end/ConsoleView.js b/Source/WebCore/inspector/front-end/ConsoleView.js index a40030e..bd08e60 100644 --- a/Source/WebCore/inspector/front-end/ConsoleView.js +++ b/Source/WebCore/inspector/front-end/ConsoleView.js @@ -149,6 +149,11 @@ WebInspector.ConsoleView.prototype = { consoleMessagesCleared: function() { console.clearMessages(); + }, + + monitoringXHRStateChanged: function(enabled) + { + console._monitoringXHREnabled = enabled; } } InspectorBackend.registerDomainDispatcher("Console", dispatcher); @@ -355,14 +360,11 @@ WebInspector.ConsoleView.prototype = { // Collect comma separated object properties for the completion. var includeInspectorCommandLineAPI = (!dotNotation && !bracketNotation); - var callFrameId = WebInspector.panels.scripts.selectedCallFrameId(); var injectedScriptAccess; - if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) { - var selectedCallFrame = WebInspector.panels.scripts.sidebarPanes.callstack.selectedCallFrame; - injectedScriptAccess = InjectedScriptAccess.get(selectedCallFrame.worldId); - } else - injectedScriptAccess = InjectedScriptAccess.getDefault(); - injectedScriptAccess.getCompletions(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions); + if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) + InspectorBackend.getCompletionsOnCallFrame(WebInspector.panels.scripts.selectedCallFrameId(), expressionString, includeInspectorCommandLineAPI, reportCompletions); + else + InspectorBackend.getCompletions(expressionString, includeInspectorCommandLineAPI, reportCompletions); }, _reportCompletions: function(bestMatchOnly, completionsReadyCallback, dotNotation, bracketNotation, prefix, result, isException) { @@ -416,14 +418,9 @@ WebInspector.ConsoleView.prototype = { return; } + var itemAction = InspectorBackend.setMonitoringXHREnabled.bind(InspectorBackend, !this._monitoringXHREnabled); var contextMenu = new WebInspector.ContextMenu(); - - function monitoringXHRWasChanged(newState) - { - WebInspector.monitoringXHREnabled = newState; - } - var itemAction = InspectorBackend.setMonitoringXHREnabled.bind(InspectorBackend, !WebInspector.monitoringXHREnabled, monitoringXHRWasChanged); - contextMenu.appendCheckboxItem(WebInspector.UIString("XMLHttpRequest logging"), itemAction, WebInspector.monitoringXHREnabled); + contextMenu.appendCheckboxItem(WebInspector.UIString("XMLHttpRequest logging"), itemAction, this._monitoringXHREnabled); contextMenu.appendItem(WebInspector.UIString("Clear Console"), this.requestClearMessages.bind(this)); contextMenu.show(event); }, @@ -532,8 +529,8 @@ WebInspector.ConsoleView.prototype = { function evalCallback(result) { callback(WebInspector.RemoteObject.fromPayload(result)); - }; - InjectedScriptAccess.getDefault().evaluate(expression, objectGroup, evalCallback); + } + InspectorBackend.evaluate(expression, objectGroup, evalCallback); }, _enterKeyPressed: function(event) @@ -681,6 +678,15 @@ WebInspector.ConsoleMessage = function(source, type, level, line, url, repeatCou this._parameters = parameters; this._stackTrace = stackTrace; this._requestId = requestId; + + if (stackTrace && stackTrace.length) { + var topCallFrame = stackTrace[0]; + if (!this.url) + this.url = topCallFrame.scriptName; + if (!this.line) + this.line = topCallFrame.lineNumber; + } + this._formatMessage(); } @@ -737,17 +743,8 @@ WebInspector.ConsoleMessage.prototype = { this._formattedMessage = document.createElement("span"); this._formattedMessage.className = "console-message-text source-code"; - if (stackTrace && stackTrace.length) { - var topCallFrame = stackTrace[0]; - var sourceName = topCallFrame.scriptName; - var sourceLine = topCallFrame.lineNumber; - } else { - var sourceName = this.url; - var sourceLine = this.line; - } - - if (sourceName && sourceName !== "undefined") { - var urlElement = WebInspector.linkifyResourceAsNode(sourceName, "scripts", sourceLine, "console-message-url"); + if (this.url && this.url !== "undefined") { + var urlElement = WebInspector.linkifyResourceAsNode(this.url, "scripts", this.line, "console-message-url"); this._formattedMessage.appendChild(urlElement); } diff --git a/Source/WebCore/inspector/front-end/DebuggerModel.js b/Source/WebCore/inspector/front-end/DebuggerModel.js index 8f5bcf7..717486c 100644 --- a/Source/WebCore/inspector/front-end/DebuggerModel.js +++ b/Source/WebCore/inspector/front-end/DebuggerModel.js @@ -31,6 +31,7 @@ WebInspector.DebuggerModel = function() { this._paused = false; + this._callFrames = []; this._breakpoints = {}; this._sourceIDAndLineToBreakpointId = {}; this._scripts = {}; @@ -43,6 +44,7 @@ WebInspector.DebuggerModel.Events = { DebuggerResumed: "debugger-resumed", ParsedScriptSource: "parsed-script-source", FailedToParseScriptSource: "failed-to-parse-script-source", + ScriptSourceChanged: "script-source-changed", BreakpointAdded: "breakpoint-added", BreakpointRemoved: "breakpoint-removed" } @@ -84,6 +86,7 @@ WebInspector.DebuggerModel.prototype = { delete this._breakpoints[breakpointId]; delete this._sourceIDAndLineToBreakpointId[this._encodeSourceIDAndLine(breakpoint.sourceID, breakpoint.line)]; this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointRemoved, breakpointId); + breakpoint.dispatchEventToListeners("removed"); }, _breakpointSetOnBackend: function(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber, restored) @@ -103,6 +106,11 @@ WebInspector.DebuggerModel.prototype = { this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointAdded, breakpoint); }, + breakpointForId: function(breakpointId) + { + return this._breakpoints[breakpointId]; + }, + queryBreakpoints: function(filter) { var breakpoints = []; @@ -129,6 +137,7 @@ WebInspector.DebuggerModel.prototype = { reset: function() { this._paused = false; + this._callFrames = []; this._breakpoints = {}; delete this._oneTimeBreakpoint; this._sourceIDAndLineToBreakpointId = {}; @@ -156,39 +165,81 @@ WebInspector.DebuggerModel.prototype = { return scripts; }, + editScriptSource: function(sourceID, scriptSource) + { + function didEditScriptSource(success, newBodyOrErrorMessage, callFrames) + { + if (success) { + if (callFrames && callFrames.length) + this._callFrames = callFrames; + this._updateScriptSource(sourceID, newBodyOrErrorMessage); + } else + WebInspector.log(newBodyOrErrorMessage, WebInspector.ConsoleMessage.MessageLevel.Warning); + } + InspectorBackend.editScriptSource(sourceID, scriptSource, didEditScriptSource.bind(this)); + }, + + _updateScriptSource: function(sourceID, scriptSource) + { + var script = this._scripts[sourceID]; + var oldSource = script.source; + script.source = scriptSource; + + // Clear and re-create breakpoints according to text diff. + var diff = Array.diff(oldSource.split("\n"), script.source.split("\n")); + for (var id in this._breakpoints) { + var breakpoint = this._breakpoints[id]; + if (breakpoint.sourceID !== sourceID) + continue; + breakpoint.remove(); + var lineNumber = breakpoint.line - 1; + var newLineNumber = diff.left[lineNumber].row; + if (newLineNumber === undefined) { + for (var i = lineNumber - 1; i >= 0; --i) { + if (diff.left[i].row === undefined) + continue; + var shiftedLineNumber = diff.left[i].row + lineNumber - i; + if (shiftedLineNumber < diff.right.length) { + var originalLineNumber = diff.right[shiftedLineNumber].row; + if (originalLineNumber === lineNumber || originalLineNumber === undefined) + newLineNumber = shiftedLineNumber; + } + break; + } + } + if (newLineNumber !== undefined) + this.setBreakpoint(sourceID, newLineNumber + 1, breakpoint.enabled, breakpoint.condition); + } + + this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ScriptSourceChanged, { sourceID: sourceID, oldSource: oldSource }); + }, + + get callFrames() + { + return this._callFrames; + }, + _pausedScript: function(details) { this._paused = true; + this._callFrames = details.callFrames; if ("_continueToLineBreakpointId" in this) { InspectorBackend.removeBreakpoint(this._continueToLineBreakpointId); delete this._continueToLineBreakpointId; } this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerPaused, details); - - if (details.eventType === WebInspector.DebuggerEventTypes.JavaScriptPause || details.eventType === WebInspector.DebuggerEventTypes.NativeBreakpoint) - return; - - var breakpoint = this.findBreakpoint(details.callFrames[0].sourceID, details.callFrames[0].line); - if (!breakpoint) - return; - breakpoint.hit = true; - this._lastHitBreakpoint = breakpoint; }, _resumedScript: function() { this._paused = false; + this._callFrames = []; this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerResumed); - - if (!this._lastHitBreakpoint) - return; - this._lastHitBreakpoint.hit = false; - delete this._lastHitBreakpoint; }, - _parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType) + _parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, length, scriptWorldType) { - var script = new WebInspector.Script(sourceID, sourceURL, "", lineOffset, columnOffset, undefined, undefined, scriptWorldType); + var script = new WebInspector.Script(sourceID, sourceURL, "", lineOffset, columnOffset, length, undefined, undefined, scriptWorldType); this._scripts[sourceID] = script; this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID); }, @@ -234,9 +285,9 @@ WebInspector.DebuggerDispatcher.prototype = { WebInspector.panels.scripts.debuggerWasDisabled(); }, - parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType) + parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, length, scriptWorldType) { - this._debuggerModel._parsedScriptSource(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType); + this._debuggerModel._parsedScriptSource(sourceID, sourceURL, lineOffset, columnOffset, length, scriptWorldType); }, failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage) diff --git a/Source/WebCore/inspector/front-end/ElementsTreeOutline.js b/Source/WebCore/inspector/front-end/ElementsTreeOutline.js index 67d34b2..722c028 100644 --- a/Source/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/Source/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -411,8 +411,7 @@ WebInspector.ElementsTreeElement.prototype = { else this.tooltip = WebInspector.UIString("%d × %d pixels (Natural: %d × %d pixels)", properties.offsetWidth, properties.offsetHeight, properties.naturalWidth, properties.naturalHeight); } - - InjectedScriptAccess.getForNode(node).getNodeProperties(node.id, ["naturalHeight", "naturalWidth", "offsetHeight", "offsetWidth"], setTooltip.bind(this)); + InspectorBackend.getNodeProperties(node.id, ["naturalHeight", "naturalWidth", "offsetHeight", "offsetWidth"], setTooltip.bind(this)); }, updateSelection: function() diff --git a/Source/WebCore/inspector/front-end/ExtensionAPI.js b/Source/WebCore/inspector/front-end/ExtensionAPI.js index a9a2423..b10452d 100644 --- a/Source/WebCore/inspector/front-end/ExtensionAPI.js +++ b/Source/WebCore/inspector/front-end/ExtensionAPI.js @@ -450,8 +450,9 @@ ExtensionServerClient.prototype = { _onCallback: function(request) { if (request.requestId in this._callbacks) { - this._callbacks[request.requestId](request.result); + var callback = this._callbacks[request.requestId]; delete this._callbacks[request.requestId]; + callback(request.result); } }, diff --git a/Source/WebCore/inspector/front-end/ExtensionPanel.js b/Source/WebCore/inspector/front-end/ExtensionPanel.js index 4b42e68..fb98350 100644 --- a/Source/WebCore/inspector/front-end/ExtensionPanel.js +++ b/Source/WebCore/inspector/front-end/ExtensionPanel.js @@ -95,7 +95,7 @@ WebInspector.ExtensionWatchSidebarPane.prototype = { setExpression: function(expression, title) { - InjectedScriptAccess.getDefault().evaluate(expression, this._onEvaluate.bind(this, title)); + InspectorBackend.evaluate(expression, "extension-watch", this._onEvaluate.bind(this, title)); }, _onEvaluate: function(title, result) diff --git a/Source/WebCore/inspector/front-end/ExtensionServer.js b/Source/WebCore/inspector/front-end/ExtensionServer.js index 1320efb..0924106 100644 --- a/Source/WebCore/inspector/front-end/ExtensionServer.js +++ b/Source/WebCore/inspector/front-end/ExtensionServer.js @@ -53,7 +53,6 @@ WebInspector.ExtensionServer = function() this._registerHandler("subscribe", this._onSubscribe.bind(this)); this._registerHandler("unsubscribe", this._onUnsubscribe.bind(this)); - window.addEventListener("message", this._onWindowMessage.bind(this), false); } @@ -68,11 +67,6 @@ WebInspector.ExtensionServer.prototype = { this._postNotification("panel-objectSelected-" + panelId, objectId); }, - notifyResourceFinished: function(resource) - { - this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build()); - }, - notifySearchAction: function(panelId, action, searchString) { this._postNotification("panel-search-" + panelId, action, searchString); @@ -114,6 +108,12 @@ WebInspector.ExtensionServer.prototype = { delete this._clientObjects[auditRun.id]; }, + _notifyResourceFinished: function(event) + { + var resource = event.data; + this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build()); + }, + _postNotification: function(type, details) { var subscribers = this._subscribers[type]; @@ -272,7 +272,7 @@ WebInspector.ExtensionServer.prototype = { var evalExpression = "JSON.stringify(eval('" + "with (window.console._commandLineAPI) with (window) {' + unescape('" + escape(message.expression) + "') + '}'));"; - InjectedScriptAccess.getDefault().evaluate(evalExpression, callback.bind(this)); + InspectorBackend.evaluate(evalExpression, "none", callback.bind(this)); }, _onRevealAndSelect: function(message) @@ -356,6 +356,9 @@ WebInspector.ExtensionServer.prototype = { initExtensions: function() { + // The networkManager is normally created after the ExtensionServer is constructed, but before initExtensions() is called. + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._notifyResourceFinished, this); + InspectorExtensionRegistry.getExtensionsAsync(); }, @@ -393,7 +396,6 @@ WebInspector.ExtensionServer.prototype = { "var apiPrivate = {};" + "(" + WebInspector.commonExtensionSymbols.toString() + ")(apiPrivate);" + "(" + WebInspector.injectedExtensionAPI.toString() + ").apply(this, arguments);" + - "webInspector.resources.Types = " + JSON.stringify(resourceTypes) + ";" + platformAPI + "})"; }, diff --git a/Source/WebCore/inspector/front-end/InjectedScriptAccess.js b/Source/WebCore/inspector/front-end/InjectedScriptAccess.js deleted file mode 100644 index cb3c2b8..0000000 --- a/Source/WebCore/inspector/front-end/InjectedScriptAccess.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2009 Joseph Pecoraro - * - * 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. - */ - -function InjectedScriptAccess(worldId) { - this._worldId = worldId; -} - -InjectedScriptAccess.get = function(worldId) -{ - if (typeof worldId === "number") - return new InjectedScriptAccess(worldId); - - console.assert(false, "Access to injected script with no id"); -} - -InjectedScriptAccess.getForNode = function(node) -{ - // FIXME: do something. - return InjectedScriptAccess.get(-node.id); -} - -InjectedScriptAccess.getForObjectId = function(objectId) -{ - // FIXME: move to native layer. - var tokens = objectId.split(":"); - return InjectedScriptAccess.get(parseInt(tokens[0])); -} - -InjectedScriptAccess.getDefault = function() -{ - return InjectedScriptAccess.get(0); -} - -InjectedScriptAccess.prototype = {}; - -InjectedScriptAccess._installHandler = function(methodName, async) -{ - InjectedScriptAccess.prototype[methodName] = function() - { - var allArgs = Array.prototype.slice.call(arguments); - var callback = allArgs[allArgs.length - 1]; - var argsString = JSON.stringify(Array.prototype.slice.call(allArgs, 0, allArgs.length - 1)); - - function myCallback(result, isException) - { - if (!isException) - callback(result); - else - WebInspector.console.addMessage(WebInspector.ConsoleMessage.createTextMessage("Error dispatching: " + methodName)); - } - InspectorBackend.dispatchOnInjectedScript(this._worldId, methodName, argsString, myCallback); - }; -} - -// InjectedScriptAccess message forwarding puts some constraints on the way methods are implemented and called: -// - Make sure corresponding methods in InjectedScript return non-null and non-undefined values, -// - Make sure last parameter of all the InjectedSriptAccess.* calls is a callback function. -// We keep these sorted. -InjectedScriptAccess._installHandler("evaluate"); -InjectedScriptAccess._installHandler("evaluateInCallFrame"); -InjectedScriptAccess._installHandler("evaluateOnSelf"); -InjectedScriptAccess._installHandler("getCompletions"); -InjectedScriptAccess._installHandler("getProperties"); -InjectedScriptAccess._installHandler("getPrototypes"); -InjectedScriptAccess._installHandler("pushNodeToFrontend"); -InjectedScriptAccess._installHandler("resolveNode"); -InjectedScriptAccess._installHandler("getNodeProperties"); -InjectedScriptAccess._installHandler("setPropertyValue"); diff --git a/Source/WebCore/inspector/front-end/NetworkManager.js b/Source/WebCore/inspector/front-end/NetworkManager.js index a657377..ed4309e 100644 --- a/Source/WebCore/inspector/front-end/NetworkManager.js +++ b/Source/WebCore/inspector/front-end/NetworkManager.js @@ -30,6 +30,8 @@ WebInspector.NetworkManager = function(resourceTreeModel) { + WebInspector.Object.call(this); + this._inflightResources = {}; this._resourceTreeModel = resourceTreeModel; this._lastIdentifierForCachedResource = 0; @@ -86,6 +88,13 @@ WebInspector.NetworkManager.updateResourceWithCachedResource = function(resource WebInspector.NetworkManager.updateResourceWithResponse(resource, cachedResource.response); } +WebInspector.NetworkManager.EventTypes = { + ResourceStarted: "ResourceStarted", + ResourceUpdated: "ResourceUpdated", + ResourceFinished: "ResourceFinished", + MainResourceCommitLoad: "MainResourceCommitLoad" +} + WebInspector.NetworkManager.prototype = { reset: function() { @@ -119,7 +128,7 @@ WebInspector.NetworkManager.prototype = { if (isRedirect) this._startResource(resource); else - WebInspector.panels.network.refreshResource(resource); + this._updateResource(resource); }, markResourceAsCached: function(identifier) @@ -129,7 +138,7 @@ WebInspector.NetworkManager.prototype = { return; resource.cached = true; - WebInspector.panels.network.refreshResource(resource); + this._updateResource(resource); }, didReceiveResponse: function(identifier, time, resourceType, response) @@ -143,7 +152,7 @@ WebInspector.NetworkManager.prototype = { WebInspector.NetworkManager.updateResourceWithResponse(resource, response); - WebInspector.panels.network.refreshResource(resource); + this._updateResource(resource); this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource); }, @@ -156,7 +165,7 @@ WebInspector.NetworkManager.prototype = { resource.resourceSize += lengthReceived; resource.endTime = time; - WebInspector.panels.network.refreshResource(resource); + this._updateResource(resource); }, didFinishLoading: function(identifier, finishTime) @@ -204,8 +213,7 @@ WebInspector.NetworkManager.prototype = { resource.type = WebInspector.Resource.Type[type]; resource.setInitialContent(sourceString); - WebInspector.panels.resources.refreshResource(resource); - WebInspector.panels.network.refreshResource(resource); + this._updateResource(resource); }, didCommitLoadForFrame: function(frame, loader) @@ -216,7 +224,7 @@ WebInspector.NetworkManager.prototype = { if (mainResource) { WebInspector.mainResource = mainResource; mainResource.isMainResource = true; - WebInspector.panels.network.mainResourceChanged(); + this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, mainResource); } } }, @@ -239,7 +247,7 @@ WebInspector.NetworkManager.prototype = { resource.webSocketRequestKey3 = request.webSocketRequestKey3; resource.startTime = time; - WebInspector.panels.network.refreshResource(resource); + this._updateResource(resource); }, didReceiveWebSocketHandshakeResponse: function(identifier, time, response) @@ -254,7 +262,7 @@ WebInspector.NetworkManager.prototype = { resource.webSocketChallengeResponse = response.webSocketChallengeResponse; resource.responseReceivedTime = time; - WebInspector.panels.network.refreshResource(resource); + this._updateResource(resource); }, didCloseWebSocket: function(identifier, time) @@ -283,20 +291,24 @@ WebInspector.NetworkManager.prototype = { return newResource; }, - _startResource: function(resource, skipRefresh) + _startResource: function(resource) { this._inflightResources[resource.identifier] = resource; - WebInspector.panels.network.appendResource(resource, skipRefresh); - WebInspector.panels.audits.resourceStarted(resource); + this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceStarted, resource); + }, + + _updateResource: function(resource) + { + this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceUpdated, resource); }, _finishResource: function(resource, finishTime) { resource.endTime = finishTime; resource.finished = true; - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceFinished(resource); - WebInspector.extensionServer.notifyResourceFinished(resource); + this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceFinished, resource); delete this._inflightResources[resource.identifier]; } } + +WebInspector.NetworkManager.prototype.__proto__ = WebInspector.Object.prototype; diff --git a/Source/WebCore/inspector/front-end/NetworkPanel.js b/Source/WebCore/inspector/front-end/NetworkPanel.js index 28cbd36..943ee7f 100644 --- a/Source/WebCore/inspector/front-end/NetworkPanel.js +++ b/Source/WebCore/inspector/front-end/NetworkPanel.js @@ -78,6 +78,11 @@ WebInspector.NetworkPanel = function() this._filter(this._filterAllElement, false); this._toggleGridMode(); + + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this); + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._onResourceUpdated, this); + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this); + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, this._onMainResourceCommitLoad, this); } WebInspector.NetworkPanel.prototype = { @@ -772,7 +777,12 @@ WebInspector.NetworkPanel.prototype = { return this._resourcesById[id]; }, - appendResource: function(resource) + _onResourceStarted: function(event) + { + this._appendResource(event.data); + }, + + _appendResource: function(resource) { this._resources.push(resource); this._resourcesById[resource.identifier] = resource; @@ -781,13 +791,18 @@ WebInspector.NetworkPanel.prototype = { // Pull all the redirects of the main resource upon commit load. if (resource.redirects) { for (var i = 0; i < resource.redirects.length; ++i) - this.refreshResource(resource.redirects[i]); + this._refreshResource(resource.redirects[i]); } - this.refreshResource(resource); + this._refreshResource(resource); + }, + + _onResourceUpdated: function(event) + { + this._refreshResource(event.data); }, - refreshResource: function(resource) + _refreshResource: function(resource) { this._staleResources.push(resource); this._scheduleRefresh(); @@ -811,7 +826,7 @@ WebInspector.NetworkPanel.prototype = { this._reset(); }, - mainResourceChanged: function() + _onMainResourceCommitLoad: function() { if (this._preserveLogToggle.toggled) return; @@ -819,7 +834,7 @@ WebInspector.NetworkPanel.prototype = { this._reset(); // Now resurrect the main resource along with all redirects that lead to it. var resourcesToAppend = (WebInspector.mainResource.redirects || []).concat(WebInspector.mainResource); - resourcesToAppend.forEach(this.appendResource, this); + resourcesToAppend.forEach(this._appendResource, this); }, canShowSourceLine: function(url, line) diff --git a/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js b/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js index b9c212a..a1e37bc 100644 --- a/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js +++ b/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js @@ -42,11 +42,11 @@ WebInspector.PropertiesSidebarPane.prototype = { return; } - var self = this; - var callback = function(prototypes) { - var body = self.bodyElement; + function callback(prototypes) + { + var body = this.bodyElement; body.removeChildren(); - self.sections = []; + this.sections = []; // Get array of prototype user-friendly names. for (var i = 0; i < prototypes.length; ++i) { @@ -55,11 +55,11 @@ WebInspector.PropertiesSidebarPane.prototype = { if (title.match(/Prototype$/)) title = title.replace(/Prototype$/, ""); var section = new WebInspector.ObjectPropertiesSection(prototype, title); - self.sections.push(section); + this.sections.push(section); body.appendChild(section.element); } - }; - InjectedScriptAccess.getForNode(node).getPrototypes(node.id, callback); + } + InspectorBackend.getNodePrototypes(node.id, callback.bind(this)); } } diff --git a/Source/WebCore/inspector/front-end/RemoteObject.js b/Source/WebCore/inspector/front-end/RemoteObject.js index 4d6736c..10af2e3 100644 --- a/Source/WebCore/inspector/front-end/RemoteObject.js +++ b/Source/WebCore/inspector/front-end/RemoteObject.js @@ -52,7 +52,7 @@ WebInspector.RemoteObject.resolveNode = function(node, callback) { callback(object ? WebInspector.RemoteObject.fromPayload(object) : null); } - InjectedScriptAccess.getForNode(node).resolveNode(node.id, mycallback); + InspectorBackend.resolveNode(node.id, mycallback); } WebInspector.RemoteObject.fromPayload = function(payload) @@ -118,7 +118,7 @@ WebInspector.RemoteObject.prototype = { properties[i].value = WebInspector.RemoteObject.fromPayload(properties[i].value); callback(properties); } - InjectedScriptAccess.getForObjectId(this._objectId).getProperties(this._objectId, ignoreHasOwnProperty, abbreviate, remoteObjectBinder); + InspectorBackend.getProperties(this._objectId, !!ignoreHasOwnProperty, abbreviate, remoteObjectBinder); }, setPropertyValue: function(name, value, callback) @@ -127,12 +127,12 @@ WebInspector.RemoteObject.prototype = { callback(false); return; } - InjectedScriptAccess.getForObjectId(this._objectId).setPropertyValue(this._objectId, name, value, callback); + InspectorBackend.setPropertyValue(this._objectId, name, value, callback); }, pushNodeToFrontend: function(callback) { - InjectedScriptAccess.getForObjectId(this._objectId).pushNodeToFrontend(this._objectId, callback); + InspectorBackend.pushNodeToFrontend(this._objectId, callback); } } diff --git a/Source/WebCore/inspector/front-end/Resource.js b/Source/WebCore/inspector/front-end/Resource.js index 7340645..00c1fb9 100644 --- a/Source/WebCore/inspector/front-end/Resource.js +++ b/Source/WebCore/inspector/front-end/Resource.js @@ -44,7 +44,6 @@ WebInspector.Resource.Type = { Font: 3, Script: 4, XHR: 5, - Media: 6, WebSocket: 7, Other: 8, @@ -68,8 +67,6 @@ WebInspector.Resource.Type = { return WebInspector.UIString("Script"); case this.XHR: return WebInspector.UIString("XHR"); - case this.Media: - return WebInspector.UIString("Media"); case this.WebSocket: return WebInspector.UIString("WebSocket"); case this.Other: @@ -95,8 +92,6 @@ WebInspector.Resource.Type = { return "script"; case this.XHR: return "xhr"; - case this.Media: - return "media"; case this.WebSocket: return "websocket"; case this.Other: @@ -669,6 +664,13 @@ WebInspector.Resource.prototype = { requestContent: function(callback) { + // We do not support content retrieval for WebSockets at the moment. + // Since WebSockets are potentially long-living, fail requests immediately + // to prevent caller blocking until resource is marked as finished. + if (this.type === WebInspector.Resource.Type.WebSocket) { + callback(null, null); + return; + } if (this._content) { callback(this._content, this._contentEncoded); return; diff --git a/Source/WebCore/inspector/front-end/ResourcesPanel.js b/Source/WebCore/inspector/front-end/ResourcesPanel.js index d96989b..7e1fcc0 100644 --- a/Source/WebCore/inspector/front-end/ResourcesPanel.js +++ b/Source/WebCore/inspector/front-end/ResourcesPanel.js @@ -78,6 +78,8 @@ WebInspector.ResourcesPanel = function(database) this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false); this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false); + + WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._refreshResource, this); } WebInspector.ResourcesPanel.prototype = { @@ -253,8 +255,9 @@ WebInspector.ResourcesPanel.prototype = { frameTreeElement.removeChildren(); }, - refreshResource: function(resource) + _refreshResource: function(event) { + var resource = event.data; // FIXME: do not add XHR in the first place based on the native instrumentation. if (resource.type === WebInspector.Resource.Type.XHR) { var resourceTreeElement = this._findTreeElementForResource(resource); diff --git a/Source/WebCore/inspector/front-end/Script.js b/Source/WebCore/inspector/front-end/Script.js index 89b2121..6e3b18d 100644 --- a/Source/WebCore/inspector/front-end/Script.js +++ b/Source/WebCore/inspector/front-end/Script.js @@ -23,13 +23,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.Script = function(sourceID, sourceURL, source, lineOffset, columnOffset, errorLine, errorMessage, worldType) +WebInspector.Script = function(sourceID, sourceURL, source, lineOffset, columnOffset, length, errorLine, errorMessage, worldType) { this.sourceID = sourceID; this.sourceURL = sourceURL; this._source = source; this.lineOffset = lineOffset; this.columnOffset = columnOffset; + this.length = length; this.errorLine = errorLine; this.errorMessage = errorMessage; this.worldType = worldType; @@ -96,12 +97,15 @@ WebInspector.Script.prototype = { get source() { + if (!this._source && this.resource) + this._source = this.resource.content; return this._source; }, set source(source) { this._source = source; + delete this._lineEndings; }, requestSource: function(callback) diff --git a/Source/WebCore/inspector/front-end/ScriptFormatter.js b/Source/WebCore/inspector/front-end/ScriptFormatter.js new file mode 100644 index 0000000..69ffb74 --- /dev/null +++ b/Source/WebCore/inspector/front-end/ScriptFormatter.js @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2011 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. + */ + +WebInspector.ScriptFormatter = function(source) +{ + this._originalSource = source; + this._originalLineEndings = source.findAll("\n"); + this._originalLineEndings.push(source.length); +} + +WebInspector.ScriptFormatter.locationToPosition = function(lineEndings, location) +{ + var position = location.line ? lineEndings[location.line - 1] + 1 : 0; + return position + location.column; +} + +WebInspector.ScriptFormatter.positionToLocation = function(lineEndings, position) +{ + var location = {}; + location.line = lineEndings.upperBound(position - 1); + if (!location.line) + location.column = position; + else + location.column = position - lineEndings[location.line - 1] - 1; + return location; +} + +WebInspector.ScriptFormatter.prototype = { + format: function(callback) + { + var worker = new Worker("scriptFormatterWorker.js"); + function messageHandler(event) + { + var formattedSource = event.data; + this._formatted = true; + this._formattedSource = formattedSource; + this._formattedLineEndings = formattedSource.findAll("\n"); + this._formattedLineEndings.push(formattedSource.length); + this._buildMapping(); + callback(formattedSource); + } + worker.onmessage = messageHandler.bind(this); + worker.postMessage(this._originalSource); + }, + + _buildMapping: function() + { + this._originalSymbolPositions = []; + this._formattedSymbolPositions = []; + var lastCodePosition = 0; + var regexp = /[\$\.\w]+|{|}|;/g; + while (true) { + var match = regexp.exec(this._formattedSource); + if (!match) + break; + var position = this._originalSource.indexOf(match[0], lastCodePosition); + if (position === -1) + continue; + this._originalSymbolPositions.push(position); + this._formattedSymbolPositions.push(match.index); + lastCodePosition = position + match[0].length; + } + this._originalSymbolPositions.push(this._originalSource.length); + this._formattedSymbolPositions.push(this._formattedSource.length); + }, + + originalLineNumberToFormattedLineNumber: function(originalLineNumber) + { + if (!this._formatted) + return originalLineNumber; + var originalPosition = WebInspector.ScriptFormatter.locationToPosition(this._originalLineEndings, { line: originalLineNumber, column: 0 }); + return this.originalPositionToFormattedLineNumber(originalPosition); + }, + + formattedLineNumberToOriginalLineNumber: function(formattedLineNumber) + { + if (!this._formatted) + return formattedLineNumber; + var originalPosition = this.formattedLineNumberToOriginalPosition(formattedLineNumber); + return WebInspector.ScriptFormatter.positionToLocation(this._originalLineEndings, originalPosition).line; + }, + + originalPositionToFormattedLineNumber: function(originalPosition) + { + var lineEndings = this._formatted ? this._formattedLineEndings : this._originalLineEndings; + if (this._formatted) + formattedPosition = this._convertPosition(this._originalSymbolPositions, this._formattedSymbolPositions, originalPosition); + return WebInspector.ScriptFormatter.positionToLocation(lineEndings, formattedPosition).line; + }, + + formattedLineNumberToOriginalPosition: function(formattedLineNumber) + { + var lineEndings = this._formatted ? this._formattedLineEndings : this._originalLineEndings; + var formattedPosition = WebInspector.ScriptFormatter.locationToPosition(lineEndings, { line: formattedLineNumber, column: 0 }); + if (!this._formatted) + return formattedPosition; + return this._convertPosition(this._formattedSymbolPositions, this._originalSymbolPositions, formattedPosition); + }, + + _convertPosition: function(symbolPositions1, symbolPositions2, position) + { + var index = symbolPositions1.upperBound(position); + if (index === symbolPositions2.length - 1) + return symbolPositions2[index] - 1; + return symbolPositions2[index]; + } +} diff --git a/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js b/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js new file mode 100644 index 0000000..e900317 --- /dev/null +++ b/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011 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. + */ + +var parse = loadModule("parse-js.js"); +var process = loadModule("process.js"); + +onmessage = function(event) { + postMessage(beautify(event.data)); +}; + +function beautify(source) +{ + var ast = parse.parse(source); + var beautifyOptions = { + indent_level: 4, + indent_start: 0, + quote_keys: false, + space_colon: false + }; + return process.gen_code(ast, beautifyOptions); +} + +function loadModule(src) +{ + var request = new XMLHttpRequest(); + request.open("GET", src, false); + request.send(); + + var exports = {}; + eval(request.responseText); + return exports; +} + +function require() +{ + return parse; +} diff --git a/Source/WebCore/inspector/front-end/ScriptView.js b/Source/WebCore/inspector/front-end/ScriptView.js index d6c1c59..f631fcc 100644 --- a/Source/WebCore/inspector/front-end/ScriptView.js +++ b/Source/WebCore/inspector/front-end/ScriptView.js @@ -30,7 +30,7 @@ WebInspector.ScriptView = function(script) this.element.addStyleClass("script-view"); var contentProvider = new WebInspector.SourceFrameContentProviderForScript(script); - this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, "", WebInspector.panels.scripts.canEditScripts()); + this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, "", true); } WebInspector.ScriptView.prototype = { diff --git a/Source/WebCore/inspector/front-end/ScriptsPanel.js b/Source/WebCore/inspector/front-end/ScriptsPanel.js index 32212d4..a74f80d 100644 --- a/Source/WebCore/inspector/front-end/ScriptsPanel.js +++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js @@ -63,6 +63,15 @@ WebInspector.ScriptsPanel = function() // FIXME: append the functions select element to the top status bar when it is implemented. // this.topStatusBar.appendChild(this.functionsSelectElement); + this.formatButton = document.createElement("button"); + this.formatButton.className = "status-bar-item"; + this.formatButton.id = "format-script"; + this.formatButton.title = WebInspector.UIString("Format script."); + this.formatButton.appendChild(document.createElement("img")); + this.formatButton.addEventListener("click", this._formatScript.bind(this), false); + if (Preferences.debugMode) + this.topStatusBar.appendChild(this.formatButton); + this.sidebarButtonsElement = document.createElement("div"); this.sidebarButtonsElement.id = "scripts-sidebar-buttons"; this.topStatusBar.appendChild(this.sidebarButtonsElement); @@ -131,7 +140,7 @@ WebInspector.ScriptsPanel = function() this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSidebarPane(); this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane(); this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane(); - this.sidebarPanes.jsBreakpoints = WebInspector.createJSBreakpointsSidebarPane(); + this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSidebarPane(); if (Preferences.nativeInstrumentationEnabled) { this.sidebarPanes.domBreakpoints = WebInspector.createDOMBreakpointsSidebarPane(); this.sidebarPanes.xhrBreakpoints = WebInspector.createXHRBreakpointsSidebarPane(); @@ -168,8 +177,6 @@ WebInspector.ScriptsPanel = function() this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scripts-pause-on-exceptions-status-bar-item", 3); this._pauseOnExceptionButton.addEventListener("click", this._togglePauseOnExceptions.bind(this), false); - this._pauseOnExceptionButton.state = WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions; - this._pauseOnExceptionButton.title = WebInspector.UIString("Don't pause on exceptions.\nClick to Pause on all exceptions."); this._registerShortcuts(); @@ -179,6 +186,7 @@ WebInspector.ScriptsPanel = function() WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this); WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._failedToParseScriptSource, this); + WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ScriptSourceChanged, this._scriptSourceChanged, this); WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this); } @@ -244,6 +252,27 @@ WebInspector.ScriptsPanel.prototype = { this._addScript(event.data); }, + _scriptSourceChanged: function(event) + { + var sourceID = event.data.sourceID; + var oldSource = event.data.oldSource; + + var script = WebInspector.debuggerModel.scriptForSourceID(sourceID); + var oldView = script._scriptView; + if (oldView) { + script._scriptView = new WebInspector.ScriptView(script); + this.viewRecreated(oldView, script._scriptView); + } + if (script.resource) { + var revertHandle = WebInspector.debuggerModel.editScriptSource.bind(WebInspector.debuggerModel, sourceID, oldSource); + script.resource.setContent(script.source, revertHandle); + } + + var callFrames = WebInspector.debuggerModel.callFrames; + if (callFrames.length) + this._debuggerPaused({ data: { callFrames: callFrames } }); + }, + _addScript: function(script) { var resource = WebInspector.resourceForURL(script.sourceURL); @@ -279,52 +308,6 @@ WebInspector.ScriptsPanel.prototype = { delete resource._scriptsPendingResourceLoad; }, - canEditScripts: function() - { - return Preferences.canEditScriptSource; - }, - - editScriptSource: function(editData, revertEditingCallback, cancelEditingCallback) - { - if (!this.canEditScripts()) - return; - - // Need to clear breakpoints and re-create them later when editing source. - var breakpoints = WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID === editData.sourceID }); - for (var i = 0; i < breakpoints.length; ++i) - breakpoints[i].remove(); - - function mycallback(success, newBodyOrErrorMessage, callFrames) - { - if (success) { - var script = WebInspector.debuggerModel.scriptForSourceID(editData.sourceID); - script.source = newBodyOrErrorMessage; - var oldView = script._scriptView - if (oldView) { - script._scriptView = new WebInspector.ScriptView(script); - this.viewRecreated(oldView, script._scriptView); - } - if (script.resource) - script.resource.setContent(newBodyOrErrorMessage, revertEditingCallback); - - if (callFrames && callFrames.length) - this._debuggerPaused({ data: { callFrames: callFrames } }); - } else { - if (cancelEditingCallback) - cancelEditingCallback(); - WebInspector.log(newBodyOrErrorMessage, WebInspector.ConsoleMessage.MessageLevel.Warning); - } - for (var i = 0; i < breakpoints.length; ++i) { - var breakpoint = breakpoints[i]; - var newLine = breakpoint.line; - if (success && breakpoint.line >= editData.line) - newLine += editData.linesCountToShift; - WebInspector.debuggerModel.setBreakpoint(editData.sourceID, newLine, breakpoint.enabled, breakpoint.condition); - } - }; - InspectorBackend.editScriptSource(editData.sourceID, editData.content, mycallback.bind(this)); - }, - selectedCallFrameId: function() { var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame; @@ -359,7 +342,7 @@ WebInspector.ScriptsPanel.prototype = { if (result) callback(WebInspector.RemoteObject.fromPayload(result)); } - InjectedScriptAccess.get(callFrame.worldId).evaluateInCallFrame(callFrame.id, code, objectGroup, evalCallback); + InspectorBackend.evaluateOnCallFrame(callFrame.id, code, objectGroup, evalCallback); }, _debuggerPaused: function(event) @@ -392,9 +375,10 @@ WebInspector.ScriptsPanel.prototype = { debuggerWasEnabled: function() { + this._setPauseOnExceptions(WebInspector.settings.pauseOnExceptionState); + if (this._debuggerEnabled) return; - this._debuggerEnabled = true; this.reset(true); }, @@ -677,7 +661,7 @@ WebInspector.ScriptsPanel.prototype = { _clearCurrentExecutionLine: function() { if (this._executionSourceFrame) - this._executionSourceFrame.executionLine = 0; + this._executionSourceFrame.clearExecutionLine(); delete this._executionSourceFrame; }, @@ -699,7 +683,7 @@ WebInspector.ScriptsPanel.prototype = { this._executionSourceFrame = this._sourceFrameForScriptOrResource(scriptOrResource); if (this._executionSourceFrame) - this._executionSourceFrame.executionLine = currentFrame.line; + this._executionSourceFrame.setExecutionLine(currentFrame.line); }, _changeVisibleFile: function(event) @@ -744,16 +728,21 @@ WebInspector.ScriptsPanel.prototype = { this.resize(); }, - updatePauseOnExceptionsState: function(pauseOnExceptionsState) + _setPauseOnExceptions: function(pauseOnExceptionsState) { - if (pauseOnExceptionsState == WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions) - this._pauseOnExceptionButton.title = WebInspector.UIString("Don't pause on exceptions.\nClick to Pause on all exceptions."); - else if (pauseOnExceptionsState == WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnAllExceptions) - this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on all exceptions.\nClick to Pause on uncaught exceptions."); - else if (pauseOnExceptionsState == WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnUncaughtExceptions) - this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on uncaught exceptions.\nClick to Not pause on exceptions."); - - this._pauseOnExceptionButton.state = pauseOnExceptionsState; + function callback(pauseOnExceptionsState) + { + if (pauseOnExceptionsState == WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions) + this._pauseOnExceptionButton.title = WebInspector.UIString("Don't pause on exceptions.\nClick to Pause on all exceptions."); + else if (pauseOnExceptionsState == WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnAllExceptions) + this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on all exceptions.\nClick to Pause on uncaught exceptions."); + else if (pauseOnExceptionsState == WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnUncaughtExceptions) + this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on uncaught exceptions.\nClick to Not pause on exceptions."); + + this._pauseOnExceptionButton.state = pauseOnExceptionsState; + WebInspector.settings.pauseOnExceptionState = pauseOnExceptionsState; + } + InspectorBackend.setPauseOnExceptionsState(pauseOnExceptionsState, callback.bind(this)); }, _updateDebuggerButtons: function() @@ -833,6 +822,12 @@ WebInspector.ScriptsPanel.prototype = { this._updateBackAndForwardButtons(); }, + _formatScript: function() + { + if (this.visibleView && this.visibleView.sourceFrame) + this.visibleView.sourceFrame.formatSource(); + }, + _enableDebugging: function() { if (this._debuggerEnabled) @@ -854,7 +849,7 @@ WebInspector.ScriptsPanel.prototype = { _togglePauseOnExceptions: function() { - InspectorBackend.setPauseOnExceptionsState((this._pauseOnExceptionButton.state + 1) % this._pauseOnExceptionButton.states, this.updatePauseOnExceptionsState.bind(this)); + this._setPauseOnExceptions((this._pauseOnExceptionButton.state + 1) % this._pauseOnExceptionButton.states); }, _togglePause: function() diff --git a/Source/WebCore/inspector/front-end/Settings.js b/Source/WebCore/inspector/front-end/Settings.js index bc50ce9..e26b1d7 100644 --- a/Source/WebCore/inspector/front-end/Settings.js +++ b/Source/WebCore/inspector/front-end/Settings.js @@ -65,6 +65,7 @@ WebInspector.Settings = function() this.installApplicationSetting("showUserAgentStyles", true); this.installApplicationSetting("watchExpressions", []); this.installApplicationSetting("lastActivePanel", "elements"); + this.installApplicationSetting("pauseOnExceptionState", WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions); this.installProjectSetting("breakpoints", {}); this.installProjectSetting("nativeBreakpoints", []); diff --git a/Source/WebCore/inspector/front-end/SourceFrame.js b/Source/WebCore/inspector/front-end/SourceFrame.js index af10f1e..eb89f24 100644 --- a/Source/WebCore/inspector/front-end/SourceFrame.js +++ b/Source/WebCore/inspector/front-end/SourceFrame.js @@ -28,12 +28,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.SourceFrame = function(parentElement, contentProvider, url, canEditScripts) +WebInspector.SourceFrame = function(parentElement, contentProvider, url, isScript) { this._parentElement = parentElement; this._contentProvider = contentProvider; this._url = url; - this._canEditScripts = canEditScripts; + this._isScript = isScript; + this._textModel = new WebInspector.TextEditorModel(); this._textModel.replaceTabsWithSpaces = true; @@ -71,23 +72,6 @@ WebInspector.SourceFrame.prototype = { } }, - get executionLine() - { - return this._executionLine; - }, - - set executionLine(x) - { - if (this._executionLine === x) - return; - - var previousLine = this._executionLine; - this._executionLine = x; - - if (this._textViewer) - this._updateExecutionLine(previousLine); - }, - markDiff: function(diffData) { if (this._diffLines && this._textViewer) @@ -172,6 +156,7 @@ WebInspector.SourceFrame.prototype = { { this._content = content; this._textModel.setText(null, content); + this._formatter = new WebInspector.ScriptFormatter(content); this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url); var element = this._textViewer.element; @@ -179,15 +164,13 @@ WebInspector.SourceFrame.prototype = { element.addEventListener("mousedown", this._mouseDown.bind(this), true); element.addEventListener("mousemove", this._mouseMove.bind(this), true); element.addEventListener("scroll", this._scroll.bind(this), true); + element.addEventListener("dblclick", this._doubleClick.bind(this), true); this._parentElement.appendChild(element); this._textViewer.beginUpdates(); this._textViewer.mimeType = mimeType; - this._addExistingMessagesToSource(); - this._updateExecutionLine(); - this._updateDiffDecorations(); - this._textViewer.resize(); + this._setTextViewerDecorations(); if (this._lineNumberToReveal) { this.revealLine(this._lineNumberToReveal); @@ -210,15 +193,34 @@ WebInspector.SourceFrame.prototype = { delete this._delayedFindSearchMatches; } + this._textViewer.endUpdates(); + + WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this); + + if (this._canEditScripts) + this._textViewer.editCallback = this._editLine.bind(this); + }, + + _setTextViewerDecorations: function() + { + this._rowMessages = {}; + this._messageBubbles = {}; + + this._textViewer.beginUpdates(); + + this._addExistingMessagesToSource(); + this._updateDiffDecorations(); + + if (this._executionLine) + this.setExecutionLine(this._executionLine); + var breakpoints = this._breakpoints(); for (var i = 0; i < breakpoints.length; ++i) this._addBreakpoint(breakpoints[i]); - WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this); - this._textViewer.endUpdates(); + this._textViewer.resize(); - if (this._canEditScripts) - this._textViewer.editCallback = this._editLine.bind(this); + this._textViewer.endUpdates(); }, findSearchMatches: function(query, finishedCallback) @@ -300,18 +302,22 @@ WebInspector.SourceFrame.prototype = { msg._resourceMessageRepeatCountElement.textContent = WebInspector.UIString(" (repeated %d times)", msg.repeatCount); }, - _updateExecutionLine: function(previousLine) + setExecutionLine: function(lineNumber) { - if (previousLine) { - if (previousLine - 1 < this._textModel.linesCount) - this._textViewer.removeDecoration(previousLine - 1, "webkit-execution-line"); - } - - if (!this._executionLine) + this._executionLine = lineNumber; + if (!this._textViewer) return; + var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(this._executionLine - 1); + this._textViewer.addDecoration(textViewerLineNumber, "webkit-execution-line"); + }, - if (this._executionLine < this._textModel.linesCount) - this._textViewer.addDecoration(this._executionLine - 1, "webkit-execution-line"); + clearExecutionLine: function() + { + if (!this._textViewer) + return; + var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(this._executionLine - 1); + this._textViewer.removeDecoration(textViewerLineNumber, "webkit-execution-line"); + delete this._executionLine; }, _updateDiffDecorations: function() @@ -412,14 +418,15 @@ WebInspector.SourceFrame.prototype = { _addBreakpoint: function(breakpoint) { - if (breakpoint.line > this._textModel.linesCount) + var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(breakpoint.line - 1); + if (textViewerLineNumber >= this._textModel.linesCount) return; breakpoint.addEventListener("enable-changed", this._breakpointChanged, this); breakpoint.addEventListener("condition-changed", this._breakpointChanged, this); breakpoint.addEventListener("removed", this._breakpointRemoved, this); - this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition); + this._setBreakpointDecoration(textViewerLineNumber, breakpoint.enabled, !!breakpoint.condition); }, _breakpointRemoved: function(event) @@ -430,18 +437,19 @@ WebInspector.SourceFrame.prototype = { breakpoint.removeEventListener("condition-changed", null, this); breakpoint.removeEventListener("removed", null, this); - this._removeBreakpointDecoration(breakpoint.line); + var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(breakpoint.line - 1); + this._removeBreakpointDecoration(textViewerLineNumber); }, _breakpointChanged: function(event) { var breakpoint = event.target; - this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition); + var textViewerLineNumber = this._formatter.originalLineNumberToFormattedLineNumber(breakpoint.line - 1); + this._setBreakpointDecoration(textViewerLineNumber, breakpoint.enabled, !!breakpoint.condition); }, _setBreakpointDecoration: function(lineNumber, enabled, hasCondition) { - lineNumber -= 1; this._textViewer.beginUpdates(); this._textViewer.addDecoration(lineNumber, "webkit-breakpoint"); if (enabled) @@ -457,7 +465,6 @@ WebInspector.SourceFrame.prototype = { _removeBreakpointDecoration: function(lineNumber) { - lineNumber -= 1; this._textViewer.beginUpdates(); this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint"); this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint-disabled"); @@ -473,27 +480,28 @@ WebInspector.SourceFrame.prototype = { var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number"); if (!target) return; - var lineNumber = target.parentElement.lineNumber + 1; + var textViewerLineNumber = target.parentElement.lineNumber; + var originalLineNumber = this._formatter.formattedLineNumberToOriginalLineNumber(textViewerLineNumber); var contextMenu = new WebInspector.ContextMenu(); - contextMenu.appendItem(WebInspector.UIString("Continue to Here"), this._continueToLine.bind(this, lineNumber)); + contextMenu.appendItem(WebInspector.UIString("Continue to Here"), this._continueToLine.bind(this, originalLineNumber)); - var breakpoint = this._findBreakpoint(lineNumber); + var breakpoint = this._findBreakpoint(originalLineNumber); if (!breakpoint) { // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint. - contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this._setBreakpoint.bind(this, lineNumber, "", true)); + contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this._setBreakpoint.bind(this, originalLineNumber, "", true)); function addConditionalBreakpoint() { - this._setBreakpointDecoration(lineNumber, true, true); + this._setBreakpointDecoration(textViewerLineNumber, true, true); function didEditBreakpointCondition(committed, condition) { - this._removeBreakpointDecoration(lineNumber); + this._removeBreakpointDecoration(textViewerLineNumber); if (committed) - this._setBreakpoint(lineNumber, true, condition); + this._setBreakpoint(originalLineNumber, true, condition); } - this._editBreakpointCondition(lineNumber, "", didEditBreakpointCondition.bind(this)); + this._editBreakpointCondition(textViewerLineNumber, "", didEditBreakpointCondition.bind(this)); } contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint…"), addConditionalBreakpoint.bind(this)); } else { @@ -505,16 +513,16 @@ WebInspector.SourceFrame.prototype = { { if (committed) { breakpoint.remove(); - this._setBreakpoint(breakpoint.line, breakpoint.enabled, condition); + this._setBreakpoint(originalLineNumber, breakpoint.enabled, condition); } } - this._editBreakpointCondition(lineNumber, breakpoint.condition, didEditBreakpointCondition.bind(this)); + this._editBreakpointCondition(textViewerLineNumber, breakpoint.condition, didEditBreakpointCondition.bind(this)); } contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), editBreakpointCondition.bind(this)); function setBreakpointEnabled(enabled) { breakpoint.remove(); - this._setBreakpoint(breakpoint.line, enabled, breakpoint.condition); + this._setBreakpoint(originalLineNumber, enabled, breakpoint.condition); } if (breakpoint.enabled) contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), setBreakpointEnabled.bind(this, false)); @@ -538,15 +546,15 @@ WebInspector.SourceFrame.prototype = { var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number"); if (!target) return; - var lineNumber = target.parentElement.lineNumber + 1; + var originalLineNumber = this._formatter.formattedLineNumberToOriginalLineNumber(target.parentElement.lineNumber); - var breakpoint = this._findBreakpoint(lineNumber); + var breakpoint = this._findBreakpoint(originalLineNumber); if (breakpoint) { breakpoint.remove(); if (event.shiftKey) - this._setBreakpoint(breakpoint.line, !breakpoint.enabled, breakpoint.condition); + this._setBreakpoint(originalLineNumber, !breakpoint.enabled, breakpoint.condition); } else - this._setBreakpoint(lineNumber, true, ""); + this._setBreakpoint(originalLineNumber, true, ""); event.preventDefault(); }, @@ -710,7 +718,6 @@ WebInspector.SourceFrame.prototype = { _editBreakpointCondition: function(lineNumber, condition, callback) { - lineNumber -= 1; this._conditionElement = this._createConditionElement(lineNumber); this._textViewer.addDecoration(lineNumber, this._conditionElement); @@ -776,49 +783,55 @@ WebInspector.SourceFrame.prototype = { this._textViewer.resize(); }, + formatSource: function() + { + if (!this._formatter) + return; + + function didFormat(source) + { + this._textModel.setText(null, source); + this._setTextViewerDecorations(); + } + this._formatter.format(didFormat.bind(this)); + }, + _continueToLine: function(lineNumber) { var sourceID = this._sourceIDForLine(lineNumber); if (!sourceID) return; - WebInspector.debuggerModel.continueToLine(sourceID, lineNumber); + WebInspector.debuggerModel.continueToLine(sourceID, lineNumber + 1); }, - _editLine: function(lineNumber, newContent, cancelEditingCallback) + _doubleClick: function(event) { - lineNumber += 1; - - var lines = []; - var oldLines = this._content.split('\n'); - for (var i = 0; i < oldLines.length; ++i) { - if (i === lineNumber - 1) - lines.push(newContent); - else - lines.push(oldLines[i]); - } + if (!Preferences.canEditScriptSource || !this._isScript) + return; - var editData = {}; - editData.sourceID = this._sourceIDForLine(lineNumber); - editData.content = lines.join("\n"); - editData.line = lineNumber; - editData.linesCountToShift = newContent.split("\n").length - 1; - this._doEditLine(editData, cancelEditingCallback); - }, + var target = event.target.enclosingNodeOrSelfWithNodeName("TD"); + if (!target || target.parentElement.firstChild === target) + return; // Do not trigger editing from line numbers. - _revertEditLine: function(editData, contentToRevertTo) - { - var newEditData = {}; - newEditData.sourceID = editData.sourceID; - newEditData.content = contentToRevertTo; - newEditData.line = editData.line; - newEditData.linesCountToShift = -editData.linesCountToShift; - this._doEditLine(newEditData); - }, + var lineRow = target.parentElement; + var lineNumber = lineRow.lineNumber; + var sourceID = this._sourceIDForLine(lineNumber); + if (!sourceID) + return; - _doEditLine: function(editData, cancelEditingCallback) - { - var revertEditingCallback = this._revertEditLine.bind(this, editData); - WebInspector.panels.scripts.editScriptSource(editData, revertEditingCallback, cancelEditingCallback); + function didEditLine(newContent) + { + var lines = []; + var oldLines = this._content.split('\n'); + for (var i = 0; i < oldLines.length; ++i) { + if (i === lineNumber) + lines.push(newContent); + else + lines.push(oldLines[i]); + } + WebInspector.debuggerModel.editScriptSource(sourceID, lines.join("\n")); + } + this._textViewer.editLine(lineRow, didEditLine.bind(this)); }, _setBreakpoint: function(lineNumber, enabled, condition) @@ -826,7 +839,7 @@ WebInspector.SourceFrame.prototype = { var sourceID = this._sourceIDForLine(lineNumber); if (!sourceID) return; - WebInspector.debuggerModel.setBreakpoint(sourceID, lineNumber, enabled, condition); + WebInspector.debuggerModel.setBreakpoint(sourceID, lineNumber + 1, enabled, condition); if (!WebInspector.panels.scripts.breakpointsActivated) WebInspector.panels.scripts.toggleBreakpointsClicked(); }, @@ -840,7 +853,7 @@ WebInspector.SourceFrame.prototype = { _findBreakpoint: function(lineNumber) { var sourceID = this._sourceIDForLine(lineNumber); - return WebInspector.debuggerModel.findBreakpoint(sourceID, lineNumber); + return WebInspector.debuggerModel.findBreakpoint(sourceID, lineNumber + 1); }, _sourceIDForLine: function(lineNumber) @@ -849,9 +862,9 @@ WebInspector.SourceFrame.prototype = { var closestStartingLine = 0; var scripts = this._contentProvider.scripts(); for (var i = 0; i < scripts.length; ++i) { - var startingLine = scripts[i].startingLine; - if (startingLine <= lineNumber && startingLine >= closestStartingLine) { - closestStartingLine = startingLine; + var lineOffset = scripts[i].lineOffset; + if (lineOffset <= lineNumber && lineOffset >= closestStartingLine) { + closestStartingLine = lineOffset; sourceIDForLine = scripts[i].sourceID; } } diff --git a/Source/WebCore/inspector/front-end/SourceView.js b/Source/WebCore/inspector/front-end/SourceView.js index e78ff94..37caabb 100644 --- a/Source/WebCore/inspector/front-end/SourceView.js +++ b/Source/WebCore/inspector/front-end/SourceView.js @@ -33,8 +33,8 @@ WebInspector.SourceView = function(resource) this.element.addStyleClass("source"); var contentProvider = new WebInspector.SourceFrameContentProviderForResource(resource); - var canEditScripts = WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script; - this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, resource.url, canEditScripts); + var isScript = resource.type === WebInspector.Resource.Type.Script; + this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, resource.url, isScript); } WebInspector.SourceView.prototype = { diff --git a/Source/WebCore/inspector/front-end/StylesSidebarPane.js b/Source/WebCore/inspector/front-end/StylesSidebarPane.js index d646829..9880adc 100644 --- a/Source/WebCore/inspector/front-end/StylesSidebarPane.js +++ b/Source/WebCore/inspector/front-end/StylesSidebarPane.js @@ -81,6 +81,8 @@ WebInspector.StylesSidebarPane = function(computedStylePane) this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true); } +WebInspector.StylesSidebarPane.StyleValueDelimiters = " \t\n\"':;,/()"; + // Taken from http://www.w3.org/TR/CSS21/propidx.html. WebInspector.StylesSidebarPane.InheritedProperties = [ "azimuth", "border-collapse", "border-spacing", "caption-side", "color", "cursor", "direction", "elevation", @@ -1379,6 +1381,8 @@ WebInspector.StylePropertyTreeElement.prototype = { } this.listItemElement.removeChildren(); + nameElement.normalize(); + valueElement.normalize(); if (!this.treeOutline) return; @@ -1529,16 +1533,15 @@ WebInspector.StylePropertyTreeElement.prototype = { var context = { expanded: this.expanded, hasChildren: this.hasChildren, - keyDownListener: isEditingName ? this.editingNameKeyDown.bind(this) : this.editingValueKeyDown.bind(this), - keyPressListener: isEditingName ? this.editingNameKeyPress.bind(this) : this.editingValueKeyPress.bind(this), + keyDownListener: isEditingName ? null : this.editingValueKeyDown.bind(this), isEditingName: isEditingName, }; // Lie about our children to prevent expanding on double click and to collapse shorthands. this.hasChildren = false; - selectElement.addEventListener("keydown", context.keyDownListener, false); - selectElement.addEventListener("keypress", context.keyPressListener, false); + if (!isEditingName) + selectElement.addEventListener("keydown", context.keyDownListener, false); if (selectElement.parentElement) selectElement.parentElement.addStyleClass("child-editing"); selectElement.textContent = selectElement.textContent; // remove color swatch and the like @@ -1613,76 +1616,15 @@ WebInspector.StylePropertyTreeElement.prototype = { customFinishHandler: nameValueFinishHandler.bind(this, context, isEditingName), pasteHandler: isEditingName ? pasteHandler.bind(this, context) : null }); - window.getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1); - }, - - editingNameKeyPress: function(event) - { - // Complete property names. - var character = event.data.toLowerCase(); - if (character && /[a-z-]/.test(character)) { - var selection = window.getSelection(); - var prefix = selection.anchorNode.textContent.substring(0, selection.anchorOffset); - var property = WebInspector.cssNameCompletions.firstStartsWith(prefix + character); - if (!selection.isCollapsed) - selection.deleteFromDocument(); - - this.restoreNameElement(); - - if (property) { - if (property !== this.nameElement.textContent) - this.nameElement.textContent = property; - this.nameElement.firstChild.select(prefix.length + 1); - event.preventDefault(); - } - } - }, - - editingValueKeyPress: function(event) - { - // FIXME: This should complete property values. - }, - - editingNameKeyDown: function(event) - { - var showNext; - if (event.keyIdentifier === "Up") - showNext = false; - else if (event.keyIdentifier === "Down") - showNext = true; - else - return; - - var selection = window.getSelection(); - if (!selection.rangeCount) - return; - - var selectionRange = selection.getRangeAt(0); - if (selectionRange.commonAncestorContainer !== this.nameElement && !selectionRange.commonAncestorContainer.isDescendant(this.nameElement)) - return; - - const styleValueDelimeters = " \t\n\"':;,/()"; - var wordRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, styleValueDelimeters, this.nameElement); - var wordString = wordRange.toString(); - var cursorPosition = selectionRange.startOffset != selectionRange.endOffset ? selectionRange.startOffset : 0; - var prefix = selectionRange.startContainer.textContent.substring(0, cursorPosition); - var property; - - if (showNext) - property = WebInspector.cssNameCompletions.next(wordString, prefix); - else - property = WebInspector.cssNameCompletions.previous(wordString, prefix); - - if (property) { - this.nameElement.textContent = property; - this.nameElement.firstChild.select(cursorPosition); - } - event.preventDefault(); + this._prompt = new WebInspector.StylesSidebarPane.CSSPropertyPrompt(selectElement, isEditingName ? WebInspector.cssNameCompletions : WebInspector.CSSKeywordCompletions.forProperty(this.nameElement.textContent)); + window.getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1); }, editingValueKeyDown: function(event) { + if (event.handled) + return; var arrowKeyPressed = (event.keyIdentifier === "Up" || event.keyIdentifier === "Down"); var pageKeyPressed = (event.keyIdentifier === "PageUp" || event.keyIdentifier === "PageDown"); if (!arrowKeyPressed && !pageKeyPressed) @@ -1696,8 +1638,7 @@ WebInspector.StylePropertyTreeElement.prototype = { if (selectionRange.commonAncestorContainer !== this.valueElement && !selectionRange.commonAncestorContainer.isDescendant(this.valueElement)) return; - const styleValueDelimeters = " \t\n\"':;,/()"; - var wordRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, styleValueDelimeters, this.valueElement); + var wordRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, WebInspector.StylesSidebarPane.StyleValueDelimiters, this.valueElement); var wordString = wordRange.toString(); var replacementString = wordString; @@ -1739,42 +1680,45 @@ WebInspector.StylePropertyTreeElement.prototype = { } replacementString = prefix + number + suffix; - } else { - // FIXME: this should cycle through known keywords for the current property value. - } - var replacementTextNode = document.createTextNode(replacementString); + var replacementTextNode = document.createTextNode(replacementString); - wordRange.deleteContents(); - wordRange.insertNode(replacementTextNode); + wordRange.deleteContents(); + wordRange.insertNode(replacementTextNode); - var finalSelectionRange = document.createRange(); - finalSelectionRange.setStart(replacementTextNode, 0); - finalSelectionRange.setEnd(replacementTextNode, replacementString.length); + var finalSelectionRange = document.createRange(); + finalSelectionRange.setStart(replacementTextNode, 0); + finalSelectionRange.setEnd(replacementTextNode, replacementString.length); - selection.removeAllRanges(); - selection.addRange(finalSelectionRange); + selection.removeAllRanges(); + selection.addRange(finalSelectionRange); - event.preventDefault(); + event.handled = true; + event.preventDefault(); - if (!("originalPropertyText" in this)) { - // Remember the rule's original CSS text on [Page](Up|Down), so it can be restored - // if the editing is canceled. - this.originalPropertyText = this.property.propertyText; - } + if (!("originalPropertyText" in this)) { + // Remember the rule's original CSS text on [Page](Up|Down), so it can be restored + // if the editing is canceled. + this.originalPropertyText = this.property.propertyText; + } - // Synthesize property text disregarding any comments, custom whitespace etc. - this.applyStyleText(this.nameElement.textContent + ": " + this.valueElement.textContent); + // Synthesize property text disregarding any comments, custom whitespace etc. + this.applyStyleText(this.nameElement.textContent + ": " + this.valueElement.textContent); + } }, editingEnded: function(context) { + if (this._prompt) { + this._prompt.removeFromElement(); + delete this._prompt; + } this.hasChildren = context.hasChildren; if (context.expanded) this.expand(); var editedElement = context.isEditingName ? this.nameElement : this.valueElement; - editedElement.removeEventListener("keydown", context.keyDownListener, false); - editedElement.removeEventListener("keypress", context.keyPressListener, false); + if (!context.isEditingName) + editedElement.removeEventListener("keydown", context.keyDownListener, false); if (editedElement.parentElement) editedElement.parentElement.removeStyleClass("child-editing"); @@ -1791,6 +1735,8 @@ WebInspector.StylePropertyTreeElement.prototype = { else this.updateTitle(); } + + // This should happen last, as it clears the info necessary to restore the property value after [Page]Up/Down changes. this.editingEnded(context); }, @@ -1948,3 +1894,57 @@ WebInspector.StylePropertyTreeElement.prototype = { } WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototype; + +WebInspector.StylesSidebarPane.CSSPropertyPrompt = function(element, cssCompletions) +{ + WebInspector.TextPrompt.call(this, element, this._buildPropertyCompletions.bind(this), WebInspector.StylesSidebarPane.StyleValueDelimiters, true); + this._cssCompletions = cssCompletions; +} + +WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype = { + upKeyPressed: function(event) + { + this._handleNameOrValueUpDown(event); + }, + + downKeyPressed: function(event) + { + this._handleNameOrValueUpDown(event); + }, + + tabKeyPressed: function(event) + { + this.acceptAutoComplete(); + }, + + _handleNameOrValueUpDown: function(event) + { + var reverse = event.keyIdentifier === "Up"; + if (this.autoCompleteElement) + this.complete(false, reverse); // Accept the current suggestion, if any. + this.complete(false, reverse); // Actually increment/decrement the suggestion. + event.handled = true; + }, + + _buildPropertyCompletions: function(wordRange, bestMatchOnly, completionsReadyCallback) + { + var prefix = wordRange.toString().toLowerCase(); + if (!prefix.length) + return; + + var results; + if (bestMatchOnly) { + results = []; + var firstMatch = this._cssCompletions.firstStartsWith(prefix); + if (firstMatch) + results.push(firstMatch); + return completionsReadyCallback(results); + } + + results = this._cssCompletions.startsWith(prefix); + if (results) + completionsReadyCallback(results); + } +} + +WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype.__proto__ = WebInspector.TextPrompt.prototype; diff --git a/Source/WebCore/inspector/front-end/TextPrompt.js b/Source/WebCore/inspector/front-end/TextPrompt.js index 21a5bde..ac54d8c 100644 --- a/Source/WebCore/inspector/front-end/TextPrompt.js +++ b/Source/WebCore/inspector/front-end/TextPrompt.js @@ -26,15 +26,18 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.TextPrompt = function(element, completions, stopCharacters) +WebInspector.TextPrompt = function(element, completions, stopCharacters, omitHistory) { this.element = element; this.element.addStyleClass("text-prompt"); this.completions = completions; this.completionStopCharacters = stopCharacters; - this.history = []; - this.historyOffset = 0; - this.element.addEventListener("keydown", this._onKeyDown.bind(this), true); + if (!omitHistory) { + this.history = []; + this.historyOffset = 0; + } + this._boundOnKeyDown = this._onKeyDown.bind(this); + this.element.addEventListener("keydown", this._boundOnKeyDown, true); } WebInspector.TextPrompt.prototype = { @@ -55,6 +58,12 @@ WebInspector.TextPrompt.prototype = { this.moveCaretToEndOfPrompt(); }, + removeFromElement: function() + { + this.clearAutoComplete(true); + this.element.removeEventListener("keydown", this._boundOnKeyDown, true); + }, + _onKeyDown: function(event) { function defaultAction() @@ -63,16 +72,20 @@ WebInspector.TextPrompt.prototype = { this.autoCompleteSoon(); } + if (event.handled) + return; + var handled = false; + switch (event.keyIdentifier) { case "Up": - this._upKeyPressed(event); + this.upKeyPressed(event); break; case "Down": - this._downKeyPressed(event); + this.downKeyPressed(event); break; case "U+0009": // Tab - this._tabKeyPressed(event); + this.tabKeyPressed(event); break; case "Right": case "End": @@ -85,7 +98,7 @@ WebInspector.TextPrompt.prototype = { case "Control": break; case "U+0050": // Ctrl+P = Previous - if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) { + if (this.history && WebInspector.isMac() && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) { handled = true; this._moveBackInHistory(); break; @@ -93,7 +106,7 @@ WebInspector.TextPrompt.prototype = { defaultAction.call(this); break; case "U+004E": // Ctrl+N = Next - if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) { + if (this.history && WebInspector.isMac() && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) { handled = true; this._moveForwardInHistory(); break; @@ -105,7 +118,9 @@ WebInspector.TextPrompt.prototype = { break; } + handled |= event.handled; if (handled) { + event.handled = true; event.preventDefault(); event.stopPropagation(); } @@ -376,39 +391,33 @@ WebInspector.TextPrompt.prototype = { selection.addRange(selectionRange); }, - _tabKeyPressed: function(event) + tabKeyPressed: function(event) { - event.preventDefault(); - event.stopPropagation(); - + event.handled = true; this.complete(false, event.shiftKey); }, - _upKeyPressed: function(event) + upKeyPressed: function(event) { if (!this.isCaretOnFirstLine()) return; - event.preventDefault(); - event.stopPropagation(); - + event.handled = true; this._moveBackInHistory(); }, - _downKeyPressed: function(event) + downKeyPressed: function(event) { if (!this.isCaretOnLastLine()) return; - event.preventDefault(); - event.stopPropagation(); - + event.handled = true; this._moveForwardInHistory(); }, _moveBackInHistory: function() { - if (this.historyOffset == this.history.length) + if (!this.history || this.historyOffset == this.history.length) return; this.clearAutoComplete(true); @@ -437,7 +446,7 @@ WebInspector.TextPrompt.prototype = { _moveForwardInHistory: function() { - if (this.historyOffset === 0) + if (!this.history || this.historyOffset === 0) return; this.clearAutoComplete(true); diff --git a/Source/WebCore/inspector/front-end/TextViewer.js b/Source/WebCore/inspector/front-end/TextViewer.js index f116dea..ea36513 100644 --- a/Source/WebCore/inspector/front-end/TextViewer.js +++ b/Source/WebCore/inspector/front-end/TextViewer.js @@ -43,7 +43,6 @@ WebInspector.TextViewer = function(textModel, platform, url) this.element.addEventListener("keydown", this._handleKeyDown.bind(this), false); this.element.addEventListener("beforecopy", this._beforeCopy.bind(this), false); this.element.addEventListener("copy", this._copy.bind(this), false); - this.element.addEventListener("dblclick", this._handleDoubleClick.bind(this), false); this._url = url; @@ -80,11 +79,6 @@ WebInspector.TextViewer.prototype = { chunk.element.scrollIntoViewIfNeeded(); }, - set editCallback(editCallback) - { - this._editCallback = editCallback; - }, - addDecoration: function(lineNumber, decoration) { var chunk = this._makeLineAChunk(lineNumber); @@ -231,20 +225,20 @@ WebInspector.TextViewer.prototype = { scrollValue = -1; else if (event.keyCode == WebInspector.KeyboardShortcut.Keys.Down.code) scrollValue = 1; - + if (scrollValue) { event.preventDefault(); event.stopPropagation(); this.element.scrollByLines(scrollValue); return; } - + scrollValue = 0; if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Left.code) scrollValue = -40; else if (event.keyCode == WebInspector.KeyboardShortcut.Keys.Right.code) scrollValue = 40; - + if (scrollValue) { event.preventDefault(); event.stopPropagation(); @@ -252,42 +246,25 @@ WebInspector.TextViewer.prototype = { } }, - _handleDoubleClick: function(e) + editLine: function(lineRow, callback) { - if (!this._editCallback) - return; - - var cell = e.target.enclosingNodeOrSelfWithNodeName("TD"); - if (!cell) - return; - - var lineRow = cell.parentElement; - if (lineRow.firstChild === cell) - return; // Do not trigger editing from line numbers. - - var oldContent = lineRow.lastChild.innerHTML; - var cancelEditingCallback = this._cancelEditingLine.bind(this, lineRow.lastChild, oldContent); - var commitEditingCallback = this._commitEditingLine.bind(this, lineRow.lineNumber, lineRow.lastChild, cancelEditingCallback); - this._editingLine = WebInspector.startEditing(lineRow.lastChild, { + var element = lineRow.lastChild; + var oldContent = element.innerHTML; + function finishEditing(committed, e, newContent) + { + if (committed) + callback(newContent); + element.innerHTML = oldContent; + delete this._editingLine; + } + this._editingLine = WebInspector.startEditing(element, { context: null, - commitHandler: commitEditingCallback, - cancelHandler: cancelEditingCallback, + commitHandler: finishEditing.bind(this, true), + cancelHandler: finishEditing.bind(this, false), multiline: true }); }, - _commitEditingLine: function(lineNumber, element, cancelEditingCallback) - { - this._editCallback(lineNumber, element.textContent, cancelEditingCallback); - delete this._editingLine; - }, - - _cancelEditingLine: function(element, oldContent, e) - { - element.innerHTML = oldContent; - delete this._editingLine; - }, - _beforeCopy: function(e) { e.preventDefault(); @@ -786,7 +763,7 @@ WebInspector.TextChunk.prototype = { var lineContentElement = document.createElement("td"); lineContentElement.className = "webkit-line-content"; - lineRow.appendChild(lineContentElement); + lineRow.appendChild(lineContentElement); } lineRow.lineNumber = lineNumber; lineNumberElement.textContent = lineNumber + 1; diff --git a/Source/WebCore/inspector/front-end/UglifyJS/parse-js.js b/Source/WebCore/inspector/front-end/UglifyJS/parse-js.js new file mode 100644 index 0000000..a218c01 --- /dev/null +++ b/Source/WebCore/inspector/front-end/UglifyJS/parse-js.js @@ -0,0 +1,1233 @@ +/*********************************************************************** + + A JavaScript tokenizer / parser / beautifier / compressor. + + This version is suitable for Node.js. With minimal changes (the + exports stuff) it should work on any JS platform. + + This file contains the tokenizer/parser. It is a port to JavaScript + of parse-js [1], a JavaScript parser library written in Common Lisp + by Marijn Haverbeke. Thank you Marijn! + + [1] http://marijn.haverbeke.nl/parse-js/ + + Exported functions: + + - tokenizer(code) -- returns a function. Call the returned + function to fetch the next token. + + - parse(code) -- returns an AST of the given JavaScript code. + + -------------------------------- (C) --------------------------------- + + Author: Mihai Bazon + <mihai.bazon@gmail.com> + http://mihai.bazon.net/blog + + Distributed under the BSD license: + + Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com> + Based on parse-js (http://marijn.haverbeke.nl/parse-js/). + + 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “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 HOLDER 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. + + ***********************************************************************/ + +/* -----[ Tokenizer (constants) ]----- */ + +var KEYWORDS = array_to_hash([ + "break", + "case", + "catch", + "const", + "continue", + "default", + "delete", + "do", + "else", + "finally", + "for", + "function", + "if", + "in", + "instanceof", + "new", + "return", + "switch", + "throw", + "try", + "typeof", + "var", + "void", + "while", + "with" +]); + +var RESERVED_WORDS = array_to_hash([ + "abstract", + "boolean", + "byte", + "char", + "class", + "debugger", + "double", + "enum", + "export", + "extends", + "final", + "float", + "goto", + "implements", + "import", + "int", + "interface", + "long", + "native", + "package", + "private", + "protected", + "public", + "short", + "static", + "super", + "synchronized", + "throws", + "transient", + "volatile" +]); + +var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([ + "return", + "new", + "delete", + "throw", + "else", + "case" +]); + +var KEYWORDS_ATOM = array_to_hash([ + "false", + "null", + "true", + "undefined" +]); + +var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^")); + +var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i; +var RE_OCT_NUMBER = /^0[0-7]+$/; +var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i; + +var OPERATORS = array_to_hash([ + "in", + "instanceof", + "typeof", + "new", + "void", + "delete", + "++", + "--", + "+", + "-", + "!", + "~", + "&", + "|", + "^", + "*", + "/", + "%", + ">>", + "<<", + ">>>", + "<", + ">", + "<=", + ">=", + "==", + "===", + "!=", + "!==", + "?", + "=", + "+=", + "-=", + "/=", + "*=", + "%=", + ">>=", + "<<=", + ">>>=", + "~=", + "%=", + "|=", + "^=", + "&=", + "&&", + "||" +]); + +var WHITESPACE_CHARS = array_to_hash(characters(" \n\r\t")); + +var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:")); + +var PUNC_CHARS = array_to_hash(characters("[]{}(),;:")); + +var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy")); + +/* -----[ Tokenizer ]----- */ + +function is_alphanumeric_char(ch) { + ch = ch.charCodeAt(0); + return (ch >= 48 && ch <= 57) || + (ch >= 65 && ch <= 90) || + (ch >= 97 && ch <= 122); +}; + +function is_identifier_char(ch) { + return is_alphanumeric_char(ch) || ch == "$" || ch == "_"; +}; + +function is_digit(ch) { + ch = ch.charCodeAt(0); + return ch >= 48 && ch <= 57; +}; + +function parse_js_number(num) { + if (RE_HEX_NUMBER.test(num)) { + return parseInt(num.substr(2), 16); + } else if (RE_OCT_NUMBER.test(num)) { + return parseInt(num.substr(1), 8); + } else if (RE_DEC_NUMBER.test(num)) { + return parseFloat(num); + } +}; + +function JS_Parse_Error(message, line, col, pos) { + this.message = message; + this.line = line; + this.col = col; + this.pos = pos; + try { + ({})(); + } catch(ex) { + this.stack = ex.stack; + }; +}; + +JS_Parse_Error.prototype.toString = function() { + return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack; +}; + +function js_error(message, line, col, pos) { + throw new JS_Parse_Error(message, line, col, pos); +}; + +function is_token(token, type, val) { + return token.type == type && (val == null || token.value == val); +}; + +var EX_EOF = {}; + +function tokenizer($TEXT, skip_comments) { + + var S = { + text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''), + pos : 0, + tokpos : 0, + line : 0, + tokline : 0, + col : 0, + tokcol : 0, + newline_before : false, + regex_allowed : false + }; + + function peek() { return S.text.charAt(S.pos); }; + + function next(signal_eof) { + var ch = S.text.charAt(S.pos++); + if (signal_eof && !ch) + throw EX_EOF; + if (ch == "\n") { + S.newline_before = true; + ++S.line; + S.col = 0; + } else { + ++S.col; + } + return ch; + }; + + function eof() { + return !S.peek(); + }; + + function find(what, signal_eof) { + var pos = S.text.indexOf(what, S.pos); + if (signal_eof && pos == -1) throw EX_EOF; + return pos; + }; + + function start_token() { + S.tokline = S.line; + S.tokcol = S.col; + S.tokpos = S.pos; + }; + + function token(type, value) { + S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) || + (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) || + (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value))); + var ret = { + type : type, + value : value, + line : S.tokline, + col : S.tokcol, + pos : S.tokpos, + nlb : S.newline_before + }; + S.newline_before = false; + return ret; + }; + + function skip_whitespace() { + while (HOP(WHITESPACE_CHARS, peek())) + next(); + }; + + function read_while(pred) { + var ret = "", ch = peek(), i = 0; + while (ch && pred(ch, i++)) { + ret += next(); + ch = peek(); + } + return ret; + }; + + function parse_error(err) { + js_error(err, S.tokline, S.tokcol, S.tokpos); + }; + + function read_num(prefix) { + var has_e = false, after_e = false, has_x = false; + var num = read_while(function(ch, i){ + if (ch == "x" || ch == "X") { + if (has_x) return false; + return has_x = true; + } + if (!has_x && (ch == "E" || ch == "e")) { + if (has_e) return false; + return has_e = after_e = true; + } + if (ch == "-") { + if (after_e || (i == 0 && !prefix)) return true; + return false; + } + if (ch == "+") return after_e; + after_e = false; + return is_alphanumeric_char(ch) || ch == "."; + }); + if (prefix) + num = prefix + num; + var valid = parse_js_number(num); + if (!isNaN(valid)) { + return token("num", valid); + } else { + parse_error("Invalid syntax: " + num); + } + }; + + function read_escaped_char() { + var ch = next(true); + switch (ch) { + case "n" : return "\n"; + case "r" : return "\r"; + case "t" : return "\t"; + case "b" : return "\b"; + case "v" : return "\v"; + case "f" : return "\f"; + case "0" : return "\0"; + case "x" : return String.fromCharCode(hex_bytes(2)); + case "u" : return String.fromCharCode(hex_bytes(4)); + default : return ch; + } + }; + + function hex_bytes(n) { + var num = 0; + for (; n > 0; --n) { + var digit = parseInt(next(true), 16); + if (isNaN(digit)) + parse_error("Invalid hex-character pattern in string"); + num = (num << 4) | digit; + } + return num; + }; + + function read_string() { + return with_eof_error("Unterminated string constant", function(){ + var quote = next(), ret = ""; + for (;;) { + var ch = next(true); + if (ch == "\\") ch = read_escaped_char(); + else if (ch == quote) break; + ret += ch; + } + return token("string", ret); + }); + }; + + function read_line_comment() { + next(); + var i = find("\n"), ret; + if (i == -1) { + ret = S.text.substr(S.pos); + S.pos = S.text.length; + } else { + ret = S.text.substring(S.pos, i); + S.pos = i; + } + return token("comment1", ret); + }; + + function read_multiline_comment() { + next(); + return with_eof_error("Unterminated multiline comment", function(){ + var i = find("*/", true), + text = S.text.substring(S.pos, i), + tok = token("comment2", text); + S.pos = i + 2; + S.newline_before = text.indexOf("\n") >= 0; + return tok; + }); + }; + + function read_regexp() { + return with_eof_error("Unterminated regular expression", function(){ + var prev_backslash = false, regexp = "", ch, in_class = false; + while ((ch = next(true))) if (prev_backslash) { + regexp += "\\" + ch; + prev_backslash = false; + } else if (ch == "[") { + in_class = true; + regexp += ch; + } else if (ch == "]" && in_class) { + in_class = false; + regexp += ch; + } else if (ch == "/" && !in_class) { + break; + } else if (ch == "\\") { + prev_backslash = true; + } else { + regexp += ch; + } + var mods = read_while(function(ch){ + return HOP(REGEXP_MODIFIERS, ch); + }); + return token("regexp", [ regexp, mods ]); + }); + }; + + function read_operator(prefix) { + function grow(op) { + var bigger = op + peek(); + if (HOP(OPERATORS, bigger)) { + next(); + return grow(bigger); + } else { + return op; + } + }; + return token("operator", grow(prefix || next())); + }; + + var handle_slash = skip_comments ? function() { + next(); + var regex_allowed = S.regex_allowed; + switch (peek()) { + case "/": read_line_comment(); S.regex_allowed = regex_allowed; return next_token(); + case "*": read_multiline_comment(); S.regex_allowed = regex_allowed; return next_token(); + } + return S.regex_allowed ? read_regexp() : read_operator("/"); + } : function() { + next(); + switch (peek()) { + case "/": return read_line_comment(); + case "*": return read_multiline_comment(); + } + return S.regex_allowed ? read_regexp() : read_operator("/"); + }; + + function handle_dot() { + next(); + return is_digit(peek()) + ? read_num(".") + : token("punc", "."); + }; + + function read_word() { + var word = read_while(is_identifier_char); + return !HOP(KEYWORDS, word) + ? token("name", word) + : HOP(OPERATORS, word) + ? token("operator", word) + : HOP(KEYWORDS_ATOM, word) + ? token("atom", word) + : token("keyword", word); + }; + + function with_eof_error(eof_error, cont) { + try { + return cont(); + } catch(ex) { + if (ex === EX_EOF) parse_error(eof_error); + else throw ex; + } + }; + + function next_token(force_regexp) { + if (force_regexp) + return read_regexp(); + skip_whitespace(); + start_token(); + var ch = peek(); + if (!ch) return token("eof"); + if (is_digit(ch)) return read_num(); + if (ch == '"' || ch == "'") return read_string(); + if (HOP(PUNC_CHARS, ch)) return token("punc", next()); + if (ch == ".") return handle_dot(); + if (ch == "/") return handle_slash(); + if (HOP(OPERATOR_CHARS, ch)) return read_operator(); + if (is_identifier_char(ch)) return read_word(); + parse_error("Unexpected character '" + ch + "'"); + }; + + next_token.context = function(nc) { + if (nc) S = nc; + return S; + }; + + return next_token; + +}; + +/* -----[ Parser (constants) ]----- */ + +var UNARY_PREFIX = array_to_hash([ + "typeof", + "void", + "delete", + "--", + "++", + "!", + "~", + "-", + "+" +]); + +var UNARY_POSTFIX = array_to_hash([ "--", "++" ]); + +var ASSIGNMENT = (function(a, ret, i){ + while (i < a.length) { + ret[a[i]] = a[i].substr(0, a[i].length - 1); + i++; + } + return ret; +})( + ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "~=", "%=", "|=", "^=", "&="], + { "=": true }, + 0 +); + +var PRECEDENCE = (function(a, ret){ + for (var i = 0, n = 1; i < a.length; ++i, ++n) { + var b = a[i]; + for (var j = 0; j < b.length; ++j) { + ret[b[j]] = n; + } + } + return ret; +})( + [ + ["||"], + ["&&"], + ["|"], + ["^"], + ["&"], + ["==", "===", "!=", "!=="], + ["<", ">", "<=", ">=", "in", "instanceof"], + [">>", "<<", ">>>"], + ["+", "-"], + ["*", "/", "%"] + ], + {} +); + +var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]); + +var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]); + +/* -----[ Parser ]----- */ + +function NodeWithToken(str, start, end) { + this.name = str; + this.start = start; + this.end = end; +}; + +NodeWithToken.prototype.toString = function() { return this.name; }; + +function parse($TEXT, strict_mode, embed_tokens) { + + var S = { + input: tokenizer($TEXT, true), + token: null, + prev: null, + peeked: null, + in_function: 0, + in_loop: 0, + labels: [] + }; + + S.token = next(); + + function is(type, value) { + return is_token(S.token, type, value); + }; + + function peek() { return S.peeked || (S.peeked = S.input()); }; + + function next() { + S.prev = S.token; + if (S.peeked) { + S.token = S.peeked; + S.peeked = null; + } else { + S.token = S.input(); + } + return S.token; + }; + + function prev() { + return S.prev; + }; + + function croak(msg, line, col, pos) { + var ctx = S.input.context(); + js_error(msg, + line != null ? line : ctx.tokline, + col != null ? col : ctx.tokcol, + pos != null ? pos : ctx.tokpos); + }; + + function token_error(token, msg) { + croak(msg, token.line, token.col); + }; + + function unexpected(token) { + if (token == null) + token = S.token; + token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")"); + }; + + function expect_token(type, val) { + if (is(type, val)) { + return next(); + } + token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type); + }; + + function expect(punc) { return expect_token("punc", punc); }; + + function can_insert_semicolon() { + return !strict_mode && ( + S.token.nlb || is("eof") || is("punc", "}") + ); + }; + + function semicolon() { + if (is("punc", ";")) next(); + else if (!can_insert_semicolon()) unexpected(); + }; + + function as() { + return slice(arguments); + }; + + function parenthesised() { + expect("("); + var ex = expression(); + expect(")"); + return ex; + }; + + function add_tokens(str, start, end) { + return new NodeWithToken(str, start, end); + }; + + var statement = embed_tokens ? function() { + var start = S.token; + var stmt = $statement(); + stmt[0] = add_tokens(stmt[0], start, prev()); + return stmt; + } : $statement; + + function $statement() { + if (is("operator", "/")) { + S.peeked = null; + S.token = S.input(true); // force regexp + } + switch (S.token.type) { + case "num": + case "string": + case "regexp": + case "operator": + case "atom": + return simple_statement(); + + case "name": + return is_token(peek(), "punc", ":") + ? labeled_statement(prog1(S.token.value, next, next)) + : simple_statement(); + + case "punc": + switch (S.token.value) { + case "{": + return as("block", block_()); + case "[": + case "(": + return simple_statement(); + case ";": + next(); + return as("block"); + default: + unexpected(); + } + + case "keyword": + switch (prog1(S.token.value, next)) { + case "break": + return break_cont("break"); + + case "continue": + return break_cont("continue"); + + case "debugger": + semicolon(); + return as("debugger"); + + case "do": + return (function(body){ + expect_token("keyword", "while"); + return as("do", prog1(parenthesised, semicolon), body); + })(in_loop(statement)); + + case "for": + return for_(); + + case "function": + return function_(true); + + case "if": + return if_(); + + case "return": + if (S.in_function == 0) + croak("'return' outside of function"); + return as("return", + is("punc", ";") + ? (next(), null) + : can_insert_semicolon() + ? null + : prog1(expression, semicolon)); + + case "switch": + return as("switch", parenthesised(), switch_block_()); + + case "throw": + return as("throw", prog1(expression, semicolon)); + + case "try": + return try_(); + + case "var": + return prog1(var_, semicolon); + + case "const": + return prog1(const_, semicolon); + + case "while": + return as("while", parenthesised(), in_loop(statement)); + + case "with": + return as("with", parenthesised(), statement()); + + default: + unexpected(); + } + } + }; + + function labeled_statement(label) { + S.labels.push(label); + var start = S.token, stat = statement(); + if (strict_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0])) + unexpected(start); + S.labels.pop(); + return as("label", label, stat); + }; + + function simple_statement() { + return as("stat", prog1(expression, semicolon)); + }; + + function break_cont(type) { + var name = is("name") ? S.token.value : null; + if (name != null) { + next(); + if (!member(name, S.labels)) + croak("Label " + name + " without matching loop or statement"); + } + else if (S.in_loop == 0) + croak(type + " not inside a loop or switch"); + semicolon(); + return as(type, name); + }; + + function for_() { + expect("("); + var has_var = is("keyword", "var"); + if (has_var) + next(); + if (is("name") && is_token(peek(), "operator", "in")) { + // for (i in foo) + var name = S.token.value; + next(); next(); + var obj = expression(); + expect(")"); + return as("for-in", has_var, name, obj, in_loop(statement)); + } else { + // classic for + var init = is("punc", ";") ? null : has_var ? var_() : expression(); + expect(";"); + var test = is("punc", ";") ? null : expression(); + expect(";"); + var step = is("punc", ")") ? null : expression(); + expect(")"); + return as("for", init, test, step, in_loop(statement)); + } + }; + + function function_(in_statement) { + var name = is("name") ? prog1(S.token.value, next) : null; + if (in_statement && !name) + unexpected(); + expect("("); + return as(in_statement ? "defun" : "function", + name, + // arguments + (function(first, a){ + while (!is("punc", ")")) { + if (first) first = false; else expect(","); + if (!is("name")) unexpected(); + a.push(S.token.value); + next(); + } + next(); + return a; + })(true, []), + // body + (function(){ + ++S.in_function; + var loop = S.in_loop; + S.in_loop = 0; + var a = block_(); + --S.in_function; + S.in_loop = loop; + return a; + })()); + }; + + function if_() { + var cond = parenthesised(), body = statement(), belse; + if (is("keyword", "else")) { + next(); + belse = statement(); + } + return as("if", cond, body, belse); + }; + + function block_() { + expect("{"); + var a = []; + while (!is("punc", "}")) { + if (is("eof")) unexpected(); + a.push(statement()); + } + next(); + return a; + }; + + var switch_block_ = curry(in_loop, function(){ + expect("{"); + var a = [], cur = null; + while (!is("punc", "}")) { + if (is("eof")) unexpected(); + if (is("keyword", "case")) { + next(); + cur = []; + a.push([ expression(), cur ]); + expect(":"); + } + else if (is("keyword", "default")) { + next(); + expect(":"); + cur = []; + a.push([ null, cur ]); + } + else { + if (!cur) unexpected(); + cur.push(statement()); + } + } + next(); + return a; + }); + + function try_() { + var body = block_(), bcatch, bfinally; + if (is("keyword", "catch")) { + next(); + expect("("); + if (!is("name")) + croak("Name expected"); + var name = S.token.value; + next(); + expect(")"); + bcatch = [ name, block_() ]; + } + if (is("keyword", "finally")) { + next(); + bfinally = block_(); + } + if (!bcatch && !bfinally) + croak("Missing catch/finally blocks"); + return as("try", body, bcatch, bfinally); + }; + + function vardefs() { + var a = []; + for (;;) { + if (!is("name")) + unexpected(); + var name = S.token.value; + next(); + if (is("operator", "=")) { + next(); + a.push([ name, expression(false) ]); + } else { + a.push([ name ]); + } + if (!is("punc", ",")) + break; + next(); + } + return a; + }; + + function var_() { + return as("var", vardefs()); + }; + + function const_() { + return as("const", vardefs()); + }; + + function new_() { + var newexp = expr_atom(false), args; + if (is("punc", "(")) { + next(); + args = expr_list(")"); + } else { + args = []; + } + return subscripts(as("new", newexp, args), true); + }; + + function expr_atom(allow_calls) { + if (is("operator", "new")) { + next(); + return new_(); + } + if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) { + return make_unary("unary-prefix", + prog1(S.token.value, next), + expr_atom(allow_calls)); + } + if (is("punc")) { + switch (S.token.value) { + case "(": + next(); + return subscripts(prog1(expression, curry(expect, ")")), allow_calls); + case "[": + next(); + return subscripts(array_(), allow_calls); + case "{": + next(); + return subscripts(object_(), allow_calls); + } + unexpected(); + } + if (is("keyword", "function")) { + next(); + return subscripts(function_(false), allow_calls); + } + if (HOP(ATOMIC_START_TOKEN, S.token.type)) { + var atom = S.token.type == "regexp" + ? as("regexp", S.token.value[0], S.token.value[1]) + : as(S.token.type, S.token.value); + return subscripts(prog1(atom, next), allow_calls); + } + unexpected(); + }; + + function expr_list(closing, allow_trailing_comma) { + var first = true, a = []; + while (!is("punc", closing)) { + if (first) first = false; else expect(","); + if (allow_trailing_comma && is("punc", closing)) + break; + a.push(expression(false)); + } + next(); + return a; + }; + + function array_() { + return as("array", expr_list("]", !strict_mode)); + }; + + function object_() { + var first = true, a = []; + while (!is("punc", "}")) { + if (first) first = false; else expect(","); + if (!strict_mode && is("punc", "}")) + // allow trailing comma + break; + var type = S.token.type; + var name = as_property_name(); + if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) { + a.push([ as_name(), function_(false), name ]); + } else { + expect(":"); + a.push([ name, expression(false) ]); + } + } + next(); + return as("object", a); + }; + + function as_property_name() { + switch (S.token.type) { + case "num": + case "string": + return prog1(S.token.value, next); + } + return as_name(); + }; + + function as_name() { + switch (S.token.type) { + case "name": + case "operator": + case "keyword": + case "atom": + return prog1(S.token.value, next); + default: + unexpected(); + } + }; + + function subscripts(expr, allow_calls) { + if (is("punc", ".")) { + next(); + return subscripts(as("dot", expr, as_name()), allow_calls); + } + if (is("punc", "[")) { + next(); + return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls); + } + if (allow_calls && is("punc", "(")) { + next(); + return subscripts(as("call", expr, expr_list(")")), true); + } + if (allow_calls && is("operator") && HOP(UNARY_POSTFIX, S.token.value)) { + return prog1(curry(make_unary, "unary-postfix", S.token.value, expr), + next); + } + return expr; + }; + + function make_unary(tag, op, expr) { + if ((op == "++" || op == "--") && !is_assignable(expr)) + croak("Invalid use of " + op + " operator"); + return as(tag, op, expr); + }; + + function expr_op(left, min_prec) { + var op = is("operator") ? S.token.value : null; + var prec = op != null ? PRECEDENCE[op] : null; + if (prec != null && prec > min_prec) { + next(); + var right = expr_op(expr_atom(true), prec); + return expr_op(as("binary", op, left, right), min_prec); + } + return left; + }; + + function expr_ops() { + return expr_op(expr_atom(true), 0); + }; + + function maybe_conditional() { + var expr = expr_ops(); + if (is("operator", "?")) { + next(); + var yes = expression(false); + expect(":"); + return as("conditional", expr, yes, expression(false)); + } + return expr; + }; + + function is_assignable(expr) { + switch (expr[0]) { + case "dot": + case "sub": + return true; + case "name": + return expr[1] != "this"; + } + }; + + function maybe_assign() { + var left = maybe_conditional(), val = S.token.value; + if (is("operator") && HOP(ASSIGNMENT, val)) { + if (is_assignable(left)) { + next(); + return as("assign", ASSIGNMENT[val], left, maybe_assign()); + } + croak("Invalid assignment"); + } + return left; + }; + + function expression(commas) { + if (arguments.length == 0) + commas = true; + var expr = maybe_assign(); + if (commas && is("punc", ",")) { + next(); + return as("seq", expr, expression()); + } + return expr; + }; + + function in_loop(cont) { + try { + ++S.in_loop; + return cont(); + } finally { + --S.in_loop; + } + }; + + return as("toplevel", (function(a){ + while (!is("eof")) + a.push(statement()); + return a; + })([])); + +}; + +/* -----[ Utilities ]----- */ + +function curry(f) { + var args = slice(arguments, 1); + return function() { return f.apply(this, args.concat(slice(arguments))); }; +}; + +function prog1(ret) { + if (ret instanceof Function) + ret = ret(); + for (var i = 1, n = arguments.length; --n > 0; ++i) + arguments[i](); + return ret; +}; + +function array_to_hash(a) { + var ret = {}; + for (var i = 0; i < a.length; ++i) + ret[a[i]] = true; + return ret; +}; + +function slice(a, start) { + return Array.prototype.slice.call(a, start == null ? 0 : start); +}; + +function characters(str) { + return str.split(""); +}; + +function member(name, array) { + for (var i = array.length; --i >= 0;) + if (array[i] === name) + return true; + return false; +}; + +function HOP(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +}; + +/* -----[ Exports ]----- */ + +exports.tokenizer = tokenizer; +exports.parse = parse; +exports.slice = slice; +exports.curry = curry; +exports.member = member; +exports.array_to_hash = array_to_hash; +exports.PRECEDENCE = PRECEDENCE; +exports.KEYWORDS_ATOM = KEYWORDS_ATOM; +exports.RESERVED_WORDS = RESERVED_WORDS; +exports.KEYWORDS = KEYWORDS; +exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN; +exports.OPERATORS = OPERATORS; +exports.is_alphanumeric_char = is_alphanumeric_char; diff --git a/Source/WebCore/inspector/front-end/UglifyJS/process.js b/Source/WebCore/inspector/front-end/UglifyJS/process.js new file mode 100755 index 0000000..65dbc0e --- /dev/null +++ b/Source/WebCore/inspector/front-end/UglifyJS/process.js @@ -0,0 +1,1560 @@ +/*********************************************************************** + + A JavaScript tokenizer / parser / beautifier / compressor. + + This version is suitable for Node.js. With minimal changes (the + exports stuff) it should work on any JS platform. + + This file implements some AST processors. They work on data built + by parse-js. + + Exported functions: + + - ast_mangle(ast, include_toplevel) -- mangles the + variable/function names in the AST. Returns an AST. Pass true + as second argument to mangle toplevel names too. + + - ast_squeeze(ast) -- employs various optimizations to make the + final generated code even smaller. Returns an AST. + + - gen_code(ast, beautify) -- generates JS code from the AST. Pass + true (or an object, see the code for some options) as second + argument to get "pretty" (indented) code. + + -------------------------------- (C) --------------------------------- + + Author: Mihai Bazon + <mihai.bazon@gmail.com> + http://mihai.bazon.net/blog + + Distributed under the BSD license: + + Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com> + + 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “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 HOLDER 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. + + ***********************************************************************/ + +var jsp = require("./parse-js"), + slice = jsp.slice, + member = jsp.member, + PRECEDENCE = jsp.PRECEDENCE, + OPERATORS = jsp.OPERATORS; + +/* -----[ helper for AST traversal ]----- */ + +function ast_walker(ast) { + function _vardefs(defs) { + return MAP(defs, function(def){ + var a = [ def[0] ]; + if (def.length > 1) + a[1] = walk(def[1]); + return a; + }); + }; + var walkers = { + "string": function(str) { + return [ "string", str ]; + }, + "num": function(num) { + return [ "num", num ]; + }, + "name": function(name) { + return [ "name", name ]; + }, + "toplevel": function(statements) { + return [ "toplevel", MAP(statements, walk) ]; + }, + "block": function(statements) { + var out = [ "block" ]; + if (statements != null) + out.push(MAP(statements, walk)); + return out; + }, + "var": function(defs) { + return [ "var", _vardefs(defs) ]; + }, + "const": function(defs) { + return [ "const", _vardefs(defs) ]; + }, + "try": function(t, c, f) { + return [ + "try", + MAP(t, walk), + c != null ? [ c[0], MAP(c[1], walk) ] : null, + f != null ? MAP(f, walk) : null + ]; + }, + "throw": function(expr) { + return [ "throw", walk(expr) ]; + }, + "new": function(ctor, args) { + return [ "new", walk(ctor), MAP(args, walk) ]; + }, + "switch": function(expr, body) { + return [ "switch", walk(expr), MAP(body, function(branch){ + return [ branch[0] ? walk(branch[0]) : null, + MAP(branch[1], walk) ]; + }) ]; + }, + "break": function(label) { + return [ "break", label ]; + }, + "continue": function(label) { + return [ "continue", label ]; + }, + "conditional": function(cond, t, e) { + return [ "conditional", walk(cond), walk(t), walk(e) ]; + }, + "assign": function(op, lvalue, rvalue) { + return [ "assign", op, walk(lvalue), walk(rvalue) ]; + }, + "dot": function(expr) { + return [ "dot", walk(expr) ].concat(slice(arguments, 1)); + }, + "call": function(expr, args) { + return [ "call", walk(expr), MAP(args, walk) ]; + }, + "function": function(name, args, body) { + return [ "function", name, args.slice(), MAP(body, walk) ]; + }, + "defun": function(name, args, body) { + return [ "defun", name, args.slice(), MAP(body, walk) ]; + }, + "if": function(conditional, t, e) { + return [ "if", walk(conditional), walk(t), walk(e) ]; + }, + "for": function(init, cond, step, block) { + return [ "for", walk(init), walk(cond), walk(step), walk(block) ]; + }, + "for-in": function(has_var, key, hash, block) { + return [ "for-in", has_var, key, walk(hash), walk(block) ]; + }, + "while": function(cond, block) { + return [ "while", walk(cond), walk(block) ]; + }, + "do": function(cond, block) { + return [ "do", walk(cond), walk(block) ]; + }, + "return": function(expr) { + return [ "return", walk(expr) ]; + }, + "binary": function(op, left, right) { + return [ "binary", op, walk(left), walk(right) ]; + }, + "unary-prefix": function(op, expr) { + return [ "unary-prefix", op, walk(expr) ]; + }, + "unary-postfix": function(op, expr) { + return [ "unary-postfix", op, walk(expr) ]; + }, + "sub": function(expr, subscript) { + return [ "sub", walk(expr), walk(subscript) ]; + }, + "object": function(props) { + return [ "object", MAP(props, function(p){ + return p.length == 2 + ? [ p[0], walk(p[1]) ] + : [ p[0], walk(p[1]), p[2] ]; // get/set-ter + }) ]; + }, + "regexp": function(rx, mods) { + return [ "regexp", rx, mods ]; + }, + "array": function(elements) { + return [ "array", MAP(elements, walk) ]; + }, + "stat": function(stat) { + return [ "stat", walk(stat) ]; + }, + "seq": function() { + return [ "seq" ].concat(MAP(slice(arguments), walk)); + }, + "label": function(name, block) { + return [ "label", name, walk(block) ]; + }, + "with": function(expr, block) { + return [ "with", walk(expr), walk(block) ]; + }, + "atom": function(name) { + return [ "atom", name ]; + } + }; + + var user = {}; + var stack = []; + function walk(ast) { + if (ast == null) + return null; + try { + stack.push(ast); + var type = ast[0]; + var gen = user[type]; + if (gen) { + var ret = gen.apply(ast, ast.slice(1)); + if (ret != null) + return ret; + } + gen = walkers[type]; + return gen.apply(ast, ast.slice(1)); + } finally { + stack.pop(); + } + }; + + function with_walkers(walkers, cont){ + var save = {}, i; + for (i in walkers) if (HOP(walkers, i)) { + save[i] = user[i]; + user[i] = walkers[i]; + } + var ret = cont(); + for (i in save) if (HOP(save, i)) { + if (!save[i]) delete user[i]; + else user[i] = save[i]; + } + return ret; + }; + + return { + walk: walk, + with_walkers: with_walkers, + parent: function() { + return stack[stack.length - 2]; // last one is current node + }, + stack: function() { + return stack; + } + }; +}; + +/* -----[ Scope and mangling ]----- */ + +function Scope(parent) { + this.names = {}; // names defined in this scope + this.mangled = {}; // mangled names (orig.name => mangled) + this.rev_mangled = {}; // reverse lookup (mangled => orig.name) + this.cname = -1; // current mangled name + this.refs = {}; // names referenced from this scope + this.uses_with = false; // will become TRUE if eval() is detected in this or any subscopes + this.uses_eval = false; // will become TRUE if with() is detected in this or any subscopes + this.parent = parent; // parent scope + this.children = []; // sub-scopes + if (parent) { + this.level = parent.level + 1; + parent.children.push(this); + } else { + this.level = 0; + } +}; + +var base54 = (function(){ + var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; + return function(num) { + var ret = ""; + do { + ret = DIGITS.charAt(num % 54) + ret; + num = Math.floor(num / 54); + } while (num > 0); + return ret; + }; +})(); + +Scope.prototype = { + has: function(name) { + for (var s = this; s; s = s.parent) + if (HOP(s.names, name)) + return s; + }, + has_mangled: function(mname) { + for (var s = this; s; s = s.parent) + if (HOP(s.rev_mangled, mname)) + return s; + }, + toJSON: function() { + return { + names: this.names, + uses_eval: this.uses_eval, + uses_with: this.uses_with + }; + }, + + next_mangled: function() { + // we must be careful that the new mangled name: + // + // 1. doesn't shadow a mangled name from a parent + // scope, unless we don't reference the original + // name from this scope OR from any sub-scopes! + // This will get slow. + // + // 2. doesn't shadow an original name from a parent + // scope, in the event that the name is not mangled + // in the parent scope and we reference that name + // here OR IN ANY SUBSCOPES! + // + // 3. doesn't shadow a name that is referenced but not + // defined (possibly global defined elsewhere). + for (;;) { + var m = base54(++this.cname), prior; + + // case 1. + prior = this.has_mangled(m); + if (prior && this.refs[prior.rev_mangled[m]] === prior) + continue; + + // case 2. + prior = this.has(m); + if (prior && prior !== this && this.refs[m] === prior && !prior.has_mangled(m)) + continue; + + // case 3. + if (HOP(this.refs, m) && this.refs[m] == null) + continue; + + // I got "do" once. :-/ + if (!is_identifier(m)) + continue; + + return m; + } + }, + get_mangled: function(name, newMangle) { + if (this.uses_eval || this.uses_with) return name; // no mangle if eval or with is in use + var s = this.has(name); + if (!s) return name; // not in visible scope, no mangle + if (HOP(s.mangled, name)) return s.mangled[name]; // already mangled in this scope + if (!newMangle) return name; // not found and no mangling requested + + var m = s.next_mangled(); + s.rev_mangled[m] = name; + return s.mangled[name] = m; + }, + define: function(name) { + if (name != null) + return this.names[name] = name; + } +}; + +function ast_add_scope(ast) { + + var current_scope = null; + var w = ast_walker(), walk = w.walk; + var having_eval = []; + + function with_new_scope(cont) { + current_scope = new Scope(current_scope); + var ret = current_scope.body = cont(); + ret.scope = current_scope; + current_scope = current_scope.parent; + return ret; + }; + + function define(name) { + return current_scope.define(name); + }; + + function reference(name) { + current_scope.refs[name] = true; + }; + + function _lambda(name, args, body) { + return [ this[0], define(name), args, with_new_scope(function(){ + MAP(args, define); + return MAP(body, walk); + })]; + }; + + return with_new_scope(function(){ + // process AST + var ret = w.with_walkers({ + "function": _lambda, + "defun": _lambda, + "with": function(expr, block) { + for (var s = current_scope; s; s = s.parent) + s.uses_with = true; + }, + "var": function(defs) { + MAP(defs, function(d){ define(d[0]) }); + }, + "const": function(defs) { + MAP(defs, function(d){ define(d[0]) }); + }, + "try": function(t, c, f) { + if (c != null) return [ + "try", + MAP(t, walk), + [ define(c[0]), MAP(c[1], walk) ], + f != null ? MAP(f, walk) : null + ]; + }, + "name": function(name) { + if (name == "eval") + having_eval.push(current_scope); + reference(name); + }, + "for-in": function(has_var, name) { + if (has_var) define(name); + else reference(name); + } + }, function(){ + return walk(ast); + }); + + // the reason why we need an additional pass here is + // that names can be used prior to their definition. + + // scopes where eval was detected and their parents + // are marked with uses_eval, unless they define the + // "eval" name. + MAP(having_eval, function(scope){ + if (!scope.has("eval")) while (scope) { + scope.uses_eval = true; + scope = scope.parent; + } + }); + + // for referenced names it might be useful to know + // their origin scope. current_scope here is the + // toplevel one. + function fixrefs(scope, i) { + // do children first; order shouldn't matter + for (i = scope.children.length; --i >= 0;) + fixrefs(scope.children[i]); + for (i in scope.refs) if (HOP(scope.refs, i)) { + // find origin scope and propagate the reference to origin + for (var origin = scope.has(i), s = scope; s; s = s.parent) { + s.refs[i] = origin; + if (s === origin) break; + } + } + }; + fixrefs(current_scope); + + return ret; + }); + +}; + +/* -----[ mangle names ]----- */ + +function ast_mangle(ast, do_toplevel) { + var w = ast_walker(), walk = w.walk, scope; + + function get_mangled(name, newMangle) { + if (!do_toplevel && !scope.parent) return name; // don't mangle toplevel + return scope.get_mangled(name, newMangle); + }; + + function _lambda(name, args, body) { + if (name) name = get_mangled(name); + body = with_scope(body.scope, function(){ + args = MAP(args, function(name){ return get_mangled(name) }); + return MAP(body, walk); + }); + return [ this[0], name, args, body ]; + }; + + function with_scope(s, cont) { + var _scope = scope; + scope = s; + for (var i in s.names) if (HOP(s.names, i)) { + get_mangled(i, true); + } + var ret = cont(); + ret.scope = s; + scope = _scope; + return ret; + }; + + function _vardefs(defs) { + return MAP(defs, function(d){ + return [ get_mangled(d[0]), walk(d[1]) ]; + }); + }; + + return w.with_walkers({ + "function": _lambda, + "defun": function() { + // move function declarations to the top when + // they are not in some block. + var ast = _lambda.apply(this, arguments); + switch (w.parent()[0]) { + case "toplevel": + case "function": + case "defun": + return MAP.at_top(ast); + } + return ast; + }, + "var": function(defs) { + return [ "var", _vardefs(defs) ]; + }, + "const": function(defs) { + return [ "const", _vardefs(defs) ]; + }, + "name": function(name) { + return [ "name", get_mangled(name) ]; + }, + "try": function(t, c, f) { + return [ "try", + MAP(t, walk), + c != null ? [ get_mangled(c[0]), MAP(c[1], walk) ] : null, + f != null ? MAP(f, walk) : null ]; + }, + "toplevel": function(body) { + return with_scope(this.scope, function(){ + return [ "toplevel", MAP(body, walk) ]; + }); + }, + "for-in": function(has_var, name, obj, stat) { + return [ "for-in", has_var, get_mangled(name), walk(obj), walk(stat) ]; + } + }, function() { + return walk(ast_add_scope(ast)); + }); +}; + +/* -----[ + - compress foo["bar"] into foo.bar, + - remove block brackets {} where possible + - join consecutive var declarations + - various optimizations for IFs: + - if (cond) foo(); else bar(); ==> cond?foo():bar(); + - if (cond) foo(); ==> cond&&foo(); + - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); // also for throw + - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} + ]----- */ + +var warn = function(){}; + +function best_of(ast1, ast2) { + return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1; +}; + +function last_stat(b) { + if (b[0] == "block" && b[1] && b[1].length > 0) + return b[1][b[1].length - 1]; + return b; +} + +function aborts(t) { + if (t) { + t = last_stat(t); + if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw") + return true; + } +}; + +function negate(c) { + var not_c = [ "unary-prefix", "!", c ]; + switch (c[0]) { + case "unary-prefix": + return c[1] == "!" ? c[2] : not_c; + case "binary": + var op = c[1], left = c[2], right = c[3]; + switch (op) { + case "<=": return [ "binary", ">", left, right ]; + case "<": return [ "binary", ">=", left, right ]; + case ">=": return [ "binary", "<", left, right ]; + case ">": return [ "binary", "<=", left, right ]; + case "==": return [ "binary", "!=", left, right ]; + case "!=": return [ "binary", "==", left, right ]; + case "===": return [ "binary", "!==", left, right ]; + case "!==": return [ "binary", "===", left, right ]; + case "&&": return best_of(not_c, [ "binary", "||", negate(left), negate(right) ]); + case "||": return best_of(not_c, [ "binary", "&&", negate(left), negate(right) ]); + } + break; + } + return not_c; +}; + +function make_conditional(c, t, e) { + if (c[0] == "unary-prefix" && c[1] == "!") { + return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ]; + } else { + return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ]; + } +}; + +function empty(b) { + return !b || (b[0] == "block" && (!b[1] || b[1].length == 0)); +}; + +function ast_squeeze(ast, options) { + options = defaults(options, { + make_seqs : true, + dead_code : true, + no_warnings : false, + extra : false + }); + + var w = ast_walker(), walk = w.walk, scope; + + function with_scope(s, cont) { + var _scope = scope; + scope = s; + var ret = cont(); + ret.scope = s; + scope = _scope; + return ret; + }; + + function is_constant(node) { + return node[0] == "string" || node[0] == "num"; + }; + + function find_first_execute(node) { + if (!node) + return false; + + switch (node[0]) { + case "num": + case "string": + case "name": + return node; + case "call": + case "conditional": + case "for": + case "if": + case "new": + case "return": + case "stat": + case "switch": + case "throw": + return find_first_execute(node[1]); + case "binary": + return find_first_execute(node[2]); + case "assign": + if (node[1] === true) + return find_first_execute(node[3]); + break; + case "var": + if (node[1][0].length > 1) + return find_first_execute(node[1][0][1]); + break; + } + return null; + } + + function find_assign_recursive(p, v) { + if (p[0] == "assign" && p[1] != true || p[0] == "unary-prefix") { + if (p[2][0] == "name" && v[0] == "name" && p[2][1] == v[1]) + return true; + return false; + } + + if (p[0] != "assign" || p[1] !== true) + return false; + + if ((is_constant(p[3]) && p[3][0] == v[0] && p[3][1] == v[1]) || + (p[3][0] == "name" && v[0] == "name" && p[3][1] == v[1]) || + (p[2][0] == "name" && v[0] == "name" && p[2][1] == v[1])) + return true; + + return find_assign_recursive(p[3], v); + }; + + function rmblock(block) { + if (block != null && block[0] == "block" && block[1] && block[1].length == 1) + block = block[1][0]; + return block; + }; + + function clone(obj) { + if (obj && obj.constructor == Array) + return MAP(obj, clone); + return obj; + }; + + function make_seq_to_statements(node) { + if (node[0] != "seq") { + switch (node[0]) { + case "var": + case "const": + return [ node ]; + default: + return [ [ "stat", node ] ]; + } + } + + var ret = []; + for (var i = 1; i < node.length; i++) + ret.push.apply(ret, make_seq_to_statements(node[i])); + + return ret; + }; + + function _lambda(name, args, body) { + return [ this[0], name, args, with_scope(body.scope, function(){ + return tighten(MAP(body, walk), "lambda"); + }) ]; + }; + + // we get here for blocks that have been already transformed. + // this function does a few things: + // 1. discard useless blocks + // 2. join consecutive var declarations + // 3. remove obviously dead code + // 4. transform consecutive statements using the comma operator + // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... } + function tighten(statements, block_type) { + statements = statements.reduce(function(a, stat){ + if (stat[0] == "block") { + if (stat[1]) { + a.push.apply(a, stat[1]); + } + } else { + a.push(stat); + } + return a; + }, []); + + if (options.extra) { + // Detightening things. We do this because then we can assume that the + // statements are structured in a specific way. + statements = (function(a, prev) { + statements.forEach(function(cur) { + switch (cur[0]) { + case "for": + if (cur[1] != null) { + a.push.apply(a, make_seq_to_statements(cur[1])); + cur[1] = null; + } + a.push(cur); + break; + case "stat": + var stats = make_seq_to_statements(cur[1]); + stats.forEach(function(s) { + if (s[1][0] == "unary-postfix") + s[1][0] = "unary-prefix"; + }); + a.push.apply(a, stats); + break; + default: + a.push(cur); + } + }); + return a; + })([]); + + statements = (function(a, prev) { + statements.forEach(function(cur) { + if (!(prev && prev[0] == "stat")) { + a.push(cur); + prev = cur; + return; + } + + var p = prev[1]; + var c = find_first_execute(cur); + if (c && find_assign_recursive(p, c)) { + var old_cur = clone(cur); + c.splice(0, c.length); + c.push.apply(c, p); + var tmp_cur = best_of(cur, [ "toplevel", [ prev, old_cur ] ]); + if (tmp_cur == cur) { + a[a.length -1] = cur; + } else { + cur = old_cur; + a.push(cur); + } + } else { + a.push(cur); + } + prev = cur; + }); + return a; + })([]); + } + + statements = (function(a, prev){ + statements.forEach(function(cur){ + if (prev && ((cur[0] == "var" && prev[0] == "var") || + (cur[0] == "const" && prev[0] == "const"))) { + prev[1] = prev[1].concat(cur[1]); + } else { + a.push(cur); + prev = cur; + } + }); + return a; + })([]); + + if (options.dead_code) statements = (function(a, has_quit){ + statements.forEach(function(st){ + if (has_quit) { + if (member(st[0], [ "function", "defun" , "var", "const" ])) { + a.push(st); + } + else if (!options.no_warnings) + warn("Removing unreachable code: " + gen_code(st, true)); + } + else { + a.push(st); + if (member(st[0], [ "return", "throw", "break", "continue" ])) + has_quit = true; + } + }); + return a; + })([]); + + if (options.make_seqs) statements = (function(a, prev) { + statements.forEach(function(cur){ + if (prev && prev[0] == "stat" && cur[0] == "stat") { + prev[1] = [ "seq", prev[1], cur[1] ]; + } else { + a.push(cur); + prev = cur; + } + }); + return a; + })([]); + + if (options.extra) { + statements = (function(a, prev){ + statements.forEach(function(cur){ + var replaced = false; + if (prev && cur[0] == "for" && cur[1] == null && (prev[0] == "var" || prev[0] == "const" || prev[0] == "stat")) { + cur[1] = prev; + a[a.length - 1] = cur; + } else { + a.push(cur); + } + prev = cur; + }); + return a; + })([]); + } + + if (block_type == "lambda") statements = (function(i, a, stat){ + while (i < statements.length) { + stat = statements[i++]; + if (stat[0] == "if" && !stat[3]) { + if (stat[2][0] == "return" && stat[2][1] == null) { + a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ])); + break; + } + var last = last_stat(stat[2]); + if (last[0] == "return" && last[1] == null) { + a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ])); + break; + } + } + a.push(stat); + } + return a; + })(0, []); + + return statements; + }; + + function make_if(c, t, e) { + c = walk(c); + t = walk(t); + e = walk(e); + + if (empty(t)) { + c = negate(c); + t = e; + e = null; + } else if (empty(e)) { + e = null; + } else { + // if we have both else and then, maybe it makes sense to switch them? + (function(){ + var a = gen_code(c); + var n = negate(c); + var b = gen_code(n); + if (b.length < a.length) { + var tmp = t; + t = e; + e = tmp; + c = n; + } + })(); + } + if (empty(e) && empty(t)) + return [ "stat", c ]; + var ret = [ "if", c, t, e ]; + if (t[0] == "stat") { + if (e) { + if (e[0] == "stat") { + ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]); + } + } + else { + ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]); + } + } + else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw")) { + ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]); + } + else if (e && aborts(t)) { + ret = [ [ "if", c, t ] ]; + if (e[0] == "block") { + if (e[1]) ret = ret.concat(e[1]); + } + else { + ret.push(e); + } + ret = walk([ "block", ret ]); + } + else if (t && aborts(e)) { + ret = [ [ "if", negate(c), e ] ]; + if (t[0] == "block") { + if (t[1]) ret = ret.concat(t[1]); + } else { + ret.push(t); + } + ret = walk([ "block", ret ]); + } + return ret; + }; + + return w.with_walkers({ + "sub": function(expr, subscript) { + if (subscript[0] == "string") { + var name = subscript[1]; + if (is_identifier(name)) { + return [ "dot", walk(expr), name ]; + } + } + }, + "if": make_if, + "toplevel": function(body) { + return [ "toplevel", with_scope(this.scope, function(){ + return tighten(MAP(body, walk)); + }) ]; + }, + "switch": function(expr, body) { + var last = body.length - 1; + return [ "switch", walk(expr), MAP(body, function(branch, i){ + var block = tighten(MAP(branch[1], walk)); + if (i == last && block.length > 0) { + var node = block[block.length - 1]; + if (node[0] == "break" && !node[1]) + block.pop(); + } + return [ branch[0] ? walk(branch[0]) : null, block ]; + }) ]; + }, + "function": _lambda, + "defun": _lambda, + "block": function(body) { + if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]); + }, + "binary": function(op, left, right) { + left = walk(left); + right = walk(right); + var best = [ "binary", op, left, right ]; + if (is_constant(right)) { + if (is_constant(left)) { + var val = null; + switch (op) { + case "+": val = left[1] + right[1]; break; + case "*": val = left[1] * right[1]; break; + case "/": val = left[1] / right[1]; break; + case "-": val = left[1] - right[1]; break; + case "<<": val = left[1] << right[1]; break; + case ">>": val = left[1] >> right[1]; break; + case ">>>": val = left[1] >>> right[1]; break; + } + if (val != null) { + best = best_of(best, [ typeof val == "string" ? "string" : "num", val ]); + } + } else if (left[0] == "binary" && left[1] == "+" && left[3][0] == "string") { + best = best_of(best, [ "binary", "+", left[2], [ "string", left[3][1] + right[1] ] ]); + } + } + return best; + }, + "conditional": function(c, t, e) { + return make_conditional(walk(c), walk(t), walk(e)); + }, + "try": function(t, c, f) { + return [ + "try", + tighten(MAP(t, walk)), + c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null, + f != null ? tighten(MAP(f, walk)) : null + ]; + }, + "unary-prefix": function(op, cond) { + if (op == "!") { + cond = walk(cond); + if (cond[0] == "unary-prefix" && cond[1] == "!") { + var p = w.parent(); + if (p[0] == "unary-prefix" && p[1] == "!") + return cond[2]; + return [ "unary-prefix", "!", cond ]; + } + return best_of(this, negate(cond)); + } + }, + "name": function(name) { + switch (name) { + case "true": return [ "unary-prefix", "!", [ "num", 0 ]]; + case "false": return [ "unary-prefix", "!", [ "num", 1 ]]; + } + }, + "new": function(ctor, args) { + if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) { + if (args.length != 1) { + return [ "array", args ]; + } else { + return [ "call", [ "name", "Array" ], args ]; + } + } + }, + "call": function(expr, args) { + if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) { + return [ "array", args ]; + } + } + }, function() { + return walk(ast_add_scope(ast)); + }); +}; + +/* -----[ re-generate code from the AST ]----- */ + +var DOT_CALL_NO_PARENS = jsp.array_to_hash([ + "name", + "array", + "string", + "dot", + "sub", + "call", + "regexp" +]); + +function make_string(str) { + var dq = 0, sq = 0; + str = str.replace(/[\\\b\f\n\r\t\x22\x27]/g, function(s){ + switch (s) { + case "\\": return "\\\\"; + case "\b": return "\\b"; + case "\f": return "\\f"; + case "\n": return "\\n"; + case "\r": return "\\r"; + case "\t": return "\\t"; + case '"': ++dq; return '"'; + case "'": ++sq; return "'"; + } + return s; + }); + if (dq > sq) { + return "'" + str.replace(/\x27/g, "\\'") + "'"; + } else { + return '"' + str.replace(/\x22/g, '\\"') + '"'; + } +}; + +function gen_code(ast, beautify) { + if (beautify) beautify = defaults(beautify, { + indent_start : 0, + indent_level : 4, + quote_keys : false, + space_colon : false + }); + var indentation = 0, + newline = beautify ? "\n" : "", + space = beautify ? " " : ""; + + function indent(line) { + if (line == null) + line = ""; + if (beautify) + line = repeat_string(" ", beautify.indent_start + indentation * beautify.indent_level) + line; + return line; + }; + + function with_indent(cont, incr) { + if (incr == null) incr = 1; + indentation += incr; + try { return cont.apply(null, slice(arguments, 1)); } + finally { indentation -= incr; } + }; + + function add_spaces(a) { + if (beautify) + return a.join(" "); + var b = []; + for (var i = 0; i < a.length; ++i) { + var next = a[i + 1]; + b.push(a[i]); + if (next && + ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) || + (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) { + b.push(" "); + } + } + return b.join(""); + }; + + function add_commas(a) { + return a.join("," + space); + }; + + function parenthesize(expr) { + var gen = make(expr); + for (var i = 1; i < arguments.length; ++i) { + var el = arguments[i]; + if ((el instanceof Function && el(expr)) || expr[0] == el) + return "(" + gen + ")"; + } + return gen; + }; + + function best_of(a) { + if (a.length == 1) { + return a[0]; + } + if (a.length == 2) { + var b = a[1]; + a = a[0]; + return a.length <= b.length ? a : b; + } + return best_of([ a[0], best_of(a.slice(1)) ]); + }; + + function needs_parens(expr) { + if (expr[0] == "function") { + // dot/call on a literal function requires the + // function literal itself to be parenthesized + // only if it's the first "thing" in a + // statement. This means that the parent is + // "stat", but it could also be a "seq" and + // we're the first in this "seq" and the + // parent is "stat", and so on. Messy stuff, + // but it worths the trouble. + var a = slice($stack), self = a.pop(), p = a.pop(); + while (p) { + if (p[0] == "stat") return true; + if ((p[0] == "seq" && p[1] === self) || + (p[0] == "call" && p[1] === self) || + (p[0] == "binary" && p[2] === self)) { + self = p; + p = a.pop(); + } else { + return false; + } + } + } + return !HOP(DOT_CALL_NO_PARENS, expr[0]); + }; + + function make_num(num) { + var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m; + if (Math.floor(num) === num) { + a.push("0x" + num.toString(16).toLowerCase(), // probably pointless + "0" + num.toString(8)); // same. + if ((m = /^(.*?)(0+)$/.exec(num))) { + a.push(m[1] + "e" + m[2].length); + } + } else if ((m = /^0?\.(0+)(.*)$/.exec(num))) { + a.push(m[2] + "e-" + (m[1].length + m[2].length), + str.substr(str.indexOf("."))); + } + return best_of(a); + }; + + var generators = { + "string": make_string, + "num": make_num, + "name": make_name, + "toplevel": function(statements) { + return make_block_statements(statements) + .join(newline + newline); + }, + "block": make_block, + "var": function(defs) { + return "var " + add_commas(MAP(defs, make_1vardef)) + ";"; + }, + "const": function(defs) { + return "const " + add_commas(MAP(defs, make_1vardef)) + ";"; + }, + "try": function(tr, ca, fi) { + var out = [ "try", make_block(tr) ]; + if (ca) out.push("catch", "(" + ca[0] + ")", make_block(ca[1])); + if (fi) out.push("finally", make_block(fi)); + return add_spaces(out); + }, + "throw": function(expr) { + return add_spaces([ "throw", make(expr) ]) + ";"; + }, + "new": function(ctor, args) { + args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : ""; + return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){ + var w = ast_walker(), has_call = {}; + try { + w.with_walkers({ + "call": function() { throw has_call }, + "function": function() { return this } + }, function(){ + w.walk(expr); + }); + } catch(ex) { + if (ex === has_call) + return true; + throw ex; + } + }) + args ]); + }, + "switch": function(expr, body) { + return add_spaces([ "switch", "(" + make(expr) + ")", make_switch_block(body) ]); + }, + "break": function(label) { + var out = "break"; + if (label != null) + out += " " + make_name(label); + return out + ";"; + }, + "continue": function(label) { + var out = "continue"; + if (label != null) + out += " " + make_name(label); + return out + ";"; + }, + "conditional": function(co, th, el) { + return add_spaces([ parenthesize(co, "assign", "seq", "conditional"), "?", + parenthesize(th, "seq"), ":", + parenthesize(el, "seq") ]); + }, + "assign": function(op, lvalue, rvalue) { + if (op && op !== true) op += "="; + else op = "="; + return add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]); + }, + "dot": function(expr) { + var out = make(expr), i = 1; + if (needs_parens(expr)) + out = "(" + out + ")"; + while (i < arguments.length) + out += "." + make_name(arguments[i++]); + return out; + }, + "call": function(func, args) { + var f = make(func); + if (needs_parens(func)) + f = "(" + f + ")"; + return f + "(" + add_commas(MAP(args, function(expr){ + return parenthesize(expr, "seq"); + })) + ")"; + }, + "function": make_function, + "defun": make_function, + "if": function(co, th, el) { + var out = [ "if", "(" + make(co) + ")", el ? make_then(th) : make(th) ]; + if (el) { + out.push("else", make(el)); + } + return add_spaces(out); + }, + "for": function(init, cond, step, block) { + var out = [ "for" ]; + init = (init != null ? make(init) : "").replace(/;*\s*$/, ";" + space); + cond = (cond != null ? make(cond) : "").replace(/;*\s*$/, ";" + space); + step = (step != null ? make(step) : "").replace(/;*\s*$/, ""); + var args = init + cond + step; + if (args == "; ; ") args = ";;"; + out.push("(" + args + ")", make(block)); + return add_spaces(out); + }, + "for-in": function(has_var, key, hash, block) { + var out = add_spaces([ "for", "(" ]); + if (has_var) + out += "var "; + out += add_spaces([ make_name(key) + " in " + make(hash) + ")", make(block) ]); + return out; + }, + "while": function(condition, block) { + return add_spaces([ "while", "(" + make(condition) + ")", make(block) ]); + }, + "do": function(condition, block) { + return add_spaces([ "do", make(block), "while", "(" + make(condition) + ")" ]) + ";"; + }, + "return": function(expr) { + var out = [ "return" ]; + if (expr != null) out.push(make(expr)); + return add_spaces(out) + ";"; + }, + "binary": function(operator, lvalue, rvalue) { + var left = make(lvalue), right = make(rvalue); + // XXX: I'm pretty sure other cases will bite here. + // we need to be smarter. + // adding parens all the time is the safest bet. + if (member(lvalue[0], [ "assign", "conditional", "seq" ]) || + lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) { + left = "(" + left + ")"; + } + if (member(rvalue[0], [ "assign", "conditional", "seq" ]) || + rvalue[0] == "binary" && PRECEDENCE[operator] >= PRECEDENCE[rvalue[1]]) { + right = "(" + right + ")"; + } + return add_spaces([ left, operator, right ]); + }, + "unary-prefix": function(operator, expr) { + var val = make(expr); + if (!(expr[0] == "num" || (expr[0] == "unary-prefix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) + val = "(" + val + ")"; + return operator + (jsp.is_alphanumeric_char(operator.charAt(0)) ? " " : "") + val; + }, + "unary-postfix": function(operator, expr) { + var val = make(expr); + if (!(expr[0] == "num" || (expr[0] == "unary-postfix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) + val = "(" + val + ")"; + return val + operator; + }, + "sub": function(expr, subscript) { + var hash = make(expr); + if (needs_parens(expr)) + hash = "(" + hash + ")"; + return hash + "[" + make(subscript) + "]"; + }, + "object": function(props) { + if (props.length == 0) + return "{}"; + return "{" + newline + with_indent(function(){ + return MAP(props, function(p){ + if (p.length == 3) { + // getter/setter. The name is in p[0], the arg.list in p[1][2], the + // body in p[1][3] and type ("get" / "set") in p[2]. + return indent(make_function(p[0], p[1][2], p[1][3], p[2])); + } + var key = p[0], val = make(p[1]); + if (beautify && beautify.quote_keys) { + key = make_string(key); + } else if (typeof key == "number" || !beautify && +key + "" == key) { + key = make_num(+key); + } else if (!is_identifier(key)) { + key = make_string(key); + } + return indent(add_spaces(beautify && beautify.space_colon + ? [ key, ":", val ] + : [ key + ":", val ])); + }).join("," + newline); + }) + newline + indent("}"); + }, + "regexp": function(rx, mods) { + return "/" + rx + "/" + mods; + }, + "array": function(elements) { + if (elements.length == 0) return "[]"; + return add_spaces([ "[", add_commas(MAP(elements, function(el){ + return parenthesize(el, "seq"); + })), "]" ]); + }, + "stat": function(stmt) { + return make(stmt).replace(/;*\s*$/, ";"); + }, + "seq": function() { + return add_commas(MAP(slice(arguments), make)); + }, + "label": function(name, block) { + return add_spaces([ make_name(name), ":", make(block) ]); + }, + "with": function(expr, block) { + return add_spaces([ "with", "(" + make(expr) + ")", make(block) ]); + }, + "atom": function(name) { + return make_name(name); + }, + "comment1": function(text) { + return "//" + text + "\n"; + }, + "comment2": function(text) { + return "/*" + text + "*/"; + } + }; + + // The squeezer replaces "block"-s that contain only a single + // statement with the statement itself; technically, the AST + // is correct, but this can create problems when we output an + // IF having an ELSE clause where the THEN clause ends in an + // IF *without* an ELSE block (then the outer ELSE would refer + // to the inner IF). This function checks for this case and + // adds the block brackets if needed. + function make_then(th) { + if (th[0] == "do") { + // https://github.com/mishoo/UglifyJS/issues/#issue/57 + // IE croaks with "syntax error" on code like this: + // if (foo) do ... while(cond); else ... + // we need block brackets around do/while + return make([ "block", [ th ]]); + } + var b = th; + while (true) { + var type = b[0]; + if (type == "if") { + if (!b[3]) + // no else, we must add the block + return make([ "block", [ th ]]); + b = b[3]; + } + else if (type == "while" || type == "do") b = b[2]; + else if (type == "for" || type == "for-in") b = b[4]; + else break; + } + return make(th); + }; + + function make_function(name, args, body, keyword) { + var out = keyword || "function"; + if (name) { + out += " " + make_name(name); + } + out += "(" + add_commas(MAP(args, make_name)) + ")"; + return add_spaces([ out, make_block(body) ]); + }; + + function make_name(name) { + return name.toString(); + }; + + function make_block_statements(statements) { + for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) { + var stat = statements[i]; + var code = make(stat); + if (code != ";") { + if (!beautify && i == last) + code = code.replace(/;+\s*$/, ""); + a.push(code); + } + } + return MAP(a, indent); + }; + + function make_switch_block(body) { + var n = body.length; + if (n == 0) return "{}"; + return "{" + newline + MAP(body, function(branch, i){ + var has_body = branch[1].length > 0, code = with_indent(function(){ + return indent(branch[0] + ? add_spaces([ "case", make(branch[0]) + ":" ]) + : "default:"); + }, 0.5) + (has_body ? newline + with_indent(function(){ + return make_block_statements(branch[1]).join(newline); + }) : ""); + if (!beautify && has_body && i < n - 1) + code += ";"; + return code; + }).join(newline) + newline + indent("}"); + }; + + function make_block(statements) { + if (!statements) return ";"; + if (statements.length == 0) return "{}"; + return "{" + newline + with_indent(function(){ + return make_block_statements(statements).join(newline); + }) + newline + indent("}"); + }; + + function make_1vardef(def) { + var name = def[0], val = def[1]; + if (val != null) + name = add_spaces([ name, "=", make(val) ]); + return name; + }; + + var $stack = []; + + function make(node) { + var type = node[0]; + var gen = generators[type]; + if (!gen) + throw new Error("Can't find generator for \"" + type + "\""); + $stack.push(node); + var ret = gen.apply(type, node.slice(1)); + $stack.pop(); + return ret; + }; + + return make(ast); +}; + +/* -----[ Utilities ]----- */ + +function repeat_string(str, i) { + if (i <= 0) return ""; + if (i == 1) return str; + var d = repeat_string(str, i >> 1); + d += d; + if (i & 1) d += str; + return d; +}; + +function defaults(args, defs) { + var ret = {}; + if (args === true) + args = {}; + for (var i in defs) if (HOP(defs, i)) { + ret[i] = (args && HOP(args, i)) ? args[i] : defs[i]; + } + return ret; +}; + +function is_identifier(name) { + return /^[a-z_$][a-z0-9_$]*$/i.test(name) + && name != "this" + && !HOP(jsp.KEYWORDS_ATOM, name) + && !HOP(jsp.RESERVED_WORDS, name) + && !HOP(jsp.KEYWORDS, name); +}; + +function HOP(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +}; + +// some utilities + +var MAP; + +(function(){ + MAP = function(a, f, o) { + var ret = []; + for (var i = 0; i < a.length; ++i) { + var val = f.call(o, a[i], i); + if (val instanceof AtTop) ret.unshift(val.v); + else ret.push(val); + } + return ret; + }; + MAP.at_top = function(val) { return new AtTop(val) }; + function AtTop(val) { this.v = val }; +})(); + +/* -----[ Exports ]----- */ + +exports.ast_walker = ast_walker; +exports.ast_mangle = ast_mangle; +exports.ast_squeeze = ast_squeeze; +exports.gen_code = gen_code; +exports.ast_add_scope = ast_add_scope; +exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more; +exports.set_logger = function(logger) { warn = logger }; diff --git a/Source/WebCore/inspector/front-end/WebKit.qrc b/Source/WebCore/inspector/front-end/WebKit.qrc index 80a6533..edc1861 100644 --- a/Source/WebCore/inspector/front-end/WebKit.qrc +++ b/Source/WebCore/inspector/front-end/WebKit.qrc @@ -23,6 +23,7 @@ <file>CookieParser.js</file> <file>CookiesTable.js</file> <file>CSSCompletions.js</file> + <file>CSSKeywordCompletions.js</file> <file>CSSStyleModel.js</file> <file>Database.js</file> <file>DatabaseQueryView.js</file> @@ -51,7 +52,6 @@ <file>HelpScreen.js</file> <file>ImageView.js</file> <file>InjectedFakeWorker.js</file> - <file>InjectedScriptAccess.js</file> <file>inspector.js</file> <file>InspectorFrontendHostStub.js</file> <file>KeyboardShortcut.js</file> @@ -81,6 +81,8 @@ <file>ResourcesPanel.js</file> <file>ScopeChainSidebarPane.js</file> <file>Script.js</file> + <file>ScriptFormatter.js</file> + <file>ScriptFormatterWorker.js</file> <file>ScriptsPanel.js</file> <file>ScriptView.js</file> <file>Section.js</file> @@ -114,6 +116,8 @@ <file>WatchExpressionsSidebarPane.js</file> <file>WelcomeView.js</file> <file>WorkersSidebarPane.js</file> + <file>UglifyJS/parse-js.js</file> + <file>UglifyJS/process.js</file> <file>audits.css</file> <file>goToLineDialog.css</file> <file>heapProfiler.css</file> diff --git a/Source/WebCore/inspector/front-end/inspector.css b/Source/WebCore/inspector/front-end/inspector.css index c908427..f629d12 100644 --- a/Source/WebCore/inspector/front-end/inspector.css +++ b/Source/WebCore/inspector/front-end/inspector.css @@ -778,8 +778,8 @@ body.platform-linux .monospace, body.platform-linux .source-code { color: red; } -.auto-complete-text { - color: rgb(128, 128, 128); +.auto-complete-text, .editing .auto-complete-text { + color: rgb(128, 128, 128) !important; -webkit-user-select: none; -webkit-user-modify: read-only; } diff --git a/Source/WebCore/inspector/front-end/inspector.html b/Source/WebCore/inspector/front-end/inspector.html index 44f096f..0e0b9e9 100644 --- a/Source/WebCore/inspector/front-end/inspector.html +++ b/Source/WebCore/inspector/front-end/inspector.html @@ -92,6 +92,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="EventListenersSidebarPane.js"></script> <script type="text/javascript" src="Color.js"></script> <script type="text/javascript" src="CSSCompletions.js"></script> + <script type="text/javascript" src="CSSKeywordCompletions.js"></script> <script type="text/javascript" src="StylesSidebarPane.js"></script> <script type="text/javascript" src="PanelEnablerView.js"></script> <script type="text/javascript" src="WelcomeView.js"></script> @@ -121,6 +122,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="NetworkItemView.js"></script> <script type="text/javascript" src="ResourceView.js"></script> <script type="text/javascript" src="SourceFrame.js"></script> + <script type="text/javascript" src="ScriptFormatter.js"></script> <script type="text/javascript" src="DOMSyntaxHighlighter.js"></script> <script type="text/javascript" src="TextEditorModel.js"></script> <script type="text/javascript" src="TextEditorHighlighter.js"></script> @@ -142,7 +144,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="HeapSnapshotView.js"></script> <script type="text/javascript" src="DebuggerModel.js"></script> <script type="text/javascript" src="DOMAgent.js"></script> - <script type="text/javascript" src="InjectedScriptAccess.js"></script> <script type="text/javascript" src="TimelineAgent.js"></script> <script type="text/javascript" src="TimelinePanel.js"></script> <script type="text/javascript" src="TimelineOverviewPane.js"></script> diff --git a/Source/WebCore/inspector/front-end/inspector.js b/Source/WebCore/inspector/front-end/inspector.js index d8a93b1..77abe78 100644 --- a/Source/WebCore/inspector/front-end/inspector.js +++ b/Source/WebCore/inspector/front-end/inspector.js @@ -185,20 +185,9 @@ var WebInspector = { } }, - createJSBreakpointsSidebarPane: function() - { - var pane = new WebInspector.BreakpointsSidebarPane(WebInspector.UIString("Breakpoints")); - function breakpointAdded(event) - { - pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data)); - } - WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, breakpointAdded); - return pane; - }, - createDOMBreakpointsSidebarPane: function() { - var pane = new WebInspector.BreakpointsSidebarPane(WebInspector.UIString("DOM Breakpoints")); + var pane = new WebInspector.NativeBreakpointsSidebarPane(WebInspector.UIString("DOM Breakpoints")); function breakpointAdded(event) { pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data)); @@ -534,7 +523,7 @@ WebInspector.doLoadedDone = function() scripts: new WebInspector.ResourceCategory("scripts", WebInspector.UIString("Scripts"), "rgb(255,121,0)"), xhr: new WebInspector.ResourceCategory("xhr", WebInspector.UIString("XHR"), "rgb(231,231,10)"), fonts: new WebInspector.ResourceCategory("fonts", WebInspector.UIString("Fonts"), "rgb(255,82,62)"), - websockets: new WebInspector.ResourceCategory("websockets", WebInspector.UIString("WebSocket"), "rgb(186,186,186)"), // FIXME: Decide the color. + websockets: new WebInspector.ResourceCategory("websockets", WebInspector.UIString("WebSockets"), "rgb(186,186,186)"), // FIXME: Decide the color. other: new WebInspector.ResourceCategory("other", WebInspector.UIString("Other"), "rgb(186,186,186)") }; @@ -601,14 +590,6 @@ WebInspector.doLoadedDone = function() this.extensionServer.initExtensions(); - function populateInspectorState(inspectorState) - { - WebInspector.monitoringXHREnabled = inspectorState.monitoringXHREnabled; - if ("pauseOnExceptionsState" in inspectorState) - WebInspector.panels.scripts.updatePauseOnExceptionsState(inspectorState.pauseOnExceptionsState); - } - InspectorBackend.getInspectorState(populateInspectorState); - function onPopulateScriptObjects() { if (!WebInspector.currentPanel) diff --git a/Source/WebCore/inspector/front-end/utilities.js b/Source/WebCore/inspector/front-end/utilities.js index 4320ba8..5ed9a8c 100644 --- a/Source/WebCore/inspector/front-end/utilities.js +++ b/Source/WebCore/inspector/front-end/utilities.js @@ -745,6 +745,22 @@ Object.defineProperty(Array.prototype, "keySet", { value: function() return keys; }}); +Object.defineProperty(Array.prototype, "upperBound", { value: function(value) +{ + var first = 0; + var count = this.length; + while (count > 0) { + var step = count >> 1; + var middle = first + step; + if (value >= this[middle]) { + first = middle + 1; + count -= step + 1; + } else + count = step; + } + return first; +}}); + Array.diff = function(left, right) { var o = left; diff --git a/Source/WebCore/loader/CrossOriginPreflightResultCache.h b/Source/WebCore/loader/CrossOriginPreflightResultCache.h index 1016aed..ddd5070 100644 --- a/Source/WebCore/loader/CrossOriginPreflightResultCache.h +++ b/Source/WebCore/loader/CrossOriginPreflightResultCache.h @@ -38,7 +38,8 @@ namespace WebCore { class HTTPHeaderMap; class ResourceResponse; - class CrossOriginPreflightResultCacheItem : public Noncopyable { + class CrossOriginPreflightResultCacheItem { + WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCacheItem); WTF_MAKE_FAST_ALLOCATED; public: CrossOriginPreflightResultCacheItem(bool credentials) : m_absoluteExpiryTime(0) @@ -63,7 +64,8 @@ namespace WebCore { HeadersSet m_headers; }; - class CrossOriginPreflightResultCache : public Noncopyable { + class CrossOriginPreflightResultCache { + WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCache); WTF_MAKE_FAST_ALLOCATED; public: static CrossOriginPreflightResultCache& shared(); diff --git a/Source/WebCore/loader/DocumentThreadableLoader.h b/Source/WebCore/loader/DocumentThreadableLoader.h index ebf3a25..3a3cc64 100644 --- a/Source/WebCore/loader/DocumentThreadableLoader.h +++ b/Source/WebCore/loader/DocumentThreadableLoader.h @@ -47,6 +47,7 @@ namespace WebCore { class ThreadableLoaderClient; class DocumentThreadableLoader : public RefCounted<DocumentThreadableLoader>, public ThreadableLoader, private SubresourceLoaderClient { + WTF_MAKE_FAST_ALLOCATED; public: static void loadResourceSynchronously(Document*, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&); static PassRefPtr<DocumentThreadableLoader> create(Document*, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&); diff --git a/Source/WebCore/loader/DocumentWriter.h b/Source/WebCore/loader/DocumentWriter.h index 5fb3dc1..fb93606 100644 --- a/Source/WebCore/loader/DocumentWriter.h +++ b/Source/WebCore/loader/DocumentWriter.h @@ -39,7 +39,8 @@ class Frame; class SecurityOrigin; class TextResourceDecoder; -class DocumentWriter : public Noncopyable { +class DocumentWriter { + WTF_MAKE_NONCOPYABLE(DocumentWriter); public: DocumentWriter(Frame*); diff --git a/Source/WebCore/loader/EmptyClients.h b/Source/WebCore/loader/EmptyClients.h index e04d22d..d0a4350 100644 --- a/Source/WebCore/loader/EmptyClients.h +++ b/Source/WebCore/loader/EmptyClients.h @@ -161,6 +161,9 @@ public: #if ENABLE(TILED_BACKING_STORE) virtual void delegatedScrollRequested(const IntSize&) { } #endif +#if ENABLE(REQUEST_ANIMATION_FRAME) + virtual void scheduleAnimation() { } +#endif virtual IntPoint screenToWindow(const IntPoint& p) const { return p; } virtual IntRect windowToScreen(const IntRect& r) const { return r; } @@ -218,8 +221,10 @@ public: #endif }; -class EmptyFrameLoaderClient : public FrameLoaderClient, public Noncopyable { +class EmptyFrameLoaderClient : public FrameLoaderClient { + WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED; public: + EmptyFrameLoaderClient() { } virtual ~EmptyFrameLoaderClient() { } virtual void frameLoaderDestroyed() { } @@ -395,8 +400,10 @@ public: virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext() { return PassRefPtr<FrameNetworkingContext>(); } }; -class EmptyEditorClient : public EditorClient, public Noncopyable { +class EmptyEditorClient : public EditorClient { + WTF_MAKE_NONCOPYABLE(EmptyEditorClient); WTF_MAKE_FAST_ALLOCATED; public: + EmptyEditorClient() { } virtual ~EmptyEditorClient() { } virtual void pageDestroyed() { } @@ -509,8 +516,10 @@ public: }; #if ENABLE(CONTEXT_MENUS) -class EmptyContextMenuClient : public ContextMenuClient, public Noncopyable { +class EmptyContextMenuClient : public ContextMenuClient { + WTF_MAKE_NONCOPYABLE(EmptyContextMenuClient); WTF_MAKE_FAST_ALLOCATED; public: + EmptyContextMenuClient() { } virtual ~EmptyContextMenuClient() { } virtual void contextMenuDestroyed() { } @@ -536,8 +545,10 @@ public: #endif // ENABLE(CONTEXT_MENUS) #if ENABLE(DRAG_SUPPORT) -class EmptyDragClient : public DragClient, public Noncopyable { +class EmptyDragClient : public DragClient { + WTF_MAKE_NONCOPYABLE(EmptyDragClient); WTF_MAKE_FAST_ALLOCATED; public: + EmptyDragClient() { } virtual ~EmptyDragClient() {} virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) { } virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) { } @@ -549,8 +560,10 @@ public: }; #endif // ENABLE(DRAG_SUPPORT) -class EmptyInspectorClient : public InspectorClient, public Noncopyable { +class EmptyInspectorClient : public InspectorClient { + WTF_MAKE_NONCOPYABLE(EmptyInspectorClient); WTF_MAKE_FAST_ALLOCATED; public: + EmptyInspectorClient() { } virtual ~EmptyInspectorClient() { } virtual void inspectorDestroyed() { } diff --git a/Source/WebCore/loader/FormSubmission.h b/Source/WebCore/loader/FormSubmission.h index d724835..7f58f91 100644 --- a/Source/WebCore/loader/FormSubmission.h +++ b/Source/WebCore/loader/FormSubmission.h @@ -47,7 +47,8 @@ class FormSubmission : public RefCounted<FormSubmission> { public: enum Method { GetMethod, PostMethod }; - class Attributes : public Noncopyable { + class Attributes { + WTF_MAKE_NONCOPYABLE(Attributes); public: Attributes() : m_method(GetMethod) diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp index 9c6257b..3a19791 100644 --- a/Source/WebCore/loader/FrameLoader.cpp +++ b/Source/WebCore/loader/FrameLoader.cpp @@ -101,10 +101,6 @@ #include <wtf/text/CString.h> #include <wtf/text/StringConcatenate.h> -#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) -#include "HTMLMediaElement.h" -#endif - #if ENABLE(SHARED_WORKERS) #include "SharedWorkerRepository.h" #endif @@ -1003,6 +999,18 @@ ObjectContentType FrameLoader::defaultObjectContentType(const KURL& url, const S return WebCore::ObjectContentNone; } +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) +void FrameLoader::hideMediaPlayerProxyPlugin(Widget* widget) +{ + m_client->hideMediaPlayerProxyPlugin(widget); +} + +void FrameLoader::showMediaPlayerProxyPlugin(Widget* widget) +{ + m_client->showMediaPlayerProxyPlugin(widget); +} +#endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO) + String FrameLoader::outgoingReferrer() const { return m_outgoingReferrer; @@ -1692,13 +1700,13 @@ bool FrameLoader::shouldAllowNavigation(Frame* targetFrame) const return false; } -void FrameLoader::stopLoadingSubframes() +void FrameLoader::stopLoadingSubframes(DatabasePolicy databasePolicy, ClearProvisionalItemPolicy clearProvisionalItemPolicy) { for (RefPtr<Frame> child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) - child->loader()->stopAllLoaders(); + child->loader()->stopAllLoaders(databasePolicy, clearProvisionalItemPolicy); } -void FrameLoader::stopAllLoaders(DatabasePolicy databasePolicy) +void FrameLoader::stopAllLoaders(DatabasePolicy databasePolicy, ClearProvisionalItemPolicy clearProvisionalItemPolicy) { ASSERT(!m_frame->document() || !m_frame->document()->inPageCache()); if (m_pageDismissalEventBeingDispatched) @@ -1712,7 +1720,12 @@ void FrameLoader::stopAllLoaders(DatabasePolicy databasePolicy) policyChecker()->stopCheck(); - stopLoadingSubframes(); + // If no new load is in progress, we should clear the provisional item from history + // before we call stopLoading. + if (clearProvisionalItemPolicy == ShouldClearProvisionalItem) + history()->setProvisionalItem(0); + + stopLoadingSubframes(databasePolicy, clearProvisionalItemPolicy); if (m_provisionalDocumentLoader) m_provisionalDocumentLoader->stopLoading(databasePolicy); if (m_documentLoader) @@ -2370,7 +2383,8 @@ void FrameLoader::checkLoadCompleteForThisFrame() // Reset the back forward list to the last committed history item at the top level. item = page->mainFrame()->loader()->history()->currentItem(); - bool shouldReset = true; + // Only reset if we aren't already going to a new provisional item. + bool shouldReset = !history()->provisionalItem(); if (!(pdl->isLoadingInAPISense() && !pdl->isStopping())) { m_delegateIsHandlingProvisionalLoadError = true; m_client->dispatchDidFailProvisionalLoad(error); @@ -2379,7 +2393,7 @@ void FrameLoader::checkLoadCompleteForThisFrame() // FIXME: can stopping loading here possibly have any effect, if isLoading is false, // which it must be to be in this branch of the if? And is it OK to just do a full-on // stopAllLoaders instead of stopLoadingSubframes? - stopLoadingSubframes(); + stopLoadingSubframes(DatabasePolicyStop, ShouldNotClearProvisionalItem); pdl->stopLoading(); // If we're in the middle of loading multipart data, we need to restore the document loader. @@ -2987,7 +3001,8 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass } FrameLoadType type = policyChecker()->loadType(); - stopAllLoaders(); + // A new navigation is in progress, so don't clear the history's provisional item. + stopAllLoaders(DatabasePolicyStop, ShouldNotClearProvisionalItem); // <rdar://problem/6250856> - In certain circumstances on pages with multiple frames, stopAllLoaders() // might detach the current FrameLoader, in which case we should bail on this newly defunct load. diff --git a/Source/WebCore/loader/FrameLoader.h b/Source/WebCore/loader/FrameLoader.h index 12afbdd..b9eac9d 100644 --- a/Source/WebCore/loader/FrameLoader.h +++ b/Source/WebCore/loader/FrameLoader.h @@ -86,7 +86,8 @@ struct WindowFeatures; bool isBackForwardLoadType(FrameLoadType); -class FrameLoader : public Noncopyable { +class FrameLoader { + WTF_MAKE_NONCOPYABLE(FrameLoader); public: FrameLoader(Frame*, FrameLoaderClient*); ~FrameLoader(); @@ -129,7 +130,7 @@ public: bool canHandleRequest(const ResourceRequest&); // Also not cool. - void stopAllLoaders(DatabasePolicy = DatabasePolicyStop); + void stopAllLoaders(DatabasePolicy = DatabasePolicyStop, ClearProvisionalItemPolicy = ShouldClearProvisionalItem); void stopForUserCancel(bool deferCheckLoadComplete = false); bool isLoadingMainResource() const { return m_isLoadingMainResource; } @@ -306,6 +307,11 @@ public: void open(CachedFrameBase&); +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) + void hideMediaPlayerProxyPlugin(Widget*); + void showMediaPlayerProxyPlugin(Widget*); +#endif + // FIXME: Should these really be public? void completed(); bool allAncestorsAreComplete() const; // including this @@ -351,7 +357,7 @@ private: void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType loadType, bool isMainResource, bool cookiePolicyURLFromRequest); // Also not cool. - void stopLoadingSubframes(); + void stopLoadingSubframes(DatabasePolicy, ClearProvisionalItemPolicy); void clearProvisionalLoad(); void markLoadComplete(); diff --git a/Source/WebCore/loader/FrameLoaderStateMachine.h b/Source/WebCore/loader/FrameLoaderStateMachine.h index c3408c2..fe37ece 100644 --- a/Source/WebCore/loader/FrameLoaderStateMachine.h +++ b/Source/WebCore/loader/FrameLoaderStateMachine.h @@ -35,7 +35,8 @@ namespace WebCore { // Encapsulates a state machine for FrameLoader. Note that this is different from FrameState, // which stores the state of the current load that FrameLoader is executing. -class FrameLoaderStateMachine : public Noncopyable { +class FrameLoaderStateMachine { + WTF_MAKE_NONCOPYABLE(FrameLoaderStateMachine); public: FrameLoaderStateMachine(); diff --git a/Source/WebCore/loader/FrameLoaderTypes.h b/Source/WebCore/loader/FrameLoaderTypes.h index 016de19..9f63c44 100644 --- a/Source/WebCore/loader/FrameLoaderTypes.h +++ b/Source/WebCore/loader/FrameLoaderTypes.h @@ -73,6 +73,11 @@ namespace WebCore { DatabasePolicyStop, // The database thread should be stopped and database connections closed. DatabasePolicyContinue }; + + enum ClearProvisionalItemPolicy { + ShouldClearProvisionalItem, + ShouldNotClearProvisionalItem + }; enum ObjectContentType { ObjectContentNone, diff --git a/Source/WebCore/loader/HistoryController.cpp b/Source/WebCore/loader/HistoryController.cpp index dda4e56..7c0fc97 100644 --- a/Source/WebCore/loader/HistoryController.cpp +++ b/Source/WebCore/loader/HistoryController.cpp @@ -260,6 +260,10 @@ void HistoryController::updateForBackForwardNavigation() // Must grab the current scroll position before disturbing it if (!m_frameLoadComplete) saveScrollPositionAndViewStateToItem(m_previousItem.get()); + + // When traversing history, we may end up redirecting to a different URL + // this time (e.g., due to cookies). See http://webkit.org/b/49654. + updateCurrentItem(); } void HistoryController::updateForReload() @@ -274,11 +278,11 @@ void HistoryController::updateForReload() if (m_frame->loader()->loadType() == FrameLoadTypeReload || m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin) saveScrollPositionAndViewStateToItem(m_currentItem.get()); - - // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072 - if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty()) - m_currentItem->setURL(m_frame->loader()->documentLoader()->requestURL()); } + + // When reloading the page, we may end up redirecting to a different URL + // this time (e.g., due to cookies). See http://webkit.org/b/4072. + updateCurrentItem(); } // There are 3 things you might think of as "history", all of which are handled by these functions. @@ -310,9 +314,9 @@ void HistoryController::updateForStandardLoad(HistoryUpdateType updateType) if (Page* page = m_frame->page()) page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForward()->currentItem()); } - } else if (frameLoader->documentLoader()->unreachableURL().isEmpty() && m_currentItem) { - m_currentItem->setURL(frameLoader->documentLoader()->url()); - m_currentItem->setFormInfoFromRequest(frameLoader->documentLoader()->request()); + } else { + // The client redirect replaces the current history item. + updateCurrentItem(); } if (!historyURL.isEmpty() && !needPrivacy) { @@ -349,14 +353,12 @@ void HistoryController::updateForRedirectWithLockedBackForwardList() page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForward()->currentItem()); } } - if (m_currentItem) { - m_currentItem->setURL(m_frame->loader()->documentLoader()->url()); - m_currentItem->setFormInfoFromRequest(m_frame->loader()->documentLoader()->request()); - } + // The client redirect replaces the current history item. + updateCurrentItem(); } else { Frame* parentFrame = m_frame->tree()->parent(); if (parentFrame && parentFrame->loader()->history()->m_currentItem) - parentFrame->loader()->history()->m_currentItem->setChildItem(createItem(true)); + parentFrame->loader()->history()->m_currentItem->setChildItem(createItem()); } if (!historyURL.isEmpty() && !needPrivacy) { @@ -506,12 +508,13 @@ void HistoryController::setProvisionalItem(HistoryItem* item) m_provisionalItem = item; } -PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal) +void HistoryController::initializeItem(HistoryItem* item) { DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); - - KURL unreachableURL = documentLoader ? documentLoader->unreachableURL() : KURL(); - + ASSERT(documentLoader); + + KURL unreachableURL = documentLoader->unreachableURL(); + KURL url; KURL originalURL; @@ -519,15 +522,10 @@ PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal) url = unreachableURL; originalURL = unreachableURL; } else { - originalURL = documentLoader ? documentLoader->originalURL() : KURL(); - if (useOriginal) - url = originalURL; - else if (documentLoader) - url = documentLoader->requestURL(); + url = documentLoader->url(); + originalURL = documentLoader->originalURL(); } - LOG(History, "WebCoreHistory: Creating item for %s", url.string().ascii().data()); - // Frames that have never successfully loaded any content // may have no URL at all. Currently our history code can't // deal with such things, so we nip that in the bud here. @@ -540,21 +538,25 @@ PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal) Frame* parentFrame = m_frame->tree()->parent(); String parent = parentFrame ? parentFrame->tree()->uniqueName() : ""; - String title = documentLoader ? documentLoader->title() : ""; + String title = documentLoader->title(); - RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->uniqueName(), parent, title); + item->setURL(url); + item->setTarget(m_frame->tree()->uniqueName()); + item->setParent(parent); + item->setTitle(title); item->setOriginalURLString(originalURL.string()); - if (!unreachableURL.isEmpty() || !documentLoader || documentLoader->response().httpStatusCode() >= 400) + if (!unreachableURL.isEmpty() || documentLoader->response().httpStatusCode() >= 400) item->setLastVisitWasFailure(true); // Save form state if this is a POST - if (documentLoader) { - if (useOriginal) - item->setFormInfoFromRequest(documentLoader->originalRequest()); - else - item->setFormInfoFromRequest(documentLoader->request()); - } + item->setFormInfoFromRequest(documentLoader->request()); +} + +PassRefPtr<HistoryItem> HistoryController::createItem() +{ + RefPtr<HistoryItem> item = HistoryItem::create(); + initializeItem(item.get()); // Set the item for which we will save document state m_frameLoadComplete = false; @@ -566,7 +568,7 @@ PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal) PassRefPtr<HistoryItem> HistoryController::createItemTree(Frame* targetFrame, bool clipAtTarget) { - RefPtr<HistoryItem> bfItem = createItem(m_frame->tree()->parent() ? true : false); + RefPtr<HistoryItem> bfItem = createItem(); if (!m_frameLoadComplete) saveScrollPositionAndViewStateToItem(m_previousItem.get()); @@ -656,6 +658,14 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt bool HistoryController::itemsAreClones(HistoryItem* item1, HistoryItem* item2) const { + // It appears that one of the items can be null in release builds, leading + // to the crashes seen in http://webkit.org/b/52819. For now, try to + // narrow it down with a more specific crash. + if (!item1) + CRASH(); + if (!item2) + CRASH(); + // If the item we're going to is a clone of the item we're at, then we do // not need to load it again. The current frame tree and the frame tree // snapshot in the item have to match. @@ -713,6 +723,31 @@ void HistoryController::updateBackForwardListClippedAtTarget(bool doClip) page->backForward()->addItem(topItem.release()); } +void HistoryController::updateCurrentItem() +{ + if (!m_currentItem) + return; + + DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); + + if (!documentLoader->unreachableURL().isEmpty()) + return; + + if (m_currentItem->url() != documentLoader->url()) { + // We ended up on a completely different URL this time, so the HistoryItem + // needs to be re-initialized. Preserve the isTargetItem flag as it is a + // property of how this HistoryItem was originally created and is not + // dependent on the document. + bool isTargetItem = m_currentItem->isTargetItem(); + m_currentItem->reset(); + initializeItem(m_currentItem.get()); + m_currentItem->setIsTargetItem(isTargetItem); + } else { + // Even if the final URL didn't change, the form data may have changed. + m_currentItem->setFormInfoFromRequest(documentLoader->request()); + } +} + void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject, const String& title, const String& urlString) { if (!m_currentItem) diff --git a/Source/WebCore/loader/HistoryController.h b/Source/WebCore/loader/HistoryController.h index 9923179..061f235 100644 --- a/Source/WebCore/loader/HistoryController.h +++ b/Source/WebCore/loader/HistoryController.h @@ -41,7 +41,8 @@ class Frame; class HistoryItem; class SerializedScriptValue; -class HistoryController : public Noncopyable { +class HistoryController { + WTF_MAKE_NONCOPYABLE(HistoryController); public: enum HistoryUpdateType { UpdateAll, UpdateAllExceptBackForwardList }; @@ -84,7 +85,8 @@ public: void replaceState(PassRefPtr<SerializedScriptValue>, const String& title, const String& url); private: - PassRefPtr<HistoryItem> createItem(bool useOriginal); + void initializeItem(HistoryItem*); + PassRefPtr<HistoryItem> createItem(); PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget); void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*, FrameLoadType); @@ -93,6 +95,7 @@ private: bool itemsAreClones(HistoryItem*, HistoryItem*) const; bool currentFramesMatchItem(HistoryItem*) const; void updateBackForwardListClippedAtTarget(bool doClip); + void updateCurrentItem(); Frame* m_frame; diff --git a/Source/WebCore/loader/ImageLoader.cpp b/Source/WebCore/loader/ImageLoader.cpp index a77e8c0..069b40e 100644 --- a/Source/WebCore/loader/ImageLoader.cpp +++ b/Source/WebCore/loader/ImageLoader.cpp @@ -57,7 +57,8 @@ template<> struct ValueCheck<WebCore::ImageLoader*> { namespace WebCore { -class ImageEventSender : public Noncopyable { +class ImageEventSender { + WTF_MAKE_NONCOPYABLE(ImageEventSender); WTF_MAKE_FAST_ALLOCATED; public: ImageEventSender(const AtomicString& eventType); diff --git a/Source/WebCore/loader/NavigationScheduler.cpp b/Source/WebCore/loader/NavigationScheduler.cpp index 175219c..d51575b 100644 --- a/Source/WebCore/loader/NavigationScheduler.cpp +++ b/Source/WebCore/loader/NavigationScheduler.cpp @@ -53,7 +53,8 @@ namespace WebCore { unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; -class ScheduledNavigation : public Noncopyable { +class ScheduledNavigation { + WTF_MAKE_NONCOPYABLE(ScheduledNavigation); WTF_MAKE_FAST_ALLOCATED; public: ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange) : m_delay(delay) diff --git a/Source/WebCore/loader/PingLoader.h b/Source/WebCore/loader/PingLoader.h index 3a076fb..5988b60 100644 --- a/Source/WebCore/loader/PingLoader.h +++ b/Source/WebCore/loader/PingLoader.h @@ -50,7 +50,8 @@ class ResourceResponse; // to allow the load to live long enough to ensure the message was actually sent. // Therefore, as soon as a callback is received from the ResourceHandle, this class // will cancel the load and delete itself. -class PingLoader : private ResourceHandleClient, public Noncopyable { +class PingLoader : private ResourceHandleClient { + WTF_MAKE_NONCOPYABLE(PingLoader); WTF_MAKE_FAST_ALLOCATED; public: static void loadImage(Frame*, const KURL& url); static void sendPing(Frame*, const KURL& pingURL, const KURL& destinationURL); diff --git a/Source/WebCore/loader/PolicyChecker.h b/Source/WebCore/loader/PolicyChecker.h index 541729c..3118dae 100644 --- a/Source/WebCore/loader/PolicyChecker.h +++ b/Source/WebCore/loader/PolicyChecker.h @@ -45,7 +45,8 @@ class NavigationAction; class ResourceError; class ResourceResponse; -class PolicyChecker : public Noncopyable { +class PolicyChecker { + WTF_MAKE_NONCOPYABLE(PolicyChecker); public: PolicyChecker(Frame*); diff --git a/Source/WebCore/loader/ProgressTracker.cpp b/Source/WebCore/loader/ProgressTracker.cpp index cd15433..65dd1c5 100644 --- a/Source/WebCore/loader/ProgressTracker.cpp +++ b/Source/WebCore/loader/ProgressTracker.cpp @@ -50,7 +50,9 @@ static const double finalProgressValue = 0.9; // 1.0 - initialProgressValue static const int progressItemDefaultEstimatedLength = 1024 * 16; -struct ProgressItem : Noncopyable { +struct ProgressItem { + WTF_MAKE_NONCOPYABLE(ProgressItem); WTF_MAKE_FAST_ALLOCATED; +public: ProgressItem(long long length) : bytesReceived(0) , estimatedLength(length) { } diff --git a/Source/WebCore/loader/ProgressTracker.h b/Source/WebCore/loader/ProgressTracker.h index 5d5b6b2..ea5f7f9 100644 --- a/Source/WebCore/loader/ProgressTracker.h +++ b/Source/WebCore/loader/ProgressTracker.h @@ -36,7 +36,8 @@ class Frame; class ResourceResponse; struct ProgressItem; -class ProgressTracker : public Noncopyable { +class ProgressTracker { + WTF_MAKE_NONCOPYABLE(ProgressTracker); WTF_MAKE_FAST_ALLOCATED; public: ProgressTracker(); ~ProgressTracker(); diff --git a/Source/WebCore/loader/ResourceLoadNotifier.h b/Source/WebCore/loader/ResourceLoadNotifier.h index 2f10856..a6d92fb 100644 --- a/Source/WebCore/loader/ResourceLoadNotifier.h +++ b/Source/WebCore/loader/ResourceLoadNotifier.h @@ -43,7 +43,8 @@ class ResourceLoader; class ResourceResponse; class ResourceRequest; -class ResourceLoadNotifier : public Noncopyable { +class ResourceLoadNotifier { + WTF_MAKE_NONCOPYABLE(ResourceLoadNotifier); public: ResourceLoadNotifier(Frame*); diff --git a/Source/WebCore/loader/ResourceLoadScheduler.h b/Source/WebCore/loader/ResourceLoadScheduler.h index 163b67e..f2e627f 100644 --- a/Source/WebCore/loader/ResourceLoadScheduler.h +++ b/Source/WebCore/loader/ResourceLoadScheduler.h @@ -44,7 +44,8 @@ class ResourceRequest; class SubresourceLoader; class SubresourceLoaderClient; -class ResourceLoadScheduler : public Noncopyable { +class ResourceLoadScheduler { + WTF_MAKE_NONCOPYABLE(ResourceLoadScheduler); public: friend ResourceLoadScheduler* resourceLoadScheduler(); @@ -69,7 +70,8 @@ private: void scheduleServePendingRequests(); void requestTimerFired(Timer<ResourceLoadScheduler>*); - class HostInformation : public Noncopyable { + class HostInformation { + WTF_MAKE_NONCOPYABLE(HostInformation); public: HostInformation(const String&, unsigned); ~HostInformation(); diff --git a/Source/WebCore/loader/SubframeLoader.cpp b/Source/WebCore/loader/SubframeLoader.cpp index eba3173..ae8ce98 100644 --- a/Source/WebCore/loader/SubframeLoader.cpp +++ b/Source/WebCore/loader/SubframeLoader.cpp @@ -184,17 +184,6 @@ PassRefPtr<Widget> SubframeLoader::loadMediaPlayerProxyPlugin(Node* node, const return widget ? widget.release() : 0; } - -void FrameLoader::hideMediaPlayerProxyPlugin(Widget* widget) -{ - m_client->hideMediaPlayerProxyPlugin(widget); -} - -void FrameLoader::showMediaPlayerProxyPlugin(Widget* widget) -{ - m_client->showMediaPlayerProxyPlugin(widget); -} - #endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO) PassRefPtr<Widget> SubframeLoader::createJavaAppletWidget(const IntSize& size, HTMLAppletElement* element, const HashMap<String, String>& args) diff --git a/Source/WebCore/loader/SubframeLoader.h b/Source/WebCore/loader/SubframeLoader.h index a573045..ba63a5c 100644 --- a/Source/WebCore/loader/SubframeLoader.h +++ b/Source/WebCore/loader/SubframeLoader.h @@ -54,7 +54,8 @@ class Node; class Widget; // This is a slight misnomer. It handles the higher level logic of loading both subframes and plugins. -class SubframeLoader : public Noncopyable { +class SubframeLoader { + WTF_MAKE_NONCOPYABLE(SubframeLoader); public: SubframeLoader(Frame*); diff --git a/Source/WebCore/loader/ThreadableLoader.h b/Source/WebCore/loader/ThreadableLoader.h index f41a774..f574c94 100644 --- a/Source/WebCore/loader/ThreadableLoader.h +++ b/Source/WebCore/loader/ThreadableLoader.h @@ -65,7 +65,8 @@ namespace WebCore { // Useful for doing loader operations from any thread (not threadsafe, // just able to run on threads other than the main thread). - class ThreadableLoader : public Noncopyable { + class ThreadableLoader { + WTF_MAKE_NONCOPYABLE(ThreadableLoader); public: static void loadResourceSynchronously(ScriptExecutionContext*, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&); static PassRefPtr<ThreadableLoader> create(ScriptExecutionContext*, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&); @@ -75,6 +76,7 @@ namespace WebCore { void deref() { derefThreadableLoader(); } protected: + ThreadableLoader() { } virtual ~ThreadableLoader() { } virtual void refThreadableLoader() = 0; virtual void derefThreadableLoader() = 0; diff --git a/Source/WebCore/loader/ThreadableLoaderClient.h b/Source/WebCore/loader/ThreadableLoaderClient.h index bcf68be..cea8b0f 100644 --- a/Source/WebCore/loader/ThreadableLoaderClient.h +++ b/Source/WebCore/loader/ThreadableLoaderClient.h @@ -31,14 +31,14 @@ #ifndef ThreadableLoaderClient_h #define ThreadableLoaderClient_h -#include <wtf/Noncopyable.h> namespace WebCore { class ResourceError; class ResourceResponse; - class ThreadableLoaderClient : public Noncopyable { + class ThreadableLoaderClient { + WTF_MAKE_NONCOPYABLE(ThreadableLoaderClient); WTF_MAKE_FAST_ALLOCATED; public: virtual void didSendData(unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { } @@ -51,6 +51,7 @@ namespace WebCore { virtual void didReceiveAuthenticationCancellation(const ResourceResponse&) { } protected: + ThreadableLoaderClient() { } virtual ~ThreadableLoaderClient() { } }; diff --git a/Source/WebCore/loader/WorkerThreadableLoader.h b/Source/WebCore/loader/WorkerThreadableLoader.h index 81da2e0..65cc637 100644 --- a/Source/WebCore/loader/WorkerThreadableLoader.h +++ b/Source/WebCore/loader/WorkerThreadableLoader.h @@ -54,6 +54,7 @@ namespace WebCore { struct CrossThreadResourceRequestData; class WorkerThreadableLoader : public RefCounted<WorkerThreadableLoader>, public ThreadableLoader { + WTF_MAKE_FAST_ALLOCATED; public: static void loadResourceSynchronously(WorkerContext*, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&); static PassRefPtr<WorkerThreadableLoader> create(WorkerContext* workerContext, ThreadableLoaderClient* client, const String& taskMode, const ResourceRequest& request, const ThreadableLoaderOptions& options) diff --git a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h index 2d8b83e..f3a117e 100644 --- a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h +++ b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h @@ -53,7 +53,8 @@ enum ApplicationCacheUpdateOption { ApplicationCacheUpdateWithoutBrowsingContext }; -class ApplicationCacheGroup : public Noncopyable, ResourceHandleClient { +class ApplicationCacheGroup : ResourceHandleClient { + WTF_MAKE_NONCOPYABLE(ApplicationCacheGroup); WTF_MAKE_FAST_ALLOCATED; public: ApplicationCacheGroup(const KURL& manifestURL, bool isCopy = false); ~ApplicationCacheGroup(); diff --git a/Source/WebCore/loader/appcache/ApplicationCacheHost.h b/Source/WebCore/loader/appcache/ApplicationCacheHost.h index 8ac5357..a1f2841 100644 --- a/Source/WebCore/loader/appcache/ApplicationCacheHost.h +++ b/Source/WebCore/loader/appcache/ApplicationCacheHost.h @@ -58,7 +58,8 @@ namespace WebCore { class ApplicationCacheStorage; #endif - class ApplicationCacheHost : public Noncopyable { + class ApplicationCacheHost { + WTF_MAKE_NONCOPYABLE(ApplicationCacheHost); WTF_MAKE_FAST_ALLOCATED; public: // The Status numeric values are specified in the HTML5 spec. enum Status { diff --git a/Source/WebCore/loader/appcache/ApplicationCacheStorage.h b/Source/WebCore/loader/appcache/ApplicationCacheStorage.h index 7db34e6..8bfdf13 100644 --- a/Source/WebCore/loader/appcache/ApplicationCacheStorage.h +++ b/Source/WebCore/loader/appcache/ApplicationCacheStorage.h @@ -44,7 +44,8 @@ template <class T> class StorageIDJournal; class SecurityOrigin; -class ApplicationCacheStorage : public Noncopyable { +class ApplicationCacheStorage { + WTF_MAKE_NONCOPYABLE(ApplicationCacheStorage); WTF_MAKE_FAST_ALLOCATED; public: enum FailureReason { OriginQuotaReached, diff --git a/Source/WebCore/loader/archive/ArchiveResourceCollection.h b/Source/WebCore/loader/archive/ArchiveResourceCollection.h index 9d630d1..fd2ddbf 100644 --- a/Source/WebCore/loader/archive/ArchiveResourceCollection.h +++ b/Source/WebCore/loader/archive/ArchiveResourceCollection.h @@ -39,7 +39,8 @@ namespace WebCore { -class ArchiveResourceCollection : public Noncopyable { +class ArchiveResourceCollection { + WTF_MAKE_NONCOPYABLE(ArchiveResourceCollection); WTF_MAKE_FAST_ALLOCATED; public: ArchiveResourceCollection(); diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h index 3600a02..5c8b38f 100644 --- a/Source/WebCore/loader/cache/CachedResource.h +++ b/Source/WebCore/loader/cache/CachedResource.h @@ -50,7 +50,8 @@ class PurgeableBuffer; // A resource that is held in the cache. Classes who want to use this object should derive // from CachedResourceClient, to get the function calls in case the requested data has arrived. // This class also does the actual communication with the loader to obtain the resource from the network. -class CachedResource : public Noncopyable { +class CachedResource { + WTF_MAKE_NONCOPYABLE(CachedResource); WTF_MAKE_FAST_ALLOCATED; friend class MemoryCache; friend class InspectorResource; diff --git a/Source/WebCore/loader/cache/CachedResourceClient.h b/Source/WebCore/loader/cache/CachedResourceClient.h index 275d331..1c56f13 100644 --- a/Source/WebCore/loader/cache/CachedResourceClient.h +++ b/Source/WebCore/loader/cache/CachedResourceClient.h @@ -45,8 +45,8 @@ namespace WebCore { * inherit from this class and overload one of the 3 functions * */ - class CachedResourceClient : public FastAllocBase - { + class CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: virtual ~CachedResourceClient() { } diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.h b/Source/WebCore/loader/cache/CachedResourceLoader.h index bc351ce..4f67e72 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.h +++ b/Source/WebCore/loader/cache/CachedResourceLoader.h @@ -49,7 +49,8 @@ class ImageLoader; class KURL; // The CachedResourceLoader manages the loading of scripts/images/stylesheets for a single document. -class CachedResourceLoader : public Noncopyable { +class CachedResourceLoader { + WTF_MAKE_NONCOPYABLE(CachedResourceLoader); WTF_MAKE_FAST_ALLOCATED; friend class ImageLoader; public: diff --git a/Source/WebCore/loader/cache/CachedScript.cpp b/Source/WebCore/loader/cache/CachedScript.cpp index 54b4503..8950ddb 100644 --- a/Source/WebCore/loader/cache/CachedScript.cpp +++ b/Source/WebCore/loader/cache/CachedScript.cpp @@ -34,6 +34,10 @@ #include "TextResourceDecoder.h" #include <wtf/Vector.h> +#if USE(JSC) +#include <parser/SourceProvider.h> +#endif + namespace WebCore { CachedScript::CachedScript(const String& url, const String& charset) @@ -111,7 +115,12 @@ void CachedScript::error(CachedResource::Status status) void CachedScript::destroyDecodedData() { m_script = String(); - setDecodedSize(0); + unsigned extraSize = 0; +#if USE(JSC) + // FIXME: SourceInfoCache should be wiped out too but not this easily. + extraSize = m_sourceProviderCache ? m_sourceProviderCache->byteSize() : 0; +#endif + setDecodedSize(extraSize); if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable()) makePurgeable(true); } @@ -121,4 +130,18 @@ void CachedScript::decodedDataDeletionTimerFired(Timer<CachedScript>*) destroyDecodedData(); } +#if USE(JSC) +JSC::SourceProviderCache* CachedScript::sourceProviderCache() const +{ + if (!m_sourceProviderCache) + m_sourceProviderCache = adoptPtr(new JSC::SourceProviderCache); + return m_sourceProviderCache.get(); +} + +void CachedScript::sourceProviderCacheSizeChanged(int delta) +{ + setDecodedSize(decodedSize() + delta); +} +#endif + } // namespace WebCore diff --git a/Source/WebCore/loader/cache/CachedScript.h b/Source/WebCore/loader/cache/CachedScript.h index 30fcb1e..14294f2 100644 --- a/Source/WebCore/loader/cache/CachedScript.h +++ b/Source/WebCore/loader/cache/CachedScript.h @@ -29,6 +29,12 @@ #include "CachedResource.h" #include "Timer.h" +#if USE(JSC) +namespace JSC { + class SourceProviderCache; +} +#endif + namespace WebCore { class CachedResourceLoader; @@ -51,7 +57,11 @@ namespace WebCore { void checkNotify(); virtual void destroyDecodedData(); - +#if USE(JSC) + // Allows JSC to cache additional information about the source. + JSC::SourceProviderCache* sourceProviderCache() const; + void sourceProviderCacheSizeChanged(int delta); +#endif private: void decodedDataDeletionTimerFired(Timer<CachedScript>*); virtual PurgePriority purgePriority() const { return PurgeLast; } @@ -59,6 +69,9 @@ namespace WebCore { String m_script; RefPtr<TextResourceDecoder> m_decoder; Timer<CachedScript> m_decodedDataDeletionTimer; +#if USE(JSC) + mutable OwnPtr<JSC::SourceProviderCache> m_sourceProviderCache; +#endif }; } diff --git a/Source/WebCore/loader/cache/MemoryCache.h b/Source/WebCore/loader/cache/MemoryCache.h index 7a567ea..12452c1 100644 --- a/Source/WebCore/loader/cache/MemoryCache.h +++ b/Source/WebCore/loader/cache/MemoryCache.h @@ -70,7 +70,8 @@ class KURL; // its member variables) are allocated in non-purgeable TC-malloc'd memory so we would see slightly // more memory use due to this. -class MemoryCache : public Noncopyable { +class MemoryCache { + WTF_MAKE_NONCOPYABLE(MemoryCache); WTF_MAKE_FAST_ALLOCATED; public: friend MemoryCache* memoryCache(); diff --git a/Source/WebCore/loader/icon/IconDatabase.h b/Source/WebCore/loader/icon/IconDatabase.h index 6146aa6..e08dcd4 100644 --- a/Source/WebCore/loader/icon/IconDatabase.h +++ b/Source/WebCore/loader/icon/IconDatabase.h @@ -62,8 +62,8 @@ enum IconLoadDecision { IconLoadUnknown }; -class IconDatabase : public Noncopyable { - +class IconDatabase { + WTF_MAKE_NONCOPYABLE(IconDatabase); WTF_MAKE_FAST_ALLOCATED; // *** Main Thread Only *** public: void setClient(IconDatabaseClient*); diff --git a/Source/WebCore/loader/icon/IconDatabaseClient.h b/Source/WebCore/loader/icon/IconDatabaseClient.h index c210d7d..f97a2a8 100644 --- a/Source/WebCore/loader/icon/IconDatabaseClient.h +++ b/Source/WebCore/loader/icon/IconDatabaseClient.h @@ -29,6 +29,7 @@ #ifndef IconDatabaseClient_h #define IconDatabaseClient_h +#include <wtf/FastAllocBase.h> #include <wtf/Forward.h> #include <wtf/Noncopyable.h> @@ -37,8 +38,10 @@ namespace WebCore { -class IconDatabaseClient : public Noncopyable { +class IconDatabaseClient { + WTF_MAKE_NONCOPYABLE(IconDatabaseClient); WTF_MAKE_FAST_ALLOCATED; public: + IconDatabaseClient() { } virtual ~IconDatabaseClient() { } virtual bool performImport() { return true; } virtual void dispatchDidRemoveAllIcons() { } diff --git a/Source/WebCore/loader/icon/IconLoader.h b/Source/WebCore/loader/icon/IconLoader.h index 1ebac48..2985393 100644 --- a/Source/WebCore/loader/icon/IconLoader.h +++ b/Source/WebCore/loader/icon/IconLoader.h @@ -37,7 +37,8 @@ class Frame; class KURL; class SharedBuffer; -class IconLoader : private SubresourceLoaderClient, public Noncopyable { +class IconLoader : private SubresourceLoaderClient { + WTF_MAKE_NONCOPYABLE(IconLoader); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<IconLoader> create(Frame*); ~IconLoader(); diff --git a/Source/WebCore/loader/icon/PageURLRecord.h b/Source/WebCore/loader/icon/PageURLRecord.h index f7ccb8f..7935dc9 100644 --- a/Source/WebCore/loader/icon/PageURLRecord.h +++ b/Source/WebCore/loader/icon/PageURLRecord.h @@ -51,7 +51,8 @@ public: String iconURL; }; -class PageURLRecord : public Noncopyable { +class PageURLRecord { + WTF_MAKE_NONCOPYABLE(PageURLRecord); WTF_MAKE_FAST_ALLOCATED; public: PageURLRecord(const String& pageURL); ~PageURLRecord(); diff --git a/Source/WebCore/mathml/MathMLMathElement.cpp b/Source/WebCore/mathml/MathMLMathElement.cpp index 6c5c3c6..ae74b52 100644 --- a/Source/WebCore/mathml/MathMLMathElement.cpp +++ b/Source/WebCore/mathml/MathMLMathElement.cpp @@ -44,6 +44,14 @@ PassRefPtr<MathMLMathElement> MathMLMathElement::create(const QualifiedName& tag return adoptRef(new MathMLMathElement(tagName, document)); } +void MathMLMathElement::insertedIntoDocument() +{ + // There are sibling rules in the MathML default style. + document()->setUsesSiblingRules(true); + + MathMLInlineContainerElement::insertedIntoDocument(); +} + RenderObject* MathMLMathElement::createRenderer(RenderArena* arena, RenderStyle*) { return new (arena) RenderMathMLMath(this); diff --git a/Source/WebCore/mathml/MathMLMathElement.h b/Source/WebCore/mathml/MathMLMathElement.h index d31d548..81f161b 100644 --- a/Source/WebCore/mathml/MathMLMathElement.h +++ b/Source/WebCore/mathml/MathMLMathElement.h @@ -39,6 +39,7 @@ public: private: MathMLMathElement(const QualifiedName& tagName, Document*); + virtual void insertedIntoDocument(); virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); }; diff --git a/Source/WebCore/notifications/Notification.h b/Source/WebCore/notifications/Notification.h index f14a302..73131e5 100644 --- a/Source/WebCore/notifications/Notification.h +++ b/Source/WebCore/notifications/Notification.h @@ -59,6 +59,7 @@ namespace WebCore { class WorkerContext; class Notification : public RefCounted<Notification>, public ActiveDOMObject, public ThreadableLoaderClient, public EventTarget { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<Notification> create(const KURL& url, ScriptExecutionContext* context, ExceptionCode& ec, PassRefPtr<NotificationCenter> provider); static PassRefPtr<Notification> create(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, PassRefPtr<NotificationCenter> provider); diff --git a/Source/WebCore/page/Chrome.cpp b/Source/WebCore/page/Chrome.cpp index 0405408..d96b6c9 100644 --- a/Source/WebCore/page/Chrome.cpp +++ b/Source/WebCore/page/Chrome.cpp @@ -445,6 +445,13 @@ void Chrome::setCursor(const Cursor& cursor) m_client->setCursor(cursor); } +#if ENABLE(REQUEST_ANIMATION_FRAME) +void Chrome::scheduleAnimation() +{ + m_client->scheduleAnimation(); +} +#endif + #if ENABLE(NOTIFICATIONS) NotificationPresenter* Chrome::notificationPresenter() const { diff --git a/Source/WebCore/page/Chrome.h b/Source/WebCore/page/Chrome.h index 93b8c4a..0afd807 100644 --- a/Source/WebCore/page/Chrome.h +++ b/Source/WebCore/page/Chrome.h @@ -78,6 +78,9 @@ namespace WebCore { virtual PlatformPageClient platformPageClient() const; virtual void scrollbarsModeDidChange() const; virtual void setCursor(const Cursor&); +#if ENABLE(REQUEST_ANIMATION_FRAME) + virtual void scheduleAnimation(); +#endif void scrollRectIntoView(const IntRect&) const; diff --git a/Source/WebCore/page/ChromeClient.h b/Source/WebCore/page/ChromeClient.h index 51c8959..98b56da 100644 --- a/Source/WebCore/page/ChromeClient.h +++ b/Source/WebCore/page/ChromeClient.h @@ -151,6 +151,9 @@ namespace WebCore { virtual PlatformPageClient platformPageClient() const = 0; virtual void scrollbarsModeDidChange() const = 0; virtual void setCursor(const Cursor&) = 0; +#if ENABLE(REQUEST_ANIMATION_FRAME) + virtual void scheduleAnimation() = 0; +#endif // End methods used by HostWindow. virtual void dispatchViewportDataDidChange(const ViewportArguments&) const { } diff --git a/Source/WebCore/page/Console.cpp b/Source/WebCore/page/Console.cpp index d4aed41..0c19421 100644 --- a/Source/WebCore/page/Console.cpp +++ b/Source/WebCore/page/Console.cpp @@ -262,20 +262,13 @@ void Console::profile(const String& title, ScriptState* state, PassRefPtr<Script if (!page) return; -#if ENABLE(INSPECTOR) - InspectorController* controller = page->inspectorController(); // FIXME: log a console message when profiling is disabled. - if (!controller->profilerEnabled()) + if (!InspectorInstrumentation::profilerEnabled(page)) return; -#endif String resolvedTitle = title; if (title.isNull()) // no title so give it the next user initiated profile title. -#if ENABLE(INSPECTOR) - resolvedTitle = controller->getCurrentUserInitiatedProfileName(true); -#else - resolvedTitle = ""; -#endif + resolvedTitle = InspectorInstrumentation::getCurrentUserInitiatedProfileName(page, true); ScriptProfiler::start(state, resolvedTitle); @@ -289,22 +282,15 @@ void Console::profileEnd(const String& title, ScriptState* state, PassRefPtr<Scr if (!page) return; -#if ENABLE(INSPECTOR) - InspectorController* controller = page->inspectorController(); - if (!controller->profilerEnabled()) + if (!InspectorInstrumentation::profilerEnabled(page)) return; -#endif RefPtr<ScriptProfile> profile = ScriptProfiler::stop(state, title); if (!profile) return; m_profiles.append(profile); - -#if ENABLE(INSPECTOR) - const ScriptCallFrame& lastCaller = callStack->at(0); - controller->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL()); -#endif + InspectorInstrumentation::addProfile(page, profile, callStack.get()); } #endif diff --git a/Source/WebCore/page/ContextMenuController.h b/Source/WebCore/page/ContextMenuController.h index ab92796..e6a0a00 100644 --- a/Source/WebCore/page/ContextMenuController.h +++ b/Source/WebCore/page/ContextMenuController.h @@ -41,7 +41,8 @@ namespace WebCore { class Event; class Page; - class ContextMenuController : public Noncopyable { + class ContextMenuController { + WTF_MAKE_NONCOPYABLE(ContextMenuController); WTF_MAKE_FAST_ALLOCATED; public: ContextMenuController(Page*, ContextMenuClient*); ~ContextMenuController(); diff --git a/Source/WebCore/page/DOMSelection.cpp b/Source/WebCore/page/DOMSelection.cpp index 7691da4..dbb0944 100644 --- a/Source/WebCore/page/DOMSelection.cpp +++ b/Source/WebCore/page/DOMSelection.cpp @@ -76,23 +76,23 @@ const VisibleSelection& DOMSelection::visibleSelection() const static Position anchorPosition(const VisibleSelection& selection) { Position anchor = selection.isBaseFirst() ? selection.start() : selection.end(); - return rangeCompliantEquivalent(anchor); + return anchor.parentAnchoredEquivalent(); } static Position focusPosition(const VisibleSelection& selection) { Position focus = selection.isBaseFirst() ? selection.end() : selection.start(); - return rangeCompliantEquivalent(focus); + return focus.parentAnchoredEquivalent(); } static Position basePosition(const VisibleSelection& selection) { - return rangeCompliantEquivalent(selection.base()); + return selection.base().parentAnchoredEquivalent(); } static Position extentPosition(const VisibleSelection& selection) { - return rangeCompliantEquivalent(selection.extent()); + return selection.extent().parentAnchoredEquivalent(); } Node* DOMSelection::anchorNode() const diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp index 9c29071..0860d65 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -105,6 +105,10 @@ #include "LocalFileSystem.h" #endif +#if ENABLE(REQUEST_ANIMATION_FRAME) +#include "RequestAnimationFrameCallback.h" +#endif + using std::min; using std::max; @@ -1476,6 +1480,21 @@ void DOMWindow::clearInterval(int timeoutId) DOMTimer::removeById(context, timeoutId); } +#if ENABLE(REQUEST_ANIMATION_FRAME) +int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e) +{ + if (Document* d = document()) + return d->webkitRequestAnimationFrame(callback, e); + return 0; +} + +void DOMWindow::webkitCancelRequestAnimationFrame(int id) +{ + if (Document* d = document()) + d->webkitCancelRequestAnimationFrame(id); +} +#endif + bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) { if (!EventTarget::addEventListener(eventType, listener, useCapture)) @@ -1627,6 +1646,9 @@ void DOMWindow::clearDOMStorage() void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow, SetLocationLocking locking) { + if (!m_frame) + return; + Frame* activeFrame = activeWindow->frame(); if (!activeFrame) return; diff --git a/Source/WebCore/page/DOMWindow.h b/Source/WebCore/page/DOMWindow.h index 3614627..f02a7ac 100644 --- a/Source/WebCore/page/DOMWindow.h +++ b/Source/WebCore/page/DOMWindow.h @@ -64,6 +64,10 @@ namespace WebCore { class StyleMedia; class WebKitPoint; +#if ENABLE(REQUEST_ANIMATION_FRAME) + class RequestAnimationFrameCallback; +#endif + struct WindowFeatures; typedef int ExceptionCode; @@ -237,6 +241,12 @@ namespace WebCore { int setInterval(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&); void clearInterval(int timeoutId); + // WebKit animation extensions +#if ENABLE(REQUEST_ANIMATION_FRAME) + int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>, Element*); + void webkitCancelRequestAnimationFrame(int id); +#endif + // Events // EventTarget API virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); @@ -269,6 +279,8 @@ namespace WebCore { DEFINE_ATTRIBUTE_EVENT_LISTENER(ended); DEFINE_ATTRIBUTE_EVENT_LISTENER(error); DEFINE_ATTRIBUTE_EVENT_LISTENER(focus); + DEFINE_ATTRIBUTE_EVENT_LISTENER(formchange); + DEFINE_ATTRIBUTE_EVENT_LISTENER(forminput); DEFINE_ATTRIBUTE_EVENT_LISTENER(hashchange); DEFINE_ATTRIBUTE_EVENT_LISTENER(input); DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid); diff --git a/Source/WebCore/page/DOMWindow.idl b/Source/WebCore/page/DOMWindow.idl index 77ffe41..a814558 100644 --- a/Source/WebCore/page/DOMWindow.idl +++ b/Source/WebCore/page/DOMWindow.idl @@ -235,6 +235,12 @@ module window { // [Custom] long setInterval(in DOMString code, in long timeout); void clearInterval(in long handle); +#if defined(ENABLE_REQUEST_ANIMATION_FRAME) + // WebKit animation extensions + long webkitRequestAnimationFrame(in [Callback] RequestAnimationFrameCallback callback, in Element element); + void webkitCancelRequestAnimationFrame(in long id); +#endif + // Base64 DOMString atob(in [ConvertNullToNullString] DOMString string) raises(DOMException); @@ -264,6 +270,8 @@ module window { attribute EventListener onended; attribute EventListener onerror; attribute EventListener onfocus; + attribute EventListener onformchange; + attribute EventListener onforminput; attribute EventListener onhashchange; attribute EventListener oninput; attribute EventListener oninvalid; @@ -308,8 +316,6 @@ module window { // Not implemented yet. // attribute EventListener onafterprint; // attribute EventListener onbeforeprint; - // attribute EventListener onformchange; - // attribute EventListener onforminput; // attribute EventListener onreadystatechange; // attribute EventListener onredo; // attribute EventListener onshow; @@ -439,6 +445,7 @@ module window { attribute HTMLImageElementConstructor HTMLImageElement; attribute HTMLInputElementConstructor HTMLInputElement; attribute HTMLIsIndexElementConstructor HTMLIsIndexElement; + attribute HTMLKeygenElementConstructor HTMLKeygenElement; attribute HTMLLIElementConstructor HTMLLIElement; attribute HTMLLabelElementConstructor HTMLLabelElement; attribute HTMLLegendElementConstructor HTMLLegendElement; @@ -509,7 +516,7 @@ module window { attribute [JSCCustomGetter,Conditional=3D_CANVAS|BLOB,EnabledAtRuntime] Float32ArrayConstructor Float32Array; // Usable with new operator attribute [JSCCustomGetter,Conditional=3D_CANVAS|BLOB,EnabledAtRuntime] DataViewConstructor DataView; // Usable with new operator - attribute [JSCCustomGetter,Conditional=WEB_AUDIO] AudioContextConstructor webkitAudioContext; // Usable with new operator + attribute [JSCCustomGetter,Conditional=WEB_AUDIO,EnabledAtRuntime] AudioContextConstructor webkitAudioContext; // Usable with new operator attribute [Conditional=WEB_AUDIO] AudioPannerNodeConstructor webkitAudioPannerNode; // Needed for panning model constants attribute EventConstructor Event; diff --git a/Source/WebCore/page/DragController.h b/Source/WebCore/page/DragController.h index 10bb5f8..0f176b1 100644 --- a/Source/WebCore/page/DragController.h +++ b/Source/WebCore/page/DragController.h @@ -47,7 +47,8 @@ namespace WebCore { class Range; class SelectionController; - class DragController : public Noncopyable { + class DragController { + WTF_MAKE_NONCOPYABLE(DragController); WTF_MAKE_FAST_ALLOCATED; public: DragController(Page*, DragClient*); ~DragController(); diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index 942f032..476921e 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -2674,12 +2674,11 @@ cleanupDrag: } #endif // ENABLE(DRAG_SUPPORT) -bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEvent, bool isLineBreak, bool isBackTab) +bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEvent, TextEventInputType inputType) { // Platforms should differentiate real commands like selectAll from text input in disguise (like insertNewline), // and avoid dispatching text input events from keydown default handlers. ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || static_cast<KeyboardEvent*>(underlyingEvent)->type() == eventNames().keypressEvent); - ASSERT(!(isLineBreak && isBackTab)); if (!m_frame) return false; @@ -2695,7 +2694,7 @@ bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve if (FrameView* view = m_frame->view()) view->resetDeferredRepaintDelay(); - RefPtr<TextEvent> event = TextEvent::create(m_frame->domWindow(), text, TextEvent::selectInputType(isLineBreak, isBackTab)); + RefPtr<TextEvent> event = TextEvent::create(m_frame->domWindow(), text, inputType); event->setUnderlyingEvent(underlyingEvent); ExceptionCode ec; diff --git a/Source/WebCore/page/EventHandler.h b/Source/WebCore/page/EventHandler.h index 65695c2..d12a56e 100644 --- a/Source/WebCore/page/EventHandler.h +++ b/Source/WebCore/page/EventHandler.h @@ -31,6 +31,7 @@ #include "HitTestRequest.h" #include "PlatformMouseEvent.h" #include "ScrollTypes.h" +#include "TextEventInputType.h" #include "Timer.h" #include <wtf/Forward.h> #include <wtf/RefPtr.h> @@ -80,7 +81,8 @@ extern const int GeneralDragHysteresis; enum HitTestScrollbars { ShouldHitTestScrollbars, DontHitTestScrollbars }; -class EventHandler : public Noncopyable { +class EventHandler { + WTF_MAKE_NONCOPYABLE(EventHandler); public: EventHandler(Frame*); ~EventHandler(); @@ -173,8 +175,7 @@ public: bool keyEvent(const PlatformKeyboardEvent&); void defaultKeyboardEventHandler(KeyboardEvent*); - bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, - bool isLineBreak = false, bool isBackTab = false); + bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, TextEventInputType = TextEventInputKeyboard); void defaultTextInputEventHandler(TextEvent*); #if ENABLE(DRAG_SUPPORT) @@ -224,7 +225,10 @@ private: PerformDragAndDrop }; - struct EventHandlerDragState : Noncopyable { + struct EventHandlerDragState { + WTF_MAKE_NONCOPYABLE(EventHandlerDragState); WTF_MAKE_FAST_ALLOCATED; + public: + EventHandlerDragState() { } RefPtr<Node> m_dragSrc; // element that may be a drag source, for the current mouse gesture bool m_dragSrcIsLink; bool m_dragSrcIsImage; diff --git a/Source/WebCore/page/EventSource.h b/Source/WebCore/page/EventSource.h index ffed592..10ad6ba 100644 --- a/Source/WebCore/page/EventSource.h +++ b/Source/WebCore/page/EventSource.h @@ -51,6 +51,7 @@ namespace WebCore { class ThreadableLoader; class EventSource : public RefCounted<EventSource>, public EventTarget, private ThreadableLoaderClient, public ActiveDOMObject { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<EventSource> create(const String& url, ScriptExecutionContext*, ExceptionCode&); virtual ~EventSource(); diff --git a/Source/WebCore/page/FocusController.h b/Source/WebCore/page/FocusController.h index be51c77..50fa2ea 100644 --- a/Source/WebCore/page/FocusController.h +++ b/Source/WebCore/page/FocusController.h @@ -40,7 +40,8 @@ class KeyboardEvent; class Node; class Page; -class FocusController : public Noncopyable { +class FocusController { + WTF_MAKE_NONCOPYABLE(FocusController); WTF_MAKE_FAST_ALLOCATED; public: FocusController(Page*); diff --git a/Source/WebCore/page/FrameTree.h b/Source/WebCore/page/FrameTree.h index 94b8d16..bac5475 100644 --- a/Source/WebCore/page/FrameTree.h +++ b/Source/WebCore/page/FrameTree.h @@ -26,7 +26,8 @@ namespace WebCore { class Frame; - class FrameTree : public Noncopyable { + class FrameTree { + WTF_MAKE_NONCOPYABLE(FrameTree); public: FrameTree(Frame* thisFrame, Frame* parentFrame) : m_thisFrame(thisFrame) diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index fdf01ec..7546270 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -117,7 +117,10 @@ double FrameView::s_deferredRepaintDelayIncrementDuringLoading = 0; // The maximum number of updateWidgets iterations that should be done before returning. static const unsigned maxUpdateWidgetsIterations = 2; -struct ScheduledEvent : Noncopyable { +struct ScheduledEvent { + WTF_MAKE_NONCOPYABLE(ScheduledEvent); WTF_MAKE_FAST_ALLOCATED; +public: + ScheduledEvent() { } RefPtr<Event> m_event; RefPtr<Node> m_eventTarget; }; @@ -354,6 +357,14 @@ void FrameView::setFrameRect(const IntRect& newRect) #endif } +#if ENABLE(REQUEST_ANIMATION_FRAME) +void FrameView::scheduleAnimation() +{ + if (hostWindow()) + hostWindow()->scheduleAnimation(); +} +#endif + void FrameView::setMarginWidth(int w) { // make it update the rendering area when set @@ -566,10 +577,19 @@ void FrameView::updateCompositingLayers() #endif } -void FrameView::syncCompositingStateForThisFrame() +bool FrameView::syncCompositingStateForThisFrame() { - if (RenderView* view = m_frame->contentRenderer()) - view->compositor()->flushPendingLayerChanges(); + ASSERT(m_frame->view() == this); + RenderView* view = m_frame->contentRenderer(); + if (!view) + return true; // We don't want to keep trying to update layers if we have no renderer. + + // If we sync compositing layers when a layout is pending, we may cause painting of compositing + // layer content to occur before layout has happened, which will cause paintContents() to bail. + if (needsLayout()) + return false; + + view->compositor()->flushPendingLayerChanges(); #if ENABLE(FULLSCREEN_API) // The fullScreenRenderer's graphicsLayer has been re-parented, and the above recursive syncCompositingState @@ -581,7 +601,8 @@ void FrameView::syncCompositingStateForThisFrame() if (GraphicsLayer* fullScreenLayer = backing->graphicsLayer()) fullScreenLayer->syncCompositingState(); } -#endif +#endif + return true; } void FrameView::setNeedsOneShotDrawingSynchronization() @@ -660,32 +681,16 @@ bool FrameView::isEnclosedInCompositingLayer() const return false; } -bool FrameView::syncCompositingStateRecursive() +bool FrameView::syncCompositingStateIncludingSubframes() { #if USE(ACCELERATED_COMPOSITING) - ASSERT(m_frame->view() == this); - RenderView* contentRenderer = m_frame->contentRenderer(); - if (!contentRenderer) - return true; // We don't want to keep trying to update layers if we have no renderer. - - // If we sync compositing layers when a layout is pending, we may cause painting of compositing - // layer content to occur before layout has happened, which will cause paintContents() to bail. - if (needsLayout()) - return false; + bool allFramesSynced = syncCompositingStateForThisFrame(); - syncCompositingStateForThisFrame(); - - bool allSubframesSynced = true; - const HashSet<RefPtr<Widget> >* viewChildren = children(); - HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end(); - for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin(); current != end; ++current) { - Widget* widget = (*current).get(); - if (widget->isFrameView()) { - bool synced = static_cast<FrameView*>(widget)->syncCompositingStateRecursive(); - allSubframesSynced &= synced; - } + for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->traverseNext(m_frame.get())) { + bool synced = child->view()->syncCompositingStateForThisFrame(); + allFramesSynced &= synced; } - return allSubframesSynced; + return allFramesSynced; #else // USE(ACCELERATED_COMPOSITING) return true; #endif @@ -1721,6 +1726,14 @@ void FrameView::unscheduleRelayout() m_delayedLayout = false; } +#if ENABLE(REQUEST_ANIMATION_FRAME) +void FrameView::serviceScriptedAnimations() +{ + for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext()) + frame->document()->serviceScriptedAnimations(); +} +#endif + bool FrameView::isTransparent() const { return m_isTransparent; @@ -2020,23 +2033,15 @@ bool FrameView::isActive() const return page && page->focusController()->isActive(); } -void FrameView::valueChanged(Scrollbar* bar) +void FrameView::scrollTo(const IntSize& newOffset) { - // Figure out if we really moved. IntSize offset = scrollOffset(); - ScrollView::valueChanged(bar); + ScrollView::scrollTo(newOffset); if (offset != scrollOffset()) scrollPositionChanged(); frame()->loader()->client()->didChangeScrollOffset(); } -void FrameView::valueChanged(const IntSize& scrollDelta) -{ - ScrollView::valueChanged(scrollDelta); - frame()->eventHandler()->sendScrollEvent(); - frame()->loader()->client()->didChangeScrollOffset(); -} - void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) { // Add in our offset within the FrameView. diff --git a/Source/WebCore/page/FrameView.h b/Source/WebCore/page/FrameView.h index bdeab90..c75aab8 100644 --- a/Source/WebCore/page/FrameView.h +++ b/Source/WebCore/page/FrameView.h @@ -62,6 +62,9 @@ public: virtual void invalidateRect(const IntRect&); virtual void setFrameRect(const IntRect&); +#if ENABLE(REQUEST_ANIMATION_FRAME) + void scheduleAnimation(); +#endif Frame* frame() const { return m_frame.get(); } void clearFrame(); @@ -97,13 +100,18 @@ public: bool needsFullRepaint() const { return m_doFullRepaint; } +<<<<<<< HEAD #if PLATFORM(ANDROID) void updatePositionedObjects(); +======= +#if ENABLE(REQUEST_ANIMATION_FRAME) + void serviceScriptedAnimations(); +>>>>>>> WebKit.org at r76408 #endif #if USE(ACCELERATED_COMPOSITING) void updateCompositingLayers(); - void syncCompositingStateForThisFrame(); + bool syncCompositingStateForThisFrame(); // Called when changes to the GraphicsLayer hierarchy have to be synchronized with // content rendered via the normal painting path. @@ -121,7 +129,7 @@ public: // Only used with accelerated compositing, but outside the #ifdef to make linkage easier. // Returns true if the sync was completed. - bool syncCompositingStateRecursive(); + bool syncCompositingStateIncludingSubframes(); // Returns true when a paint with the PaintBehaviorFlattenCompositingLayers flag set gives // a faithful representation of the content. @@ -294,13 +302,13 @@ private: virtual IntPoint convertToContainingView(const IntPoint&) const; virtual IntPoint convertFromContainingView(const IntPoint&) const; - // ScrollBarClient interface - virtual void valueChanged(Scrollbar*); - virtual void valueChanged(const IntSize&); + // ScrollableArea interface virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); virtual bool isActive() const; virtual void getTickmarks(Vector<IntRect>&) const; + virtual void scrollTo(const IntSize&); + void deferredRepaintTimerFired(Timer<FrameView>*); void doDeferredRepaints(); void updateDeferredRepaintDelay(); diff --git a/Source/WebCore/page/GeolocationController.h b/Source/WebCore/page/GeolocationController.h index 7db1951..1a2ce69 100644 --- a/Source/WebCore/page/GeolocationController.h +++ b/Source/WebCore/page/GeolocationController.h @@ -40,7 +40,8 @@ class GeolocationError; class GeolocationPosition; class Page; -class GeolocationController : public Noncopyable { +class GeolocationController { + WTF_MAKE_NONCOPYABLE(GeolocationController); public: GeolocationController(Page*, GeolocationClient*); ~GeolocationController(); diff --git a/Source/WebCore/page/GroupSettings.h b/Source/WebCore/page/GroupSettings.h index fb6f6b5..1bbad2b 100644 --- a/Source/WebCore/page/GroupSettings.h +++ b/Source/WebCore/page/GroupSettings.h @@ -33,7 +33,8 @@ namespace WebCore { class PageGroup; -class GroupSettings : public Noncopyable { +class GroupSettings { + WTF_MAKE_NONCOPYABLE(GroupSettings); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<GroupSettings> create() { diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h index 7413bb6..071b142 100644 --- a/Source/WebCore/page/Page.h +++ b/Source/WebCore/page/Page.h @@ -90,12 +90,15 @@ namespace WebCore { enum FindDirection { FindDirectionForward, FindDirectionBackward }; - class Page : public Noncopyable { + class Page { + WTF_MAKE_NONCOPYABLE(Page); public: static void scheduleForcedStyleRecalcForAllPages(); // It is up to the platform to ensure that non-null clients are provided where required. - struct PageClients : Noncopyable { + struct PageClients { + WTF_MAKE_NONCOPYABLE(PageClients); WTF_MAKE_FAST_ALLOCATED; + public: PageClients(); ~PageClients(); diff --git a/Source/WebCore/page/PageGroup.cpp b/Source/WebCore/page/PageGroup.cpp index 746cd04..96e7301 100644 --- a/Source/WebCore/page/PageGroup.cpp +++ b/Source/WebCore/page/PageGroup.cpp @@ -37,7 +37,7 @@ #include "StorageNamespace.h" #if PLATFORM(CHROMIUM) -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #endif #ifdef ANDROID @@ -218,7 +218,7 @@ bool PageGroup::isLinkVisited(LinkHash visitedLinkHash) { #if PLATFORM(CHROMIUM) // Use Chromium's built-in visited link database. - return ChromiumBridge::isLinkVisited(visitedLinkHash); + return PlatformBridge::isLinkVisited(visitedLinkHash); #else if (!m_visitedLinksPopulated) { m_visitedLinksPopulated = true; diff --git a/Source/WebCore/page/PageGroup.h b/Source/WebCore/page/PageGroup.h index 0c4b26f..aa600a5 100644 --- a/Source/WebCore/page/PageGroup.h +++ b/Source/WebCore/page/PageGroup.h @@ -41,7 +41,8 @@ namespace WebCore { class Page; class StorageNamespace; - class PageGroup : public Noncopyable { + class PageGroup { + WTF_MAKE_NONCOPYABLE(PageGroup); WTF_MAKE_FAST_ALLOCATED; public: PageGroup(const String& name); PageGroup(Page*); diff --git a/Source/WebCore/page/PageGroupLoadDeferrer.h b/Source/WebCore/page/PageGroupLoadDeferrer.h index d443ebd..f7956c4 100644 --- a/Source/WebCore/page/PageGroupLoadDeferrer.h +++ b/Source/WebCore/page/PageGroupLoadDeferrer.h @@ -28,7 +28,8 @@ namespace WebCore { class Frame; class Page; - class PageGroupLoadDeferrer : public Noncopyable { + class PageGroupLoadDeferrer { + WTF_MAKE_NONCOPYABLE(PageGroupLoadDeferrer); public: PageGroupLoadDeferrer(Page*, bool deferSelf); ~PageGroupLoadDeferrer(); diff --git a/Source/WebCore/page/PluginHalter.h b/Source/WebCore/page/PluginHalter.h index af8b31e..5b96d19 100644 --- a/Source/WebCore/page/PluginHalter.h +++ b/Source/WebCore/page/PluginHalter.h @@ -35,7 +35,8 @@ namespace WebCore { class HaltablePlugin; -class PluginHalter : public Noncopyable { +class PluginHalter { + WTF_MAKE_NONCOPYABLE(PluginHalter); WTF_MAKE_FAST_ALLOCATED; public: PluginHalter(PluginHalterClient*); diff --git a/Source/WebCore/page/Settings.cpp b/Source/WebCore/page/Settings.cpp index 8b174be..a88ca6b 100644 --- a/Source/WebCore/page/Settings.cpp +++ b/Source/WebCore/page/Settings.cpp @@ -168,6 +168,7 @@ Settings::Settings(Page* page) , m_showRepaintCounter(false) , m_experimentalNotificationsEnabled(false) , m_webGLEnabled(false) + , m_webAudioEnabled(false) , m_acceleratedCanvas2dEnabled(false) , m_loadDeferringEnabled(true) , m_tiledBackingStoreEnabled(false) @@ -857,6 +858,11 @@ void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTime } #endif +void Settings::setWebAudioEnabled(bool enabled) +{ + m_webAudioEnabled = enabled; +} + void Settings::setWebGLEnabled(bool enabled) { m_webGLEnabled = enabled; diff --git a/Source/WebCore/page/Settings.h b/Source/WebCore/page/Settings.h index f6b2e2d..9f0982a 100644 --- a/Source/WebCore/page/Settings.h +++ b/Source/WebCore/page/Settings.h @@ -50,7 +50,8 @@ namespace WebCore { TextDirectionSubmenuAlwaysIncluded }; - class Settings : public Noncopyable { + class Settings { + WTF_MAKE_NONCOPYABLE(Settings); WTF_MAKE_FAST_ALLOCATED; public: Settings(Page*); @@ -379,6 +380,9 @@ namespace WebCore { void setPluginAllowedRunTime(unsigned); unsigned pluginAllowedRunTime() const { return m_pluginAllowedRunTime; } + void setWebAudioEnabled(bool); + bool webAudioEnabled() const { return m_webAudioEnabled; } + void setWebGLEnabled(bool); bool webGLEnabled() const { return m_webGLEnabled; } @@ -544,6 +548,7 @@ namespace WebCore { bool m_showRepaintCounter : 1; bool m_experimentalNotificationsEnabled : 1; bool m_webGLEnabled : 1; + bool m_webAudioEnabled : 1; bool m_acceleratedCanvas2dEnabled : 1; bool m_loadDeferringEnabled : 1; bool m_tiledBackingStoreEnabled : 1; diff --git a/Source/WebCore/page/SpeechInput.cpp b/Source/WebCore/page/SpeechInput.cpp index f36ed4d..9605dd3 100644 --- a/Source/WebCore/page/SpeechInput.cpp +++ b/Source/WebCore/page/SpeechInput.cpp @@ -33,7 +33,7 @@ #if ENABLE(INPUT_SPEECH) -#include "Frame.h" +#include "SecurityOrigin.h" #include "SpeechInputClient.h" #include "SpeechInputListener.h" @@ -93,10 +93,10 @@ void SpeechInput::setRecognitionResult(int listenerId, const SpeechInputResultAr m_listeners.get(listenerId)->setRecognitionResult(listenerId, result); } -bool SpeechInput::startRecognition(int listenerId, const IntRect& elementRect, const AtomicString& language, const String& grammar) +bool SpeechInput::startRecognition(int listenerId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin* origin) { ASSERT(m_listeners.contains(listenerId)); - return m_client->startRecognition(listenerId, elementRect, language, grammar); + return m_client->startRecognition(listenerId, elementRect, language, grammar, origin); } void SpeechInput::stopRecording(int listenerId) diff --git a/Source/WebCore/page/SpeechInput.h b/Source/WebCore/page/SpeechInput.h index 4532d49..52d6c03 100644 --- a/Source/WebCore/page/SpeechInput.h +++ b/Source/WebCore/page/SpeechInput.h @@ -36,18 +36,19 @@ #include "SpeechInputListener.h" #include <wtf/Forward.h> #include <wtf/HashMap.h> -#include <wtf/Noncopyable.h> namespace WebCore { class IntRect; +class SecurityOrigin; class SpeechInputClient; class SpeechInputListener; // This class connects the input elements requiring speech input with the platform specific // speech recognition engine. It provides methods for the input elements to activate speech // recognition and methods for the speech recognition engine to return back the results. -class SpeechInput : public Noncopyable, public SpeechInputListener { +class SpeechInput : public SpeechInputListener { + WTF_MAKE_NONCOPYABLE(SpeechInput); public: SpeechInput(SpeechInputClient*); virtual ~SpeechInput(); @@ -61,7 +62,7 @@ public: void unregisterListener(int); // Methods invoked by the input elements. - bool startRecognition(int listenerId, const IntRect& elementRect, const AtomicString& language, const String& grammar); + bool startRecognition(int listenerId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin*); void stopRecording(int); void cancelRecognition(int); diff --git a/Source/WebCore/page/SpeechInputClient.h b/Source/WebCore/page/SpeechInputClient.h index 2a2e160..4f8fd5e 100644 --- a/Source/WebCore/page/SpeechInputClient.h +++ b/Source/WebCore/page/SpeechInputClient.h @@ -38,6 +38,7 @@ namespace WebCore { class IntRect; +class SecurityOrigin; class SpeechInputListener; // Provides an interface for SpeechInput to call into the embedder. @@ -50,7 +51,7 @@ public: virtual void setListener(SpeechInputListener*) = 0; // Starts speech recognition and audio recording. - virtual bool startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar) = 0; + virtual bool startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin*) = 0; // Stops audio recording and performs recognition with the audio recorded until now // (does not discard audio). diff --git a/Source/WebCore/page/UserScript.h b/Source/WebCore/page/UserScript.h index 0652439..0514090 100644 --- a/Source/WebCore/page/UserScript.h +++ b/Source/WebCore/page/UserScript.h @@ -35,7 +35,8 @@ namespace WebCore { -class UserScript : public Noncopyable { +class UserScript { + WTF_MAKE_NONCOPYABLE(UserScript); WTF_MAKE_FAST_ALLOCATED; public: UserScript(const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist, diff --git a/Source/WebCore/page/UserStyleSheet.h b/Source/WebCore/page/UserStyleSheet.h index fa42e2c..068df1e 100644 --- a/Source/WebCore/page/UserStyleSheet.h +++ b/Source/WebCore/page/UserStyleSheet.h @@ -35,7 +35,8 @@ namespace WebCore { -class UserStyleSheet : public Noncopyable { +class UserStyleSheet { + WTF_MAKE_NONCOPYABLE(UserStyleSheet); WTF_MAKE_FAST_ALLOCATED; public: UserStyleSheet(const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist, diff --git a/Source/WebCore/page/XSSAuditor.h b/Source/WebCore/page/XSSAuditor.h index 2b781f1..5beed61 100644 --- a/Source/WebCore/page/XSSAuditor.h +++ b/Source/WebCore/page/XSSAuditor.h @@ -69,7 +69,8 @@ namespace WebCore { // * HTMLDocumentParser::shouldLoadExternalScriptFromSrc - used to load external JavaScript scripts. // * SubframeLoader::requestObject - used to load <object>/<embed> elements. // - class XSSAuditor : public Noncopyable { + class XSSAuditor { + WTF_MAKE_NONCOPYABLE(XSSAuditor); WTF_MAKE_FAST_ALLOCATED; public: XSSAuditor(Frame*); ~XSSAuditor(); diff --git a/Source/WebCore/page/animation/AnimationBase.cpp b/Source/WebCore/page/animation/AnimationBase.cpp index 14a44d2..9a906e2 100644 --- a/Source/WebCore/page/animation/AnimationBase.cpp +++ b/Source/WebCore/page/animation/AnimationBase.cpp @@ -223,7 +223,8 @@ class PropertyWrapperBase; static void addShorthandProperties(); static PropertyWrapperBase* wrapperForProperty(int propertyID); -class PropertyWrapperBase : public Noncopyable { +class PropertyWrapperBase { + WTF_MAKE_NONCOPYABLE(PropertyWrapperBase); WTF_MAKE_FAST_ALLOCATED; public: PropertyWrapperBase(int prop) : m_prop(prop) @@ -446,7 +447,8 @@ public: }; template <typename T> -class FillLayerPropertyWrapperGetter : public FillLayerPropertyWrapperBase, public Noncopyable { +class FillLayerPropertyWrapperGetter : public FillLayerPropertyWrapperBase { + WTF_MAKE_NONCOPYABLE(FillLayerPropertyWrapperGetter); public: FillLayerPropertyWrapperGetter(T (FillLayer::*getter)() const) : m_getter(getter) diff --git a/Source/WebCore/page/animation/AnimationControllerPrivate.h b/Source/WebCore/page/animation/AnimationControllerPrivate.h index 6812e09..186dd7d 100644 --- a/Source/WebCore/page/animation/AnimationControllerPrivate.h +++ b/Source/WebCore/page/animation/AnimationControllerPrivate.h @@ -49,7 +49,8 @@ class Node; class RenderObject; class RenderStyle; -class AnimationControllerPrivate : public Noncopyable { +class AnimationControllerPrivate { + WTF_MAKE_NONCOPYABLE(AnimationControllerPrivate); WTF_MAKE_FAST_ALLOCATED; public: AnimationControllerPrivate(Frame*); ~AnimationControllerPrivate(); diff --git a/Source/WebCore/page/mac/EventHandlerMac.mm b/Source/WebCore/page/mac/EventHandlerMac.mm index 2d4d86b..6011859 100644 --- a/Source/WebCore/page/mac/EventHandlerMac.mm +++ b/Source/WebCore/page/mac/EventHandlerMac.mm @@ -77,7 +77,8 @@ NSEvent *EventHandler::currentNSEvent() return currentNSEventSlot().get(); } -class CurrentEventScope : public Noncopyable { +class CurrentEventScope { + WTF_MAKE_NONCOPYABLE(CurrentEventScope); public: CurrentEventScope(NSEvent *); ~CurrentEventScope(); diff --git a/Source/WebCore/platform/AsyncFileSystem.h b/Source/WebCore/platform/AsyncFileSystem.h index d96c1ad..c34a644 100644 --- a/Source/WebCore/platform/AsyncFileSystem.h +++ b/Source/WebCore/platform/AsyncFileSystem.h @@ -44,7 +44,8 @@ class AsyncFileSystemCallbacks; class AsyncFileWriterClient; // This class provides async interface for platform-specific file system implementation. Note that all the methods take platform paths. -class AsyncFileSystem : public Noncopyable { +class AsyncFileSystem { + WTF_MAKE_NONCOPYABLE(AsyncFileSystem); public: virtual ~AsyncFileSystem() { } diff --git a/Source/WebCore/platform/AsyncFileSystemCallbacks.h b/Source/WebCore/platform/AsyncFileSystemCallbacks.h index 290a669..cee8d90 100644 --- a/Source/WebCore/platform/AsyncFileSystemCallbacks.h +++ b/Source/WebCore/platform/AsyncFileSystemCallbacks.h @@ -41,8 +41,11 @@ class AsyncFileSystem; class AsyncFileWriter; struct FileMetadata; -class AsyncFileSystemCallbacks : public Noncopyable { +class AsyncFileSystemCallbacks { + WTF_MAKE_NONCOPYABLE(AsyncFileSystemCallbacks); public: + AsyncFileSystemCallbacks() { } + // Called when a requested operation is completed successfully. virtual void didSucceed() = 0; diff --git a/Source/WebCore/platform/AutodrainedPool.h b/Source/WebCore/platform/AutodrainedPool.h index d44ee1e..f03ec81 100644 --- a/Source/WebCore/platform/AutodrainedPool.h +++ b/Source/WebCore/platform/AutodrainedPool.h @@ -39,7 +39,8 @@ class NSAutoreleasePool; namespace WebCore { -class AutodrainedPool : public Noncopyable { +class AutodrainedPool { + WTF_MAKE_NONCOPYABLE(AutodrainedPool); public: AutodrainedPool(int iterationLimit = 1); ~AutodrainedPool(); diff --git a/Source/WebCore/platform/ContextMenu.h b/Source/WebCore/platform/ContextMenu.h index 575c86d..2977749 100644 --- a/Source/WebCore/platform/ContextMenu.h +++ b/Source/WebCore/platform/ContextMenu.h @@ -41,8 +41,8 @@ namespace WebCore { class ContextMenuController; - class ContextMenu : public Noncopyable - { + class ContextMenu { + WTF_MAKE_NONCOPYABLE(ContextMenu); WTF_MAKE_FAST_ALLOCATED; public: ContextMenu(); diff --git a/Source/WebCore/platform/ContextMenuItem.h b/Source/WebCore/platform/ContextMenuItem.h index 145d795..6e84131 100644 --- a/Source/WebCore/platform/ContextMenuItem.h +++ b/Source/WebCore/platform/ContextMenuItem.h @@ -223,7 +223,8 @@ namespace WebCore { typedef void* PlatformMenuItemDescription; #endif - class ContextMenuItem : public FastAllocBase { + class ContextMenuItem { + WTF_MAKE_FAST_ALLOCATED; public: ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, ContextMenu* subMenu = 0); ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, bool enabled, bool checked); diff --git a/Source/WebCore/platform/DeprecatedPtrList.h b/Source/WebCore/platform/DeprecatedPtrList.h index 47cd538..c07d173 100644 --- a/Source/WebCore/platform/DeprecatedPtrList.h +++ b/Source/WebCore/platform/DeprecatedPtrList.h @@ -33,7 +33,8 @@ namespace WebCore { template <class T> class DeprecatedPtrListIterator; -template <class T> class DeprecatedPtrList : public FastAllocBase { +template <class T> class DeprecatedPtrList { + WTF_MAKE_FAST_ALLOCATED; public: DeprecatedPtrList() : impl(deleteFunc), del_item(false) { } ~DeprecatedPtrList() { impl.clear(del_item); } diff --git a/Source/WebCore/platform/DeprecatedPtrListImpl.cpp b/Source/WebCore/platform/DeprecatedPtrListImpl.cpp index 96fd513..c633741 100644 --- a/Source/WebCore/platform/DeprecatedPtrListImpl.cpp +++ b/Source/WebCore/platform/DeprecatedPtrListImpl.cpp @@ -29,12 +29,13 @@ #include <cstddef> #include <algorithm> #include <wtf/Assertions.h> +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> namespace WebCore { -class DeprecatedListNode : public Noncopyable -{ +class DeprecatedListNode { + WTF_MAKE_NONCOPYABLE(DeprecatedListNode); WTF_MAKE_FAST_ALLOCATED; public: DeprecatedListNode(void *d) : data(d), next(0), prev(0) { } diff --git a/Source/WebCore/platform/EventLoop.h b/Source/WebCore/platform/EventLoop.h index b0507f7..128e92b 100644 --- a/Source/WebCore/platform/EventLoop.h +++ b/Source/WebCore/platform/EventLoop.h @@ -30,7 +30,8 @@ namespace WebCore { - class EventLoop : public Noncopyable { + class EventLoop { + WTF_MAKE_NONCOPYABLE(EventLoop); public: EventLoop() : m_ended(false) diff --git a/Source/WebCore/platform/GeolocationService.h b/Source/WebCore/platform/GeolocationService.h index 2cb70f2..cf51b1e 100644 --- a/Source/WebCore/platform/GeolocationService.h +++ b/Source/WebCore/platform/GeolocationService.h @@ -42,7 +42,8 @@ public: virtual void geolocationServiceErrorOccurred(GeolocationService*) = 0; }; -class GeolocationService : public Noncopyable { +class GeolocationService { + WTF_MAKE_NONCOPYABLE(GeolocationService); public: static GeolocationService* create(GeolocationServiceClient*); virtual ~GeolocationService() { } diff --git a/Source/WebCore/platform/HostWindow.h b/Source/WebCore/platform/HostWindow.h index 7882d48..0d19356 100644 --- a/Source/WebCore/platform/HostWindow.h +++ b/Source/WebCore/platform/HostWindow.h @@ -26,15 +26,16 @@ #ifndef HostWindow_h #define HostWindow_h -#include <wtf/Noncopyable.h> #include "Widget.h" namespace WebCore { class Cursor; -class HostWindow : public Noncopyable { +class HostWindow { + WTF_MAKE_NONCOPYABLE(HostWindow); WTF_MAKE_FAST_ALLOCATED; public: + HostWindow() { } virtual ~HostWindow() { } // Requests the host invalidate the window, not the contents. If immediate is true do so synchronously, otherwise async. @@ -66,6 +67,10 @@ public: // Request that the cursor change. virtual void setCursor(const Cursor&) = 0; + +#if ENABLE(REQUEST_ANIMATION_FRAME) + virtual void scheduleAnimation() = 0; +#endif }; } // namespace WebCore diff --git a/Source/WebCore/platform/KillRing.h b/Source/WebCore/platform/KillRing.h index 8e27350..b687274 100644 --- a/Source/WebCore/platform/KillRing.h +++ b/Source/WebCore/platform/KillRing.h @@ -31,6 +31,7 @@ namespace WebCore { class KillRing { + WTF_MAKE_FAST_ALLOCATED; public: void append(const String&); void prepend(const String&); diff --git a/Source/WebCore/platform/Length.h b/Source/WebCore/platform/Length.h index 7dd875e..9da71c7 100644 --- a/Source/WebCore/platform/Length.h +++ b/Source/WebCore/platform/Length.h @@ -35,7 +35,9 @@ const int intMinForLength = (-0x7ffffff - 1); // min value for a 28-bit int enum LengthType { Auto, Relative, Percent, Fixed, Static, Intrinsic, MinIntrinsic }; -struct Length : FastAllocBase { +struct Length { + WTF_MAKE_FAST_ALLOCATED; +public: Length() : m_value(0) { diff --git a/Source/WebCore/platform/Pasteboard.h b/Source/WebCore/platform/Pasteboard.h index 78a40b3..50a9cb6 100644 --- a/Source/WebCore/platform/Pasteboard.h +++ b/Source/WebCore/platform/Pasteboard.h @@ -81,7 +81,8 @@ class Node; class Range; class ArchiveResource; -class Pasteboard : public Noncopyable { +class Pasteboard { + WTF_MAKE_NONCOPYABLE(Pasteboard); WTF_MAKE_FAST_ALLOCATED; public: #if PLATFORM(MAC) //Helper functions to allow Clipboard to share code diff --git a/Source/WebCore/platform/PlatformKeyboardEvent.h b/Source/WebCore/platform/PlatformKeyboardEvent.h index 7ce7017..eb144f7 100644 --- a/Source/WebCore/platform/PlatformKeyboardEvent.h +++ b/Source/WebCore/platform/PlatformKeyboardEvent.h @@ -75,7 +75,8 @@ typedef unsigned long int uint32; namespace WebCore { - class PlatformKeyboardEvent : public FastAllocBase { + class PlatformKeyboardEvent { + WTF_MAKE_FAST_ALLOCATED; public: enum Type { // KeyDown is sent by platforms such as Mac OS X, gtk and Qt, and has information about both physical pressed key, and its translation. diff --git a/Source/WebCore/platform/PopupMenuClient.h b/Source/WebCore/platform/PopupMenuClient.h index 45912a1..f33b9e2 100644 --- a/Source/WebCore/platform/PopupMenuClient.h +++ b/Source/WebCore/platform/PopupMenuClient.h @@ -32,7 +32,7 @@ class Color; class FontSelector; class HostWindow; class Scrollbar; -class ScrollbarClient; +class ScrollableArea; class PopupMenuClient { public: @@ -66,7 +66,7 @@ public: virtual FontSelector* fontSelector() const = 0; virtual HostWindow* hostWindow() const = 0; - virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize) = 0; + virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize) = 0; }; #if ENABLE(NO_LISTBOX_RENDERING) diff --git a/Source/WebCore/platform/PurgeableBuffer.h b/Source/WebCore/platform/PurgeableBuffer.h index 9bda2d5..44136c2 100644 --- a/Source/WebCore/platform/PurgeableBuffer.h +++ b/Source/WebCore/platform/PurgeableBuffer.h @@ -27,13 +27,13 @@ #define PurgeableBuffer_h #include "PurgePriority.h" -#include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> namespace WebCore { - class PurgeableBuffer : public Noncopyable { + class PurgeableBuffer { + WTF_MAKE_NONCOPYABLE(PurgeableBuffer); public: static PassOwnPtr<PurgeableBuffer> create(const char* data, size_t); diff --git a/Source/WebCore/platform/RunLoopTimer.h b/Source/WebCore/platform/RunLoopTimer.h index 65f253e..f8c529f 100644 --- a/Source/WebCore/platform/RunLoopTimer.h +++ b/Source/WebCore/platform/RunLoopTimer.h @@ -30,15 +30,16 @@ #define RunLoopTimer_h #include "SchedulePair.h" -#include <wtf/Noncopyable.h> #include <wtf/RetainPtr.h> namespace WebCore { // Time intervals are all in seconds. -class RunLoopTimerBase : public Noncopyable { +class RunLoopTimerBase { + WTF_MAKE_NONCOPYABLE(RunLoopTimerBase); public: + RunLoopTimerBase() { } virtual ~RunLoopTimerBase(); void schedule(const SchedulePair*); diff --git a/Source/WebCore/platform/ScrollAnimator.cpp b/Source/WebCore/platform/ScrollAnimator.cpp index 583e833..428a79d 100644 --- a/Source/WebCore/platform/ScrollAnimator.cpp +++ b/Source/WebCore/platform/ScrollAnimator.cpp @@ -31,20 +31,22 @@ #include "config.h" #include "ScrollAnimator.h" -#include "ScrollbarClient.h" +#include "FloatPoint.h" +#include "ScrollableArea.h" #include <algorithm> +#include <wtf/PassOwnPtr.h> namespace WebCore { #if !ENABLE(SMOOTH_SCROLLING) -ScrollAnimator* ScrollAnimator::create(ScrollbarClient* client) +PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea) { - return new ScrollAnimator(client); + return adoptPtr(new ScrollAnimator(scrollableArea)); } #endif -ScrollAnimator::ScrollAnimator(ScrollbarClient* client) - : m_client(client) +ScrollAnimator::ScrollAnimator(ScrollableArea* scrollableArea) + : m_scrollableArea(scrollableArea) , m_currentPosX(0) , m_currentPosY(0) { @@ -57,20 +59,33 @@ ScrollAnimator::~ScrollAnimator() bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier) { float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX : &m_currentPosY; - float newPos = std::max(std::min(*currentPos + (step * multiplier), static_cast<float>(m_client->scrollSize(orientation))), 0.0f); + float newPos = std::max(std::min(*currentPos + (step * multiplier), static_cast<float>(m_scrollableArea->scrollSize(orientation))), 0.0f); if (*currentPos == newPos) return false; *currentPos = newPos; - m_client->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_currentPosY)); + + notityPositionChanged(); + return true; } -void ScrollAnimator::setScrollPositionAndStopAnimation(ScrollbarOrientation orientation, float pos) +void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset) +{ + if (m_currentPosX != offset.x() || m_currentPosY != offset.y()) { + m_currentPosX = offset.x(); + m_currentPosY = offset.y(); + notityPositionChanged(); + } +} + +FloatPoint ScrollAnimator::currentPosition() const +{ + return FloatPoint(m_currentPosX, m_currentPosY); +} + +void ScrollAnimator::notityPositionChanged() { - if (orientation == HorizontalScrollbar) - m_currentPosX = pos; - else - m_currentPosY = pos; + m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_currentPosY)); } } // namespace WebCore diff --git a/Source/WebCore/platform/ScrollAnimator.h b/Source/WebCore/platform/ScrollAnimator.h index e674339..155c6e5 100644 --- a/Source/WebCore/platform/ScrollAnimator.h +++ b/Source/WebCore/platform/ScrollAnimator.h @@ -32,16 +32,17 @@ #define ScrollAnimator_h #include "ScrollTypes.h" +#include <wtf/Forward.h> namespace WebCore { -class ScrollbarClient; +class FloatPoint; +class ScrollableArea; class ScrollAnimator { public: - static ScrollAnimator* create(ScrollbarClient*); + static PassOwnPtr<ScrollAnimator> create(ScrollableArea*); - ScrollAnimator(ScrollbarClient* client); virtual ~ScrollAnimator(); // Computes a scroll destination for the given parameters. Returns false if @@ -50,16 +51,20 @@ public: // The base class implementation always scrolls immediately, never animates. virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier); - // Stops any animation in the given direction and updates the ScrollAnimator - // with the current scroll position. This does not cause a callback to the - // ScrollbarClient. - virtual void setScrollPositionAndStopAnimation(ScrollbarOrientation, float); + virtual void scrollToOffsetWithoutAnimation(const FloatPoint&); + + FloatPoint currentPosition() const; protected: - ScrollbarClient* m_client; + ScrollAnimator(ScrollableArea*); + + void notityPositionChanged(); + + ScrollableArea* m_scrollableArea; float m_currentPosX; // We avoid using a FloatPoint in order to reduce float m_currentPosY; // subclass code complexity. }; } // namespace WebCore -#endif + +#endif // ScrollAnimator_h diff --git a/Source/WebCore/platform/ScrollAnimatorWin.cpp b/Source/WebCore/platform/ScrollAnimatorWin.cpp index 025aa71..47a00cb 100644 --- a/Source/WebCore/platform/ScrollAnimatorWin.cpp +++ b/Source/WebCore/platform/ScrollAnimatorWin.cpp @@ -34,17 +34,18 @@ #include "ScrollAnimatorWin.h" -#include "ScrollbarClient.h" +#include "FloatPoint.h" +#include "ScrollableArea.h" #include "ScrollbarTheme.h" #include <algorithm> #include <wtf/CurrentTime.h> +#include <wtf/PassOwnPtr.h> namespace WebCore { -// static -ScrollAnimator* ScrollAnimator::create(ScrollbarClient* client) +PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea) { - return new ScrollAnimatorWin(client); + return adoptPtr(new ScrollAnimatorWin(scrollableArea)); } const double ScrollAnimatorWin::animationTimerDelay = 0.01; @@ -60,8 +61,8 @@ ScrollAnimatorWin::PerAxisData::PerAxisData(ScrollAnimatorWin* parent, float* cu } -ScrollAnimatorWin::ScrollAnimatorWin(ScrollbarClient* client) - : ScrollAnimator(client) +ScrollAnimatorWin::ScrollAnimatorWin(ScrollableArea* scrollableArea) + : ScrollAnimator(scrollableArea) , m_horizontalData(this, &m_currentPosX) , m_verticalData(this, &m_currentPosY) { @@ -81,7 +82,7 @@ bool ScrollAnimatorWin::scroll(ScrollbarOrientation orientation, ScrollGranulari // This is an animatable scroll. Calculate the scroll delta. PerAxisData* data = (orientation == VerticalScrollbar) ? &m_verticalData : &m_horizontalData; - float newPos = std::max(std::min(data->m_desiredPos + (step * multiplier), static_cast<float>(m_client->scrollSize(orientation))), 0.0f); + float newPos = std::max(std::min(data->m_desiredPos + (step * multiplier), static_cast<float>(m_scrollableArea->scrollSize(orientation))), 0.0f); if (newPos == data->m_desiredPos) return false; data->m_desiredPos = newPos; @@ -177,17 +178,24 @@ bool ScrollAnimatorWin::scroll(ScrollbarOrientation orientation, ScrollGranulari return true; } -void ScrollAnimatorWin::setScrollPositionAndStopAnimation(ScrollbarOrientation orientation, float pos) +void ScrollAnimatorWin::scrollToOffsetWithoutAnimation(const FloatPoint& offset) { - PerAxisData* data = (orientation == HorizontalScrollbar) ? &m_horizontalData : &m_verticalData; - stopAnimationTimerIfNeeded(data); - *data->m_currentPos = pos; - data->m_desiredPos = pos; - data->m_currentVelocity = 0; - data->m_desiredVelocity = 0; + stopAnimationTimerIfNeeded(&m_horizontalData); + stopAnimationTimerIfNeeded(&m_verticalData); + + *m_horizontalData.m_currentPos = offset.x(); + m_horizontalData.m_desiredPos = offset.x(); + m_horizontalData.m_currentVelocity = 0; + m_horizontalData.m_desiredVelocity = 0; + + *m_verticalData.m_currentPos = offset.y(); + m_verticalData.m_desiredPos = offset.y(); + m_verticalData.m_currentVelocity = 0; + m_verticalData.m_desiredVelocity = 0; + + notityPositionChanged(); } -// static double ScrollAnimatorWin::accelerationTime() { // We elect to use ScrollbarTheme::nativeTheme()->autoscrollTimerDelay() as @@ -293,7 +301,8 @@ void ScrollAnimatorWin::animateScroll(PerAxisData* data) data->m_animationTimer.startOneShot(animationTimerDelay); data->m_lastAnimationTime = WTF::currentTime(); } - m_client->setScrollOffsetFromAnimation(IntPoint(*m_horizontalData.m_currentPos, *m_verticalData.m_currentPos)); + + notityPositionChanged(); } } // namespace WebCore diff --git a/Source/WebCore/platform/ScrollAnimatorWin.h b/Source/WebCore/platform/ScrollAnimatorWin.h index 7043634..6f87e58 100644 --- a/Source/WebCore/platform/ScrollAnimatorWin.h +++ b/Source/WebCore/platform/ScrollAnimatorWin.h @@ -40,11 +40,11 @@ namespace WebCore { class ScrollAnimatorWin : public ScrollAnimator { public: - ScrollAnimatorWin(ScrollbarClient*); + ScrollAnimatorWin(ScrollableArea*); virtual ~ScrollAnimatorWin(); virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier); - virtual void setScrollPositionAndStopAnimation(ScrollbarOrientation, float); + virtual void scrollToOffsetWithoutAnimation(const FloatPoint&); private: struct PerAxisData { @@ -69,8 +69,8 @@ private: PerAxisData m_verticalData; }; -} +} // namespace WebCore #endif // ENABLE(SMOOTH_SCROLLING) -#endif +#endif // ScrollAnimatorWin_h diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp index 6ea60df..b07c743 100644 --- a/Source/WebCore/platform/ScrollView.cpp +++ b/Source/WebCore/platform/ScrollView.cpp @@ -229,9 +229,15 @@ IntRect ScrollView::visibleContentRect(bool includeScrollbars) const if (paintsEntireContents()) return IntRect(IntPoint(0, 0), contentsSize()); + bool hasOverlayScrollbars = ScrollbarTheme::nativeTheme()->usesOverlayScrollbars(); + int verticalScrollbarWidth = verticalScrollbar() && !hasOverlayScrollbars && !includeScrollbars + ? verticalScrollbar()->width() : 0; + int horizontalScrollbarHeight = horizontalScrollbar() && !hasOverlayScrollbars && !includeScrollbars + ? horizontalScrollbar()->height() : 0; + return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()), - IntSize(max(0, width() - (verticalScrollbar() && !includeScrollbars ? verticalScrollbar()->width() : 0)), - max(0, height() - (horizontalScrollbar() && !includeScrollbars ? horizontalScrollbar()->height() : 0)))); + IntSize(max(0, width() - verticalScrollbarWidth), + max(0, height() - horizontalScrollbarHeight))); } #endif @@ -344,25 +350,20 @@ int ScrollView::scrollSize(ScrollbarOrientation orientation) const return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; } -void ScrollView::setScrollOffsetFromAnimation(const IntPoint& offset) +void ScrollView::setScrollOffset(const IntPoint& offset) { - if (m_horizontalScrollbar) - m_horizontalScrollbar->setValue(offset.x(), Scrollbar::FromScrollAnimator); - if (m_verticalScrollbar) - m_verticalScrollbar->setValue(offset.y(), Scrollbar::FromScrollAnimator); -} + int horizontalOffset = std::max(std::min(offset.x(), contentsWidth() - visibleWidth()), 0); + int verticalOffset = std::max(std::min(offset.y(), contentsHeight() - visibleHeight()), 0); -void ScrollView::valueChanged(Scrollbar* scrollbar) -{ - // Figure out if we really moved. IntSize newOffset = m_scrollOffset; - if (scrollbar) { - if (scrollbar->orientation() == HorizontalScrollbar) - newOffset.setWidth(scrollbar->value() - m_scrollOrigin.x()); - else if (scrollbar->orientation() == VerticalScrollbar) - newOffset.setHeight(scrollbar->value() - m_scrollOrigin.y()); - } + newOffset.setWidth(horizontalOffset - m_scrollOrigin.x()); + newOffset.setHeight(verticalOffset - m_scrollOrigin.y()); + + scrollTo(newOffset); +} +void ScrollView::scrollTo(const IntSize& newOffset) +{ IntSize scrollDelta = newOffset - m_scrollOffset; if (scrollDelta == IntSize()) return; @@ -375,13 +376,13 @@ void ScrollView::valueChanged(Scrollbar* scrollbar) scrollContents(scrollDelta); } -void ScrollView::valueChanged(const IntSize& scrollDelta) +int ScrollView::scrollPosition(Scrollbar* scrollbar) const { - if (scrollbarsSuppressed()) - return; - - repaintFixedElementsAfterScrolling(); - scrollContents(scrollDelta); + if (scrollbar->orientation() == HorizontalScrollbar) + return scrollPosition().x() + m_scrollOrigin.x(); + if (scrollbar->orientation() == VerticalScrollbar) + return scrollPosition().y() + m_scrollOrigin.y(); + return 0; } void ScrollView::setScrollPosition(const IntPoint& scrollPoint) @@ -415,15 +416,8 @@ bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity { if (platformWidget()) return platformScroll(direction, granularity); - - if (direction == ScrollUp || direction == ScrollDown) { - if (m_verticalScrollbar) - return m_verticalScrollbar->scroll(direction, granularity); - } else { - if (m_horizontalScrollbar) - return m_horizontalScrollbar->scroll(direction, granularity); - } - return false; + + return ScrollableArea::scroll(direction, granularity); } bool ScrollView::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity) @@ -554,7 +548,6 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) m_horizontalScrollbar->setSuppressInvalidation(true); m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); - m_horizontalScrollbar->setValue(scroll.width() + m_scrollOrigin.x(), Scrollbar::NotFromScrollAnimator); if (m_scrollbarsSuppressed) m_horizontalScrollbar->setSuppressInvalidation(false); } @@ -576,7 +569,6 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) m_verticalScrollbar->setSuppressInvalidation(true); m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); - m_verticalScrollbar->setValue(scroll.height() + m_scrollOrigin.y(), Scrollbar::NotFromScrollAnimator); if (m_scrollbarsSuppressed) m_verticalScrollbar->setSuppressInvalidation(false); } @@ -586,15 +578,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) updateScrollCorner(); } - // See if our offset has changed in a situation where we might not have scrollbars. - // This can happen when editing a body with overflow:hidden and scrolling to reveal selection. - // It can also happen when maximizing a window that has scrollbars (but the new maximized result - // does not). - IntSize scrollDelta = scroll - m_scrollOffset; - if (scrollDelta != IntSize()) { - m_scrollOffset = scroll; - valueChanged(scrollDelta); - } + ScrollableArea::scrollToOffsetWithoutAnimation(FloatPoint(scroll.width() + m_scrollOrigin.x(), scroll.height() + m_scrollOrigin.y())); m_inUpdateScrollbars = false; } @@ -781,6 +765,7 @@ void ScrollView::wheelEvent(PlatformWheelEvent& e) // scroll any further. float deltaX = m_horizontalScrollbar ? e.deltaX() : 0; float deltaY = m_verticalScrollbar ? e.deltaY() : 0; + IntSize maxForwardScrollDelta = maximumScrollPosition() - scrollPosition(); IntSize maxBackwardScrollDelta = scrollPosition() - minimumScrollPosition(); if ((deltaX < 0 && maxForwardScrollDelta.width() > 0) @@ -797,9 +782,9 @@ void ScrollView::wheelEvent(PlatformWheelEvent& e) } if (deltaY) - m_verticalScrollbar->scroll(ScrollUp, ScrollByPixel, deltaY); + ScrollableArea::scroll(ScrollUp, ScrollByPixel, deltaY); if (deltaX) - m_horizontalScrollbar->scroll(ScrollLeft, ScrollByPixel, deltaX); + ScrollableArea::scroll(ScrollLeft, ScrollByPixel, deltaX); } } @@ -857,7 +842,10 @@ void ScrollView::repaintContentRectangle(const IntRect& rect, bool now) IntRect ScrollView::scrollCornerRect() const { IntRect cornerRect; - + + if (ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()) + return cornerRect; + if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) { cornerRect.unite(IntRect(m_horizontalScrollbar->width(), height() - m_horizontalScrollbar->height(), diff --git a/Source/WebCore/platform/ScrollView.h b/Source/WebCore/platform/ScrollView.h index 97b2c47..cb895f6 100644 --- a/Source/WebCore/platform/ScrollView.h +++ b/Source/WebCore/platform/ScrollView.h @@ -29,7 +29,7 @@ #include "IntRect.h" #include "Scrollbar.h" -#include "ScrollbarClient.h" +#include "ScrollableArea.h" #include "ScrollTypes.h" #include "Widget.h" @@ -54,16 +54,18 @@ class HostWindow; class PlatformWheelEvent; class Scrollbar; -class ScrollView : public Widget, public ScrollbarClient { +class ScrollView : public Widget, public ScrollableArea { public: ~ScrollView(); - // ScrollbarClient functions. FrameView overrides the others. + // ScrollableArea functions. FrameView overrides the others. virtual int scrollSize(ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const IntPoint&); - virtual void valueChanged(Scrollbar*); - virtual void valueChanged(const IntSize&); + virtual int scrollPosition(Scrollbar*) const; + virtual void setScrollOffset(const IntPoint&); + // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. + virtual void scrollTo(const IntSize& newOffset); + // The window thats hosts the ScrollView. The ScrollView will communicate scrolls and repaints to the // host window in the window's coordinate space. virtual HostWindow* hostWindow() const = 0; @@ -78,8 +80,8 @@ public: // If the scroll view does not use a native widget, then it will have cross-platform Scrollbars. These functions // can be used to obtain those scrollbars. - Scrollbar* horizontalScrollbar() const { return m_horizontalScrollbar.get(); } - Scrollbar* verticalScrollbar() const { return m_verticalScrollbar.get(); } + virtual Scrollbar* horizontalScrollbar() const { return m_horizontalScrollbar.get(); } + virtual Scrollbar* verticalScrollbar() const { return m_verticalScrollbar.get(); } bool isScrollViewScrollbar(const Widget* child) const { return horizontalScrollbar() == child || verticalScrollbar() == child; } // Functions for setting and retrieving the scrolling mode in each axis (horizontal/vertical). The mode has values of diff --git a/Source/WebCore/platform/ScrollableArea.cpp b/Source/WebCore/platform/ScrollableArea.cpp new file mode 100644 index 0000000..176cb7e --- /dev/null +++ b/Source/WebCore/platform/ScrollableArea.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2010, Google Inc. All rights reserved. + * Copyright (C) 2008, 2011 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: + * + * * 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 "ScrollableArea.h" + +#include "FloatPoint.h" +#include "PlatformWheelEvent.h" +#include "ScrollAnimator.h" +#include <wtf/PassOwnPtr.h> + +namespace WebCore { + +ScrollableArea::ScrollableArea() + : m_scrollAnimator(ScrollAnimator::create(this)) +{ +} + +ScrollableArea::~ScrollableArea() +{ +} + +bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) +{ + ScrollbarOrientation orientation; + Scrollbar* scrollbar; + if (direction == ScrollUp || direction == ScrollDown) { + orientation = VerticalScrollbar; + scrollbar = verticalScrollbar(); + } else { + orientation = HorizontalScrollbar; + scrollbar = horizontalScrollbar(); + } + + if (!scrollbar) + return false; + + float step = 0; + switch (granularity) { + case ScrollByLine: + step = scrollbar->lineStep(); + break; + case ScrollByPage: + step = scrollbar->pageStep(); + break; + case ScrollByDocument: + step = scrollbar->totalSize(); + break; + case ScrollByPixel: + step = scrollbar->pixelStep(); + break; + } + + if (direction == ScrollUp || direction == ScrollLeft) + multiplier = -multiplier; + + return m_scrollAnimator->scroll(orientation, granularity, step, multiplier); +} + +void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) +{ + m_scrollAnimator->scrollToOffsetWithoutAnimation(offset); +} + +void ScrollableArea::scrollToOffsetWithoutAnimation(ScrollbarOrientation orientation, float offset) +{ + if (orientation == HorizontalScrollbar) + scrollToXOffsetWithoutAnimation(offset); + else + scrollToYOffsetWithoutAnimation(offset); +} + +void ScrollableArea::scrollToXOffsetWithoutAnimation(float x) +{ + scrollToOffsetWithoutAnimation(FloatPoint(x, m_scrollAnimator->currentPosition().y())); +} + +void ScrollableArea::scrollToYOffsetWithoutAnimation(float y) +{ + scrollToOffsetWithoutAnimation(FloatPoint(m_scrollAnimator->currentPosition().x(), y)); +} + +void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset) +{ + // Tell the derived class to scroll its contents. + setScrollOffset(offset); + + // Tell the scrollbars to update their thumb postions. + if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) + horizontalScrollbar->offsetDidChange(); + if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) + verticalScrollbar->offsetDidChange(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/ScrollbarClient.h b/Source/WebCore/platform/ScrollableArea.h index ab3b10e..148ecdb 100644 --- a/Source/WebCore/platform/ScrollbarClient.h +++ b/Source/WebCore/platform/ScrollableArea.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,35 +23,42 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ScrollbarClient_h -#define ScrollbarClient_h +#ifndef ScrollableArea_h +#define ScrollableArea_h -#include "IntPoint.h" #include "IntRect.h" #include "Scrollbar.h" #include <wtf/Vector.h> namespace WebCore { +class FloatPoint; +class PlatformWheelEvent; class ScrollAnimator; -class ScrollbarClient { +class ScrollableArea { public: - ScrollbarClient(); - virtual ~ScrollbarClient(); + ScrollableArea(); + virtual ~ScrollableArea(); - bool scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier); - void setScrollPositionAndStopAnimation(ScrollbarOrientation orientation, float pos); + bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); + void scrollToOffsetWithoutAnimation(const FloatPoint&); + void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); + void scrollToXOffsetWithoutAnimation(float x); + void scrollToYOffsetWithoutAnimation(float x); - virtual int scrollSize(ScrollbarOrientation orientation) const = 0; - virtual void setScrollOffsetFromAnimation(const IntPoint&) = 0; - virtual void valueChanged(Scrollbar*) = 0; + virtual int scrollSize(ScrollbarOrientation) const = 0; + virtual int scrollPosition(Scrollbar*) const = 0; virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; virtual bool isActive() const = 0; virtual bool scrollbarCornerPresent() const = 0; - virtual void getTickmarks(Vector<IntRect>&) const { } + // This function should be overriden by subclasses to perform the actual + // scroll of the content. + virtual void setScrollOffset(const IntPoint&) = 0; + + // Convert points and rects between the scrollbar and its containing view. // The client needs to implement these in order to be aware of layout effects // like CSS transforms. @@ -72,9 +79,17 @@ public: return scrollbar->Widget::convertFromContainingView(parentPoint); } + virtual Scrollbar* horizontalScrollbar() const { return 0; } + virtual Scrollbar* verticalScrollbar() const { return 0; } + private: + // NOTE: Only called from the ScrollAnimator. + friend class ScrollAnimator; + void setScrollOffsetFromAnimation(const IntPoint&); + OwnPtr<ScrollAnimator> m_scrollAnimator; }; -} -#endif +} // namespace WebCore + +#endif // ScrollableArea_h diff --git a/Source/WebCore/platform/Scrollbar.cpp b/Source/WebCore/platform/Scrollbar.cpp index 7fd2651..4c625f4 100644 --- a/Source/WebCore/platform/Scrollbar.cpp +++ b/Source/WebCore/platform/Scrollbar.cpp @@ -26,14 +26,14 @@ #include "config.h" #include "Scrollbar.h" -#include "AccessibilityScrollbar.h" #include "AXObjectCache.h" +#include "AccessibilityScrollbar.h" #include "EventHandler.h" #include "Frame.h" #include "FrameView.h" #include "GraphicsContext.h" #include "PlatformMouseEvent.h" -#include "ScrollbarClient.h" +#include "ScrollableArea.h" #include "ScrollbarTheme.h" #include <algorithm> @@ -49,9 +49,9 @@ using namespace std; namespace WebCore { #if !PLATFORM(EFL) -PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size) +PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size) { - return adoptRef(new Scrollbar(client, orientation, size)); + return adoptRef(new Scrollbar(scrollableArea, orientation, size)); } #endif @@ -61,9 +61,9 @@ int Scrollbar::maxOverlapBetweenPages() return maxOverlapBetweenPages; } -Scrollbar::Scrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, +Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, ScrollbarTheme* theme) - : m_client(client) + : m_scrollableArea(scrollableArea) , m_orientation(orientation) , m_controlSize(controlSize) , m_theme(theme) @@ -104,13 +104,19 @@ Scrollbar::~Scrollbar() m_theme->unregisterScrollbar(this); } -bool Scrollbar::setValue(int v, ScrollSource source) +void Scrollbar::offsetDidChange() { - v = max(min(v, m_totalSize - m_visibleSize), 0); - if (value() == v) - return false; // Our value stayed the same. - setCurrentPos(v, source); - return true; + ASSERT(m_scrollableArea); + + float position = static_cast<float>(m_scrollableArea->scrollPosition(this)); + if (position == m_currentPos) + return; + + int oldThumbPosition = theme()->thumbPosition(this); + m_currentPos = position; + updateThumbPosition(); + if (m_pressedPart == ThumbPart) + setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPosition); } void Scrollbar::setProportion(int visibleSize, int totalSize) @@ -131,31 +137,6 @@ void Scrollbar::setSteps(int lineStep, int pageStep, int pixelsPerStep) m_pixelStep = 1.0f / pixelsPerStep; } -bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) -{ -#if HAVE(ACCESSIBILITY) - if (AXObjectCache::accessibilityEnabled() && axObjectCache()) - axObjectCache()->postNotification(axObjectCache()->getOrCreate(this), 0, AXObjectCache::AXValueChanged, true); -#endif - - // Ignore perpendicular scrolls. - if ((m_orientation == HorizontalScrollbar) ? (direction == ScrollUp || direction == ScrollDown) : (direction == ScrollLeft || direction == ScrollRight)) - return false; - float step = 0; - switch (granularity) { - case ScrollByLine: step = m_lineStep; break; - case ScrollByPage: step = m_pageStep; break; - case ScrollByDocument: step = m_totalSize; break; - case ScrollByPixel: step = m_pixelStep; break; - } - if (direction == ScrollUp || direction == ScrollLeft) - multiplier = -multiplier; - if (client()) - return client()->scroll(m_orientation, granularity, step, multiplier); - - return setCurrentPos(max(min(m_currentPos + (step * multiplier), static_cast<float>(m_totalSize - m_visibleSize)), 0.0f), NotFromScrollAnimator); -} - void Scrollbar::updateThumb() { #ifdef THUMB_POSITION_AFFECTS_BUTTONS @@ -215,7 +196,7 @@ void Scrollbar::autoscrollPressedPart(double delay) } // Handle the arrows and track. - if (scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) + if (scrollableArea()->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) startTimerIfNeeded(delay); } @@ -284,28 +265,11 @@ void Scrollbar::moveThumb(int pos) delta = min(maxPos - thumbPos, delta); else if (delta < 0) delta = max(-thumbPos, delta); - if (delta) - setCurrentPos(static_cast<float>(thumbPos + delta) * maximum() / (trackLen - thumbLen), NotFromScrollAnimator); -} - -bool Scrollbar::setCurrentPos(float pos, ScrollSource source) -{ - if ((source != FromScrollAnimator) && client()) - client()->setScrollPositionAndStopAnimation(m_orientation, pos); - - if (pos == m_currentPos) - return false; - - int oldValue = value(); - int oldThumbPos = theme()->thumbPosition(this); - m_currentPos = pos; - updateThumbPosition(); - if (m_pressedPart == ThumbPart) - setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPos); - - if (value() != oldValue && client()) - client()->valueChanged(this); - return true; + + if (delta) { + float newPosition = static_cast<float>(thumbPos + delta) * maximum() / (trackLen - thumbLen); + scrollableArea()->scrollToOffsetWithoutAnimation(m_orientation, newPosition); + } } void Scrollbar::setHoveredPart(ScrollbarPart part) @@ -337,7 +301,7 @@ bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { if (m_pressedPart == ThumbPart) { if (theme()->shouldSnapBackToDragOrigin(this, evt)) - setCurrentPos(m_dragOrigin, NotFromScrollAnimator); + scrollableArea()->scrollToOffsetWithoutAnimation(m_orientation, m_dragOrigin); else { moveThumb(m_orientation == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : @@ -469,7 +433,7 @@ void Scrollbar::setEnabled(bool e) bool Scrollbar::isWindowActive() const { - return m_client && m_client->isActive(); + return m_scrollableArea && m_scrollableArea->isActive(); } AXObjectCache* Scrollbar::axObjectCache() const @@ -485,40 +449,40 @@ void Scrollbar::invalidateRect(const IntRect& rect) { if (suppressInvalidation()) return; - if (m_client) - m_client->invalidateScrollbarRect(this, rect); + if (m_scrollableArea) + m_scrollableArea->invalidateScrollbarRect(this, rect); } IntRect Scrollbar::convertToContainingView(const IntRect& localRect) const { - if (m_client) - return m_client->convertFromScrollbarToContainingView(this, localRect); + if (m_scrollableArea) + return m_scrollableArea->convertFromScrollbarToContainingView(this, localRect); return Widget::convertToContainingView(localRect); } IntRect Scrollbar::convertFromContainingView(const IntRect& parentRect) const { - if (m_client) - return m_client->convertFromContainingViewToScrollbar(this, parentRect); + if (m_scrollableArea) + return m_scrollableArea->convertFromContainingViewToScrollbar(this, parentRect); return Widget::convertFromContainingView(parentRect); } IntPoint Scrollbar::convertToContainingView(const IntPoint& localPoint) const { - if (m_client) - return m_client->convertFromScrollbarToContainingView(this, localPoint); + if (m_scrollableArea) + return m_scrollableArea->convertFromScrollbarToContainingView(this, localPoint); return Widget::convertToContainingView(localPoint); } IntPoint Scrollbar::convertFromContainingView(const IntPoint& parentPoint) const { - if (m_client) - return m_client->convertFromContainingViewToScrollbar(this, parentPoint); + if (m_scrollableArea) + return m_scrollableArea->convertFromContainingViewToScrollbar(this, parentPoint); return Widget::convertFromContainingView(parentPoint); } -} +} // namespace WebCore diff --git a/Source/WebCore/platform/Scrollbar.h b/Source/WebCore/platform/Scrollbar.h index 69e94a1..5db191a 100644 --- a/Source/WebCore/platform/Scrollbar.h +++ b/Source/WebCore/platform/Scrollbar.h @@ -36,32 +36,30 @@ namespace WebCore { class GraphicsContext; class IntRect; -class ScrollbarClient; -class ScrollbarTheme; class PlatformMouseEvent; +class ScrollableArea; +class ScrollbarTheme; class Scrollbar : public Widget { public: - enum ScrollSource { - FromScrollAnimator, - NotFromScrollAnimator, - }; + // Must be implemented by platforms that can't simply use the Scrollbar base class. Right now the only platform that is not using the base class is GTK. + static PassRefPtr<Scrollbar> createNativeScrollbar(ScrollableArea*, ScrollbarOrientation orientation, ScrollbarControlSize size); virtual ~Scrollbar(); - // Must be implemented by platforms that can't simply use the Scrollbar base class. Right now the only platform that is not using the base class is GTK. - static PassRefPtr<Scrollbar> createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size); + // Called by the ScrollableArea when the scroll offset changes. + void offsetDidChange(); static int pixelsPerLineStep() { return 40; } static float minFractionToStepWhenPaging() { return 0.875f; } static int maxOverlapBetweenPages(); - void setClient(ScrollbarClient* client) { m_client = client; } - ScrollbarClient* client() const { return m_client; } + void disconnectFromScrollableArea() { m_scrollableArea = 0; } + ScrollableArea* scrollableArea() const { return m_scrollableArea; } virtual bool isCustomScrollbar() const { return false; } ScrollbarOrientation orientation() const { return m_orientation; } - + int value() const { return lroundf(m_currentPos); } float currentPos() const { return m_currentPos; } int pressedPos() const { return m_pressedPos; } @@ -73,18 +71,15 @@ public: int lineStep() const { return m_lineStep; } int pageStep() const { return m_pageStep; } float pixelStep() const { return m_pixelStep; } - + ScrollbarPart pressedPart() const { return m_pressedPart; } ScrollbarPart hoveredPart() const { return m_hoveredPart; } virtual void setHoveredPart(ScrollbarPart); virtual void setPressedPart(ScrollbarPart); void setSteps(int lineStep, int pageStep, int pixelsPerStep = 1); - bool setValue(int, ScrollSource source); void setProportion(int visibleSize, int totalSize); void setPressedPos(int p) { m_pressedPos = p; } - - bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); virtual void paint(GraphicsContext*, const IntRect& damageRect); @@ -130,7 +125,7 @@ public: virtual IntPoint convertFromContainingView(const IntPoint&) const; protected: - Scrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0); + Scrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0); void updateThumb(); virtual void updateThumbPosition(); @@ -145,7 +140,7 @@ protected: void moveThumb(int pos); - ScrollbarClient* m_client; + ScrollableArea* m_scrollableArea; ScrollbarOrientation m_orientation; ScrollbarControlSize m_controlSize; ScrollbarTheme* m_theme; @@ -172,10 +167,8 @@ protected: private: virtual bool isScrollbar() const { return true; } virtual AXObjectCache* axObjectCache() const; - - bool setCurrentPos(float pos, ScrollSource source); }; -} +} // namespace WebCore -#endif +#endif // Scrollbar_h diff --git a/Source/WebCore/platform/ScrollbarTheme.h b/Source/WebCore/platform/ScrollbarTheme.h index 0efaf7a..ef52b0d 100644 --- a/Source/WebCore/platform/ScrollbarTheme.h +++ b/Source/WebCore/platform/ScrollbarTheme.h @@ -36,8 +36,10 @@ class PlatformMouseEvent; class Scrollbar; class ScrollView; -class ScrollbarTheme : public Noncopyable { +class ScrollbarTheme { + WTF_MAKE_NONCOPYABLE(ScrollbarTheme); WTF_MAKE_FAST_ALLOCATED; public: + ScrollbarTheme() { } virtual ~ScrollbarTheme() {}; virtual bool paint(Scrollbar*, GraphicsContext*, const IntRect& /*damageRect*/) { return false; } @@ -48,6 +50,7 @@ public: virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarButtonsSingle; } virtual bool supportsControlTints() const { return false; } + virtual bool usesOverlayScrollbars() const { return false; } virtual void themeChanged() {} diff --git a/Source/WebCore/platform/ScrollbarThemeComposite.cpp b/Source/WebCore/platform/ScrollbarThemeComposite.cpp index bf00ebb..7bc266f 100644 --- a/Source/WebCore/platform/ScrollbarThemeComposite.cpp +++ b/Source/WebCore/platform/ScrollbarThemeComposite.cpp @@ -34,7 +34,7 @@ #include "Page.h" #include "PlatformMouseEvent.h" #include "Scrollbar.h" -#include "ScrollbarClient.h" +#include "ScrollableArea.h" #include "Settings.h" namespace WebCore { @@ -104,7 +104,7 @@ bool ScrollbarThemeComposite::paint(Scrollbar* scrollbar, GraphicsContext* graph float proportion = static_cast<float>(scrollbar->visibleSize()) / scrollbar->totalSize(); float value = scrollbar->currentPos() / static_cast<float>(scrollbar->maximum()); ScrollbarControlState s = 0; - if (scrollbar->client()->isActive()) + if (scrollbar->scrollableArea()->isActive()) s |= ActiveScrollbarState; if (scrollbar->enabled()) s |= EnabledScrollbarState; diff --git a/Source/WebCore/platform/SharedTimer.h b/Source/WebCore/platform/SharedTimer.h index 5b5cd14..16e0d0b 100644 --- a/Source/WebCore/platform/SharedTimer.h +++ b/Source/WebCore/platform/SharedTimer.h @@ -26,6 +26,7 @@ #ifndef SharedTimer_h #define SharedTimer_h +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> namespace WebCore { @@ -33,8 +34,10 @@ namespace WebCore { // Each thread has its own single instance of shared timer, which implements this interface. // This instance is shared by all timers in the thread. // Not intended to be used directly; use the Timer class instead. - class SharedTimer : public Noncopyable { + class SharedTimer { + WTF_MAKE_NONCOPYABLE(SharedTimer); WTF_MAKE_FAST_ALLOCATED; public: + SharedTimer() { } virtual ~SharedTimer() {} virtual void setFiredFunction(void (*)()) = 0; diff --git a/Source/WebCore/platform/ThreadGlobalData.h b/Source/WebCore/platform/ThreadGlobalData.h index 9f57f00..76377b4 100644 --- a/Source/WebCore/platform/ThreadGlobalData.h +++ b/Source/WebCore/platform/ThreadGlobalData.h @@ -45,7 +45,8 @@ namespace WebCore { struct TECConverterWrapper; class ThreadTimers; - class ThreadGlobalData : public Noncopyable { + class ThreadGlobalData { + WTF_MAKE_NONCOPYABLE(ThreadGlobalData); public: ThreadGlobalData(); ~ThreadGlobalData(); diff --git a/Source/WebCore/platform/ThreadTimers.h b/Source/WebCore/platform/ThreadTimers.h index ab42598..3d7b5f9 100644 --- a/Source/WebCore/platform/ThreadTimers.h +++ b/Source/WebCore/platform/ThreadTimers.h @@ -37,7 +37,8 @@ namespace WebCore { class TimerBase; // A collection of timers per thread. Kept in ThreadGlobalData. - class ThreadTimers : public Noncopyable { + class ThreadTimers { + WTF_MAKE_NONCOPYABLE(ThreadTimers); WTF_MAKE_FAST_ALLOCATED; public: ThreadTimers(); diff --git a/Source/WebCore/platform/Timer.h b/Source/WebCore/platform/Timer.h index c4443da..c331e3d 100644 --- a/Source/WebCore/platform/Timer.h +++ b/Source/WebCore/platform/Timer.h @@ -35,7 +35,8 @@ namespace WebCore { class TimerHeapElement; -class TimerBase : public Noncopyable { +class TimerBase { + WTF_MAKE_NONCOPYABLE(TimerBase); WTF_MAKE_FAST_ALLOCATED; public: TimerBase(); virtual ~TimerBase(); diff --git a/Source/WebCore/platform/TreeShared.h b/Source/WebCore/platform/TreeShared.h index 9d9ac1f..9e27c5e 100644 --- a/Source/WebCore/platform/TreeShared.h +++ b/Source/WebCore/platform/TreeShared.h @@ -32,7 +32,8 @@ template<typename T> class TreeShared; template<typename T> void adopted(TreeShared<T>*); #endif -template<typename T> class TreeShared : public Noncopyable { +template<typename T> class TreeShared { + WTF_MAKE_NONCOPYABLE(TreeShared); public: TreeShared() : m_refCount(1) diff --git a/Source/WebCore/platform/android/PlatformBridge.h b/Source/WebCore/platform/android/PlatformBridge.h index faa823e..f20a001 100644 --- a/Source/WebCore/platform/android/PlatformBridge.h +++ b/Source/WebCore/platform/android/PlatformBridge.h @@ -90,7 +90,7 @@ class Widget; // An interface to the embedding layer, which has the ability to answer // questions about the system and so on... -// This is very similar to ChromiumBridge and the two are likely to converge +// This is very similar to chromium/PlatformBridge and the two are likely to converge // in the future. // // The methods in this class all need to reach across a JNI layer to the Java VM diff --git a/Source/WebCore/platform/animation/AnimationList.h b/Source/WebCore/platform/animation/AnimationList.h index 9a334ca..bf8ff9f 100644 --- a/Source/WebCore/platform/animation/AnimationList.h +++ b/Source/WebCore/platform/animation/AnimationList.h @@ -31,7 +31,8 @@ namespace WebCore { -class AnimationList : public FastAllocBase { +class AnimationList { + WTF_MAKE_FAST_ALLOCATED; public: AnimationList() { } AnimationList(const AnimationList&); diff --git a/Source/WebCore/platform/audio/AudioBus.h b/Source/WebCore/platform/audio/AudioBus.h index 4318b81..888f6bf 100644 --- a/Source/WebCore/platform/audio/AudioBus.h +++ b/Source/WebCore/platform/audio/AudioBus.h @@ -39,7 +39,8 @@ namespace WebCore { // An AudioBus represents a collection of one or more AudioChannels. // The data layout is "planar" as opposed to "interleaved". // An AudioBus with one channel is mono, an AudioBus with two channels is stereo, etc. -class AudioBus : public Noncopyable { +class AudioBus { + WTF_MAKE_NONCOPYABLE(AudioBus); public: enum { ChannelLeft = 0, diff --git a/Source/WebCore/platform/audio/AudioChannel.h b/Source/WebCore/platform/audio/AudioChannel.h index 6816830..7325e9f 100644 --- a/Source/WebCore/platform/audio/AudioChannel.h +++ b/Source/WebCore/platform/audio/AudioChannel.h @@ -30,14 +30,14 @@ #define AudioChannel_h #include "AudioArray.h" -#include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> namespace WebCore { // An AudioChannel represents a buffer of non-interleaved floating-point audio samples. // The PCM samples are normally assumed to be in a nominal range -1.0 -> +1.0 -class AudioChannel : public Noncopyable { +class AudioChannel { + WTF_MAKE_NONCOPYABLE(AudioChannel); public: // Memory can be externally referenced, or can be internally allocated with an AudioFloatArray. diff --git a/Source/WebCore/platform/audio/FFTFrameStub.cpp b/Source/WebCore/platform/audio/FFTFrameStub.cpp new file mode 100644 index 0000000..17405c9 --- /dev/null +++ b/Source/WebCore/platform/audio/FFTFrameStub.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2011 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 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. + */ + +// FFTFrame stub implementation to avoid link errors during bringup + +#include "config.h" + +#if ENABLE(WEB_AUDIO) + +#if !OS(DARWIN) && !USE(WEBAUDIO_MKL) && !USE(WEBAUDIO_FFTW) + +#include "FFTFrame.h" + +namespace WebCore { + +// Normal constructor: allocates for a given fftSize. +FFTFrame::FFTFrame(unsigned fftSize) + : m_FFTSize(fftSize) + , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) +{ + ASSERT_NOT_REACHED(); +} + +// Creates a blank/empty frame (interpolate() must later be called). +FFTFrame::FFTFrame() + : m_FFTSize(0) + , m_log2FFTSize(0) +{ + ASSERT_NOT_REACHED(); +} + +// Copy constructor. +FFTFrame::FFTFrame(const FFTFrame& frame) + : m_FFTSize(frame.m_FFTSize) + , m_log2FFTSize(frame.m_log2FFTSize) +{ + ASSERT_NOT_REACHED(); +} + +FFTFrame::~FFTFrame() +{ + ASSERT_NOT_REACHED(); +} + +void FFTFrame::multiply(const FFTFrame& frame) +{ + ASSERT_NOT_REACHED(); +} + +void FFTFrame::doFFT(float* data) +{ + ASSERT_NOT_REACHED(); +} + +void FFTFrame::doInverseFFT(float* data) +{ + ASSERT_NOT_REACHED(); +} + +void FFTFrame::cleanup() +{ + ASSERT_NOT_REACHED(); +} + +float* FFTFrame::realData() const +{ + ASSERT_NOT_REACHED(); + return 0; +} + +float* FFTFrame::imagData() const +{ + ASSERT_NOT_REACHED(); + return 0; +} + +} // namespace WebCore + +#endif // !OS(DARWIN) && !USE(WEBAUDIO_MKL) && !USE(WEBAUDIO_FFTW) + +#endif // ENABLE(WEB_AUDIO) diff --git a/Source/WebCore/platform/audio/HRTFDatabase.h b/Source/WebCore/platform/audio/HRTFDatabase.h index c33b38f..bf13a3a 100644 --- a/Source/WebCore/platform/audio/HRTFDatabase.h +++ b/Source/WebCore/platform/audio/HRTFDatabase.h @@ -43,7 +43,8 @@ namespace WebCore { class HRTFKernel; -class HRTFDatabase : public Noncopyable { +class HRTFDatabase { + WTF_MAKE_NONCOPYABLE(HRTFDatabase); public: static PassOwnPtr<HRTFDatabase> create(double sampleRate); diff --git a/Source/WebCore/platform/audio/HRTFElevation.h b/Source/WebCore/platform/audio/HRTFElevation.h index b388b34..24b7822 100644 --- a/Source/WebCore/platform/audio/HRTFElevation.h +++ b/Source/WebCore/platform/audio/HRTFElevation.h @@ -43,7 +43,8 @@ namespace WebCore { // HRTFElevation contains all of the HRTFKernels (one left ear and one right ear per azimuth angle) for a particular elevation. -class HRTFElevation : public Noncopyable { +class HRTFElevation { + WTF_MAKE_NONCOPYABLE(HRTFElevation); public: // Loads and returns an HRTFElevation with the given HRTF database subject name and elevation from browser (or WebKit.framework) resources. // Normally, there will only be a single HRTF database set, but this API supports the possibility of multiple ones with different names. diff --git a/Source/WebCore/platform/audio/chromium/AudioBusChromium.cpp b/Source/WebCore/platform/audio/chromium/AudioBusChromium.cpp index a93703d..83ab9bf 100644 --- a/Source/WebCore/platform/audio/chromium/AudioBusChromium.cpp +++ b/Source/WebCore/platform/audio/chromium/AudioBusChromium.cpp @@ -29,21 +29,19 @@ #include "AudioBus.h" #include "AudioFileReader.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include <wtf/PassOwnPtr.h> namespace WebCore { -// We will use this version of loadPlatformResource() once the resources are checked into Chromium. - -// PassOwnPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, double sampleRate) -// { -// return ChromiumBridge::loadPlatformAudioResource(name, sampleRate); -// } +PassOwnPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, double sampleRate) +{ + return PlatformBridge::loadPlatformAudioResource(name, sampleRate); +} PassOwnPtr<AudioBus> createBusFromInMemoryAudioFile(const void* data, size_t dataSize, bool mixToMono, double sampleRate) { - OwnPtr<AudioBus> audioBus = ChromiumBridge::decodeAudioFileData(static_cast<const char*>(data), dataSize, sampleRate); + OwnPtr<AudioBus> audioBus = PlatformBridge::decodeAudioFileData(static_cast<const char*>(data), dataSize, sampleRate); if (audioBus->numberOfChannels() == 2 && mixToMono) { OwnPtr<AudioBus> monoAudioBus = adoptPtr(new AudioBus(1, audioBus->length())); diff --git a/Source/WebCore/platform/chromium/ChromiumBridge.h b/Source/WebCore/platform/chromium/ChromiumBridge.h deleted file mode 100644 index d3b8528..0000000 --- a/Source/WebCore/platform/chromium/ChromiumBridge.h +++ /dev/null @@ -1,356 +0,0 @@ -/* - * 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 ChromiumBridge_h -#define ChromiumBridge_h - -#if ENABLE(WEB_AUDIO) -#include "AudioBus.h" -#endif - -#include "FileSystem.h" -#include "ImageSource.h" -#include "LinkHash.h" -#include "PassRefPtr.h" -#include "PasteboardPrivate.h" -#include "PluginData.h" - -#include <wtf/Forward.h> -#include <wtf/HashSet.h> -#include <wtf/Vector.h> - -typedef struct NPObject NPObject; -typedef struct _NPP NPP_t; -typedef NPP_t* NPP; - -#if OS(DARWIN) -typedef struct CGFont* CGFontRef; -typedef uintptr_t ATSFontContainerRef; -#ifdef __OBJC__ -@class NSFont; -#else -class NSFont; -#endif -#endif // OS(DARWIN) - -#if OS(WINDOWS) -typedef struct HFONT__* HFONT; -#endif - -namespace WebCore { - - class ClipboardData; - class Color; - class Cursor; - class Document; - class Frame; - class GeolocationServiceBridge; - class GeolocationServiceChromium; - class GraphicsContext; - class Image; - class IDBFactoryBackendInterface; - class IDBKey; - class IntRect; - class KURL; - class SerializedScriptValue; - class Widget; - - struct Cookie; - struct FontRenderStyle; - - // An interface to the embedding layer, which has the ability to answer - // questions about the system and so on... - - class ChromiumBridge { - public: - // Cache -------------------------------------------------------------- - static void cacheMetadata(const KURL& url, double responseTime, const Vector<char>&); - - // Clipboard ---------------------------------------------------------- - static bool clipboardIsFormatAvailable(PasteboardPrivate::ClipboardFormat, PasteboardPrivate::ClipboardBuffer); - - static String clipboardReadPlainText(PasteboardPrivate::ClipboardBuffer); - static void clipboardReadHTML(PasteboardPrivate::ClipboardBuffer, String*, KURL*); - - // Only the clipboardRead functions take a buffer argument because - // Chromium currently uses a different technique to write to alternate - // clipboard buffers. - static void clipboardWriteSelection(const String&, const KURL&, const String&, bool); - static void clipboardWritePlainText(const String&); - static void clipboardWriteURL(const KURL&, const String&); - static void clipboardWriteImage(NativeImagePtr, const KURL&, const String&); - static void clipboardWriteData(const String& type, const String& data, const String& metadata); - - // Interface for handling copy and paste, drag and drop, and selection copy. - static HashSet<String> clipboardReadAvailableTypes(PasteboardPrivate::ClipboardBuffer, bool* containsFilenames); - static bool clipboardReadData(PasteboardPrivate::ClipboardBuffer, const String& type, String& data, String& metadata); - static Vector<String> clipboardReadFilenames(PasteboardPrivate::ClipboardBuffer); - - // Cookies ------------------------------------------------------------ - static void setCookies(const Document*, const KURL&, const String& value); - static String cookies(const Document*, const KURL&); - static String cookieRequestHeaderFieldValue(const Document*, const KURL&); - static bool rawCookies(const Document*, const KURL& url, Vector<Cookie>&); - static void deleteCookie(const Document*, const KURL& url, const String& cookieName); - static bool cookiesEnabled(const Document*); - - // DNS ---------------------------------------------------------------- - static void prefetchDNS(const String& hostname); - - // File --------------------------------------------------------------- - static void revealFolderInOS(const String&); - static bool fileExists(const String&); - static bool deleteFile(const String&); - static bool deleteEmptyDirectory(const String&); - static bool getFileSize(const String&, long long& result); - static bool getFileModificationTime(const String&, time_t& result); - static String directoryName(const String& path); - static String pathByAppendingComponent(const String& path, const String& component); - static bool makeAllDirectories(const String& path); - static String getAbsolutePath(const String&); - static bool isDirectory(const String&); - static KURL filePathToURL(const String&); - static PlatformFileHandle openFile(const String& path, FileOpenMode); - static void closeFile(PlatformFileHandle&); - static long long seekFile(PlatformFileHandle, long long offset, FileSeekOrigin); - static bool truncateFile(PlatformFileHandle, long long offset); - static int readFromFile(PlatformFileHandle, char* data, int length); - static int writeToFile(PlatformFileHandle, const char* data, int length); - - // Font --------------------------------------------------------------- -#if OS(WINDOWS) - static bool ensureFontLoaded(HFONT font); -#endif -#if OS(LINUX) || OS(FREEBSD) - static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result); - static String getFontFamilyForCharacters(const UChar*, size_t numCharacters); -#endif -#if OS(DARWIN) - static bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); -#endif - - // Forms -------------------------------------------------------------- - static void notifyFormStateChanged(const Document*); - - // Databases ---------------------------------------------------------- - // Returns a handle to the DB file and ooptionally a handle to its containing directory - static PlatformFileHandle databaseOpenFile(const String& vfsFleName, int desiredFlags); - // Returns a SQLite code (SQLITE_OK = 0, on success) - static int databaseDeleteFile(const String& vfsFileName, bool syncDir = false); - // Returns the attributes of the DB file - static long databaseGetFileAttributes(const String& vfsFileName); - // Returns the size of the DB file - static long long databaseGetFileSize(const String& vfsFileName); - - // IndexedDB ---------------------------------------------------------- - static PassRefPtr<IDBFactoryBackendInterface> idbFactory(); - static void idbShutdown(); - // Extracts keyPath from values and returns the corresponding keys. - static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys); - - // JavaScript --------------------------------------------------------- - static void notifyJSOutOfMemory(Frame*); - static bool allowScriptDespiteSettings(const KURL& documentURL); - - // Keygen ------------------------------------------------------------- - static String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challenge, const KURL& url); - - // Language ----------------------------------------------------------- - static String computedDefaultLanguage(); - - // LayoutTestMode ----------------------------------------------------- - static bool layoutTestMode(); - - // Memory ------------------------------------------------------------- - // Returns the current space allocated for the pagefile, in MB. - // That is committed size for Windows and virtual memory size for POSIX - static int memoryUsageMB(); - - // Same as above, but always returns actual value, without any caches. - static int actualMemoryUsageMB(); - - // MimeType ----------------------------------------------------------- - static bool isSupportedImageMIMEType(const String& mimeType); - static bool isSupportedJavaScriptMIMEType(const String& mimeType); - static bool isSupportedNonImageMIMEType(const String& mimeType); - static String mimeTypeForExtension(const String& fileExtension); - static String mimeTypeFromFile(const String& filePath); - static String preferredExtensionForMIMEType(const String& mimeType); - - // Plugin ------------------------------------------------------------- - static bool plugins(bool refresh, Vector<PluginInfo>*); - static NPObject* pluginScriptableObject(Widget*); - static bool popupsAllowed(NPP); - - // Resources ---------------------------------------------------------- - static PassRefPtr<Image> loadPlatformImageResource(const char* name); - -#if ENABLE(WEB_AUDIO) - static PassOwnPtr<AudioBus> loadPlatformAudioResource(const char* name, double sampleRate); - static PassOwnPtr<AudioBus> decodeAudioFileData(const char* data, size_t size, double sampleRate); -#endif - - // Sandbox ------------------------------------------------------------ - static bool sandboxEnabled(); - - // Screen ------------------------------------------------------------- - static int screenDepth(Widget*); - static int screenDepthPerComponent(Widget*); - static bool screenIsMonochrome(Widget*); - static IntRect screenRect(Widget*); - static IntRect screenAvailableRect(Widget*); - - // SharedTimers ------------------------------------------------------- - static void setSharedTimerFiredFunction(void (*func)()); - static void setSharedTimerFireTime(double fireTime); - static void stopSharedTimer(); - - // StatsCounters ------------------------------------------------------ - static void decrementStatsCounter(const char* name); - static void incrementStatsCounter(const char* name); - static void histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount); - static void histogramEnumeration(const char* name, int sample, int boundaryValue); - - // Sudden Termination - static void suddenTerminationChanged(bool enabled); - - // SystemTime --------------------------------------------------------- - static double currentTime(); - - // Theming ------------------------------------------------------------ -#if OS(WINDOWS) - static void paintButton( - GraphicsContext*, int part, int state, int classicState, const IntRect&); - static void paintMenuList( - GraphicsContext*, int part, int state, int classicState, const IntRect&); - static void paintScrollbarArrow( - GraphicsContext*, int state, int classicState, const IntRect&); - static void paintScrollbarThumb( - GraphicsContext*, int part, int state, int classicState, const IntRect&); - static void paintScrollbarTrack( - GraphicsContext*, int part, int state, int classicState, const IntRect&, const IntRect& alignRect); - static void paintSpinButton( - GraphicsContext*, int part, int state, int classicState, const IntRect&); - static void paintTextField( - GraphicsContext*, int part, int state, int classicState, const IntRect&, const Color&, bool fillContentArea, bool drawEdges); - static void paintTrackbar( - GraphicsContext*, int part, int state, int classicState, const IntRect&); - static void paintProgressBar( - GraphicsContext*, const IntRect& barRect, const IntRect& valueRect, bool determinate, double animatedSeconds); -#elif OS(LINUX) - // The UI part which is being accessed. - enum ThemePart { - PartScrollbarDownArrow, - PartScrollbarLeftArrow, - PartScrollbarRightArrow, - PartScrollbarUpArrow, - PartScrollbarHorizontalThumb, - PartScrollbarVerticalThumb, - PartScrollbarHorizontalTrack, - PartScrollbarVerticalTrack, - }; - - // The current state of the associated Part. - enum ThemePaintState { - StateDisabled, - StateHover, - StateNormal, - StatePressed, - }; - - struct ScrollbarTrackExtraParams { - // The bounds of the entire track, as opposed to the part being painted. - int trackX; - int trackY; - int trackWidth; - int trackHeight; - }; - - union ThemePaintExtraParams { - ScrollbarTrackExtraParams scrollbarTrack; - }; - - // Gets the size of the given theme part. For variable sized items - // like vertical scrollbar thumbs, the width will be the required width of - // the track while the height will be the minimum height. - static IntSize getThemePartSize(ThemePart); - // Paint the given the given theme part. - static void paintThemePart(GraphicsContext*, ThemePart, ThemePaintState, const IntRect&, const ThemePaintExtraParams*); -#elif OS(DARWIN) - enum ThemePaintState { - StateDisabled, - StateInactive, - StateActive, - StatePressed, - }; - - enum ThemePaintSize { - SizeRegular, - SizeSmall, - }; - - enum ThemePaintScrollbarOrientation { - ScrollbarOrientationHorizontal, - ScrollbarOrientationVertical, - }; - - enum ThemePaintScrollbarParent { - ScrollbarParentScrollView, - ScrollbarParentRenderLayer, - }; - - struct ThemePaintScrollbarInfo { - ThemePaintScrollbarOrientation orientation; - ThemePaintScrollbarParent parent; - int maxValue; - int currentValue; - int visibleSize; - int totalSize; - }; - - static void paintScrollbarThumb(GraphicsContext*, ThemePaintState, ThemePaintSize, const IntRect&, const ThemePaintScrollbarInfo&); -#endif - - // Trace Event -------------------------------------------------------- - static void traceEventBegin(const char* name, void* id, const char* extra); - static void traceEventEnd(const char* name, void* id, const char* extra); - - // Visited links ------------------------------------------------------ - static LinkHash visitedLinkHash(const UChar* url, unsigned length); - static LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL); - static bool isLinkVisited(LinkHash); - - // Widget ------------------------------------------------------------- - static void widgetSetCursor(Widget*, const Cursor&); - }; - -} // namespace WebCore - -#endif diff --git a/Source/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp b/Source/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp index a2952c0..82e47e2 100644 --- a/Source/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp +++ b/Source/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp @@ -31,9 +31,9 @@ #include "config.h" #include "ChromiumDataObjectLegacy.h" -#include "ChromiumBridge.h" #include "ClipboardMimeTypes.h" #include "Pasteboard.h" +#include "PlatformBridge.h" namespace WebCore { @@ -132,7 +132,7 @@ String ChromiumDataObjectLegacy::getData(const String& type, bool& success) Pasteboard::generalPasteboard()->isSelectionMode() ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer; - String text = ChromiumBridge::clipboardReadPlainText(buffer); + String text = PlatformBridge::clipboardReadPlainText(buffer); success = !text.isEmpty(); return text; } @@ -158,7 +158,7 @@ String ChromiumDataObjectLegacy::getData(const String& type, bool& success) PasteboardPrivate::StandardBuffer; String htmlText; KURL sourceURL; - ChromiumBridge::clipboardReadHTML(buffer, &htmlText, &sourceURL); + PlatformBridge::clipboardReadHTML(buffer, &htmlText, &sourceURL); success = !htmlText.isEmpty(); return htmlText; } diff --git a/Source/WebCore/platform/chromium/ClipboardChromium.h b/Source/WebCore/platform/chromium/ClipboardChromium.h index 1d69921..d5ada14 100644 --- a/Source/WebCore/platform/chromium/ClipboardChromium.h +++ b/Source/WebCore/platform/chromium/ClipboardChromium.h @@ -42,6 +42,7 @@ namespace WebCore { class IntPoint; class ClipboardChromium : public Clipboard, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: ~ClipboardChromium() {} diff --git a/Source/WebCore/platform/chromium/DragDataChromium.cpp b/Source/WebCore/platform/chromium/DragDataChromium.cpp index 8c20a00..9312505 100644 --- a/Source/WebCore/platform/chromium/DragDataChromium.cpp +++ b/Source/WebCore/platform/chromium/DragDataChromium.cpp @@ -30,16 +30,16 @@ #include "config.h" #include "DragData.h" -#include "ChromiumBridge.h" #include "ChromiumDataObject.h" #include "ClipboardMimeTypes.h" #include "DocumentFragment.h" #include "FileSystem.h" #include "Frame.h" #include "KURL.h" -#include "markup.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "PlatformString.h" +#include "markup.h" namespace WebCore { @@ -63,7 +63,7 @@ String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* if (title) *title = m_platformDragData->urlTitle(); } else if (filenamePolicy == ConvertFilenames && containsFiles()) { - url = ChromiumBridge::filePathToURL(ChromiumBridge::getAbsolutePath(m_platformDragData->filenames()[0])); + url = PlatformBridge::filePathToURL(PlatformBridge::getAbsolutePath(m_platformDragData->filenames()[0])); } return url; } diff --git a/Source/WebCore/platform/chromium/FileSystemChromium.cpp b/Source/WebCore/platform/chromium/FileSystemChromium.cpp index d8a1e3f..faf5e92 100644 --- a/Source/WebCore/platform/chromium/FileSystemChromium.cpp +++ b/Source/WebCore/platform/chromium/FileSystemChromium.cpp @@ -31,85 +31,85 @@ #include "config.h" #include "FileSystem.h" -#include "ChromiumBridge.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "PlatformString.h" namespace WebCore { bool deleteFile(const String& path) { - return ChromiumBridge::deleteFile(path); + return PlatformBridge::deleteFile(path); } bool deleteEmptyDirectory(const String& path) { - return ChromiumBridge::deleteEmptyDirectory(path); + return PlatformBridge::deleteEmptyDirectory(path); } bool getFileSize(const String& path, long long& result) { - return ChromiumBridge::getFileSize(path, result); + return PlatformBridge::getFileSize(path, result); } bool getFileModificationTime(const String& path, time_t& result) { - return ChromiumBridge::getFileModificationTime(path, result); + return PlatformBridge::getFileModificationTime(path, result); } void revealFolderInOS(const String& path) { - ChromiumBridge::revealFolderInOS(path); + PlatformBridge::revealFolderInOS(path); } String directoryName(const String& path) { - return ChromiumBridge::directoryName(path); + return PlatformBridge::directoryName(path); } String pathByAppendingComponent(const String& path, const String& component) { - return ChromiumBridge::pathByAppendingComponent(path, component); + return PlatformBridge::pathByAppendingComponent(path, component); } bool makeAllDirectories(const String& path) { - return ChromiumBridge::makeAllDirectories(path); + return PlatformBridge::makeAllDirectories(path); } bool fileExists(const String& path) { - return ChromiumBridge::fileExists(path); + return PlatformBridge::fileExists(path); } PlatformFileHandle openFile(const String& path, FileOpenMode mode) { - return ChromiumBridge::openFile(path, mode); + return PlatformBridge::openFile(path, mode); } void closeFile(PlatformFileHandle& handle) { - return ChromiumBridge::closeFile(handle); + return PlatformBridge::closeFile(handle); } long long seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin) { - return ChromiumBridge::seekFile(handle, offset, origin); + return PlatformBridge::seekFile(handle, offset, origin); } bool truncateFile(PlatformFileHandle handle, long long offset) { - return ChromiumBridge::truncateFile(handle, offset); + return PlatformBridge::truncateFile(handle, offset); } int readFromFile(PlatformFileHandle handle, char* data, int length) { - return ChromiumBridge::readFromFile(handle, data, length); + return PlatformBridge::readFromFile(handle, data, length); } int writeToFile(PlatformFileHandle handle, const char* data, int length) { - return ChromiumBridge::writeToFile(handle, data, length); + return PlatformBridge::writeToFile(handle, data, length); } } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/FramelessScrollView.h b/Source/WebCore/platform/chromium/FramelessScrollView.h index 300f418..033d953 100644 --- a/Source/WebCore/platform/chromium/FramelessScrollView.h +++ b/Source/WebCore/platform/chromium/FramelessScrollView.h @@ -61,7 +61,7 @@ namespace WebCore { virtual bool handleWheelEvent(const PlatformWheelEvent&) = 0; virtual bool handleKeyEvent(const PlatformKeyboardEvent&) = 0; - // ScrollbarClient public methods: + // ScrollableArea public methods: virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); virtual bool isActive() const; diff --git a/Source/WebCore/platform/chromium/LanguageChromium.cpp b/Source/WebCore/platform/chromium/LanguageChromium.cpp index 69fe372..fedc4d5 100644 --- a/Source/WebCore/platform/chromium/LanguageChromium.cpp +++ b/Source/WebCore/platform/chromium/LanguageChromium.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "Language.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "PlatformString.h" namespace WebCore { @@ -40,7 +40,7 @@ String platformDefaultLanguage() { static String computedDefaultLanguage; if (computedDefaultLanguage.isEmpty()) - computedDefaultLanguage = ChromiumBridge::computedDefaultLanguage(); + computedDefaultLanguage = PlatformBridge::computedDefaultLanguage(); return computedDefaultLanguage; } diff --git a/Source/WebCore/platform/chromium/LinkHashChromium.cpp b/Source/WebCore/platform/chromium/LinkHashChromium.cpp index 9cb93ea..5e1ffa4 100644 --- a/Source/WebCore/platform/chromium/LinkHashChromium.cpp +++ b/Source/WebCore/platform/chromium/LinkHashChromium.cpp @@ -31,18 +31,18 @@ #include "config.h" #include "LinkHash.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" namespace WebCore { LinkHash visitedLinkHash(const UChar* url, unsigned length) { - return ChromiumBridge::visitedLinkHash(url, length); + return PlatformBridge::visitedLinkHash(url, length); } LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL) { - return ChromiumBridge::visitedLinkHash(base, attributeURL); + return PlatformBridge::visitedLinkHash(base, attributeURL); } } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/MIMETypeRegistryChromium.cpp b/Source/WebCore/platform/chromium/MIMETypeRegistryChromium.cpp index 9df8847..fec0e9b 100644 --- a/Source/WebCore/platform/chromium/MIMETypeRegistryChromium.cpp +++ b/Source/WebCore/platform/chromium/MIMETypeRegistryChromium.cpp @@ -31,20 +31,20 @@ #include "config.h" #include "MIMETypeRegistry.h" -#include "ChromiumBridge.h" #include "MediaPlayer.h" +#include "PlatformBridge.h" #include "PluginDataChromium.h" #include <wtf/text/CString.h> // NOTE: Unlike other ports, we don't use the shared implementation bits in // MIMETypeRegistry.cpp. Instead, we need to route most functions via the -// ChromiumBridge to the embedder. +// PlatformBridge to the embedder. namespace WebCore { String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) { - return ChromiumBridge::mimeTypeForExtension(ext); + return PlatformBridge::mimeTypeForExtension(ext); } // Returns the file extension if one is found. Does not include the dot in the @@ -55,7 +55,7 @@ String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type) // FIXME: Is this really necessary?? String mimeType = type.substring(0, static_cast<unsigned>(type.find(';'))); - String ext = ChromiumBridge::preferredExtensionForMIMEType(type); + String ext = PlatformBridge::preferredExtensionForMIMEType(type); if (!ext.isEmpty() && ext[0] == '.') ext = ext.substring(1); @@ -81,7 +81,7 @@ String MIMETypeRegistry::getMIMETypeForPath(const String& path) bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType) { - return ChromiumBridge::isSupportedImageMIMEType(mimeType); + return PlatformBridge::isSupportedImageMIMEType(mimeType); } bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType) @@ -96,12 +96,12 @@ bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeTyp bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType) { - return ChromiumBridge::isSupportedJavaScriptMIMEType(mimeType); + return PlatformBridge::isSupportedJavaScriptMIMEType(mimeType); } bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType) { - return ChromiumBridge::isSupportedNonImageMIMEType(mimeType); + return PlatformBridge::isSupportedNonImageMIMEType(mimeType); } bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType) diff --git a/Source/WebCore/platform/chromium/PasteboardChromium.cpp b/Source/WebCore/platform/chromium/PasteboardChromium.cpp index 907a4b9..6beb017 100644 --- a/Source/WebCore/platform/chromium/PasteboardChromium.cpp +++ b/Source/WebCore/platform/chromium/PasteboardChromium.cpp @@ -31,20 +31,20 @@ #include "config.h" #include "Pasteboard.h" -#include "ChromiumBridge.h" #include "ClipboardUtilitiesChromium.h" -#include "DocumentFragment.h" #include "Document.h" +#include "DocumentFragment.h" #include "Element.h" #include "Frame.h" #include "HTMLNames.h" #include "HTMLParserIdioms.h" #include "Image.h" #include "KURL.h" -#include "markup.h" #include "NativeImageSkia.h" +#include "PlatformBridge.h" #include "Range.h" #include "RenderImage.h" +#include "markup.h" #if ENABLE(SVG) #include "SVGNames.h" @@ -91,7 +91,7 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, #endif replaceNBSPWithSpace(plainText); - ChromiumBridge::clipboardWriteSelection(html, url, plainText, canSmartCopyOrDelete); + PlatformBridge::clipboardWriteSelection(html, url, plainText, canSmartCopyOrDelete); } void Pasteboard::writePlainText(const String& text) @@ -99,9 +99,9 @@ void Pasteboard::writePlainText(const String& text) #if OS(WINDOWS) String plainText(text); replaceNewlinesWithWindowsStyleNewlines(plainText); - ChromiumBridge::clipboardWritePlainText(plainText); + PlatformBridge::clipboardWritePlainText(plainText); #else - ChromiumBridge::clipboardWritePlainText(text); + PlatformBridge::clipboardWritePlainText(text); #endif } @@ -116,7 +116,7 @@ void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame) title = url.host(); } - ChromiumBridge::clipboardWriteURL(url, title); + PlatformBridge::clipboardWriteURL(url, title); } void Pasteboard::writeImage(Node* node, const KURL&, const String& title) @@ -150,17 +150,17 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String& title) } KURL url = urlString.isEmpty() ? KURL() : node->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString)); - ChromiumBridge::clipboardWriteImage(bitmap, url, title); + PlatformBridge::clipboardWriteImage(bitmap, url, title); } bool Pasteboard::canSmartReplace() { - return ChromiumBridge::clipboardIsFormatAvailable(PasteboardPrivate::WebSmartPasteFormat, m_selectionMode ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer); + return PlatformBridge::clipboardIsFormatAvailable(PasteboardPrivate::WebSmartPasteFormat, m_selectionMode ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer); } String Pasteboard::plainText(Frame* frame) { - return ChromiumBridge::clipboardReadPlainText(m_selectionMode ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer); + return PlatformBridge::clipboardReadPlainText(m_selectionMode ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer); } PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText) @@ -168,10 +168,10 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP chosePlainText = false; PasteboardPrivate::ClipboardBuffer buffer = m_selectionMode ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer; - if (ChromiumBridge::clipboardIsFormatAvailable(PasteboardPrivate::HTMLFormat, buffer)) { + if (PlatformBridge::clipboardIsFormatAvailable(PasteboardPrivate::HTMLFormat, buffer)) { String markup; KURL srcURL; - ChromiumBridge::clipboardReadHTML(buffer, &markup, &srcURL); + PlatformBridge::clipboardReadHTML(buffer, &markup, &srcURL); RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), markup, srcURL, FragmentScriptingNotAllowed); @@ -180,7 +180,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP } if (allowPlainText) { - String markup = ChromiumBridge::clipboardReadPlainText(buffer); + String markup = PlatformBridge::clipboardReadPlainText(buffer); if (!markup.isEmpty()) { chosePlainText = true; diff --git a/Source/WebCore/platform/chromium/PlatformBridge.h b/Source/WebCore/platform/chromium/PlatformBridge.h index ecb7b45..f6a2564 100644 --- a/Source/WebCore/platform/chromium/PlatformBridge.h +++ b/Source/WebCore/platform/chromium/PlatformBridge.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 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 @@ -31,17 +31,378 @@ #ifndef PlatformBridge_h #define PlatformBridge_h -#include "ChromiumBridge.h" +#if ENABLE(WEB_AUDIO) +#include "AudioBus.h" +#endif + +#include "FileSystem.h" +#include "ImageSource.h" +#include "LinkHash.h" +#include "PassRefPtr.h" +#include "PasteboardPrivate.h" +#include "PluginData.h" + +#include <wtf/Forward.h> +#include <wtf/HashSet.h> +#include <wtf/Vector.h> + +typedef struct NPObject NPObject; +typedef struct _NPP NPP_t; +typedef NPP_t* NPP; + +#if OS(DARWIN) +typedef struct CGFont* CGFontRef; +typedef uintptr_t ATSFontContainerRef; +#ifdef __OBJC__ +@class NSFont; +#else +class NSFont; +#endif +#endif // OS(DARWIN) + +#if OS(WINDOWS) +typedef struct HFONT__* HFONT; +#endif namespace WebCore { -// FIXME: A better name for ChromiumBridge is PlatformBridge. Android already -// uses PlatformBridge so the code that is shared among the Android and Chromium -// ports is gradually moving towards using PlatformBridge. Once the Android -// unforking is done, we will change the name of ChromiumBridge to PlatformBridge -// and merge the two classes into one that will be shared by both ports. -typedef ChromiumBridge PlatformBridge; +class ClipboardData; +class Color; +class Cursor; +class Document; +class Frame; +class GeolocationServiceBridge; +class GeolocationServiceChromium; +class GraphicsContext; +class Image; +class IDBFactoryBackendInterface; +class IDBKey; +class IntRect; +class KURL; +class SerializedScriptValue; +class Widget; + +struct Cookie; +struct FontRenderStyle; + +// An interface to the embedding layer, which has the ability to answer +// questions about the system and so on... + +class PlatformBridge { +public: + // Cache -------------------------------------------------------------- + static void cacheMetadata(const KURL&, double responseTime, const Vector<char>&); + + // Clipboard ---------------------------------------------------------- + static bool clipboardIsFormatAvailable(PasteboardPrivate::ClipboardFormat, PasteboardPrivate::ClipboardBuffer); + + static String clipboardReadPlainText(PasteboardPrivate::ClipboardBuffer); + static void clipboardReadHTML(PasteboardPrivate::ClipboardBuffer, String*, KURL*); + + // Only the clipboardRead functions take a buffer argument because + // Chromium currently uses a different technique to write to alternate + // clipboard buffers. + static void clipboardWriteSelection(const String&, const KURL&, const String&, bool); + static void clipboardWritePlainText(const String&); + static void clipboardWriteURL(const KURL&, const String&); + static void clipboardWriteImage(NativeImagePtr, const KURL&, const String&); + static void clipboardWriteData(const String& type, const String& data, const String& metadata); + + // Interface for handling copy and paste, drag and drop, and selection copy. + static HashSet<String> clipboardReadAvailableTypes(PasteboardPrivate::ClipboardBuffer, bool* containsFilenames); + static bool clipboardReadData(PasteboardPrivate::ClipboardBuffer, const String& type, String& data, String& metadata); + static Vector<String> clipboardReadFilenames(PasteboardPrivate::ClipboardBuffer); + + // Cookies ------------------------------------------------------------ + static void setCookies(const Document*, const KURL&, const String& value); + static String cookies(const Document*, const KURL&); + static String cookieRequestHeaderFieldValue(const Document*, const KURL&); + static bool rawCookies(const Document*, const KURL&, Vector<Cookie>&); + static void deleteCookie(const Document*, const KURL&, const String& cookieName); + static bool cookiesEnabled(const Document*); + + // DNS ---------------------------------------------------------------- + static void prefetchDNS(const String& hostname); + + // File --------------------------------------------------------------- + static void revealFolderInOS(const String&); + static bool fileExists(const String&); + static bool deleteFile(const String&); + static bool deleteEmptyDirectory(const String&); + static bool getFileSize(const String&, long long& result); + static bool getFileModificationTime(const String&, time_t& result); + static String directoryName(const String& path); + static String pathByAppendingComponent(const String& path, const String& component); + static bool makeAllDirectories(const String& path); + static String getAbsolutePath(const String&); + static bool isDirectory(const String&); + static KURL filePathToURL(const String&); + static PlatformFileHandle openFile(const String& path, FileOpenMode); + static void closeFile(PlatformFileHandle&); + static long long seekFile(PlatformFileHandle, long long offset, FileSeekOrigin); + static bool truncateFile(PlatformFileHandle, long long offset); + static int readFromFile(PlatformFileHandle, char* data, int length); + static int writeToFile(PlatformFileHandle, const char* data, int length); + + // Font --------------------------------------------------------------- +#if OS(WINDOWS) + static bool ensureFontLoaded(HFONT); +#endif +#if OS(LINUX) || OS(FREEBSD) + static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result); + static String getFontFamilyForCharacters(const UChar*, size_t numCharacters); +#endif +#if OS(DARWIN) + static bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); +#endif + + // Forms -------------------------------------------------------------- + static void notifyFormStateChanged(const Document*); + + // Databases ---------------------------------------------------------- + // Returns a handle to the DB file and ooptionally a handle to its containing directory + static PlatformFileHandle databaseOpenFile(const String& vfsFleName, int desiredFlags); + // Returns a SQLite code (SQLITE_OK = 0, on success) + static int databaseDeleteFile(const String& vfsFileName, bool syncDir = false); + // Returns the attributes of the DB file + static long databaseGetFileAttributes(const String& vfsFileName); + // Returns the size of the DB file + static long long databaseGetFileSize(const String& vfsFileName); + + // IndexedDB ---------------------------------------------------------- + static PassRefPtr<IDBFactoryBackendInterface> idbFactory(); + static void idbShutdown(); + // Extracts keyPath from values and returns the corresponding keys. + static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys); + + // JavaScript --------------------------------------------------------- + static void notifyJSOutOfMemory(Frame*); + static bool allowScriptDespiteSettings(const KURL& documentURL); + + // Keygen ------------------------------------------------------------- + static String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challenge, const KURL&); + + // Language ----------------------------------------------------------- + static String computedDefaultLanguage(); + + // LayoutTestMode ----------------------------------------------------- + static bool layoutTestMode(); + + // Memory ------------------------------------------------------------- + // Returns the current space allocated for the pagefile, in MB. + // That is committed size for Windows and virtual memory size for POSIX + static int memoryUsageMB(); + + // Same as above, but always returns actual value, without any caches. + static int actualMemoryUsageMB(); + + // MimeType ----------------------------------------------------------- + static bool isSupportedImageMIMEType(const String& mimeType); + static bool isSupportedJavaScriptMIMEType(const String& mimeType); + static bool isSupportedNonImageMIMEType(const String& mimeType); + static String mimeTypeForExtension(const String& fileExtension); + static String mimeTypeFromFile(const String& filePath); + static String preferredExtensionForMIMEType(const String& mimeType); + + // Plugin ------------------------------------------------------------- + static bool plugins(bool refresh, Vector<PluginInfo>*); + static NPObject* pluginScriptableObject(Widget*); + static bool popupsAllowed(NPP); + + // Resources ---------------------------------------------------------- + static PassRefPtr<Image> loadPlatformImageResource(const char* name); + +#if ENABLE(WEB_AUDIO) + static PassOwnPtr<AudioBus> loadPlatformAudioResource(const char* name, double sampleRate); + static PassOwnPtr<AudioBus> decodeAudioFileData(const char* data, size_t, double sampleRate); +#endif + + // Sandbox ------------------------------------------------------------ + static bool sandboxEnabled(); + + // Screen ------------------------------------------------------------- + static int screenDepth(Widget*); + static int screenDepthPerComponent(Widget*); + static bool screenIsMonochrome(Widget*); + static IntRect screenRect(Widget*); + static IntRect screenAvailableRect(Widget*); + + // SharedTimers ------------------------------------------------------- + static void setSharedTimerFiredFunction(void (*func)()); + static void setSharedTimerFireTime(double); + static void stopSharedTimer(); + + // StatsCounters ------------------------------------------------------ + static void decrementStatsCounter(const char* name); + static void incrementStatsCounter(const char* name); + static void histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount); + static void histogramEnumeration(const char* name, int sample, int boundaryValue); + + // Sudden Termination + static void suddenTerminationChanged(bool enabled); + + // SystemTime --------------------------------------------------------- + static double currentTime(); + + // Theming ------------------------------------------------------------ +#if OS(WINDOWS) + static void paintButton( + GraphicsContext*, int part, int state, int classicState, const IntRect&); + static void paintMenuList( + GraphicsContext*, int part, int state, int classicState, const IntRect&); + static void paintScrollbarArrow( + GraphicsContext*, int state, int classicState, const IntRect&); + static void paintScrollbarThumb( + GraphicsContext*, int part, int state, int classicState, const IntRect&); + static void paintScrollbarTrack( + GraphicsContext*, int part, int state, int classicState, const IntRect&, const IntRect& alignRect); + static void paintSpinButton( + GraphicsContext*, int part, int state, int classicState, const IntRect&); + static void paintTextField( + GraphicsContext*, int part, int state, int classicState, const IntRect&, const Color&, bool fillContentArea, bool drawEdges); + static void paintTrackbar( + GraphicsContext*, int part, int state, int classicState, const IntRect&); + static void paintProgressBar( + GraphicsContext*, const IntRect& barRect, const IntRect& valueRect, bool determinate, double animatedSeconds); +#elif OS(LINUX) + // The UI part which is being accessed. + enum ThemePart { + // ScrollbarTheme parts + PartScrollbarDownArrow, + PartScrollbarLeftArrow, + PartScrollbarRightArrow, + PartScrollbarUpArrow, + PartScrollbarHorizontalThumb, + PartScrollbarVerticalThumb, + PartScrollbarHorizontalTrack, + PartScrollbarVerticalTrack, + + // RenderTheme parts + PartCheckbox, + PartRadio, + PartButton, + PartTextField, + PartMenuList, + PartSliderTrack, + PartSliderThumb, + PartInnerSpinButton, + PartProgressBar + }; + + // The current state of the associated Part. + enum ThemePaintState { + StateDisabled, + StateHover, + StateNormal, + StatePressed + }; + + struct ScrollbarTrackExtraParams { + // The bounds of the entire track, as opposed to the part being painted. + int trackX; + int trackY; + int trackWidth; + int trackHeight; + }; + + struct ButtonExtraParams { + bool checked; + bool indeterminate; // Whether the button state is indeterminate. + bool isDefault; // Whether the button is default button. + unsigned backgroundColor; + }; + + struct TextFieldExtraParams { + bool isTextArea; + bool isListbox; + unsigned backgroundColor; + }; + + struct MenuListExtraParams { + int arrowX; + int arrowY; + unsigned backgroundColor; + }; + + struct SliderExtraParams { + bool vertical; + bool inDrag; + }; + + struct InnerSpinButtonExtraParams { + bool spinUp; + bool readOnly; + }; + + struct ProgressBarExtraParams { + bool determinate; + int valueRectX; + int valueRectY; + int valueRectWidth; + int valueRectHeight; + }; + + union ThemePaintExtraParams { + ScrollbarTrackExtraParams scrollbarTrack; + ButtonExtraParams button; + TextFieldExtraParams textField; + MenuListExtraParams menuList; + SliderExtraParams slider; + InnerSpinButtonExtraParams innerSpin; + ProgressBarExtraParams progressBar; + }; + + // Gets the size of the given theme part. For variable sized items + // like vertical scrollbar thumbs, the width will be the required width of + // the track while the height will be the minimum height. + static IntSize getThemePartSize(ThemePart); + // Paint the given the given theme part. + static void paintThemePart(GraphicsContext*, ThemePart, ThemePaintState, const IntRect&, const ThemePaintExtraParams*); +#elif OS(DARWIN) + enum ThemePaintState { + StateDisabled, + StateInactive, + StateActive, + StatePressed, + }; + + enum ThemePaintSize { + SizeRegular, + SizeSmall, + }; + + enum ThemePaintScrollbarOrientation { + ScrollbarOrientationHorizontal, + ScrollbarOrientationVertical, + }; + + enum ThemePaintScrollbarParent { + ScrollbarParentScrollView, + ScrollbarParentRenderLayer, + }; + + struct ThemePaintScrollbarInfo { + ThemePaintScrollbarOrientation orientation; + ThemePaintScrollbarParent parent; + int maxValue; + int currentValue; + int visibleSize; + int totalSize; + }; + + static void paintScrollbarThumb(GraphicsContext*, ThemePaintState, ThemePaintSize, const IntRect&, const ThemePaintScrollbarInfo&); +#endif + + // Trace Event -------------------------------------------------------- + static void traceEventBegin(const char* name, void*, const char* extra); + static void traceEventEnd(const char* name, void*, const char* extra); + + // Visited links ------------------------------------------------------ + static LinkHash visitedLinkHash(const UChar* url, unsigned length); + static LinkHash visitedLinkHash(const KURL& base, const AtomicString& attributeURL); + static bool isLinkVisited(LinkHash); +}; } // namespace WebCore -#endif // PlatformBridge_h +#endif diff --git a/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp b/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp index e659ef5..35d5018 100644 --- a/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp +++ b/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp @@ -31,34 +31,34 @@ #include "config.h" #include "PlatformScreen.h" -#include "ChromiumBridge.h" #include "IntRect.h" +#include "PlatformBridge.h" namespace WebCore { int screenDepth(Widget* widget) { - return ChromiumBridge::screenDepth(widget); + return PlatformBridge::screenDepth(widget); } int screenDepthPerComponent(Widget* widget) { - return ChromiumBridge::screenDepthPerComponent(widget); + return PlatformBridge::screenDepthPerComponent(widget); } bool screenIsMonochrome(Widget* widget) { - return ChromiumBridge::screenIsMonochrome(widget); + return PlatformBridge::screenIsMonochrome(widget); } FloatRect screenRect(Widget* widget) { - return ChromiumBridge::screenRect(widget); + return PlatformBridge::screenRect(widget); } FloatRect screenAvailableRect(Widget* widget) { - return ChromiumBridge::screenAvailableRect(widget); + return PlatformBridge::screenAvailableRect(widget); } } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp index bb45e79..075cef0 100644 --- a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp +++ b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp @@ -54,6 +54,7 @@ #include "ScrollbarTheme.h" #include "StringTruncator.h" #include "SystemTime.h" +#include "TextRun.h" #include "UserGestureIndicator.h" #include <wtf/CurrentTime.h> diff --git a/Source/WebCore/platform/chromium/ReadableDataObject.cpp b/Source/WebCore/platform/chromium/ReadableDataObject.cpp index 97c481b..dbf4739 100644 --- a/Source/WebCore/platform/chromium/ReadableDataObject.cpp +++ b/Source/WebCore/platform/chromium/ReadableDataObject.cpp @@ -31,10 +31,10 @@ #include "config.h" #include "ReadableDataObject.h" -#include "ChromiumBridge.h" #include "ClipboardMimeTypes.h" #include "Pasteboard.h" #include "PasteboardPrivate.h" +#include "PlatformBridge.h" namespace WebCore { @@ -80,19 +80,19 @@ String ReadableDataObject::getData(const String& type, bool& succeeded) const Pasteboard::generalPasteboard()->isSelectionMode() ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer; - data = ChromiumBridge::clipboardReadPlainText(buffer); + data = PlatformBridge::clipboardReadPlainText(buffer); } else if (type == mimeTypeTextHTML) { PasteboardPrivate::ClipboardBuffer buffer = Pasteboard::generalPasteboard()->isSelectionMode() ? PasteboardPrivate::SelectionBuffer : PasteboardPrivate::StandardBuffer; KURL ignoredSourceURL; - ChromiumBridge::clipboardReadHTML(buffer, &data, &ignoredSourceURL); + PlatformBridge::clipboardReadHTML(buffer, &data, &ignoredSourceURL); } succeeded = !data.isEmpty(); return data; } - succeeded = ChromiumBridge::clipboardReadData( + succeeded = PlatformBridge::clipboardReadData( clipboardBuffer(m_clipboardType), type, data, ignoredMetadata); return data; } @@ -101,7 +101,7 @@ String ReadableDataObject::urlTitle() const { String ignoredData; String urlTitle; - ChromiumBridge::clipboardReadData( + PlatformBridge::clipboardReadData( clipboardBuffer(m_clipboardType), mimeTypeTextURIList, ignoredData, urlTitle); return urlTitle; } @@ -110,7 +110,7 @@ KURL ReadableDataObject::htmlBaseUrl() const { String ignoredData; String htmlBaseUrl; - ChromiumBridge::clipboardReadData( + PlatformBridge::clipboardReadData( clipboardBuffer(m_clipboardType), mimeTypeTextHTML, ignoredData, htmlBaseUrl); return KURL(ParsedURLString, htmlBaseUrl); } @@ -123,7 +123,7 @@ bool ReadableDataObject::containsFilenames() const Vector<String> ReadableDataObject::filenames() const { - return ChromiumBridge::clipboardReadFilenames(clipboardBuffer(m_clipboardType)); + return PlatformBridge::clipboardReadFilenames(clipboardBuffer(m_clipboardType)); } void ReadableDataObject::ensureTypeCacheInitialized() const @@ -131,7 +131,7 @@ void ReadableDataObject::ensureTypeCacheInitialized() const if (m_isTypeCacheInitialized) return; - m_types = ChromiumBridge::clipboardReadAvailableTypes( + m_types = PlatformBridge::clipboardReadAvailableTypes( clipboardBuffer(m_clipboardType), &m_containsFilenames); m_isTypeCacheInitialized = true; } diff --git a/Source/WebCore/platform/chromium/SSLKeyGeneratorChromium.cpp b/Source/WebCore/platform/chromium/SSLKeyGeneratorChromium.cpp index 49d9517..6467764 100644 --- a/Source/WebCore/platform/chromium/SSLKeyGeneratorChromium.cpp +++ b/Source/WebCore/platform/chromium/SSLKeyGeneratorChromium.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "SSLKeyGenerator.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "PlatformString.h" namespace WebCore { @@ -51,7 +51,7 @@ String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const KURL& url) { - return ChromiumBridge::signedPublicKeyAndChallengeString(keySizeIndex, + return PlatformBridge::signedPublicKeyAndChallengeString(keySizeIndex, challengeString, url); } diff --git a/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp b/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp index 234d0ee..b23e625 100644 --- a/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp +++ b/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp @@ -27,10 +27,10 @@ #include "config.h" #include "ScrollbarThemeChromium.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "PlatformMouseEvent.h" +#include "ScrollableArea.h" #include "Scrollbar.h" -#include "ScrollbarClient.h" #include "ScrollbarThemeComposite.h" // ----------------------------------------------------------------------------- @@ -110,7 +110,7 @@ void ScrollbarThemeChromium::paintTickmarks(GraphicsContext* context, Scrollbar* // Get the tickmarks for the frameview. Vector<IntRect> tickmarks; - scrollbar->client()->getTickmarks(tickmarks); + scrollbar->scrollableArea()->getTickmarks(tickmarks); if (!tickmarks.size()) return; diff --git a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp index ba10953..e173dff 100644 --- a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp +++ b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "ScrollbarThemeChromiumLinux.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "PlatformMouseEvent.h" #include "Scrollbar.h" @@ -46,22 +46,22 @@ ScrollbarTheme* ScrollbarTheme::nativeTheme() int ScrollbarThemeChromiumLinux::scrollbarThickness(ScrollbarControlSize controlSize) { // Horiz and Vert scrollbars are the same thickness. - IntSize scrollbarSize = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarVerticalTrack); + IntSize scrollbarSize = PlatformBridge::getThemePartSize(PlatformBridge::PartScrollbarVerticalTrack); return scrollbarSize.width(); } void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType) { - ChromiumBridge::ThemePaintState state = scrollbar->hoveredPart() == partType ? ChromiumBridge::StateHover : ChromiumBridge::StateNormal; + PlatformBridge::ThemePaintState state = scrollbar->hoveredPart() == partType ? PlatformBridge::StateHover : PlatformBridge::StateNormal; IntRect alignRect = trackRect(scrollbar, false); - ChromiumBridge::ThemePaintExtraParams extraParams; + PlatformBridge::ThemePaintExtraParams extraParams; extraParams.scrollbarTrack.trackX = alignRect.x(); extraParams.scrollbarTrack.trackY = alignRect.y(); extraParams.scrollbarTrack.trackWidth = alignRect.width(); extraParams.scrollbarTrack.trackHeight = alignRect.height(); - ChromiumBridge::paintThemePart( + PlatformBridge::paintThemePart( gc, - scrollbar->orientation() == HorizontalScrollbar ? ChromiumBridge::PartScrollbarHorizontalTrack : ChromiumBridge::PartScrollbarVerticalTrack, + scrollbar->orientation() == HorizontalScrollbar ? PlatformBridge::PartScrollbarHorizontalTrack : PlatformBridge::PartScrollbarVerticalTrack, state, rect, &extraParams); @@ -69,52 +69,52 @@ void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar void ScrollbarThemeChromiumLinux::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part) { - ChromiumBridge::ThemePart paintPart; - ChromiumBridge::ThemePaintState state = ChromiumBridge::StateNormal; + PlatformBridge::ThemePart paintPart; + PlatformBridge::ThemePaintState state = PlatformBridge::StateNormal; bool checkMin = false; bool checkMax = false; if (scrollbar->orientation() == HorizontalScrollbar) { if (part == BackButtonStartPart) { - paintPart = ChromiumBridge::PartScrollbarLeftArrow; + paintPart = PlatformBridge::PartScrollbarLeftArrow; checkMin = true; } else { - paintPart = ChromiumBridge::PartScrollbarRightArrow; + paintPart = PlatformBridge::PartScrollbarRightArrow; checkMax = true; } } else { if (part == BackButtonStartPart) { - paintPart = ChromiumBridge::PartScrollbarUpArrow; + paintPart = PlatformBridge::PartScrollbarUpArrow; checkMin = true; } else { - paintPart = ChromiumBridge::PartScrollbarDownArrow; + paintPart = PlatformBridge::PartScrollbarDownArrow; checkMax = true; } } if ((checkMin && (scrollbar->currentPos() <= 0)) || (checkMax && scrollbar->currentPos() == scrollbar->maximum())) { - state = ChromiumBridge::StateDisabled; + state = PlatformBridge::StateDisabled; } else { if (part == scrollbar->pressedPart()) - state = ChromiumBridge::StatePressed; + state = PlatformBridge::StatePressed; else if (part == scrollbar->hoveredPart()) - state = ChromiumBridge::StateHover; + state = PlatformBridge::StateHover; } - ChromiumBridge::paintThemePart(gc, paintPart, state, rect, 0); + PlatformBridge::paintThemePart(gc, paintPart, state, rect, 0); } void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect) { - ChromiumBridge::ThemePaintState state; + PlatformBridge::ThemePaintState state; if (scrollbar->pressedPart() == ThumbPart) - state = ChromiumBridge::StatePressed; + state = PlatformBridge::StatePressed; else if (scrollbar->hoveredPart() == ThumbPart) - state = ChromiumBridge::StateHover; + state = PlatformBridge::StateHover; else - state = ChromiumBridge::StateNormal; - ChromiumBridge::paintThemePart( + state = PlatformBridge::StateNormal; + PlatformBridge::paintThemePart( gc, - scrollbar->orientation() == HorizontalScrollbar ? ChromiumBridge::PartScrollbarHorizontalThumb : ChromiumBridge::PartScrollbarVerticalThumb, + scrollbar->orientation() == HorizontalScrollbar ? PlatformBridge::PartScrollbarHorizontalThumb : PlatformBridge::PartScrollbarVerticalThumb, state, rect, 0); @@ -128,23 +128,23 @@ bool ScrollbarThemeChromiumLinux::shouldCenterOnThumb(Scrollbar*, const Platform IntSize ScrollbarThemeChromiumLinux::buttonSize(Scrollbar* scrollbar) { if (scrollbar->orientation() == VerticalScrollbar) { - IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarUpArrow); + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartScrollbarUpArrow); return IntSize(size.width(), scrollbar->height() < 2 * size.height() ? scrollbar->height() / 2 : size.height()); } // HorizontalScrollbar - IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarLeftArrow); + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartScrollbarLeftArrow); return IntSize(scrollbar->width() < 2 * size.width() ? scrollbar->width() / 2 : size.width(), size.height()); } int ScrollbarThemeChromiumLinux::minimumThumbLength(Scrollbar* scrollbar) { if (scrollbar->orientation() == VerticalScrollbar) { - IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarVerticalThumb); + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartScrollbarVerticalThumb); return size.height(); } - IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarHorizontalThumb); + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartScrollbarHorizontalThumb); return size.width(); } diff --git a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm index 0aa3e10..fe1a422 100644 --- a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm +++ b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm @@ -27,9 +27,9 @@ #include "config.h" #include "ScrollbarThemeChromiumMac.h" -#include "ChromiumBridge.h" #include "FrameView.h" #include "ImageBuffer.h" +#include "PlatformBridge.h" #include "PlatformMouseEvent.h" #include "ScrollView.h" #include <Carbon/Carbon.h> @@ -370,15 +370,15 @@ static int scrollbarPartToHIPressedState(ScrollbarPart part) } } -static ChromiumBridge::ThemePaintState scrollbarStateToThemeState(Scrollbar* scrollbar) { +static PlatformBridge::ThemePaintState scrollbarStateToThemeState(Scrollbar* scrollbar) { if (!scrollbar->enabled()) - return ChromiumBridge::StateDisabled; - if (!scrollbar->client()->isActive()) - return ChromiumBridge::StateInactive; + return PlatformBridge::StateDisabled; + if (!scrollbar->scrollableArea()->isActive()) + return PlatformBridge::StateInactive; if (scrollbar->pressedPart() == ThumbPart) - return ChromiumBridge::StatePressed; + return PlatformBridge::StatePressed; - return ChromiumBridge::StateActive; + return PlatformBridge::StateActive; } bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect) @@ -398,7 +398,7 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con if (!scrollbar->enabled()) trackInfo.enableState = kThemeTrackDisabled; else - trackInfo.enableState = scrollbar->client()->isActive() ? kThemeTrackActive : kThemeTrackInactive; + trackInfo.enableState = scrollbar->scrollableArea()->isActive() ? kThemeTrackActive : kThemeTrackInactive; if (!hasButtons(scrollbar)) trackInfo.enableState = kThemeTrackNothingToScroll; @@ -428,7 +428,7 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con HIThemeDrawTrack(&trackInfo, 0, drawingContext->platformContext(), kHIThemeOrientationNormal); Vector<IntRect> tickmarks; - scrollbar->client()->getTickmarks(tickmarks); + scrollbar->scrollableArea()->getTickmarks(tickmarks); if (scrollbar->orientation() == VerticalScrollbar && tickmarks.size()) { drawingContext->save(); drawingContext->setShouldAntialias(false); @@ -463,18 +463,18 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con } if (hasThumb(scrollbar)) { - ChromiumBridge::ThemePaintScrollbarInfo scrollbarInfo; - scrollbarInfo.orientation = scrollbar->orientation() == HorizontalScrollbar ? ChromiumBridge::ScrollbarOrientationHorizontal : ChromiumBridge::ScrollbarOrientationVertical; - scrollbarInfo.parent = scrollbar->parent() && scrollbar->parent()->isFrameView() && static_cast<FrameView*>(scrollbar->parent())->isScrollViewScrollbar(scrollbar) ? ChromiumBridge::ScrollbarParentScrollView : ChromiumBridge::ScrollbarParentRenderLayer; + PlatformBridge::ThemePaintScrollbarInfo scrollbarInfo; + scrollbarInfo.orientation = scrollbar->orientation() == HorizontalScrollbar ? PlatformBridge::ScrollbarOrientationHorizontal : PlatformBridge::ScrollbarOrientationVertical; + scrollbarInfo.parent = scrollbar->parent() && scrollbar->parent()->isFrameView() && static_cast<FrameView*>(scrollbar->parent())->isScrollViewScrollbar(scrollbar) ? PlatformBridge::ScrollbarParentScrollView : PlatformBridge::ScrollbarParentRenderLayer; scrollbarInfo.maxValue = scrollbar->maximum(); scrollbarInfo.currentValue = scrollbar->currentPos(); scrollbarInfo.visibleSize = scrollbar->visibleSize(); scrollbarInfo.totalSize = scrollbar->totalSize(); - ChromiumBridge::paintScrollbarThumb( + PlatformBridge::paintScrollbarThumb( drawingContext, scrollbarStateToThemeState(scrollbar), - scrollbar->controlSize() == RegularScrollbar ? ChromiumBridge::SizeRegular : ChromiumBridge::SizeSmall, + scrollbar->controlSize() == RegularScrollbar ? PlatformBridge::SizeRegular : PlatformBridge::SizeSmall, scrollbar->frameRect(), scrollbarInfo); } diff --git a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp index ba7e97b..29e8b44 100644 --- a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp +++ b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp @@ -30,8 +30,8 @@ #include <windows.h> #include <vsstyle.h> -#include "ChromiumBridge.h" #include "GraphicsContext.h" +#include "PlatformBridge.h" #include "PlatformContextSkia.h" #include "PlatformMouseEvent.h" #include "Scrollbar.h" @@ -61,7 +61,7 @@ int ScrollbarThemeChromiumWin::scrollbarThickness(ScrollbarControlSize controlSi { static int thickness; if (!thickness) { - if (ChromiumBridge::layoutTestMode()) + if (PlatformBridge::layoutTestMode()) return kMacScrollbarSize[controlSize]; thickness = GetSystemMetrics(SM_CXVSCROLL); } @@ -104,7 +104,7 @@ void ScrollbarThemeChromiumWin::paintTrackPiece(GraphicsContext* gc, Scrollbar* IntRect alignRect = trackRect(scrollbar, false); // Draw the track area before/after the thumb on the scroll bar. - ChromiumBridge::paintScrollbarTrack( + PlatformBridge::paintScrollbarTrack( gc, partId, getThemeState(scrollbar, partType), @@ -124,7 +124,7 @@ void ScrollbarThemeChromiumWin::paintButton(GraphicsContext* gc, Scrollbar* scro partId = horz ? DFCS_SCROLLRIGHT : DFCS_SCROLLDOWN; // Draw the thumb (the box you drag in the scroll bar to scroll). - ChromiumBridge::paintScrollbarArrow( + PlatformBridge::paintScrollbarArrow( gc, getThemeArrowState(scrollbar, part), partId | getClassicThemeState(scrollbar, part), @@ -136,7 +136,7 @@ void ScrollbarThemeChromiumWin::paintThumb(GraphicsContext* gc, Scrollbar* scrol bool horz = scrollbar->orientation() == HorizontalScrollbar; // Draw the thumb (the box you drag in the scroll bar to scroll). - ChromiumBridge::paintScrollbarThumb( + PlatformBridge::paintScrollbarThumb( gc, horz ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT, getThemeState(scrollbar, ThumbPart), @@ -144,7 +144,7 @@ void ScrollbarThemeChromiumWin::paintThumb(GraphicsContext* gc, Scrollbar* scrol rect); // Draw the gripper (the three little lines on the thumb). - ChromiumBridge::paintScrollbarThumb( + PlatformBridge::paintScrollbarThumb( gc, horz ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT, getThemeState(scrollbar, ThumbPart), @@ -256,7 +256,7 @@ IntSize ScrollbarThemeChromiumWin::buttonSize(Scrollbar* scrollbar) // test mode so that should be enough to result in repeatable results, but // preserving this hack avoids having to rebaseline pixel tests. const int kLayoutTestModeGirth = 17; - int girth = ChromiumBridge::layoutTestMode() ? kLayoutTestModeGirth : thickness; + int girth = PlatformBridge::layoutTestMode() ? kLayoutTestModeGirth : thickness; if (scrollbar->orientation() == HorizontalScrollbar) { int width = scrollbar->width() < 2 * girth ? scrollbar->width() / 2 : girth; diff --git a/Source/WebCore/platform/chromium/SharedTimerChromium.cpp b/Source/WebCore/platform/chromium/SharedTimerChromium.cpp index 5a6a000..5acb253 100644 --- a/Source/WebCore/platform/chromium/SharedTimerChromium.cpp +++ b/Source/WebCore/platform/chromium/SharedTimerChromium.cpp @@ -26,23 +26,23 @@ #include "config.h" #include "SharedTimer.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" namespace WebCore { void setSharedTimerFiredFunction(void (*f)()) { - ChromiumBridge::setSharedTimerFiredFunction(f); + PlatformBridge::setSharedTimerFiredFunction(f); } void setSharedTimerFireTime(double fireTime) { - ChromiumBridge::setSharedTimerFireTime(fireTime); + PlatformBridge::setSharedTimerFireTime(fireTime); } void stopSharedTimer() { - ChromiumBridge::stopSharedTimer(); + PlatformBridge::stopSharedTimer(); } } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/SuddenTerminationChromium.cpp b/Source/WebCore/platform/chromium/SuddenTerminationChromium.cpp index 54b8304..06cc738 100644 --- a/Source/WebCore/platform/chromium/SuddenTerminationChromium.cpp +++ b/Source/WebCore/platform/chromium/SuddenTerminationChromium.cpp @@ -1,48 +1,48 @@ -/*
- * 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"
-#include "SuddenTermination.h"
-
-#include "ChromiumBridge.h"
-
-namespace WebCore {
-
-void disableSuddenTermination()
-{
- ChromiumBridge::suddenTerminationChanged(false);
-}
-
-void enableSuddenTermination()
-{
- ChromiumBridge::suddenTerminationChanged(true);
-}
-
-} // namespace WebCore
+/* + * 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" +#include "SuddenTermination.h" + +#include "PlatformBridge.h" + +namespace WebCore { + +void disableSuddenTermination() +{ + PlatformBridge::suddenTerminationChanged(false); +} + +void enableSuddenTermination() +{ + PlatformBridge::suddenTerminationChanged(true); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/chromium/SystemTimeChromium.cpp b/Source/WebCore/platform/chromium/SystemTimeChromium.cpp index 52ac262..93ac8b1 100644 --- a/Source/WebCore/platform/chromium/SystemTimeChromium.cpp +++ b/Source/WebCore/platform/chromium/SystemTimeChromium.cpp @@ -31,15 +31,15 @@ #include "config.h" #include "SystemTime.h" -#include "ChromiumBridge.h" #include "NotImplemented.h" +#include "PlatformBridge.h" namespace WebCore { // Get the current time in seconds since epoch. double currentTime() { - return ChromiumBridge::currentTime(); + return PlatformBridge::currentTime(); } float userIdleTime() diff --git a/Source/WebCore/platform/chromium/WidgetChromium.cpp b/Source/WebCore/platform/chromium/WidgetChromium.cpp index 1b7fef4..ac52244 100644 --- a/Source/WebCore/platform/chromium/WidgetChromium.cpp +++ b/Source/WebCore/platform/chromium/WidgetChromium.cpp @@ -32,7 +32,8 @@ #include "Widget.h" #include "Assertions.h" -#include "ChromiumBridge.h" +#include "HostWindow.h" +#include "ScrollView.h" namespace WebCore { @@ -56,7 +57,9 @@ void Widget::hide() void Widget::setCursor(const Cursor& cursor) { - ChromiumBridge::widgetSetCursor(this, cursor); + ScrollView* view = root(); + if (view) + view->hostWindow()->setCursor(cursor); } void Widget::paint(GraphicsContext*, const IntRect&) diff --git a/Source/WebCore/platform/chromium/WritableDataObject.cpp b/Source/WebCore/platform/chromium/WritableDataObject.cpp index 7cbf42c..a1ac7d9 100644 --- a/Source/WebCore/platform/chromium/WritableDataObject.cpp +++ b/Source/WebCore/platform/chromium/WritableDataObject.cpp @@ -31,8 +31,8 @@ #include "config.h" #include "WritableDataObject.h" -#include "ChromiumBridge.h" #include "ClipboardMimeTypes.h" +#include "PlatformBridge.h" namespace WebCore { @@ -80,7 +80,7 @@ bool WritableDataObject::setData(const String& type, const String& data) // FIXME: This is currently unimplemented on the Chromium-side. This is // "okay" for now since the original implementation didn't support it // anyway. Going forward, this is something we'll need to fix though. - ChromiumBridge::clipboardWriteData(type, data, ""); + PlatformBridge::clipboardWriteData(type, data, ""); return true; } m_dataMap.set(type, data); diff --git a/Source/WebCore/platform/efl/ScrollbarEfl.cpp b/Source/WebCore/platform/efl/ScrollbarEfl.cpp index 282ca7c..e71d1e3 100644 --- a/Source/WebCore/platform/efl/ScrollbarEfl.cpp +++ b/Source/WebCore/platform/efl/ScrollbarEfl.cpp @@ -42,13 +42,13 @@ using namespace std; using namespace WebCore; -PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size) +PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size) { - return adoptRef(new ScrollbarEfl(client, orientation, size)); + return adoptRef(new ScrollbarEfl(scrollableArea, orientation, size)); } -ScrollbarEfl::ScrollbarEfl(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) - : Scrollbar(client, orientation, controlSize) +ScrollbarEfl::ScrollbarEfl(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) + : Scrollbar(scrollableArea, orientation, controlSize) , m_lastPos(0) , m_lastTotalSize(0) , m_lastVisibleSize(0) @@ -84,7 +84,7 @@ static void scrollbarEflEdjeMessage(void* data, Evas_Object* o, Edje_Message_Typ m = static_cast<Edje_Message_Float*>(msg); v = m->val * (that->totalSize() - that->visibleSize()); - that->setValue(v, Scrollbar::NotFromScrollAnimator); + that->scrollableArea()->scrollToOffsetWithoutAnimation(that->orientation(), v); } void ScrollbarEfl::setParent(ScrollView* view) diff --git a/Source/WebCore/platform/efl/ScrollbarEfl.h b/Source/WebCore/platform/efl/ScrollbarEfl.h index 35375a6..09dc64f 100644 --- a/Source/WebCore/platform/efl/ScrollbarEfl.h +++ b/Source/WebCore/platform/efl/ScrollbarEfl.h @@ -52,7 +52,7 @@ public: virtual void paint(GraphicsContext* context, const IntRect& damageRect); protected: - ScrollbarEfl(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize); + ScrollbarEfl(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize); virtual void updateThumbPositionAndProportion(); virtual void updateThumbPosition(); diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp index 64f19c4..f416b47 100644 --- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp +++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp @@ -28,29 +28,53 @@ #if ENABLE(3D_CANVAS) #include "ANGLEWebKitBridge.h" +#include <wtf/OwnArrayPtr.h> namespace WebCore { ANGLEWebKitBridge::ANGLEWebKitBridge() : - builtCompilers(false) + builtCompilers(false), + m_fragmentCompiler(0), + m_vertexCompiler(0) { ShInitialize(); } ANGLEWebKitBridge::~ANGLEWebKitBridge() { - if (builtCompilers) { + cleanupCompilers(); +} + +void ANGLEWebKitBridge::cleanupCompilers() +{ + if (m_fragmentCompiler) ShDestruct(m_fragmentCompiler); + m_fragmentCompiler = 0; + if (m_vertexCompiler) ShDestruct(m_vertexCompiler); - } + m_vertexCompiler = 0; + + builtCompilers = false; +} + +void ANGLEWebKitBridge::setResources(ShBuiltInResources resources) +{ + // Resources are (possibly) changing - cleanup compilers if we had them already + cleanupCompilers(); + + m_resources = resources; } bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog) { if (!builtCompilers) { - m_fragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecWebGL, &m_resources); - m_vertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecWebGL, &m_resources); + m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_WEBGL_SPEC, &m_resources); + m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_WEBGL_SPEC, &m_resources); + if (!m_fragmentCompiler || !m_vertexCompiler) { + cleanupCompilers(); + return false; + } builtCompilers = true; } @@ -64,12 +88,31 @@ bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShad const char* const shaderSourceStrings[] = { shaderSource }; - bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, EShOptNone, EDebugOpIntermediate); + bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE); + if (!validateSuccess) { + int logSize = 0; + ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &logSize); + if (logSize > 1) { + OwnArrayPtr<char> logBuffer(new char[logSize]); + if (logBuffer) { + ShGetInfoLog(compiler, logBuffer.get()); + shaderValidationLog = logBuffer.get(); + } + } + return false; + } - translatedShaderSource = ShGetObjectCode(compiler); - shaderValidationLog = ShGetInfoLog(compiler); + int translationLength = 0; + ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &translationLength); + if (translationLength > 1) { + OwnArrayPtr<char> translationBuffer(new char[translationLength]); + if (!translationBuffer) + return false; + ShGetObjectCode(compiler, translationBuffer.get()); + translatedShaderSource = translationBuffer.get(); + } - return validateSuccess; + return true; } } diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h index d01de8f..7bddbf4 100644 --- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h +++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h @@ -34,8 +34,8 @@ namespace WebCore { enum ANGLEShaderType { - SHADER_TYPE_VERTEX = EShLangVertex, - SHADER_TYPE_FRAGMENT = EShLangFragment + SHADER_TYPE_VERTEX = SH_VERTEX_SHADER, + SHADER_TYPE_FRAGMENT = SH_FRAGMENT_SHADER, }; class ANGLEWebKitBridge { @@ -44,18 +44,21 @@ public: ANGLEWebKitBridge(); ~ANGLEWebKitBridge(); - void setResources(TBuiltInResource resources) { m_resources = resources; } + ShBuiltInResources getResources() { return m_resources; } + void setResources(ShBuiltInResources); bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog); private: - ShHandle m_fragmentCompiler; - ShHandle m_vertexCompiler; + void cleanupCompilers(); bool builtCompilers; + + ShHandle m_fragmentCompiler; + ShHandle m_vertexCompiler; - TBuiltInResource m_resources; + ShBuiltInResources m_resources; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h index 72f3092..93fc464 100644 --- a/Source/WebCore/platform/graphics/BitmapImage.h +++ b/Source/WebCore/platform/graphics/BitmapImage.h @@ -68,7 +68,9 @@ template <typename T> class Timer; // FrameData Class // ================================================ -struct FrameData : Noncopyable { +struct FrameData { + WTF_MAKE_NONCOPYABLE(FrameData); +public: FrameData() : m_frame(0) , m_haveMetadata(false) diff --git a/Source/WebCore/platform/graphics/Color.h b/Source/WebCore/platform/graphics/Color.h index fa37d32..2a03238 100644 --- a/Source/WebCore/platform/graphics/Color.h +++ b/Source/WebCore/platform/graphics/Color.h @@ -78,7 +78,8 @@ inline int greenChannel(RGBA32 color) { return (color >> 8) & 0xFF; } inline int blueChannel(RGBA32 color) { return color & 0xFF; } inline int alphaChannel(RGBA32 color) { return (color >> 24) & 0xFF; } -class Color : public FastAllocBase { +class Color { + WTF_MAKE_FAST_ALLOCATED; public: Color() : m_color(0), m_valid(false) { } Color(RGBA32 col) : m_color(col), m_valid(true) { } diff --git a/Source/WebCore/platform/graphics/Extensions3D.h b/Source/WebCore/platform/graphics/Extensions3D.h index 0363a48..1a2b7a1 100644 --- a/Source/WebCore/platform/graphics/Extensions3D.h +++ b/Source/WebCore/platform/graphics/Extensions3D.h @@ -51,6 +51,7 @@ public: // GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil // GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample // GL_OES_texture_float + // GL_OES_standard_derivatives // Takes full name of extension; for example, // "GL_EXT_texture_format_BGRA8888". @@ -82,7 +83,10 @@ public: // GL_ANGLE_framebuffer_multisample names RENDERBUFFER_SAMPLES = 0x8CAB, FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56, - MAX_SAMPLES = 0x8D57 + MAX_SAMPLES = 0x8D57, + + // GL_OES_standard_derivatives names + FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B, }; // GL_ARB_robustness diff --git a/Source/WebCore/platform/graphics/FloatPoint.cpp b/Source/WebCore/platform/graphics/FloatPoint.cpp index 7e85b52..226ae71 100644 --- a/Source/WebCore/platform/graphics/FloatPoint.cpp +++ b/Source/WebCore/platform/graphics/FloatPoint.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "FloatPoint.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "FloatConversion.h" #include "IntPoint.h" diff --git a/Source/WebCore/platform/graphics/Font.cpp b/Source/WebCore/platform/graphics/Font.cpp index 887e21d..394de35 100644 --- a/Source/WebCore/platform/graphics/Font.cpp +++ b/Source/WebCore/platform/graphics/Font.cpp @@ -29,6 +29,7 @@ #include "FontTranscoder.h" #include "IntPoint.h" #include "GlyphBuffer.h" +#include "TextRun.h" #include "WidthIterator.h" #include <wtf/MathExtras.h> #include <wtf/UnusedParam.h> diff --git a/Source/WebCore/platform/graphics/Font.h b/Source/WebCore/platform/graphics/Font.h index 40a8828..2957c0a 100644 --- a/Source/WebCore/platform/graphics/Font.h +++ b/Source/WebCore/platform/graphics/Font.h @@ -29,7 +29,6 @@ #include "FontDescription.h" #include "FontFallbackList.h" #include "SimpleFontData.h" -#include "TextRun.h" #include "TypesettingFeatures.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> @@ -51,6 +50,7 @@ class GlyphBuffer; class GlyphPageTreeNode; class GraphicsContext; class SVGFontElement; +class TextRun; struct GlyphData; diff --git a/Source/WebCore/platform/graphics/FontCache.cpp b/Source/WebCore/platform/graphics/FontCache.cpp index 149ea79..cfca980 100644 --- a/Source/WebCore/platform/graphics/FontCache.cpp +++ b/Source/WebCore/platform/graphics/FontCache.cpp @@ -53,7 +53,9 @@ FontCache::FontCache() { } -struct FontPlatformDataCacheKey : FastAllocBase { +struct FontPlatformDataCacheKey { + WTF_MAKE_FAST_ALLOCATED; +public: FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), unsigned size = 0, unsigned weight = 0, bool italic = false, bool isPrinterFont = false, FontRenderingMode renderingMode = NormalRenderingMode, FontOrientation orientation = Horizontal) : m_size(size) diff --git a/Source/WebCore/platform/graphics/FontCache.h b/Source/WebCore/platform/graphics/FontCache.h index e6845d9..86f8c67 100644 --- a/Source/WebCore/platform/graphics/FontCache.h +++ b/Source/WebCore/platform/graphics/FontCache.h @@ -50,7 +50,8 @@ class FontDescription; class FontSelector; class SimpleFontData; -class FontCache : public Noncopyable { +class FontCache { + WTF_MAKE_NONCOPYABLE(FontCache); WTF_MAKE_FAST_ALLOCATED; public: friend FontCache* fontCache(); diff --git a/Source/WebCore/platform/graphics/FontData.h b/Source/WebCore/platform/graphics/FontData.h index ee94a98..3d35d2a 100644 --- a/Source/WebCore/platform/graphics/FontData.h +++ b/Source/WebCore/platform/graphics/FontData.h @@ -26,6 +26,7 @@ #ifndef FontData_h #define FontData_h +#include <wtf/FastAllocBase.h> #include <wtf/Forward.h> #include <wtf/Noncopyable.h> #include <wtf/unicode/Unicode.h> @@ -34,7 +35,8 @@ namespace WebCore { class SimpleFontData; -class FontData : public Noncopyable { +class FontData { + WTF_MAKE_NONCOPYABLE(FontData); WTF_MAKE_FAST_ALLOCATED; public: FontData() : m_maxGlyphPageTreeLevel(0) diff --git a/Source/WebCore/platform/graphics/FontFastPath.cpp b/Source/WebCore/platform/graphics/FontFastPath.cpp index 367c8a2..f927c13 100644 --- a/Source/WebCore/platform/graphics/FontFastPath.cpp +++ b/Source/WebCore/platform/graphics/FontFastPath.cpp @@ -30,6 +30,7 @@ #include "GlyphBuffer.h" #include "GlyphPageTreeNode.h" #include "SimpleFontData.h" +#include "TextRun.h" #include "WidthIterator.h" #include <wtf/MathExtras.h> diff --git a/Source/WebCore/platform/graphics/GlyphMetricsMap.h b/Source/WebCore/platform/graphics/GlyphMetricsMap.h index fa85bcc..3e13fbb 100644 --- a/Source/WebCore/platform/graphics/GlyphMetricsMap.h +++ b/Source/WebCore/platform/graphics/GlyphMetricsMap.h @@ -40,7 +40,8 @@ typedef unsigned short Glyph; const float cGlyphSizeUnknown = -1; -template<class T> class GlyphMetricsMap : public Noncopyable { +template<class T> class GlyphMetricsMap { + WTF_MAKE_NONCOPYABLE(GlyphMetricsMap); public: GlyphMetricsMap() : m_filledPrimaryPage(false) { } ~GlyphMetricsMap() diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp index c9c1f63..9f94ac9 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext.cpp +++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp @@ -31,6 +31,8 @@ #include "Generator.h" #include "ImageBuffer.h" #include "IntRect.h" +#include "RoundedIntRect.h" +#include "TextRun.h" using namespace std; @@ -536,25 +538,23 @@ void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS image->draw(this, styleColorSpace, dest, src, op, useLowQualityScale); } -void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, - const IntSize& bottomLeft, const IntSize& bottomRight) +void GraphicsContext::addRoundedRectClip(const RoundedIntRect& rect) { if (paintingDisabled()) return; Path path; - path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); + path.addRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight()); clip(path); } -void GraphicsContext::clipOutRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, - const IntSize& bottomLeft, const IntSize& bottomRight) +void GraphicsContext::clipOutRoundedRect(const RoundedIntRect& rect) { if (paintingDisabled()) return; Path path; - path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); + path.addRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight()); clipOut(path); } @@ -585,6 +585,11 @@ void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator) generator.fill(this, rect); } +void GraphicsContext::fillRoundedRect(const RoundedIntRect& rect, const Color& color, ColorSpace colorSpace) +{ + fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace); +} + void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation) { m_state.compositeOperator = compositeOperation; diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h index a648680..77321e2 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext.h +++ b/Source/WebCore/platform/graphics/GraphicsContext.h @@ -128,6 +128,7 @@ namespace WebCore { class GraphicsContextPlatformPrivate; class ImageBuffer; class IntRect; + class RoundedIntRect; class KURL; class SharedGraphicsContext3D; class TextRun; @@ -213,7 +214,8 @@ namespace WebCore { bool shadowsIgnoreTransforms : 1; }; - class GraphicsContext : public Noncopyable { + class GraphicsContext { + WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED; public: GraphicsContext(PlatformGraphicsContext*); ~GraphicsContext(); @@ -317,6 +319,7 @@ namespace WebCore { void fillRect(const FloatRect&, const Color&, ColorSpace); void fillRect(const FloatRect&, Generator&); void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace); + void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace); void clearRect(const FloatRect&); @@ -345,10 +348,10 @@ namespace WebCore { InterpolationQuality imageInterpolationQuality() const; void clip(const FloatRect&); - void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); + void addRoundedRectClip(const RoundedIntRect&); void addInnerRoundedRectClip(const IntRect&, int thickness); void clipOut(const IntRect&); - void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); + void clipOutRoundedRect(const RoundedIntRect&); void clipPath(const Path&, WindRule); void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true); void clipToImageBuffer(ImageBuffer*, const FloatRect&); @@ -457,7 +460,8 @@ namespace WebCore { void setShouldIncludeChildWindows(bool); bool shouldIncludeChildWindows() const; - class WindowsBitmap : public Noncopyable { + class WindowsBitmap { + WTF_MAKE_NONCOPYABLE(WindowsBitmap); public: WindowsBitmap(HDC, IntSize); ~WindowsBitmap(); diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h index 10aa0d7..24827e5 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h @@ -883,6 +883,7 @@ public: } ShaderSourceEntry; HashMap<Platform3DObject, ShaderSourceEntry> m_shaderSourceMap; + friend class Extensions3DOpenGL; ANGLEWebKitBridge m_compiler; OwnPtr<Extensions3DOpenGL> m_extensions; diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.h b/Source/WebCore/platform/graphics/GraphicsLayer.h index 8943f6c..e3a62b6 100644 --- a/Source/WebCore/platform/graphics/GraphicsLayer.h +++ b/Source/WebCore/platform/graphics/GraphicsLayer.h @@ -100,7 +100,8 @@ class TimingFunction; // Base class for animation values (also used for transitions). Here to // represent values for properties being animated via the GraphicsLayer, // without pulling in style-related data from outside of the platform directory. -class AnimationValue : public Noncopyable { +class AnimationValue { + WTF_MAKE_NONCOPYABLE(AnimationValue); WTF_MAKE_FAST_ALLOCATED; public: AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0) : m_keyTime(keyTime) @@ -152,7 +153,8 @@ private: // Used to store a series of values in a keyframe list. Values will all be of the same type, // which can be inferred from the property. -class KeyframeValueList : public Noncopyable { +class KeyframeValueList { + WTF_MAKE_NONCOPYABLE(KeyframeValueList); WTF_MAKE_FAST_ALLOCATED; public: KeyframeValueList(AnimatedPropertyID property) @@ -184,8 +186,8 @@ protected: // which may have associated transformation and animations. class GraphicsLayer { + WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED; public: - static PassOwnPtr<GraphicsLayer> create(GraphicsLayerClient*); virtual ~GraphicsLayer(); diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h index 338e3f8..48878da 100644 --- a/Source/WebCore/platform/graphics/ImageBuffer.h +++ b/Source/WebCore/platform/graphics/ImageBuffer.h @@ -31,7 +31,7 @@ #include "AffineTransform.h" #include "ColorSpace.h" #include "FloatRect.h" -#include "Image.h" +#include "GraphicsTypes.h" #include "IntSize.h" #include "ImageBufferData.h" #include <wtf/ByteArray.h> @@ -39,6 +39,7 @@ #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> #if (PLATFORM(MAC) && PLATFORM(CA) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)) #define WTF_USE_IOSURFACE_CANVAS_BACKING_STORE 1 @@ -47,6 +48,7 @@ namespace WebCore { class GraphicsContext; + class Image; class ImageData; class IntPoint; class IntRect; @@ -61,7 +63,8 @@ namespace WebCore { Accelerated }; - class ImageBuffer : public Noncopyable { + class ImageBuffer { + WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; public: // Will return a null pointer on allocation failure. static PassOwnPtr<ImageBuffer> create(const IntSize& size, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated) @@ -79,6 +82,8 @@ namespace WebCore { int width() const { return m_size.width(); } int height() const { return m_size.height(); } + size_t dataSize() const; + GraphicsContext* context() const; bool drawsUsingCopy() const; // If the image buffer has to render using a copied image, it will return true. diff --git a/Source/WebCore/platform/graphics/ImageSource.h b/Source/WebCore/platform/graphics/ImageSource.h index 1452b71..70b2cf5 100644 --- a/Source/WebCore/platform/graphics/ImageSource.h +++ b/Source/WebCore/platform/graphics/ImageSource.h @@ -136,7 +136,8 @@ const int cAnimationLoopOnce = 0; const int cAnimationLoopInfinite = -1; const int cAnimationNone = -2; -class ImageSource : public Noncopyable { +class ImageSource { + WTF_MAKE_NONCOPYABLE(ImageSource); public: enum AlphaOption { AlphaPremultiplied, diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp index 4a39e9e..60f55a5 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.cpp +++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp @@ -150,7 +150,9 @@ static MediaPlayerPrivateInterface* createNullMediaPlayer(MediaPlayer* player) // engine support -struct MediaPlayerFactory : Noncopyable { +struct MediaPlayerFactory { + WTF_MAKE_NONCOPYABLE(MediaPlayerFactory); WTF_MAKE_FAST_ALLOCATED; +public: MediaPlayerFactory(CreateMediaEnginePlayer constructor, MediaEngineSupportedTypes getSupportedTypes, MediaEngineSupportsType supportsTypeAndCodecs) : constructor(constructor) , getSupportedTypes(getSupportedTypes) diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h index 6525ca6..ef0b3eb 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.h +++ b/Source/WebCore/platform/graphics/MediaPlayer.h @@ -149,7 +149,8 @@ public: #endif }; -class MediaPlayer : public Noncopyable { +class MediaPlayer { + WTF_MAKE_NONCOPYABLE(MediaPlayer); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<MediaPlayer> create(MediaPlayerClient* client) diff --git a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h index d956286..6abe258 100644 --- a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h +++ b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h @@ -36,8 +36,10 @@ namespace WebCore { class IntRect; class IntSize; -class MediaPlayerPrivateInterface : public Noncopyable { +class MediaPlayerPrivateInterface { + WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateInterface); WTF_MAKE_FAST_ALLOCATED; public: + MediaPlayerPrivateInterface() { } virtual ~MediaPlayerPrivateInterface() { } virtual void load(const String& url) = 0; diff --git a/Source/WebCore/platform/graphics/Path.h b/Source/WebCore/platform/graphics/Path.h index 423a792..852d88e 100644 --- a/Source/WebCore/platform/graphics/Path.h +++ b/Source/WebCore/platform/graphics/Path.h @@ -100,7 +100,8 @@ namespace WebCore { typedef void (*PathApplierFunction)(void* info, const PathElement*); - class Path : public FastAllocBase { + class Path { + WTF_MAKE_FAST_ALLOCATED; public: Path(); ~Path(); diff --git a/Source/WebCore/platform/graphics/RoundedIntRect.cpp b/Source/WebCore/platform/graphics/RoundedIntRect.cpp new file mode 100644 index 0000000..4e80c9a --- /dev/null +++ b/Source/WebCore/platform/graphics/RoundedIntRect.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2003, 2006, 2009 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 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 "RoundedIntRect.h" + +#include "IntRect.h" +#include <algorithm> + +namespace WebCore { + +bool RoundedIntRect::Radii::isZero() const +{ + return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero(); +} + +void RoundedIntRect::Radii::scale(float factor) +{ + if (factor == 1) + return; + + // If either radius on a corner becomes zero, reset both radii on that corner. + m_topLeft.scale(factor); + if (!m_topLeft.width() || !m_topLeft.height()) + m_topLeft = IntSize(); + m_topRight.scale(factor); + if (!m_topRight.width() || !m_topRight.height()) + m_topRight = IntSize(); + m_bottomLeft.scale(factor); + if (!m_bottomLeft.width() || !m_bottomLeft.height()) + m_bottomLeft = IntSize(); + m_bottomRight.scale(factor); + if (!m_bottomRight.width() || !m_bottomRight.height()) + m_bottomRight = IntSize(); + +} + +void RoundedIntRect::Radii::expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth) +{ + m_topLeft.setWidth(std::max(0, m_topLeft.width() + leftWidth)); + m_topLeft.setHeight(std::max(0, m_topLeft.height() + topWidth)); + + m_topRight.setWidth(std::max(0, m_topRight.width() + rightWidth)); + m_topRight.setHeight(std::max(0, m_topRight.height() + topWidth)); + + m_bottomLeft.setWidth(std::max(0, m_bottomLeft.width() + leftWidth)); + m_bottomLeft.setHeight(std::max(0, m_bottomLeft.height() + bottomWidth)); + + m_bottomRight.setWidth(std::max(0, m_bottomRight.width() + rightWidth)); + m_bottomRight.setHeight(std::max(0, m_bottomRight.height() + bottomWidth)); +} + +void RoundedIntRect::Radii::includeLogicalEdges(const RoundedIntRect::Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) +{ + if (includeLogicalLeftEdge) { + if (isHorizontal) + m_bottomLeft = edges.bottomLeft(); + else + m_topRight = edges.topRight(); + m_topLeft = edges.topLeft(); + } + + if (includeLogicalRightEdge) { + if (isHorizontal) + m_topRight = edges.topRight(); + else + m_bottomLeft = edges.bottomLeft(); + m_bottomRight = edges.bottomRight(); + } +} + +void RoundedIntRect::Radii::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge) +{ + if (excludeLogicalLeftEdge) { + if (isHorizontal) + m_bottomLeft = IntSize(); + else + m_topRight = IntSize(); + m_topLeft = IntSize(); + } + + if (excludeLogicalRightEdge) { + if (isHorizontal) + m_topRight = IntSize(); + else + m_bottomLeft = IntSize(); + m_bottomRight = IntSize(); + } +} + +RoundedIntRect::RoundedIntRect(int x, int y, int width, int height) + : m_rect(x, y, width, height) +{ +} + +RoundedIntRect::RoundedIntRect(const IntRect& rect, const Radii& radii) + : m_rect(rect) + , m_radii(radii) +{ +} + +RoundedIntRect::RoundedIntRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) + : m_rect(rect) + , m_radii(topLeft, topRight, bottomLeft, bottomRight) +{ +} + +void RoundedIntRect::includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) +{ + m_radii.includeLogicalEdges(edges, isHorizontal, includeLogicalLeftEdge, includeLogicalRightEdge); +} + +void RoundedIntRect::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge) +{ + m_radii.excludeLogicalEdges(isHorizontal, excludeLogicalLeftEdge, excludeLogicalRightEdge); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/graphics/RoundedIntRect.h b/Source/WebCore/platform/graphics/RoundedIntRect.h new file mode 100644 index 0000000..c3c972f --- /dev/null +++ b/Source/WebCore/platform/graphics/RoundedIntRect.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2003, 2006, 2009 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 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. + */ + +#ifndef RoundedIntRect_h +#define RoundedIntRect_h + +#include "IntRect.h" + +namespace WebCore { + + +class RoundedIntRect { +public: + class Radii { + public: + Radii() {} + Radii(const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) + : m_topLeft(topLeft) + , m_topRight(topRight) + , m_bottomLeft(bottomLeft) + , m_bottomRight(bottomRight) + { + } + + void setTopLeft(const IntSize& size) { m_topLeft = size; } + void setTopRight(const IntSize& size) { m_topRight = size; } + void setBottomLeft(const IntSize& size) { m_bottomLeft = size; } + void setBottomRight(const IntSize& size) { m_bottomRight = size; } + const IntSize& topLeft() const { return m_topLeft; } + const IntSize& topRight() const { return m_topRight; } + const IntSize& bottomLeft() const { return m_bottomLeft; } + const IntSize& bottomRight() const { return m_bottomRight; } + + bool isZero() const; + + void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge); + void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge); + + void scale(float factor); + void expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth); + void expand(int size) { expand(size, size, size, size); } + void shrink(int topWidth, int bottomWidth, int leftWidth, int rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); } + void shrink(int size) { shrink(size, size, size, size); } + + private: + IntSize m_topLeft; + IntSize m_topRight; + IntSize m_bottomLeft; + IntSize m_bottomRight; + }; + + explicit RoundedIntRect(const IntRect&, const Radii& = Radii()); + RoundedIntRect(int x, int y, int width, int height); + RoundedIntRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); + + const IntRect& rect() const { return m_rect; } + const Radii& radii() const { return m_radii; } + bool isRounded() const { return !m_radii.isZero(); } + bool isEmpty() const { return m_rect.isEmpty(); } + + void setRect(const IntRect& rect) { m_rect = rect; } + void setRadii(const Radii& radii) { m_radii = radii; } + + void move(const IntSize& size) { m_rect.move(size); } + void inflate(int size) { m_rect.inflate(size); } + void inflateWithRadii(int size) { m_rect.inflate(size); m_radii.expand(size); } + void expandRadii(int size) { m_radii.expand(size); } + void shrinkRadii(int size) { m_radii.shrink(size); } + + void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge); + void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge); + +private: + IntRect m_rect; + Radii m_radii; +}; + +} // namespace WebCore + +#endif // RoundedIntRect_h diff --git a/Source/WebCore/platform/graphics/StringTruncator.cpp b/Source/WebCore/platform/graphics/StringTruncator.cpp index b6c86ce..65325f0 100644 --- a/Source/WebCore/platform/graphics/StringTruncator.cpp +++ b/Source/WebCore/platform/graphics/StringTruncator.cpp @@ -32,6 +32,7 @@ #include "CharacterNames.h" #include "Font.h" #include "TextBreakIterator.h" +#include "TextRun.h" #include <wtf/Assertions.h> #include <wtf/Vector.h> diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.h b/Source/WebCore/platform/graphics/TiledBackingStore.h index 58477db..06c7fe1 100644 --- a/Source/WebCore/platform/graphics/TiledBackingStore.h +++ b/Source/WebCore/platform/graphics/TiledBackingStore.h @@ -36,7 +36,8 @@ namespace WebCore { class GraphicsContext; class TiledBackingStoreClient; -class TiledBackingStore : public Noncopyable { +class TiledBackingStore { + WTF_MAKE_NONCOPYABLE(TiledBackingStore); WTF_MAKE_FAST_ALLOCATED; public: TiledBackingStore(TiledBackingStoreClient*); ~TiledBackingStore(); diff --git a/Source/WebCore/platform/graphics/WidthIterator.cpp b/Source/WebCore/platform/graphics/WidthIterator.cpp index 2a951e8..412c86e 100644 --- a/Source/WebCore/platform/graphics/WidthIterator.cpp +++ b/Source/WebCore/platform/graphics/WidthIterator.cpp @@ -25,6 +25,7 @@ #include "Font.h" #include "GlyphBuffer.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <wtf/MathExtras.h> #if USE(ICU_UNICODE) diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp index b72d761..01e25e9 100644 --- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp +++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp @@ -1105,6 +1105,10 @@ void GraphicsLayerCA::ensureStructuralLayer(StructuralLayerPurpose purpose) if (m_structuralLayer) { // Replace the transformLayer in the parent with this layer. m_layer->removeFromSuperlayer(); + + // If m_layer doesn't have a parent, it means it's the root layer and + // is likely hosted by something that is not expecting to be changed + ASSERT(m_structuralLayer->superlayer()); m_structuralLayer->superlayer()->replaceSublayer(m_structuralLayer.get(), m_layer.get()); moveOrCopyAnimationsForProperty(Move, AnimatedPropertyWebkitTransform, m_structuralLayer.get(), m_layer.get()); @@ -1178,6 +1182,9 @@ void GraphicsLayerCA::ensureStructuralLayer(StructuralLayerPurpose purpose) } // Move this layer to be a child of the transform layer. + // If m_layer doesn't have a parent, it means it's the root layer and + // is likely hosted by something that is not expecting to be changed + ASSERT(m_layer->superlayer()); m_layer->superlayer()->replaceSublayer(m_layer.get(), m_structuralLayer.get()); m_structuralLayer->appendSublayer(m_layer.get()); @@ -2013,6 +2020,9 @@ void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer) m_layer->adoptSublayers(oldLayer.get()); + // If m_layer doesn't have a parent, it means it's the root layer and + // is likely hosted by something that is not expecting to be changed + ASSERT(oldLayer->superlayer()); oldLayer->superlayer()->replaceSublayer(oldLayer.get(), m_layer.get()); updateContentsTransform(); diff --git a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp index 7c83f86..1d27608 100644 --- a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp +++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp @@ -24,17 +24,12 @@ */ #include "config.h" +#include "CACFLayerTreeHost.h" #if USE(ACCELERATED_COMPOSITING) -#ifndef NDEBUG -#define D3D_DEBUG_INFO -#endif - -#include "WKCACFLayerRenderer.h" - +#include "LayerChangesFlusher.h" #include "PlatformCALayer.h" -#include "WKCACFContextFlusher.h" #include "WebCoreInstanceHandle.h" #include <WebKitSystemInterface/WebKitSystemInterface.h> #include <limits.h> @@ -44,6 +39,11 @@ #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/StdLibExtras.h> + +#ifndef NDEBUG +#define D3D_DEBUG_INFO +#endif + #include <d3d9.h> #include <d3dx9.h> @@ -117,7 +117,7 @@ static bool hardwareCapabilitiesIndicateCoreAnimationSupport(const D3DCAPS9& cap return true; } -bool WKCACFLayerRenderer::acceleratedCompositingAvailable() +bool CACFLayerTreeHost::acceleratedCompositingAvailable() { static bool available; static bool tested; @@ -165,30 +165,31 @@ bool WKCACFLayerRenderer::acceleratedCompositingAvailable() return available; } - OwnPtr<WKCACFLayerRenderer> testLayerRenderer = WKCACFLayerRenderer::create(0); - testLayerRenderer->setHostWindow(testWindow); - available = testLayerRenderer->createRenderer(); + RefPtr<CACFLayerTreeHost> host = CACFLayerTreeHost::create(); + host->setWindow(testWindow); + available = host->createRenderer(); ::DestroyWindow(testWindow); return available; } -PassOwnPtr<WKCACFLayerRenderer> WKCACFLayerRenderer::create(WKCACFLayerRendererClient* client) +PassRefPtr<CACFLayerTreeHost> CACFLayerTreeHost::create() { if (!acceleratedCompositingAvailable()) return 0; - return new WKCACFLayerRenderer(client); + return adoptRef(new CACFLayerTreeHost()); } -WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) - : m_client(client) +CACFLayerTreeHost::CACFLayerTreeHost() + : m_client(0) , m_mightBeAbleToCreateDeviceLater(true) , m_rootLayer(PlatformCALayer::create(PlatformCALayer::LayerTypeRootLayer, 0)) , m_context(wkCACFContextCreate()) - , m_hostWindow(0) - , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired) + , m_window(0) + , m_renderTimer(this, &CACFLayerTreeHost::renderTimerFired) , m_mustResetLostDeviceBeforeRendering(false) - , m_syncLayerChanges(false) + , m_shouldFlushPendingGraphicsLayerChanges(false) + , m_isFlushingLayerChanges(false) { // Point the CACFContext to this wkCACFContextSetUserData(m_context, this); @@ -202,7 +203,7 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) // cause any repositioning. // Scrolling will affect only the position of the scroll layer without affecting the bounds. - m_rootLayer->setName("WKCACFLayerRenderer rootLayer"); + m_rootLayer->setName("CACFLayerTreeHost rootLayer"); m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0)); m_rootLayer->setGeometryFlipped(true); @@ -221,38 +222,37 @@ WKCACFLayerRenderer::WKCACFLayerRenderer(WKCACFLayerRendererClient* client) #endif } -WKCACFLayerRenderer::~WKCACFLayerRenderer() +CACFLayerTreeHost::~CACFLayerTreeHost() { - setHostWindow(0); - WKCACFContextFlusher::shared().removeContext(m_context); + setWindow(0); wkCACFContextDestroy(m_context); } -void WKCACFLayerRenderer::setHostWindow(HWND window) +void CACFLayerTreeHost::setWindow(HWND window) { - if (window == m_hostWindow) + if (window == m_window) return; - if (m_hostWindow) + if (m_window) destroyRenderer(); - m_hostWindow = window; + m_window = window; - if (m_hostWindow) + if (m_window) createRenderer(); } -PlatformCALayer* WKCACFLayerRenderer::rootLayer() const +PlatformCALayer* CACFLayerTreeHost::rootLayer() const { return m_rootLayer.get(); } -void WKCACFLayerRenderer::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer) +void CACFLayerTreeHost::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer) { m_pendingAnimatedLayers.add(layer); } -void WKCACFLayerRenderer::setRootChildLayer(PlatformCALayer* layer) +void CACFLayerTreeHost::setRootChildLayer(PlatformCALayer* layer) { m_rootLayer->removeAllSublayers(); m_rootChildLayer = layer; @@ -260,13 +260,22 @@ void WKCACFLayerRenderer::setRootChildLayer(PlatformCALayer* layer) m_rootLayer->appendSublayer(m_rootChildLayer.get()); } -void WKCACFLayerRenderer::layerTreeDidChange() +void CACFLayerTreeHost::layerTreeDidChange() { - WKCACFContextFlusher::shared().addContext(m_context); - renderSoon(); + if (m_isFlushingLayerChanges) { + // The layer tree is changing as a result of flushing GraphicsLayer changes to their + // underlying PlatformCALayers. We'll flush those changes to the context as part of that + // process, so there's no need to schedule another flush here. + return; + } + + // The layer tree is changing as a result of someone modifying a PlatformCALayer that doesn't + // have a corresponding GraphicsLayer. Schedule a flush since we won't schedule one through the + // normal GraphicsLayer mechanisms. + LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this); } -bool WKCACFLayerRenderer::createRenderer() +bool CACFLayerTreeHost::createRenderer() { if (m_d3dDevice || !m_mightBeAbleToCreateDeviceLater) return m_d3dDevice; @@ -274,14 +283,14 @@ bool WKCACFLayerRenderer::createRenderer() m_mightBeAbleToCreateDeviceLater = false; D3DPRESENT_PARAMETERS parameters = initialPresentationParameters(); - if (!d3d() || !::IsWindow(m_hostWindow)) + if (!d3d() || !::IsWindow(m_window)) return false; // D3D doesn't like to make back buffers for 0 size windows. We skirt this problem if we make the // passed backbuffer width and height non-zero. The window will necessarily get set to a non-zero // size eventually, and then the backbuffer size will get reset. RECT rect; - GetClientRect(m_hostWindow, &rect); + GetClientRect(m_window, &rect); if (rect.left-rect.right == 0 || rect.bottom-rect.top == 0) { parameters.BackBufferWidth = 1; @@ -299,7 +308,7 @@ bool WKCACFLayerRenderer::createRenderer() behaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; COMPtr<IDirect3DDevice9> device; - if (FAILED(d3d()->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hostWindow, behaviorFlags, ¶meters, &device))) { + if (FAILED(d3d()->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_window, behaviorFlags, ¶meters, &device))) { // In certain situations (e.g., shortly after waking from sleep), Direct3DCreate9() will // return an IDirect3D9 for which IDirect3D9::CreateDevice will always fail. In case we // have one of these bad IDirect3D9s, get rid of it so we'll fetch a new one the next time @@ -332,15 +341,17 @@ bool WKCACFLayerRenderer::createRenderer() wkCACFContextSetD3DDevice(m_context, m_d3dDevice.get()); - if (IsWindow(m_hostWindow)) + if (IsWindow(m_window)) m_rootLayer->setBounds(bounds()); return true; } -void WKCACFLayerRenderer::destroyRenderer() +void CACFLayerTreeHost::destroyRenderer() { - wkCACFContextSetLayer(m_context, m_rootLayer->platformLayer()); + LayerChangesFlusher::shared().cancelPendingFlush(this); + + wkCACFContextSetLayer(m_context, 0); wkCACFContextSetD3DDevice(m_context, 0); m_d3dDevice = 0; @@ -354,7 +365,7 @@ void WKCACFLayerRenderer::destroyRenderer() m_mightBeAbleToCreateDeviceLater = true; } -void WKCACFLayerRenderer::resize() +void CACFLayerTreeHost::resize() { if (!m_d3dDevice) return; @@ -365,7 +376,7 @@ void WKCACFLayerRenderer::resize() if (m_rootLayer) { m_rootLayer->setBounds(bounds()); - WKCACFContextFlusher::shared().flushAllContexts(); + wkCACFContextFlush(m_context); } } @@ -399,12 +410,12 @@ static void getDirtyRects(HWND window, Vector<CGRect>& outRects) outRects[i] = winRectToCGRect(*rect, clientRect); } -void WKCACFLayerRenderer::renderTimerFired(Timer<WKCACFLayerRenderer>*) +void CACFLayerTreeHost::renderTimerFired(Timer<CACFLayerTreeHost>*) { paint(); } -void WKCACFLayerRenderer::paint() +void CACFLayerTreeHost::paint() { createRenderer(); if (!m_d3dDevice) { @@ -414,11 +425,11 @@ void WKCACFLayerRenderer::paint() } Vector<CGRect> dirtyRects; - getDirtyRects(m_hostWindow, dirtyRects); + getDirtyRects(m_window, dirtyRects); render(dirtyRects); } -void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) +void CACFLayerTreeHost::render(const Vector<CGRect>& windowDirtyRects) { ASSERT(m_d3dDevice); @@ -428,20 +439,6 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) return; } - if (m_client && !m_client->shouldRender()) { - renderSoon(); - return; - } - - // Sync the layer if needed - if (m_syncLayerChanges) { - m_client->syncCompositingState(); - m_syncLayerChanges = false; - } - - // Flush the root layer to the render tree. - wkCACFContextFlush(m_context); - // All pending animations will have been started with the flush. Fire the animationStarted calls double currentTime = WTF::currentTime(); double currentMediaTime = CACurrentMediaTime(); @@ -521,27 +518,49 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) renderSoon(); } -void WKCACFLayerRenderer::renderSoon() +void CACFLayerTreeHost::renderSoon() { if (!m_renderTimer.isActive()) m_renderTimer.startOneShot(0); } -void WKCACFLayerRenderer::syncCompositingStateSoon() +void CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon() +{ + m_shouldFlushPendingGraphicsLayerChanges = true; + LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this); +} + +void CACFLayerTreeHost::flushPendingLayerChangesNow() { - m_syncLayerChanges = true; + // Calling out to the client could cause our last reference to go away. + RefPtr<CACFLayerTreeHost> protector(this); + + m_isFlushingLayerChanges = true; + + // Flush changes stored up in GraphicsLayers to their underlying PlatformCALayers, if + // requested. + if (m_client && m_shouldFlushPendingGraphicsLayerChanges) { + m_shouldFlushPendingGraphicsLayerChanges = false; + m_client->flushPendingGraphicsLayerChanges(); + } + + // Flush changes stored up in PlatformCALayers to the context so they will be rendered. + wkCACFContextFlush(m_context); + renderSoon(); + + m_isFlushingLayerChanges = false; } -CGRect WKCACFLayerRenderer::bounds() const +CGRect CACFLayerTreeHost::bounds() const { RECT clientRect; - GetClientRect(m_hostWindow, &clientRect); + GetClientRect(m_window, &clientRect); return winRectToCGRect(clientRect); } -void WKCACFLayerRenderer::initD3DGeometry() +void CACFLayerTreeHost::initD3DGeometry() { ASSERT(m_d3dDevice); @@ -558,7 +577,7 @@ void WKCACFLayerRenderer::initD3DGeometry() m_d3dDevice->SetTransform(D3DTS_PROJECTION, &projection); } -bool WKCACFLayerRenderer::resetDevice(ResetReason reason) +bool CACFLayerTreeHost::resetDevice(ResetReason reason) { ASSERT(m_d3dDevice); ASSERT(m_context); diff --git a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h index 02cdbdb..fc61f39 100644 --- a/Source/WebCore/platform/graphics/win/WKCACFLayerRenderer.h +++ b/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h @@ -23,8 +23,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKCACFLayerRenderer_h -#define WKCACFLayerRenderer_h +#ifndef CACFLayerTreeHost_h +#define CACFLayerTreeHost_h #if USE(ACCELERATED_COMPOSITING) @@ -32,9 +32,8 @@ #include "Timer.h" #include <wtf/HashSet.h> -#include <wtf/Noncopyable.h> -#include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> #include <wtf/RefPtr.h> #include <wtf/RetainPtr.h> #include <wtf/Vector.h> @@ -50,43 +49,45 @@ namespace WebCore { class PlatformCALayer; -class WKCACFLayerRendererClient { +class CACFLayerTreeHostClient { public: - virtual ~WKCACFLayerRendererClient() { } - virtual bool shouldRender() const = 0; - virtual void syncCompositingState() { } + virtual ~CACFLayerTreeHostClient() { } + virtual void flushPendingGraphicsLayerChanges() { } }; -// FIXME: Currently there is a WKCACFLayerRenderer for each WebView and each +// FIXME: Currently there is a CACFLayerTreeHost for each WebView and each // has its own CARenderOGLContext and Direct3DDevice9, which is inefficient. // (https://bugs.webkit.org/show_bug.cgi?id=31855) -class WKCACFLayerRenderer : public Noncopyable { +class CACFLayerTreeHost : public RefCounted<CACFLayerTreeHost> { friend PlatformCALayer; public: - static PassOwnPtr<WKCACFLayerRenderer> create(WKCACFLayerRendererClient*); - ~WKCACFLayerRenderer(); + static PassRefPtr<CACFLayerTreeHost> create(); + ~CACFLayerTreeHost(); static bool acceleratedCompositingAvailable(); + void setClient(CACFLayerTreeHostClient* client) { m_client = client; } + void setRootChildLayer(PlatformCALayer*); void layerTreeDidChange(); - void setHostWindow(HWND); + void setWindow(HWND); void paint(); void resize(); - void syncCompositingStateSoon(); + void flushPendingGraphicsLayerChangesSoon(); + void flushPendingLayerChangesNow(); protected: PlatformCALayer* rootLayer() const; void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>); private: - WKCACFLayerRenderer(WKCACFLayerRendererClient*); + CACFLayerTreeHost(); bool createRenderer(); void destroyRenderer(); void renderSoon(); - void renderTimerFired(Timer<WKCACFLayerRenderer>*); + void renderTimerFired(Timer<CACFLayerTreeHost>*); CGRect bounds() const; @@ -100,16 +101,17 @@ private: void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>()); - WKCACFLayerRendererClient* m_client; + CACFLayerTreeHostClient* m_client; bool m_mightBeAbleToCreateDeviceLater; COMPtr<IDirect3DDevice9> m_d3dDevice; RefPtr<PlatformCALayer> m_rootLayer; RefPtr<PlatformCALayer> m_rootChildLayer; WKCACFContext* m_context; - HWND m_hostWindow; - Timer<WKCACFLayerRenderer> m_renderTimer; + HWND m_window; + Timer<CACFLayerTreeHost> m_renderTimer; bool m_mustResetLostDeviceBeforeRendering; - bool m_syncLayerChanges; + bool m_shouldFlushPendingGraphicsLayerChanges; + bool m_isFlushingLayerChanges; HashSet<RefPtr<PlatformCALayer> > m_pendingAnimatedLayers; #ifndef NDEBUG @@ -121,4 +123,4 @@ private: #endif // USE(ACCELERATED_COMPOSITING) -#endif // WKCACFLayerRenderer_h +#endif // CACFLayerTreeHost_h diff --git a/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp new file mode 100644 index 0000000..3fd857b --- /dev/null +++ b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2011 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE 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 "LayerChangesFlusher.h" + +#if USE(ACCELERATED_COMPOSITING) + +#include "CACFLayerTreeHost.h" +#include "WebCoreInstanceHandle.h" +#include <wtf/StdLibExtras.h> +#include <wtf/Vector.h> + +namespace WebCore { + +LayerChangesFlusher& LayerChangesFlusher::shared() +{ + DEFINE_STATIC_LOCAL(LayerChangesFlusher, flusher, ()); + return flusher; +} + +LayerChangesFlusher::LayerChangesFlusher() + : m_hook(0) + , m_isCallingHosts(false) +{ +} + +void LayerChangesFlusher::flushPendingLayerChangesSoon(CACFLayerTreeHost* host) +{ + if (!m_hostsWithChangesToFlush.add(host).second || m_hook) + return; + + setHook(); +} + +void LayerChangesFlusher::cancelPendingFlush(CACFLayerTreeHost* host) +{ + m_hostsWithChangesToFlush.remove(host); + + if (!m_hostsWithChangesToFlush.isEmpty() || !m_hook) + return; + + // We handle removing the hook when we finish calling out to the hosts, so we shouldn't + // mess with it while we're in the process of calling them. + if (m_isCallingHosts) + return; + + removeHook(); +} + +LRESULT LayerChangesFlusher::hookCallback(int code, WPARAM wParam, LPARAM lParam) +{ + return shared().hookFired(code, wParam, lParam); +} + +LRESULT LayerChangesFlusher::hookFired(int code, WPARAM wParam, LPARAM lParam) +{ + ASSERT(m_hook); + + // Calling out to the hosts can cause m_hostsWithChangesToFlush to be modified, so we copy it + // into a Vector first. We have to hold a reference to them because otherwise they could be + // destroyed while we're calling out to them. + Vector<RefPtr<CACFLayerTreeHost> > hosts; + copyToVector(m_hostsWithChangesToFlush, hosts); + m_hostsWithChangesToFlush.clear(); + + m_isCallingHosts = true; + for (size_t i = 0; i < hosts.size(); ++i) + hosts[i]->flushPendingLayerChangesNow(); + m_isCallingHosts = false; + + LRESULT result = ::CallNextHookEx(m_hook, code, wParam, lParam); + + if (m_hostsWithChangesToFlush.isEmpty()) { + // We won't have any work to do next time around, so just remove our hook. + removeHook(); + } + + return result; +} + +void LayerChangesFlusher::setHook() +{ + ASSERT(!m_hook); + ASSERT(!m_isCallingHosts); + + DWORD threadID = ::GetCurrentThreadId(); + + m_hook = ::SetWindowsHookExW(WH_GETMESSAGE, hookCallback, instanceHandle(), threadID); + ASSERT_WITH_MESSAGE(m_hook, "::SetWindowsHookExW failed with error %lu", ::GetLastError()); + + // Post a message to the message queue to prevent ::GetMessage from blocking, which will ensure + // our hook is called soon. + ::PostThreadMessageW(threadID, WM_NULL, 0, 0); +} + +void LayerChangesFlusher::removeHook() +{ + ASSERT(m_hook); + ASSERT(!m_isCallingHosts); + + if (!::UnhookWindowsHookEx(m_hook)) + ASSERT_WITH_MESSAGE(false, "::UnhookWindowsHookEx failed with error %lu", ::GetLastError()); + + m_hook = 0; +} + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.h b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h index 17ec41d..6a98a99 100644 --- a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.h +++ b/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,41 +20,46 @@ * 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. */ -#ifndef WKCACFContextFlusher_h -#define WKCACFContextFlusher_h +#ifndef LayerChangesFlusher_h +#define LayerChangesFlusher_h #if USE(ACCELERATED_COMPOSITING) -#include <wtf/Noncopyable.h> - +#include <windows.h> #include <wtf/HashSet.h> - -struct WKCACFContext; +#include <wtf/Noncopyable.h> namespace WebCore { -class WKCACFContextFlusher : public Noncopyable { -public: - static WKCACFContextFlusher& shared(); +class CACFLayerTreeHost; - void addContext(WKCACFContext*); - void removeContext(WKCACFContext*); +class LayerChangesFlusher { + WTF_MAKE_NONCOPYABLE(LayerChangesFlusher); +public: + static LayerChangesFlusher& shared(); - void flushAllContexts(); + void flushPendingLayerChangesSoon(CACFLayerTreeHost*); + void cancelPendingFlush(CACFLayerTreeHost*); private: - WKCACFContextFlusher(); - ~WKCACFContextFlusher(); + LayerChangesFlusher(); + ~LayerChangesFlusher(); + + static LRESULT CALLBACK hookCallback(int code, WPARAM, LPARAM); + LRESULT hookFired(int code, WPARAM, LPARAM); + void setHook(); + void removeHook(); - typedef HashSet<WKCACFContext*> ContextSet; - ContextSet m_contexts; + HashSet<CACFLayerTreeHost*> m_hostsWithChangesToFlush; + HHOOK m_hook; + bool m_isCallingHosts; }; -} +} // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) -#endif // WKCACFContextFlusher_h +#endif // LayerChangesFlusher_h diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp index 7230cfc..228bb01 100644 --- a/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp +++ b/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp @@ -41,7 +41,7 @@ using namespace WebCore; -static String toCACFFillModeType(PlatformCAAnimation::FillModeType type) +static CFStringRef toCACFFillModeType(PlatformCAAnimation::FillModeType type) { switch (type) { case PlatformCAAnimation::NoFillMode: @@ -49,10 +49,11 @@ static String toCACFFillModeType(PlatformCAAnimation::FillModeType type) case PlatformCAAnimation::Backwards: return kCACFFillModeBackwards; case PlatformCAAnimation::Both: return kCACFFillModeBoth; } - return ""; + ASSERT_NOT_REACHED(); + return 0; } -static PlatformCAAnimation::FillModeType fromCACFFillModeType(const String& string) +static PlatformCAAnimation::FillModeType fromCACFFillModeType(CFStringRef string) { if (string == kCACFFillModeBackwards) return PlatformCAAnimation::Backwards; @@ -63,10 +64,10 @@ static PlatformCAAnimation::FillModeType fromCACFFillModeType(const String& stri return PlatformCAAnimation::Forwards; } -static String toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType type) +static CFStringRef toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType type) { switch (type) { - case PlatformCAAnimation::NoValueFunction: return ""; + case PlatformCAAnimation::NoValueFunction: return 0; case PlatformCAAnimation::RotateX: return kCACFValueFunctionRotateX; case PlatformCAAnimation::RotateY: return kCACFValueFunctionRotateY; case PlatformCAAnimation::RotateZ: return kCACFValueFunctionRotateZ; @@ -79,10 +80,11 @@ static String toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType typ case PlatformCAAnimation::TranslateZ: return kCACFValueFunctionTranslateZ; case PlatformCAAnimation::Translate: return kCACFValueFunctionTranslate; } - return ""; + ASSERT_NOT_REACHED(); + return 0; } -static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(const String string) +static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(CFStringRef string) { if (string == kCACFValueFunctionRotateX) return PlatformCAAnimation::RotateX; @@ -120,14 +122,14 @@ static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(const St return PlatformCAAnimation::NoValueFunction; } -static CACFTimingFunctionRef toCACFTimingFunction(const TimingFunction* timingFunction) +static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunction* timingFunction) { if (!timingFunction) - return CACFTimingFunctionCreate(0.25f, 0.1f, 0.25f, 0.1f); + return RetainPtr<CACFTimingFunctionRef>(AdoptCF, CACFTimingFunctionCreate(0.25f, 0.1f, 0.25f, 0.1f)); if (timingFunction->isCubicBezierTimingFunction()) { const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(timingFunction); - return CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2())); + return RetainPtr<CACFTimingFunctionRef>(AdoptCF, CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2()))); } return CACFTimingFunctionGetFunctionWithName(kCACFTimingFunctionLinear); @@ -162,12 +164,12 @@ PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPa PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation) { - if (String(CACFAnimationGetClass(animation)) == kCACFBasicAnimation) + if (CACFAnimationGetClass(animation) == kCACFBasicAnimation) m_type = Basic; - else if (String(CACFAnimationGetClass(animation)) == kCACFKeyframeAnimation) + else if (CACFAnimationGetClass(animation) == kCACFKeyframeAnimation) m_type = Keyframe; else { - ASSERT(0); + ASSERT_NOT_REACHED(); return; } @@ -289,13 +291,12 @@ PlatformCAAnimation::FillModeType PlatformCAAnimation::fillMode() const void PlatformCAAnimation::setFillMode(FillModeType value) { - RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFFillModeType(value).createCFString()); - CACFAnimationSetFillMode(m_animation.get(), keyPath.get()); + CACFAnimationSetFillMode(m_animation.get(), toCACFFillModeType(value)); } void PlatformCAAnimation::setTimingFunction(const TimingFunction* value) { - CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value)); + CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value).get()); } void PlatformCAAnimation::copyTimingFunctionFrom(const PlatformCAAnimation* value) @@ -330,8 +331,7 @@ PlatformCAAnimation::ValueFunctionType PlatformCAAnimation::valueFunction() cons void PlatformCAAnimation::setValueFunction(ValueFunctionType value) { - RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFValueFunctionType(value).createCFString()); - CACFAnimationSetValueFunction(m_animation.get(), CACFValueFunctionGetFunctionWithName(keyPath.get())); + CACFAnimationSetValueFunction(m_animation.get(), CACFValueFunctionGetFunctionWithName(toCACFValueFunctionType(value))); } void PlatformCAAnimation::setFromValue(float value) @@ -524,7 +524,7 @@ void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*> RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks)); for (size_t i = 0; i < value.size(); ++i) { RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i])); - CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i])); + CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i]).get()); } CACFAnimationSetTimingFunctions(m_animation.get(), array.get()); diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp index 66d0732..b5a26f4 100644 --- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp +++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp @@ -29,10 +29,10 @@ #include "PlatformCALayer.h" +#include "CACFLayerTreeHost.h" #include "Font.h" #include "GraphicsContext.h" #include "PlatformCALayerWinInternal.h" -#include "WKCACFLayerRenderer.h" #include <QuartzCore/CoreAnimationCF.h> #include <WebKitSystemInterface/WebKitSystemInterface.h> #include <wtf/CurrentTime.h> @@ -65,14 +65,14 @@ static CFStringRef toCACFFilterType(PlatformCALayer::FilterType type) } } -static WKCACFLayerRenderer* rendererForLayer(const PlatformCALayer* layer) +static CACFLayerTreeHost* layerTreeHostForLayer(const PlatformCALayer* layer) { - // We need the WKCACFLayerRenderer associated with this layer, which is stored in the UserData of the CACFContext + // We need the CACFLayerTreeHost associated with this layer, which is stored in the UserData of the CACFContext void* userData = wkCACFLayerGetContextUserData(layer->platformLayer()); if (!userData) return 0; - return static_cast<WKCACFLayerRenderer*>(userData); + return static_cast<CACFLayerTreeHost*>(userData); } static PlatformCALayerWinInternal* intern(const PlatformCALayer* layer) @@ -156,8 +156,8 @@ PlatformLayer* PlatformCALayer::platformLayer() const PlatformCALayer* PlatformCALayer::rootLayer() const { - WKCACFLayerRenderer* renderer = rendererForLayer(this); - return renderer ? renderer->rootLayer() : 0; + CACFLayerTreeHost* host = layerTreeHostForLayer(this); + return host ? host->rootLayer() : 0; } void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect) @@ -167,9 +167,9 @@ void PlatformCALayer::setNeedsDisplay(const FloatRect* dirtyRect) void PlatformCALayer::setNeedsCommit() { - WKCACFLayerRenderer* renderer = rendererForLayer(this); - if (renderer) - renderer->layerTreeDidChange(); + CACFLayerTreeHost* host = layerTreeHostForLayer(this); + if (host) + host->layerTreeDidChange(); } void PlatformCALayer::setContentsChanged() @@ -269,10 +269,10 @@ void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation* CACFLayerAddAnimation(m_layer.get(), s.get(), animation->platformAnimation()); setNeedsCommit(); - // Tell the renderer about it so we can fire the start animation event - WKCACFLayerRenderer* renderer = rendererForLayer(this); - if (renderer) - renderer->addPendingAnimatedLayer(this); + // Tell the host about it so we can fire the start animation event + CACFLayerTreeHost* host = layerTreeHostForLayer(this); + if (host) + host->addPendingAnimatedLayer(this); } void PlatformCALayer::removeAnimationForKey(const String& key) @@ -283,7 +283,7 @@ void PlatformCALayer::removeAnimationForKey(const String& key) RetainPtr<CFStringRef> s(AdoptCF, key.createCFString()); CACFLayerRemoveAnimation(m_layer.get(), s.get()); - // We don't "remove" a layer from WKCACFLayerRenderer when it loses an animation. + // We don't "remove" a layer from CACFLayerTreeHost when it loses an animation. // There may be other active animations on the layer and if an animation // callback is fired on a layer without any animations no harm is done. diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp index cdf90db..1697122 100644 --- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp +++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp @@ -31,6 +31,7 @@ #include "Font.h" #include "PlatformCALayer.h" +#include "TextRun.h" #include <QuartzCore/CACFLayer.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h index dac31f8..50ea00f 100644 --- a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h @@ -35,7 +35,8 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); public: FontCustomPlatformData(FT_Face, SharedBuffer*); ~FontCustomPlatformData(); diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp index ac5da3d..51b5ee6 100644 --- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp +++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp @@ -91,6 +91,11 @@ ImageBuffer::~ImageBuffer() cairo_surface_destroy(m_data.m_surface); } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { return m_context.get(); diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index eddf735..bcfc37b 100644 --- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -625,8 +625,8 @@ void GraphicsContext::fillRect(const FloatRect& rect) if (m_state.fillGradient) { CGContextSaveGState(context); - CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); if (hasShadow()) { + CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(rect.width(), rect.height()), 0); CGContextRef layerContext = CGLayerGetContext(layer); m_state.fillGradient->paint(layerContext); @@ -634,6 +634,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) CGLayerRelease(layer); } else { CGContextClipToRect(context, rect); + CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); m_state.fillGradient->paint(this); } CGContextRestoreGState(context); diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp index 023d098..295f632 100644 --- a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp +++ b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp @@ -173,6 +173,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.height() * m_data.m_bytesPerRow; +} + GraphicsContext* ImageBuffer::context() const { return m_context.get(); diff --git a/Source/WebCore/platform/graphics/cg/PatternCG.cpp b/Source/WebCore/platform/graphics/cg/PatternCG.cpp index 94f37b2..cfac15c 100644 --- a/Source/WebCore/platform/graphics/cg/PatternCG.cpp +++ b/Source/WebCore/platform/graphics/cg/PatternCG.cpp @@ -54,8 +54,7 @@ CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran { IntRect tileRect = tileImage()->rect(); - AffineTransform patternTransform = m_patternSpaceTransformation; - patternTransform.multiply(userSpaceTransformation); + AffineTransform patternTransform = userSpaceTransformation * m_patternSpaceTransformation; patternTransform.scaleNonUniform(1, -1); patternTransform.translate(0, -tileRect.height()); diff --git a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp index 99159e6..92861fc 100644 --- a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp @@ -32,6 +32,7 @@ #include "ComplexTextControllerLinux.h" #include "Font.h" +#include "TextRun.h" #include <unicode/normlzr.h> @@ -47,8 +48,6 @@ static int truncateFixedPointToInteger(HB_Fixed value) ComplexTextController::ComplexTextController(const TextRun& run, unsigned startingX, const Font* font) : m_font(font) - , m_startingX(startingX) - , m_offsetX(m_startingX) , m_run(getNormalizedTextRun(run, m_normalizedRun, m_normalizedBuffer)) , m_wordSpacingAdjustment(0) , m_padding(0) @@ -75,7 +74,7 @@ ComplexTextController::ComplexTextController(const TextRun& run, unsigned starti m_item.string = m_run.characters(); m_item.stringLength = m_run.length(); - reset(); + reset(startingX); } ComplexTextController::~ComplexTextController() @@ -137,10 +136,10 @@ void ComplexTextController::setPadding(int padding) m_padPerWordBreak = 0; } -void ComplexTextController::reset() +void ComplexTextController::reset(unsigned offset) { m_indexOfNextScriptRun = 0; - m_offsetX = m_startingX; + m_offsetX = offset; } // Advance to the next script run, returning false when the end of the @@ -277,8 +276,7 @@ void ComplexTextController::setGlyphXPositions(bool isRTL) int logClustersIndex = 0; // Iterate through the glyphs in logical order, flipping for RTL where necessary. - // In RTL mode all variables are positive except m_xPositions, which starts from m_offsetX and runs negative. - // It is fixed up in a second pass below. + // Glyphs are positioned starting from m_offsetX; in RTL mode they go leftwards from there. for (size_t i = 0; i < m_item.num_glyphs; ++i) { while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] < i) logClustersIndex++; @@ -303,16 +301,8 @@ void ComplexTextController::setGlyphXPositions(bool isRTL) position += advance; } - const double width = position; - - // Now that we've computed the total width, do another pass to fix positioning for RTL. - if (isRTL) { - for (size_t i = 0; i < m_item.num_glyphs; ++i) - m_xPositions[i] += width; - } - - m_pixelWidth = std::max(width, 0.0); - m_offsetX += m_pixelWidth; + m_pixelWidth = std::max(position, 0.0); + m_offsetX += m_pixelWidth * rtlFlip; } void ComplexTextController::normalizeSpacesAndMirrorChars(const UChar* source, bool rtl, UChar* destination, int length) diff --git a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h index e264b99..a2aea60 100644 --- a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h +++ b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.h @@ -68,7 +68,7 @@ public: // setPadding sets a number of pixels to be distributed across the TextRun. // WebKit uses this to justify text. void setPadding(int); - void reset(); + void reset(unsigned offset); // Advance to the next script run, returning false when the end of the // TextRun has been reached. bool nextScriptRun(); @@ -86,7 +86,6 @@ public: // Set the x offset for the next script run. This affects the values in // |xPositions| - void setXOffsetToZero() { m_offsetX = 0; } bool rtl() const { return m_run.rtl(); } const uint16_t* glyphs() const { return m_glyphs16; } @@ -114,6 +113,9 @@ public: // return the number of code points in the current script run const unsigned numCodePoints() const { return m_numCodePoints; } + // Return the current pixel position of the controller. + const unsigned offsetX() const { return m_offsetX; } + const FontPlatformData* fontPlatformDataForScriptRun() { return reinterpret_cast<FontPlatformData*>(m_item.font->userData); } private: @@ -137,7 +139,6 @@ private: uint16_t* m_glyphs16; // A vector of 16-bit glyph ids. SkScalar* m_xPositions; // A vector of x positions for each glyph. ssize_t m_indexOfNextScriptRun; // Indexes the script run in |m_run|. - const unsigned m_startingX; // Offset in pixels of the first script run. unsigned m_offsetX; // Offset in pixels to the start of the next script run. unsigned m_pixelWidth; // Width (in px) of the current script run. unsigned m_numCodePoints; // Code points in current script run. diff --git a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm b/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm index 72e3369..227fbe4 100644 --- a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm +++ b/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm @@ -30,7 +30,7 @@ #import "CrossProcessFontLoading.h" #import "../graphics/cocoa/FontPlatformData.h" -#import "ChromiumBridge.h" +#import "PlatformBridge.h" #import <AppKit/NSFont.h> #import <wtf/HashMap.h> @@ -87,7 +87,7 @@ PassRefPtr<MemoryActivatedFont> loadFontFromBrowserProcess(NSFont* nsFont) { ATSFontContainerRef container; // Send cross-process request to load font. - if (!ChromiumBridge::loadFont(nsFont, &container)) + if (!PlatformBridge::loadFont(nsFont, &container)) return 0; ATSFontContainerRef srcFontContainerRef = fontContainerRefFromNSFont(nsFont); diff --git a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp b/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp index 569dff4..2d4ca41 100644 --- a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp @@ -72,15 +72,16 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported) : m_context(context) - , m_size(size) + , m_size(-1, -1) , m_multisampleExtensionSupported(multisampleExtensionSupported) , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) , m_fbo(0) , m_colorBuffer(0) , m_depthStencilBuffer(0) + , m_depthBuffer(0) + , m_stencilBuffer(0) , m_multisampleFBO(0) , m_multisampleColorBuffer(0) - , m_multisampleDepthStencilBuffer(0) , m_internal(new DrawingBufferInternal) { if (!m_context->getExtensions()->supports("GL_CHROMIUM_copy_texture_to_parent_texture")) { @@ -91,6 +92,7 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); m_colorBuffer = generateColorTexture(context, size); createSecondaryBuffers(); + reset(size); } DrawingBuffer::~DrawingBuffer() diff --git a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp index 2c79815..f4c0dee 100644 --- a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp @@ -32,11 +32,11 @@ #include "config.h" #include "FontCache.h" -#include "ChromiumBridge.h" #include "Font.h" #include "FontUtilsChromiumWin.h" #include "HashMap.h" #include "HashSet.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" #include <unicode/uniset.h> #include <wtf/text/StringHash.h> @@ -288,9 +288,9 @@ static bool fontContainsCharacter(const FontPlatformData* fontData, HDC hdc = GetDC(0); HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(hdc, hfont)); int count = GetFontUnicodeRanges(hdc, 0); - if (count == 0 && ChromiumBridge::ensureFontLoaded(hfont)) + if (!count && PlatformBridge::ensureFontLoaded(hfont)) count = GetFontUnicodeRanges(hdc, 0); - if (count == 0) { + if (!count) { LOG_ERROR("Unable to get the font unicode range after second attempt"); SelectObject(hdc, oldFont); ReleaseDC(0, hdc); @@ -362,7 +362,7 @@ static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont winfont->lfStrikeOut = false; winfont->lfCharSet = DEFAULT_CHARSET; winfont->lfOutPrecision = OUT_TT_ONLY_PRECIS; - winfont->lfQuality = ChromiumBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings. + winfont->lfQuality = PlatformBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings. winfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; winfont->lfItalic = fontDescription.italic(); winfont->lfWeight = toGDIFontWeight(fontDescription.weight()); diff --git a/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp b/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp index bd33927..a849a6c 100644 --- a/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp @@ -31,12 +31,12 @@ #include "config.h" #include "FontCache.h" -#include "ChromiumBridge.h" #include "Font.h" #include "FontDescription.h" #include "FontPlatformData.h" #include "Logging.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" #include "SkPaint.h" @@ -57,7 +57,7 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) { - String family = ChromiumBridge::getFontFamilyForCharacters(characters, length); + String family = PlatformBridge::getFontFamilyForCharacters(characters, length); if (family.isEmpty()) return 0; diff --git a/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp index 1a00833..5da4d5a 100644 --- a/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp @@ -32,10 +32,10 @@ #include "config.h" #include "Font.h" -#include "ChromiumBridge.h" #include "FontFallbackList.h" #include "GlyphBuffer.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "PlatformContextSkia.h" #include "SimpleFontData.h" #include "SkiaFontWin.h" @@ -424,7 +424,7 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, success = painter.drawGlyphs(curLen, &glyphs[0], &advances[0], curAdvance); if (!success && executions == 0) { // Ask the browser to load the font for us and retry. - ChromiumBridge::ensureFontLoaded(font->platformData().hfont()); + PlatformBridge::ensureFontLoaded(font->platformData().hfont()); continue; } break; diff --git a/Source/WebCore/platform/graphics/chromium/FontLinux.cpp b/Source/WebCore/platform/graphics/chromium/FontLinux.cpp index f1eadf2..822bbbb 100644 --- a/Source/WebCore/platform/graphics/chromium/FontLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontLinux.cpp @@ -206,6 +206,16 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run, controller.setLetterSpacingAdjustment(letterSpacing()); controller.setPadding(run.padding()); + if (run.rtl()) { + // FIXME: this causes us to shape the text twice -- once to compute the width and then again + // below when actually rendering. Change ComplexTextController to match platform/mac and + // platform/chromium/win by having it store the shaped runs, so we can reuse the results. + controller.reset(point.x() + controller.widthOfFullRun()); + // We need to set the padding again because ComplexTextController layout consumed the value. + // Fixing the above problem would help here too. + controller.setPadding(run.padding()); + } + while (controller.nextScriptRun()) { if (fill) { controller.fontPlatformDataForScriptRun()->setupPaint(&fillPaint); @@ -231,6 +241,7 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon ComplexTextController controller(run, 0, this); controller.setWordSpacingAdjustment(wordSpacing()); controller.setLetterSpacingAdjustment(letterSpacing()); + controller.setPadding(run.padding()); return controller.widthOfFullRun(); } @@ -239,7 +250,7 @@ static int glyphIndexForXPositionInScriptRun(const ComplexTextController& contro // Iterate through the glyphs in logical order, seeing whether targetX falls between the previous // position and halfway through the current glyph. // FIXME: this code probably belongs in ComplexTextController. - int lastX = controller.rtl() ? controller.width() : 0; + int lastX = controller.offsetX() - (controller.rtl() ? -controller.width() : controller.width()); for (int glyphIndex = 0; static_cast<unsigned>(glyphIndex) < controller.length(); ++glyphIndex) { int advance = truncateFixedPointToInteger(controller.advances()[glyphIndex]); int nextX = static_cast<int>(controller.xPositions()[glyphIndex]) + advance / 2; @@ -257,53 +268,29 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, { // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem. - int x = static_cast<int>(xFloat); + int targetX = static_cast<int>(xFloat); // (Mac code ignores includePartialGlyphs, and they don't know what it's // supposed to do, so we just ignore it as well.) ComplexTextController controller(run, 0, this); controller.setWordSpacingAdjustment(wordSpacing()); controller.setLetterSpacingAdjustment(letterSpacing()); - - // If this is RTL text, the first glyph from the left is actually the last - // code point. So we need to know how many code points there are total in - // order to subtract. This is different from the length of the TextRun - // because UTF-16 surrogate pairs are a single code point, but 32-bits long. - // In LTR we leave this as 0 so that we get the correct value for - // |basePosition|, below. - unsigned totalCodePoints = 0; - if (controller.rtl()) { - ssize_t offset = 0; - while (offset < run.length()) { - utf16_to_code_point(run.characters(), run.length(), &offset); - totalCodePoints++; - } + controller.setPadding(run.padding()); + if (run.rtl()) { + // See FIXME in drawComplexText. + controller.reset(controller.widthOfFullRun()); + controller.setPadding(run.padding()); } - unsigned basePosition = totalCodePoints; - - // For RTL: - // code-point order: abcd efg hijkl - // on screen: lkjih gfe dcba - // ^ ^ - // | | - // basePosition--| | - // totalCodePoints----| - // Since basePosition is currently the total number of code-points, the - // first thing we do is decrement it so that it's pointing to the start of - // the current script-run. - // - // For LTR, basePosition is zero so it already points to the start of the - // first script run. + unsigned basePosition = 0; + + int x = controller.offsetX(); while (controller.nextScriptRun()) { - if (controller.rtl()) - basePosition -= controller.numCodePoints(); + int nextX = controller.offsetX(); - if (x >= 0 && static_cast<unsigned>(x) < controller.width()) { - // The x value in question is within this script run. We consider - // each glyph in presentation order and stop when we find the one - // covering this position. - const int glyphIndex = glyphIndexForXPositionInScriptRun(controller, x); + if (std::min(x, nextX) <= targetX && targetX <= std::max(x, nextX)) { + // The x value in question is within this script run. + const int glyphIndex = glyphIndexForXPositionInScriptRun(controller, targetX); // Now that we have a glyph index, we have to turn that into a // code-point index. Because of ligatures, several code-points may @@ -324,10 +311,7 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, return basePosition + controller.numCodePoints() - 1; } - x -= controller.width(); - - if (!controller.rtl()) - basePosition += controller.numCodePoints(); + basePosition += controller.numCodePoints(); } return basePosition; @@ -342,27 +326,21 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, ComplexTextController controller(run, 0, this); controller.setWordSpacingAdjustment(wordSpacing()); controller.setLetterSpacingAdjustment(letterSpacing()); + controller.setPadding(run.padding()); + if (run.rtl()) { + // See FIXME in drawComplexText. + controller.reset(controller.widthOfFullRun()); + controller.setPadding(run.padding()); + } - // Base will point to the x offset for the start of the current script run. Note that, in - // the LTR case, width will be 0. - int base = controller.rtl() ? controller.widthOfFullRun() : 0; - - controller.reset(); + // Iterate through the script runs in logical order, searching for the run covering the positions of interest. while (controller.nextScriptRun() && (fromX == -1 || toX == -1)) { - // ComplexTextController will helpfully accululate the x offsets for different - // script runs for us. For this code, however, we always want the x offsets - // to start from zero so we call this before each script run. - controller.setXOffsetToZero(); - - if (controller.rtl()) - base -= controller.width(); - if (fromX == -1 && from >= 0 && static_cast<unsigned>(from) < controller.numCodePoints()) { // |from| is within this script run. So we index the clusters log to // find which glyph this code-point contributed to and find its x // position. int glyph = controller.logClusters()[from]; - fromX = base + controller.xPositions()[glyph]; + fromX = controller.xPositions()[glyph]; if (controller.rtl()) fromX += truncateFixedPointToInteger(controller.advances()[glyph]); } else @@ -370,22 +348,18 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, if (toX == -1 && to >= 0 && static_cast<unsigned>(to) < controller.numCodePoints()) { int glyph = controller.logClusters()[to]; - toX = base + controller.xPositions()[glyph]; + toX = controller.xPositions()[glyph]; if (controller.rtl()) toX += truncateFixedPointToInteger(controller.advances()[glyph]); } else to -= controller.numCodePoints(); - - if (!controller.rtl()) - base += controller.width(); } // The position in question might be just after the text. - const int endEdge = base; - if (fromX == -1 && !from) - fromX = endEdge; - if (toX == -1 && !to) - toX = endEdge; + if (fromX == -1) + fromX = controller.offsetX(); + if (toX == -1) + toX = controller.offsetX(); ASSERT(fromX != -1 && toX != -1); diff --git a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp index d6c83ec..1022a9f 100644 --- a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp @@ -36,7 +36,7 @@ #include <objidl.h> #include <mlang.h> -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "SkiaFontWin.h" namespace WebCore { @@ -136,7 +136,7 @@ SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const HRESULT hr = ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties); if (S_OK != hr) { - if (ChromiumBridge::ensureFontLoaded(hfont())) { + if (PlatformBridge::ensureFontLoaded(hfont())) { // FIXME: Handle gracefully the error if this call also fails. hr = ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties); diff --git a/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp b/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp index 42942cc..a1ea012 100644 --- a/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp +++ b/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp @@ -31,9 +31,9 @@ #include "config.h" #include "FontPlatformData.h" -#include "ChromiumBridge.h" #include "HarfbuzzSkia.h" #include "NotImplemented.h" +#include "PlatformBridge.h" #include "PlatformString.h" #include "SkPaint.h" @@ -229,7 +229,7 @@ void FontPlatformData::querySystemForRenderStyle() return; } - ChromiumBridge::getRenderStyleForStrike(m_family.data(), (((int)m_textSize) << 2) | (m_typeface->style() & 3), &m_style); + PlatformBridge::getRenderStyleForStrike(m_family.data(), (((int)m_textSize) << 2) | (m_typeface->style() & 3), &m_style); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp index 697cf5e..4393f97 100644 --- a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp +++ b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp @@ -34,12 +34,16 @@ #include "DrawingBuffer.h" #include "FloatRect.h" +#include "FloatSize.h" #include "GraphicsContext3D.h" +#include "internal_glu.h" #include "IntRect.h" +#include "Path.h" #include "PlatformString.h" #include "SharedGraphicsContext3D.h" -#include "SolidFillShader.h" -#include "TexShader.h" +#if PLATFORM(SKIA) +#include "SkPath.h" +#endif #include "Texture.h" #define _USE_MATH_DEFINES @@ -50,17 +54,99 @@ namespace WebCore { +// Number of line segments used to approximate bezier curves. +const int pathTesselation = 30; +typedef void (GLAPIENTRY *TESSCB)(); +typedef WTF::Vector<float> FloatVector; +typedef WTF::Vector<double> DoubleVector; + struct GLES2Canvas::State { State() : m_fillColor(0, 0, 0, 255) , m_alpha(1.0f) , m_compositeOp(CompositeSourceOver) + , m_clippingEnabled(false) + { + } + State(const State& other) + : m_fillColor(other.m_fillColor) + , m_alpha(other.m_alpha) + , m_compositeOp(other.m_compositeOp) + , m_ctm(other.m_ctm) + , m_clippingPaths() // Don't copy; clipping paths are tracked per-state. + , m_clippingEnabled(other.m_clippingEnabled) { } Color m_fillColor; float m_alpha; CompositeOperator m_compositeOp; AffineTransform m_ctm; + WTF::Vector<Path> m_clippingPaths; + bool m_clippingEnabled; +}; + +static inline FloatPoint operator*(const FloatPoint& f, float scale) +{ + return FloatPoint(f.x() * scale, f.y() * scale); +} + +static inline FloatPoint operator*(float scale, const FloatPoint& f) +{ + return FloatPoint(f.x() * scale, f.y() * scale); +} + +static inline FloatSize operator*(const FloatSize& f, float scale) +{ + return FloatSize(f.width() * scale, f.height() * scale); +} + +static inline FloatSize operator*(float scale, const FloatSize& f) +{ + return FloatSize(f.width() * scale, f.height() * scale); +} + +class Quadratic { + public: + Quadratic(FloatPoint a, FloatPoint b, FloatPoint c) : + m_a(a), m_b(b), m_c(c) + { + } + static Quadratic fromBezier(FloatPoint p0, FloatPoint p1, FloatPoint p2) + { + FloatSize p1s(p1.x(), p1.y()); + FloatSize p2s(p2.x(), p2.y()); + FloatPoint b = -2.0f * p0 + 2.0f * p1s; + FloatPoint c = p0 - 2.0f * p1s + p2s; + return Quadratic(p0, b, c); + } + inline FloatPoint evaluate(float t) + { + return m_a + t * (m_b + t * m_c); + } + FloatPoint m_a, m_b, m_c, m_d; +}; + +class Cubic { + public: + Cubic(FloatPoint a, FloatPoint b, FloatPoint c, FloatPoint d) : + m_a(a), m_b(b), m_c(c), m_d(d) + { + } + static Cubic fromBezier(FloatPoint p0, FloatPoint p1, FloatPoint p2, FloatPoint p3) + { + FloatSize p1s(p1.x(), p1.y()); + FloatSize p2s(p2.x(), p2.y()); + FloatSize p3s(p3.x(), p3.y()); + FloatPoint b = -3.0f * p0 + 3.0f * p1s; + FloatPoint c = 3.0f * p0 - 6.0f * p1s + 3.0f * p2s; + FloatPoint d = -1.0f * p0 + 3.0f * p1s - 3.0f * p2s + p3s; + return Cubic(p0, b, c, d); + } + FloatPoint evaluate(float t) + { + return m_a + t * (m_b + t * (m_c + t * m_d)); + } + FloatPoint m_a, m_b, m_c, m_d; }; GLES2Canvas::GLES2Canvas(SharedGraphicsContext3D* context, DrawingBuffer* drawingBuffer, const IntSize& size) @@ -88,7 +174,7 @@ void GLES2Canvas::bindFramebuffer() void GLES2Canvas::clearRect(const FloatRect& rect) { bindFramebuffer(); - if (m_state->m_ctm.isIdentity()) { + if (m_state->m_ctm.isIdentity() && !m_state->m_clippingEnabled) { m_context->scissor(rect); m_context->enable(GraphicsContext3D::SCISSOR_TEST); m_context->clearColor(Color(RGBA32(0))); @@ -102,13 +188,21 @@ void GLES2Canvas::clearRect(const FloatRect& rect) } } +void GLES2Canvas::fillPath(const Path& path) +{ + m_context->applyCompositeOperator(m_state->m_compositeOp); + applyClipping(m_state->m_clippingEnabled); + fillPath(path, m_state->m_fillColor); +} + void GLES2Canvas::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace) { m_context->applyCompositeOperator(m_state->m_compositeOp); + applyClipping(m_state->m_clippingEnabled); m_context->useQuadVertices(); AffineTransform matrix(m_flipMatrix); - matrix.multLeft(m_state->m_ctm); + matrix *= m_state->m_ctm; matrix.translate(rect.x(), rect.y()); matrix.scale(rect.width(), rect.height()); @@ -150,7 +244,24 @@ void GLES2Canvas::scale(const FloatSize& size) void GLES2Canvas::concatCTM(const AffineTransform& affine) { - m_state->m_ctm.multLeft(affine); + m_state->m_ctm *= affine; +} + +void GLES2Canvas::clipPath(const Path& path) +{ + bindFramebuffer(); + checkGLError("bindFramebuffer"); + beginStencilDraw(); + // Red is used so we can see it if it ends up in the color buffer. + Color red(255, 0, 0, 255); + fillPath(path, red); + m_state->m_clippingPaths.append(path); + m_state->m_clippingEnabled = true; +} + +void GLES2Canvas::clipOut(const Path& path) +{ + ASSERT(!"clipOut is unsupported in GLES2Canvas.\n"); } void GLES2Canvas::save() @@ -162,13 +273,30 @@ void GLES2Canvas::save() void GLES2Canvas::restore() { ASSERT(!m_stateStack.isEmpty()); + bool hadClippingPaths = !m_state->m_clippingPaths.isEmpty(); m_stateStack.removeLast(); m_state = &m_stateStack.last(); + if (hadClippingPaths) { + m_context->clear(GraphicsContext3D::STENCIL_BUFFER_BIT); + beginStencilDraw(); + StateVector::const_iterator iter; + for (iter = m_stateStack.begin(); iter < m_stateStack.end(); ++iter) { + const State& state = *iter; + const Vector<Path>& clippingPaths = state.m_clippingPaths; + Vector<Path>::const_iterator pathIter; + for (pathIter = clippingPaths.begin(); pathIter < clippingPaths.end(); ++pathIter) { + // Red is used so we can see it if it ends up in the color buffer. + Color red(255, 0, 0, 255); + fillPath(*pathIter, red); + } + } + } } void GLES2Canvas::drawTexturedRect(unsigned texture, const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp) { m_context->applyCompositeOperator(compositeOp); + applyClipping(false); m_context->useQuadVertices(); m_context->setActiveTexture(GraphicsContext3D::TEXTURE0); @@ -180,13 +308,14 @@ void GLES2Canvas::drawTexturedRect(unsigned texture, const IntSize& textureSize, void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp) { - drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp); + drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp, m_state->m_clippingEnabled); } -void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp) +void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp, bool clip) { m_context->applyCompositeOperator(compositeOp); + applyClipping(clip); const TilingData& tiles = texture->tiles(); IntRect tileIdxRect = tiles.overlappedTileIndices(srcRect); @@ -220,7 +349,7 @@ void GLES2Canvas::drawTexturedRectTile(Texture* texture, int tile, const FloatRe void GLES2Canvas::drawQuad(const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha) { AffineTransform matrix(m_flipMatrix); - matrix.multLeft(transform); + matrix *= transform; matrix.translate(dstRect.x(), dstRect.y()); matrix.scale(dstRect.width(), dstRect.height()); @@ -251,6 +380,214 @@ Texture* GLES2Canvas::getTexture(NativeImagePtr ptr) return m_context->getTexture(ptr); } +#if PLATFORM(SKIA) +// This is actually cross-platform code, but since its only caller is inside a +// PLATFORM(SKIA), it will cause a warning-as-error on Chrome/Mac. +static void interpolateQuadratic(DoubleVector* vertices, const FloatPoint& p0, const FloatPoint& p1, const FloatPoint& p2) +{ + float tIncrement = 1.0f / pathTesselation, t = tIncrement; + Quadratic c = Quadratic::fromBezier(p0, p1, p2); + for (int i = 0; i < pathTesselation; ++i, t += tIncrement) { + FloatPoint p = c.evaluate(t); + vertices->append(p.x()); + vertices->append(p.y()); + vertices->append(1.0); + } +} + +static void interpolateCubic(DoubleVector* vertices, const FloatPoint& p0, const FloatPoint& p1, const FloatPoint& p2, const FloatPoint& p3) +{ + float tIncrement = 1.0f / pathTesselation, t = tIncrement; + Cubic c = Cubic::fromBezier(p0, p1, p2, p3); + for (int i = 0; i < pathTesselation; ++i, t += tIncrement) { + FloatPoint p = c.evaluate(t); + vertices->append(p.x()); + vertices->append(p.y()); + vertices->append(1.0); + } +} +#endif + +struct PolygonData { + PolygonData(FloatVector* vertices, WTF::Vector<short>* indices) + : m_vertices(vertices) + , m_indices(indices) + { + } + FloatVector* m_vertices; + WTF::Vector<short>* m_indices; +}; + +static void beginData(GLenum type, void* data) +{ + ASSERT(type == GL_TRIANGLES); +} + +static void edgeFlagData(GLboolean flag, void* data) +{ +} + +static void vertexData(void* vertexData, void* data) +{ + static_cast<PolygonData*>(data)->m_indices->append(reinterpret_cast<long>(vertexData)); +} + +static void endData(void* data) +{ +} + +static void combineData(GLdouble coords[3], void* vertexData[4], + GLfloat weight[4], void **outData, void* data) +{ + PolygonData* polygonData = static_cast<PolygonData*>(data); + int index = polygonData->m_vertices->size() / 3; + polygonData->m_vertices->append(static_cast<float>(coords[0])); + polygonData->m_vertices->append(static_cast<float>(coords[1])); + polygonData->m_vertices->append(1.0f); + *outData = reinterpret_cast<void*>(index); +} + +typedef void (*TESSCB)(); + +void GLES2Canvas::createVertexBufferFromPath(const Path& path, int* count, unsigned* vertexBuffer, unsigned* indexBuffer) +{ + *vertexBuffer = m_context->graphicsContext3D()->createBuffer(); + checkGLError("createVertexBufferFromPath, createBuffer"); + *indexBuffer = m_context->graphicsContext3D()->createBuffer(); + checkGLError("createVertexBufferFromPath, createBuffer"); + DoubleVector inVertices; + WTF::Vector<size_t> contours; +#if PLATFORM(SKIA) + const SkPath* skPath = path.platformPath(); + SkPoint pts[4]; + SkPath::Iter iter(*skPath, true); + SkPath::Verb verb; + while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { + switch (verb) { + case SkPath::kMove_Verb: + inVertices.append(pts[0].fX); + inVertices.append(pts[0].fY); + inVertices.append(1.0); + break; + case SkPath::kLine_Verb: + inVertices.append(pts[1].fX); + inVertices.append(pts[1].fY); + inVertices.append(1.0); + break; + case SkPath::kQuad_Verb: + interpolateQuadratic(&inVertices, pts[0], pts[1], pts[2]); + break; + case SkPath::kCubic_Verb: + interpolateCubic(&inVertices, pts[0], pts[1], pts[2], pts[3]); + break; + case SkPath::kClose_Verb: + contours.append(inVertices.size() / 3); + break; + case SkPath::kDone_Verb: + break; + } + } +#else + ASSERT(!"Path extraction not implemented on this platform."); +#endif + + GLUtesselator* tess = internal_gluNewTess(); + internal_gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO); + internal_gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (TESSCB) &beginData); + internal_gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (TESSCB) &vertexData); + internal_gluTessCallback(tess, GLU_TESS_END_DATA, (TESSCB) &endData); + internal_gluTessCallback(tess, GLU_TESS_EDGE_FLAG_DATA, (TESSCB) &edgeFlagData); + internal_gluTessCallback(tess, GLU_TESS_COMBINE_DATA, (TESSCB) &combineData); + WTF::Vector<short> indices; + FloatVector vertices; + vertices.reserveInitialCapacity(inVertices.size()); + PolygonData data(&vertices, &indices); + internal_gluTessBeginPolygon(tess, &data); + WTF::Vector<size_t>::const_iterator contour; + size_t i = 0; + for (contour = contours.begin(); contour != contours.end(); ++contour) { + internal_gluTessBeginContour(tess); + for (; i < *contour; ++i) { + vertices.append(inVertices[i * 3]); + vertices.append(inVertices[i * 3 + 1]); + vertices.append(1.0f); + internal_gluTessVertex(tess, &inVertices[i * 3], reinterpret_cast<void*>(i)); + } + internal_gluTessEndContour(tess); + } + internal_gluTessEndPolygon(tess); + internal_gluDeleteTess(tess); + + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, *vertexBuffer); + checkGLError("createVertexBufferFromPath, bindBuffer ARRAY_BUFFER"); + m_context->graphicsContext3D()->bufferData(GraphicsContext3D::ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GraphicsContext3D::STREAM_DRAW); + checkGLError("createVertexBufferFromPath, bufferData ARRAY_BUFFER"); + + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, *indexBuffer); + checkGLError("createVertexBufferFromPath, bindBuffer ELEMENT_ARRAY_BUFFER"); + m_context->graphicsContext3D()->bufferData(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(short), indices.data(), GraphicsContext3D::STREAM_DRAW); + checkGLError("createVertexBufferFromPath, bufferData ELEMENT_ARRAY_BUFFER"); + *count = indices.size(); +} + +void GLES2Canvas::fillPath(const Path& path, const Color& color) +{ + int count; + unsigned vertexBuffer, indexBuffer; + createVertexBufferFromPath(path, &count, &vertexBuffer, &indexBuffer); + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, vertexBuffer); + checkGLError("bindBuffer"); + m_context->graphicsContext3D()->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, indexBuffer); + checkGLError("bindBuffer"); + + AffineTransform matrix(m_flipMatrix); + matrix *= m_state->m_ctm; + + m_context->useFillSolidProgram(matrix, color); + checkGLError("useFillSolidProgram"); + + m_context->graphicsContext3D()->drawElements(GraphicsContext3D::TRIANGLES, count, GraphicsContext3D::UNSIGNED_SHORT, 0); + checkGLError("drawArrays"); + + m_context->graphicsContext3D()->deleteBuffer(vertexBuffer); + checkGLError("deleteBuffer"); + + m_context->graphicsContext3D()->deleteBuffer(indexBuffer); + checkGLError("deleteBuffer"); +} + +void GLES2Canvas::beginStencilDraw() +{ + // Turn on stencil test. + m_context->enableStencil(true); + checkGLError("enable STENCIL_TEST"); + + // Stencil test never passes, so colorbuffer is not drawn. + m_context->graphicsContext3D()->stencilFunc(GraphicsContext3D::NEVER, 1, 1); + checkGLError("stencilFunc"); + + // All writes incremement the stencil buffer. + m_context->graphicsContext3D()->stencilOp(GraphicsContext3D::INCR, + GraphicsContext3D::INCR, + GraphicsContext3D::INCR); + checkGLError("stencilOp"); +} + +void GLES2Canvas::applyClipping(bool enable) +{ + m_context->enableStencil(enable); + if (enable) { + // Enable drawing only where stencil is non-zero. + m_context->graphicsContext3D()->stencilFunc(GraphicsContext3D::EQUAL, m_state->m_clippingPaths.size() % 256, 1); + checkGLError("stencilFunc"); + // Keep all stencil values the same. + m_context->graphicsContext3D()->stencilOp(GraphicsContext3D::KEEP, + GraphicsContext3D::KEEP, + GraphicsContext3D::KEEP); + checkGLError("stencilOp"); + } +} + void GLES2Canvas::checkGLError(const char* header) { #ifndef NDEBUG @@ -283,4 +620,3 @@ void GLES2Canvas::checkGLError(const char* header) } } - diff --git a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h index 6fc1a0e..605f86f 100644 --- a/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h +++ b/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h @@ -48,13 +48,16 @@ class Color; class DrawingBuffer; class FloatRect; class GraphicsContext3D; +class Path; class SharedGraphicsContext3D; -class GLES2Canvas : public Noncopyable { +class GLES2Canvas { + WTF_MAKE_NONCOPYABLE(GLES2Canvas); public: GLES2Canvas(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&); ~GLES2Canvas(); + void fillPath(const Path&); void fillRect(const FloatRect&, const Color&, ColorSpace); void fillRect(const FloatRect&); void clearRect(const FloatRect&); @@ -65,6 +68,8 @@ public: void rotate(float angleInRadians); void scale(const FloatSize&); void concatCTM(const AffineTransform&); + void clipPath(const Path&); + void clipOut(const Path&); void save(); void restore(); @@ -72,9 +77,13 @@ public: // non-standard functions // These are not standard GraphicsContext functions, and should be pushed // down into a PlatformContextGLES2 at some point. + + // This version is called by the canvas->canvas draws. void drawTexturedRect(unsigned texture, const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator); - void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator); + // This version is called by BitmapImage::draw(). void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator); + // This version is called by the above, and by the software->hardware uploads. + void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator, bool clip); Texture* createTexture(NativeImagePtr, Texture::Format, int width, int height); Texture* getTexture(NativeImagePtr); @@ -88,6 +97,10 @@ private: void drawTexturedRectTile(Texture* texture, int tile, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha); void drawQuad(const IntSize& textureSize, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha); void applyCompositeOperator(CompositeOperator); + void createVertexBufferFromPath(const Path&, int* count, unsigned* vertexBuffer, unsigned* indexBuffer); + void fillPath(const Path&, const Color&); + void beginStencilDraw(); + void applyClipping(bool enable); void checkGLError(const char* header); IntSize m_size; @@ -96,7 +109,8 @@ private: DrawingBuffer* m_drawingBuffer; struct State; - WTF::Vector<State> m_stateStack; + typedef WTF::Vector<State> StateVector; + StateVector m_stateStack; State* m_state; AffineTransform m_flipMatrix; }; diff --git a/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp index e71f66a..ee2b5ab 100644 --- a/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp @@ -32,9 +32,9 @@ #include <windows.h> #include <vector> -#include "ChromiumBridge.h" #include "Font.h" #include "GlyphPageTreeNode.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" #include "UniscribeHelperTextRun.h" #include "WindowsVersion.h" @@ -80,12 +80,11 @@ static bool fillBMPGlyphs(unsigned offset, ReleaseDC(0, dc); if (recurse) { - if (ChromiumBridge::ensureFontLoaded(fontData->platformData().hfont())) + if (PlatformBridge::ensureFontLoaded(fontData->platformData().hfont())) return fillBMPGlyphs(offset, length, buffer, page, fontData, false); - else { - fillEmptyGlyphs(page); - return false; - } + + fillEmptyGlyphs(page); + return false; } else { // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401 diff --git a/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp index e90d566..e2b6f7a 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "Image.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" namespace WebCore { @@ -39,7 +39,7 @@ namespace WebCore { PassRefPtr<Image> Image::loadPlatformResource(const char *name) { - return ChromiumBridge::loadPlatformImageResource(name); + return PlatformBridge::loadPlatformImageResource(name); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm b/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm index 073a409..f003894 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm +++ b/Source/WebCore/platform/graphics/chromium/ImageChromiumMac.mm @@ -33,14 +33,14 @@ #include "config.h" #include "BitmapImage.h" -#include "ChromiumBridge.h" #include "Image.h" +#include "PlatformBridge.h" namespace WebCore { PassRefPtr<Image> Image::loadPlatformResource(const char* name) { - return ChromiumBridge::loadPlatformImageResource(name); + return PlatformBridge::loadPlatformImageResource(name); } // FIXME: These are temporary stubs, we need real implementations which diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp index 8d77bea..90eac74 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp @@ -119,12 +119,6 @@ LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> conte LayerRendererChromium::~LayerRendererChromium() { cleanupSharedObjects(); - - // Because the tilers need to clean up textures, clean them up explicitly - // before the GraphicsContext3D is destroyed. - m_rootLayerTiler.clear(); - m_horizontalScrollbarTiler.clear(); - m_verticalScrollbarTiler.clear(); } GraphicsContext3D* LayerRendererChromium::context() @@ -269,6 +263,9 @@ void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect updateAndDrawRootLayer(tilePaint, scrollbarPaint, visibleRect, contentRect); + // Re-enable color writes to layers, which may be partially transparent. + m_context->colorMask(true, true, true, true); + // Set the root visible/content rects --- used by subsequent drawLayers calls. m_rootVisibleRect = visibleRect; m_rootContentRect = contentRect; @@ -795,6 +792,11 @@ void LayerRendererChromium::cleanupSharedObjects() if (m_offscreenFramebufferId) GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId)); + // Clear tilers before the texture manager, as they have references to textures. + m_rootLayerTiler.clear(); + m_horizontalScrollbarTiler.clear(); + m_verticalScrollbarTiler.clear(); + m_textureManager.clear(); } diff --git a/Source/WebCore/platform/graphics/chromium/LayerTexture.h b/Source/WebCore/platform/graphics/chromium/LayerTexture.h index 711e687..b60dff2 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTexture.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTexture.h @@ -28,6 +28,7 @@ #include "IntSize.h" #include "TextureManager.h" +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> #include <wtf/RefPtr.h> @@ -37,7 +38,8 @@ namespace WebCore { class GraphicsContext3D; class TextureManager; -class LayerTexture : public Noncopyable { +class LayerTexture { + WTF_MAKE_NONCOPYABLE(LayerTexture); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<LayerTexture> create(GraphicsContext3D* context, TextureManager* manager) { diff --git a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp index b4b4a72..6b65e66 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp @@ -33,6 +33,7 @@ #include "GraphicsContext.h" #include "GraphicsContext3D.h" #include "LayerRendererChromium.h" +#include "LayerTexture.h" #if PLATFORM(SKIA) #include "NativeImageSkia.h" @@ -54,7 +55,8 @@ PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* } LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize) - : m_layerRenderer(layerRenderer) + : m_skipsDraw(false) + , m_layerRenderer(layerRenderer) { setTileSize(tileSize); } @@ -83,17 +85,7 @@ void LayerTilerChromium::setTileSize(const IntSize& size) void LayerTilerChromium::reset() { - for (size_t i = 0; i < m_tiles.size(); ++i) { - if (!m_tiles[i]) - continue; - layerRenderer()->deleteLayerTexture(m_tiles[i]->releaseTextureId()); - } m_tiles.clear(); - for (size_t i = 0; i < m_unusedTiles.size(); ++i) { - if (!m_unusedTiles[i]) - continue; - layerRenderer()->deleteLayerTexture(m_unusedTiles[i]->releaseTextureId()); - } m_unusedTiles.clear(); m_layerSize = IntSize(); @@ -110,12 +102,9 @@ LayerTilerChromium::Tile* LayerTilerChromium::createTile(int i, int j) m_tiles[index] = m_unusedTiles.last().release(); m_unusedTiles.removeLast(); } else { - const unsigned int textureId = layerRenderer()->createLayerTexture(); - OwnPtr<Tile> tile = adoptPtr(new Tile(textureId)); - GraphicsContext3D* context = layerRendererContext(); - GLC(context, context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_tileSize.width(), m_tileSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE)); - + TextureManager* manager = layerRenderer()->textureManager(); + OwnPtr<Tile> tile = adoptPtr(new Tile(LayerTexture::create(context, manager))); m_tiles[index] = tile.release(); } @@ -238,6 +227,9 @@ void LayerTilerChromium::invalidateEntireLayer() void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& contentRect) { + if (m_skipsDraw) + return; + // Invalidate old tiles that were previously used but aren't in use this // frame so that they can get reused for new tiles. IntRect layerRect = contentRectToLayerRect(contentRect); @@ -256,6 +248,8 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont Tile* tile = m_tiles[tileIndex(i, j)].get(); if (!tile) tile = createTile(i, j); + if (!tile->texture()->isValid(m_tileSize, GraphicsContext3D::RGBA)) + tile->m_dirtyLayerRect = tileLayerRect(i, j); dirtyLayerRect.unite(tile->m_dirtyLayerRect); } } @@ -318,6 +312,12 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont if (sourceRect.isEmpty()) continue; + if (!tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA)) { + m_skipsDraw = true; + reset(); + return; + } + // Calculate tile-space rectangle to upload into. IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size()); ASSERT(destRect.x() >= 0); @@ -342,7 +342,7 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont pixelSource = &m_tilePixels[0]; } - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId())); + tile->texture()->bindTexture(); GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource)); tile->clearDirty(); @@ -357,6 +357,9 @@ void LayerTilerChromium::setLayerPosition(const IntPoint& layerPosition) void LayerTilerChromium::draw(const IntRect& contentRect) { + if (m_skipsDraw) + return; + // We reuse the shader program used by ContentLayerChromium. GraphicsContext3D* context = layerRendererContext(); const ContentLayerChromium::SharedValues* contentLayerValues = layerRenderer()->contentLayerSharedValues(); @@ -370,13 +373,15 @@ void LayerTilerChromium::draw(const IntRect& contentRect) Tile* tile = m_tiles[tileIndex(i, j)].get(); ASSERT(tile); - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId())); + tile->texture()->bindTexture(); TransformationMatrix tileMatrix; IntRect tileRect = tileContentRect(i, j); tileMatrix.translate3d(tileRect.x() - contentRect.x() + tileRect.width() / 2.0, tileRect.y() - contentRect.y() + tileRect.height() / 2.0, 0); LayerChromium::drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, m_tileSize.width(), m_tileSize.height(), 1, contentLayerValues->shaderMatrixLocation(), contentLayerValues->shaderAlphaLocation()); + + tile->texture()->unreserve(); } } } @@ -410,21 +415,6 @@ void LayerTilerChromium::growLayerToContain(const IntRect& contentRect) resizeLayer(newSize); } -LayerTilerChromium::Tile::~Tile() -{ - // Each tile doesn't have a reference to the context, so can't clean up - // its own texture. If this assert is hit, then the LayerTilerChromium - // destructor didn't clean this up. - ASSERT(!m_textureId); -} - -unsigned int LayerTilerChromium::Tile::releaseTextureId() -{ - unsigned int id = m_textureId; - m_textureId = 0; - return id; -} - } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h index c066fdf..e09693d 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h @@ -30,6 +30,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "LayerChromium.h" +#include "LayerTexture.h" #include <wtf/OwnArrayPtr.h> namespace WebCore { @@ -42,7 +43,8 @@ public: virtual void paint(GraphicsContext& context, const IntRect& contentRect) = 0; }; -class LayerTilerChromium : public Noncopyable { +class LayerTilerChromium { + WTF_MAKE_NONCOPYABLE(LayerTilerChromium); public: static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium* layerRenderer, const IntSize& tileSize); @@ -62,12 +64,11 @@ private: LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize); class Tile { + WTF_MAKE_NONCOPYABLE(Tile); public: - explicit Tile(unsigned int textureId) : m_textureId(textureId) { } - ~Tile(); + explicit Tile(PassOwnPtr<LayerTexture> tex) : m_tex(tex) {} - unsigned int textureId() const { return m_textureId; } - unsigned int releaseTextureId(); + LayerTexture* texture() { return m_tex.get(); } bool dirty() const { return !m_dirtyLayerRect.isEmpty(); } void clearDirty() { m_dirtyLayerRect = IntRect(); } @@ -75,7 +76,7 @@ private: // Layer-space dirty rectangle that needs to be repainted. IntRect m_dirtyLayerRect; private: - unsigned int m_textureId; + OwnPtr<LayerTexture> m_tex; }; void resizeLayer(const IntSize& size); @@ -105,6 +106,8 @@ private: IntRect m_lastUpdateLayerRect; IntPoint m_layerPosition; + bool m_skipsDraw; + // Logical 2D array of tiles (dimensions of m_layerTileSize) Vector<OwnPtr<Tile> > m_tiles; // Linear array of unused tiles. diff --git a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h index a93218f..689a6eb 100644 --- a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h +++ b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h @@ -41,7 +41,8 @@ class LayerChromium; class LayerRendererChromium; class LayerTexture; -class RenderSurfaceChromium : public Noncopyable { +class RenderSurfaceChromium { + WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium); friend class LayerRendererChromium; public: explicit RenderSurfaceChromium(LayerChromium*); diff --git a/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp index 204c565..c23c586 100644 --- a/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp @@ -32,11 +32,11 @@ #include "config.h" #include "SimpleFontData.h" -#include "ChromiumBridge.h" +#include "FloatRect.h" #include "Font.h" #include "FontCache.h" -#include "FloatRect.h" #include "FontDescription.h" +#include "PlatformBridge.h" #include <wtf/MathExtras.h> #include <unicode/uchar.h> @@ -70,7 +70,7 @@ void SimpleFontData::platformInit() TEXTMETRIC textMetric = {0}; if (!GetTextMetrics(dc, &textMetric)) { - if (ChromiumBridge::ensureFontLoaded(m_platformData.hfont())) { + if (PlatformBridge::ensureFontLoaded(m_platformData.hfont())) { // Retry GetTextMetrics. // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401. @@ -159,7 +159,7 @@ void SimpleFontData::determinePitch() // is *not* fixed pitch. Unbelievable but true. TEXTMETRIC textMetric = {0}; if (!GetTextMetrics(dc, &textMetric)) { - if (ChromiumBridge::ensureFontLoaded(m_platformData.hfont())) { + if (PlatformBridge::ensureFontLoaded(m_platformData.hfont())) { // Retry GetTextMetrics. // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401. @@ -190,7 +190,7 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const int width = 0; if (!GetCharWidthI(dc, glyph, 1, 0, &width)) { // Ask the browser to preload the font and retry. - if (ChromiumBridge::ensureFontLoaded(m_platformData.hfont())) { + if (PlatformBridge::ensureFontLoaded(m_platformData.hfont())) { // FIXME: Handle gracefully the error if this call also fails. // See http://crbug.com/6401. if (!GetCharWidthI(dc, glyph, 1, 0, &width)) diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.h b/Source/WebCore/platform/graphics/chromium/TextureManager.h index 4891cc7..83104a9 100644 --- a/Source/WebCore/platform/graphics/chromium/TextureManager.h +++ b/Source/WebCore/platform/graphics/chromium/TextureManager.h @@ -29,6 +29,7 @@ #include "IntRect.h" #include "IntSize.h" +#include <wtf/FastAllocBase.h> #include <wtf/HashMap.h> #include <wtf/ListHashSet.h> @@ -36,7 +37,8 @@ namespace WebCore { typedef int TextureToken; -class TextureManager : public Noncopyable { +class TextureManager { + WTF_MAKE_NONCOPYABLE(TextureManager); public: static PassOwnPtr<TextureManager> create(GraphicsContext3D* context, size_t memoryLimitBytes, int maxTextureSize) { diff --git a/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp b/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp index 4dc2157..ba66eae 100644 --- a/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp +++ b/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp @@ -252,7 +252,7 @@ void TransparencyWin::setupLayerForOpaqueCompositeLayer() if (m_transformMode == Untransform){ // Compute the inverse mapping from the canvas space to the // coordinate space of our bitmap. - mapping = m_orgTransform.inverse() * mapping; + mapping *= m_orgTransform.inverse(); } compositeToCopy(*m_destContext, *m_drawContext, mapping); @@ -313,7 +313,7 @@ void TransparencyWin::setupTransformForKeepTransform(const IntRect& region) // We're making a layer, so apply the old transform to the new one // so it's maintained. We know the new layer has the identity // transform now, we we can just multiply it. - xform = m_orgTransform * xform; + xform *= m_orgTransform; m_drawContext->concatCTM(xform); } m_drawRect = m_sourceRect; diff --git a/Source/WebCore/platform/graphics/chromium/TransparencyWin.h b/Source/WebCore/platform/graphics/chromium/TransparencyWin.h index b6bef91..535cbaa 100644 --- a/Source/WebCore/platform/graphics/chromium/TransparencyWin.h +++ b/Source/WebCore/platform/graphics/chromium/TransparencyWin.h @@ -54,7 +54,8 @@ class TransparencyWin_OpaqueCompositeLayer_Test; // that is composited later manually. This is to get around Windows' inability // to handle the alpha channel, semitransparent text, and transformed form // controls. -class TransparencyWin : public Noncopyable { +class TransparencyWin { + WTF_MAKE_NONCOPYABLE(TransparencyWin); public: enum LayerMode { // No extra layer is created. Drawing will happen to the source. diff --git a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp b/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp index f801c13..aa18b4a 100644 --- a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp +++ b/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp @@ -31,9 +31,10 @@ #include "config.h" #include "UniscribeHelperTextRun.h" -#include "ChromiumBridge.h" #include "Font.h" +#include "PlatformBridge.h" #include "SimpleFontData.h" +#include "TextRun.h" namespace WebCore { @@ -79,7 +80,7 @@ void UniscribeHelperTextRun::tryToPreloadFont(HFONT font) // Ask the browser to get the font metrics for this font. // That will preload the font and it should now be accessible // from the renderer. - ChromiumBridge::ensureFontLoaded(font); + PlatformBridge::ensureFontLoaded(font); } bool UniscribeHelperTextRun::nextWinFontData( diff --git a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp index 81264b3..776b83f 100644 --- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp @@ -264,6 +264,7 @@ unsigned VideoLayerChromium::determineTextureFormat(VideoFrameChromium* frame) { switch (frame->format()) { case VideoFrameChromium::YV12: + case VideoFrameChromium::YV16: return GraphicsContext3D::LUMINANCE; case VideoFrameChromium::RGBA: return GraphicsContext3D::RGBA; @@ -330,6 +331,7 @@ void VideoLayerChromium::draw() switch (m_frameFormat) { case VideoFrameChromium::YV12: + case VideoFrameChromium::YV16: drawYUV(sv); break; case VideoFrameChromium::RGBA: diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp index c283068..dae83a2 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp @@ -67,16 +67,21 @@ void DrawingBuffer::clear() m_multisampleColorBuffer = 0; } - if (m_multisampleDepthStencilBuffer) { - m_context->deleteRenderbuffer(m_multisampleDepthStencilBuffer); - m_multisampleDepthStencilBuffer = 0; - } - if (m_depthStencilBuffer) { m_context->deleteRenderbuffer(m_depthStencilBuffer); m_depthStencilBuffer = 0; } + if (m_depthBuffer) { + m_context->deleteRenderbuffer(m_depthBuffer); + m_depthBuffer = 0; + } + + if (m_stencilBuffer) { + m_context->deleteRenderbuffer(m_stencilBuffer); + m_stencilBuffer = 0; + } + if (m_multisampleFBO) { m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); m_context->deleteFramebuffer(m_multisampleFBO); @@ -92,22 +97,52 @@ void DrawingBuffer::clear() void DrawingBuffer::createSecondaryBuffers() { - const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - - // Create the stencil and depth buffer if needed - if (!multisample() && (attributes.stencil || attributes.depth)) - m_depthStencilBuffer = m_context->createRenderbuffer(); - // create a multisample FBO if (multisample()) { m_multisampleFBO = m_context->createFramebuffer(); m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); m_multisampleColorBuffer = m_context->createRenderbuffer(); - if (attributes.stencil || attributes.depth) - m_multisampleDepthStencilBuffer = m_context->createRenderbuffer(); } } +void DrawingBuffer::resizeDepthStencil(int sampleCount) +{ + const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); + if (attributes.depth && attributes.stencil && m_packedDepthStencilExtensionSupported) { + if (!m_depthStencilBuffer) + m_depthStencilBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, Extensions3D::DEPTH24_STENCIL8, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, Extensions3D::DEPTH24_STENCIL8, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + } else { + if (attributes.depth) { + if (!m_depthBuffer) + m_depthBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, GraphicsContext3D::DEPTH_COMPONENT16, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + } + if (attributes.stencil) { + if (!m_stencilBuffer) + m_stencilBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, GraphicsContext3D::STENCIL_INDEX8, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + } + } + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); +} + void DrawingBuffer::reset(const IntSize& newSize) { if (m_size == newSize) @@ -120,7 +155,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->makeContextCurrent(); const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - unsigned long internalColorFormat, colorFormat, internalDepthStencilFormat = 0; + unsigned long internalColorFormat, colorFormat; if (attributes.alpha) { internalColorFormat = GraphicsContext3D::RGBA; colorFormat = GraphicsContext3D::RGBA; @@ -128,17 +163,7 @@ void DrawingBuffer::reset(const IntSize& newSize) internalColorFormat = GraphicsContext3D::RGB; colorFormat = GraphicsContext3D::RGB; } - if (attributes.stencil || attributes.depth) { - // We don't allow the logic where stencil is required and depth is not. - // See GraphicsContext3D constructor. - // FIXME: If packed depth/stencil is not supported, we should - // create separate renderbuffers for depth and stencil. - if (attributes.stencil && attributes.depth && m_packedDepthStencilExtensionSupported) - internalDepthStencilFormat = Extensions3D::DEPTH24_STENCIL8; - else - internalDepthStencilFormat = GraphicsContext3D::DEPTH_COMPONENT16; - } // resize multisample FBO if (multisample()) { @@ -152,15 +177,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalColorFormat, m_size.width(), m_size.height()); m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); - if (attributes.stencil || attributes.depth) { - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalDepthStencilFormat, m_size.width(), m_size.height()); - if (attributes.stencil) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - if (attributes.depth) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - } - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); + resizeDepthStencil(sampleCount); if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { // Cleanup clear(); @@ -175,15 +192,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE); m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0); m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); - if (!multisample() && (attributes.stencil || attributes.depth)) { - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, internalDepthStencilFormat, m_size.width(), m_size.height()); - if (attributes.stencil) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - if (attributes.depth) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); - } + resizeDepthStencil(0); if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { // Cleanup clear(); diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h index e0e0ee1..49ae114 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h @@ -67,6 +67,8 @@ public: // Create the depth/stencil and multisample buffers, if needed. void createSecondaryBuffers(); + void resizeDepthStencil(int sampleCount); + // Copies the multisample color buffer to the normal color buffer and leaves m_fbo bound void commit(long x = 0, long y = 0, long width = -1, long height = -1); @@ -80,8 +82,10 @@ public: #endif #if PLATFORM(CHROMIUM) - class WillPublishCallback : public Noncopyable { + class WillPublishCallback { + WTF_MAKE_NONCOPYABLE(WillPublishCallback); public: + WillPublishCallback() { } virtual ~WillPublishCallback() { } virtual void willPublish() = 0; @@ -106,13 +110,18 @@ private: bool m_packedDepthStencilExtensionSupported; Platform3DObject m_fbo; Platform3DObject m_colorBuffer; + + // This is used when we have OES_packed_depth_stencil. Platform3DObject m_depthStencilBuffer; + // These are used when we don't. + Platform3DObject m_depthBuffer; + Platform3DObject m_stencilBuffer; + // For multisampling Platform3DObject m_multisampleFBO; Platform3DObject m_multisampleColorBuffer; - Platform3DObject m_multisampleDepthStencilBuffer; - + #if PLATFORM(CHROMIUM) OwnPtr<WillPublishCallback> m_callback; OwnPtr<DrawingBufferInternal> m_internal; diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h b/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h index c665844..1bd67b8 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h @@ -30,14 +30,14 @@ #ifndef LoopBlinnClassifier_h #define LoopBlinnClassifier_h -#include <wtf/Noncopyable.h> namespace WebCore { class FloatPoint; // Classifies cubic curves into specific types. -class LoopBlinnClassifier : public Noncopyable { +class LoopBlinnClassifier { + WTF_MAKE_NONCOPYABLE(LoopBlinnClassifier); public: // The types of cubic curves. enum CurveType { diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h b/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h index ea3d7e3..d01e6c9 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h @@ -30,19 +30,20 @@ #include "FloatPoint3D.h" #include "LoopBlinnConstants.h" #include <wtf/Assertions.h> -#include <wtf/Noncopyable.h> namespace WebCore { // Performs a localized triangulation of the triangle mesh // corresponding to the four control point vertices of a cubic curve // segment. -class LoopBlinnLocalTriangulator : public Noncopyable { +class LoopBlinnLocalTriangulator { + WTF_MAKE_NONCOPYABLE(LoopBlinnLocalTriangulator); public: // The vertices that the triangulator operates upon, containing both // the position information as well as the cubic texture // coordinates. - class Vertex : public Noncopyable { + class Vertex { + WTF_MAKE_NONCOPYABLE(Vertex); public: Vertex() { diff --git a/Source/WebCore/platform/graphics/gpu/PODArena.h b/Source/WebCore/platform/graphics/gpu/PODArena.h index f68baef..6edc1db 100644 --- a/Source/WebCore/platform/graphics/gpu/PODArena.h +++ b/Source/WebCore/platform/graphics/gpu/PODArena.h @@ -158,7 +158,8 @@ private: } // Manages a chunk of memory and individual allocations out of it. - class Chunk : public Noncopyable { + class Chunk { + WTF_MAKE_NONCOPYABLE(Chunk); public: // Allocates a block of memory of the given size from the passed // Allocator. diff --git a/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h b/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h index 320ce60..5bf3de0 100644 --- a/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h +++ b/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h @@ -44,8 +44,8 @@ struct ValueToString; // supports efficient (O(lg n)) insertion, removal and querying of // intervals in the tree. template<class T, class UserData = void*> -class PODIntervalTree : public Noncopyable, - public PODRedBlackTree<PODInterval<T, UserData> > { +class PODIntervalTree : public PODRedBlackTree<PODInterval<T, UserData> > { + WTF_MAKE_NONCOPYABLE(PODIntervalTree); public: // Typedef to reduce typing when declaring intervals to be stored in // this tree. diff --git a/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h b/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h index 6d5954c..bd08988 100644 --- a/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h +++ b/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h @@ -198,7 +198,8 @@ protected: // The base Node class which is stored in the tree. Nodes are only // an internal concept; users of the tree deal only with the data // they store in it. - class Node : public Noncopyable { + class Node { + WTF_MAKE_NONCOPYABLE(Node); public: // Constructor. Newly-created nodes are colored red. explicit Node(const T& data) @@ -659,7 +660,8 @@ private: // Helper class for size() // A Visitor which simply counts the number of visited elements. - class Counter : public Visitor, public Noncopyable { + class Counter : public Visitor { + WTF_MAKE_NONCOPYABLE(Counter); public: Counter() : m_count(0) { } diff --git a/Source/WebCore/platform/graphics/gpu/Shader.h b/Source/WebCore/platform/graphics/gpu/Shader.h index e5bd8de..4f62ca9 100644 --- a/Source/WebCore/platform/graphics/gpu/Shader.h +++ b/Source/WebCore/platform/graphics/gpu/Shader.h @@ -40,7 +40,8 @@ class AffineTransform; class GraphicsContext3D; class Color; -class Shader : public Noncopyable { +class Shader { + WTF_MAKE_NONCOPYABLE(Shader); protected: Shader(GraphicsContext3D*, unsigned program); ~Shader(); diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp index 9d1298f..9c59077 100644 --- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp +++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp @@ -51,6 +51,9 @@ namespace WebCore { PassRefPtr<SharedGraphicsContext3D> SharedGraphicsContext3D::create(HostWindow* hostWindow) { GraphicsContext3D::Attributes attr; + attr.depth = false; + attr.stencil = true; + attr.antialias = false; attr.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts. RefPtr<GraphicsContext3D> context = GraphicsContext3D::create(attr, hostWindow); if (!context) @@ -293,6 +296,14 @@ void SharedGraphicsContext3D::applyCompositeOperator(CompositeOperator op) } } +void SharedGraphicsContext3D::enableStencil(bool enable) +{ + if (enable) + m_context->enable(GraphicsContext3D::STENCIL_TEST); + else + m_context->disable(GraphicsContext3D::STENCIL_TEST); +} + void SharedGraphicsContext3D::useQuadVertices() { if (!m_quadVertices) { diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h index ea1810d..1e032d7 100644 --- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h @@ -90,6 +90,7 @@ public: // Shared logic for canvas 2d void applyCompositeOperator(CompositeOperator); + void enableStencil(bool enable); void useQuadVertices(); void useFillSolidProgram(const AffineTransform&, const Color&); diff --git a/Source/WebCore/platform/graphics/gpu/TilingData.h b/Source/WebCore/platform/graphics/gpu/TilingData.h index 1bdc51a..d1140bd 100644 --- a/Source/WebCore/platform/graphics/gpu/TilingData.h +++ b/Source/WebCore/platform/graphics/gpu/TilingData.h @@ -38,7 +38,8 @@ namespace WebCore { class FloatRect; class IntRect; -class TilingData : public Noncopyable { +class TilingData { + WTF_MAKE_NONCOPYABLE(TilingData); public: TilingData(int maxTextureSize, int totalSizeX, int totalSizeY, bool hasBorderTexels); int maxTextureSize() const { return m_maxTextureSize; } diff --git a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm index 601454e..e6dfdb8 100644 --- a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm +++ b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm @@ -41,15 +41,16 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported) : m_context(context) - , m_size(size) + , m_size(-1, -1) , m_multisampleExtensionSupported(multisampleExtensionSupported) , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) , m_fbo(context->createFramebuffer()) , m_colorBuffer(0) , m_depthStencilBuffer(0) + , m_depthBuffer(0) + , m_stencilBuffer(0) , m_multisampleFBO(0) , m_multisampleColorBuffer(0) - , m_multisampleDepthStencilBuffer(0) { ASSERT(m_fbo); if (!m_fbo) { diff --git a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp index e10e61f..36b49df 100644 --- a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp @@ -36,7 +36,8 @@ using namespace WebCore; -class StreamingClient : public Noncopyable, public ResourceHandleClient { +class StreamingClient : public ResourceHandleClient { + WTF_MAKE_NONCOPYABLE(StreamingClient); public: StreamingClient(WebKitWebSrc*); virtual ~StreamingClient(); diff --git a/Source/WebCore/platform/graphics/gtk/FontGtk.cpp b/Source/WebCore/platform/graphics/gtk/FontGtk.cpp index fdf91db..4d6f509 100644 --- a/Source/WebCore/platform/graphics/gtk/FontGtk.cpp +++ b/Source/WebCore/platform/graphics/gtk/FontGtk.cpp @@ -38,6 +38,7 @@ #include "GraphicsContext.h" #include "NotImplemented.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <cairo.h> #include <gdk/gdk.h> #include <pango/pango.h> diff --git a/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h index cc348e3..86f99b2 100644 --- a/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/haiku/FontCustomPlatformData.h @@ -24,14 +24,14 @@ #include "FontOrientation.h" #include "FontRenderingMode.h" #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> namespace WebCore { class FontPlatformData; class SharedBuffer; - struct FontCustomPlatformData : Noncopyable { + struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); public: FontCustomPlatformData() { } ~FontCustomPlatformData(); diff --git a/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp b/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp index bdad6a0..7a7c88b 100644 --- a/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp +++ b/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp @@ -78,6 +78,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { ASSERT(m_data.m_view.Window()); diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp index 206fd5f..86f6bec 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -30,6 +30,7 @@ #include "FloatSize.h" #include "Font.h" #include "TextBreakIterator.h" +#include "TextRun.h" #include <wtf/StdLibExtras.h> diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp index c24a914..9c2ab6b 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp @@ -28,6 +28,7 @@ #include "CharacterNames.h" #include "Font.h" #include "ShapeArabic.h" +#include "TextRun.h" #ifdef __LP64__ // ATSUTextInserted() is SPI in 64-bit. diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp index 42e7897..07fb153 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp @@ -24,6 +24,7 @@ #include "config.h" #include "ComplexTextController.h" +#include "TextRun.h" #include "WebCoreSystemInterface.h" #if USE(CORE_TEXT) diff --git a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp index ca006d9..02bac9c 100644 --- a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp +++ b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp @@ -31,6 +31,7 @@ #include "GraphicsContext.h" #include "IntRect.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <wtf/MathExtras.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h index c11858c..7043d7e 100644 --- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h @@ -36,7 +36,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: FontCustomPlatformData(ATSFontContainerRef container, CGFontRef cgFont) : m_atsContainer(container) , m_cgFont(cgFont) diff --git a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm index 321d0ef..21eb59d 100644 --- a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm +++ b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm @@ -188,21 +188,15 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi // ANGLE initialization. - TBuiltInResource ANGLEResources; + ShBuiltInResources ANGLEResources; + ShInitBuiltInResources(&ANGLEResources); - ANGLEResources.MaxVertexAttribs = 0; getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs); - ANGLEResources.MaxVertexUniformVectors = 0; getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors); - ANGLEResources.MaxVaryingVectors = 0; getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors); - ANGLEResources.MaxVertexTextureImageUnits = 0; getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits); - ANGLEResources.MaxCombinedTextureImageUnits = 0; getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits); - ANGLEResources.MaxTextureImageUnits = 0; getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits); - ANGLEResources.MaxFragmentUniformVectors = 0; getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors); // Always set to 1 for OpenGL ES. diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp index 4215d12..3eb5196 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp @@ -33,13 +33,15 @@ #include <wtf/Vector.h> #if PLATFORM(MAC) +#include "ANGLE/ShaderLang.h" #include <OpenGL/gl.h> #endif namespace WebCore { -Extensions3DOpenGL::Extensions3DOpenGL() +Extensions3DOpenGL::Extensions3DOpenGL(GraphicsContext3D* context) : m_initializedAvailableExtensions(false) + , m_context(context) { } @@ -82,12 +84,28 @@ bool Extensions3DOpenGL::supports(const String& name) if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float") return m_availableExtensions.contains("GL_ARB_texture_float"); + // Desktop GL always supports the standard derivative functions + if (name == "GL_OES_standard_derivatives") + return true; + return m_availableExtensions.contains(name); } void Extensions3DOpenGL::ensureEnabled(const String& name) { +#if PLATFORM(MAC) + if (name == "GL_OES_standard_derivatives") { + // Enable support in ANGLE (if not enabled already) + ANGLEWebKitBridge& compiler = m_context->m_compiler; + ShBuiltInResources ANGLEResources = compiler.getResources(); + if (!ANGLEResources.OES_standard_derivatives) { + ANGLEResources.OES_standard_derivatives = 1; + compiler.setResources(ANGLEResources); + } + } +#else ASSERT_UNUSED(name, supports(name)); +#endif } int Extensions3DOpenGL::getGraphicsResetStatusARB() diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h index 59f8180..1941a42 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h @@ -48,10 +48,13 @@ public: private: // This class only needs to be instantiated by GraphicsContext3D implementations. friend class GraphicsContext3D; - Extensions3DOpenGL(); + Extensions3DOpenGL(GraphicsContext3D*); bool m_initializedAvailableExtensions; HashSet<String> m_availableExtensions; + + // Weak pointer back to GraphicsContext3D + GraphicsContext3D* m_context; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp index 221ee11..7c103f3 100644 --- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp +++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp @@ -1467,7 +1467,7 @@ void GraphicsContext3D::synthesizeGLError(GC3Denum error) Extensions3D* GraphicsContext3D::getExtensions() { if (!m_extensions) - m_extensions = adoptPtr(new Extensions3DOpenGL); + m_extensions = adoptPtr(new Extensions3DOpenGL(this)); return m_extensions.get(); } diff --git a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h b/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h index 32f1fe5..3f1494e 100644 --- a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h +++ b/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h @@ -41,7 +41,8 @@ class TiledImageOpenVG; struct PlatformPainterState; -class PainterOpenVG : public Noncopyable { +class PainterOpenVG { + WTF_MAKE_NONCOPYABLE(PainterOpenVG); public: friend class SurfaceOpenVG; friend struct PlatformPainterState; diff --git a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h b/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h index 46d1646..19d95d8 100644 --- a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h +++ b/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h @@ -42,7 +42,8 @@ class IntSize; * of #ifdefs and should make it easy to add different surface/context * implementations than EGL. */ -class SurfaceOpenVG : public Noncopyable { +class SurfaceOpenVG { + WTF_MAKE_NONCOPYABLE(SurfaceOpenVG); public: enum MakeCurrentMode { ApplyPainterStateOnSurfaceSwitch, diff --git a/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp b/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp index 834ca62..37d6b44 100644 --- a/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ContextShadowQt.cpp @@ -72,7 +72,7 @@ QImage* ShadowBuffer::scratchImage(const QSize& size) // keep too many allocated pixels for too long. if (!image.isNull() && (image.width() > width) && (image.height() > height)) if (((2 * width) > image.width()) && ((2 * height) > image.height())) { - image.fill(Qt::transparent); + image.fill(0); return ℑ } @@ -82,7 +82,7 @@ QImage* ShadowBuffer::scratchImage(const QSize& size) height = (1 + (height >> 5)) << 5; image = QImage(width, height, QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::transparent); + image.fill(0); return ℑ } diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h index 6c41d47..54fa679 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h @@ -24,6 +24,7 @@ #include "FontOrientation.h" #include "FontRenderingMode.h" +#include <wtf/FastAllocBase.h> #include <wtf/Forward.h> #include <wtf/Noncopyable.h> @@ -32,7 +33,10 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); WTF_MAKE_FAST_ALLOCATED; +public: + FontCustomPlatformData() { } ~FontCustomPlatformData(); // for use with QFontDatabase::addApplicationFont/removeApplicationFont diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformData.h b/Source/WebCore/platform/graphics/qt/FontPlatformData.h index 1c57e29..f268370 100644 --- a/Source/WebCore/platform/graphics/qt/FontPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontPlatformData.h @@ -32,7 +32,8 @@ namespace WebCore { -class FontPlatformDataPrivate : public Noncopyable { +class FontPlatformDataPrivate { + WTF_MAKE_NONCOPYABLE(FontPlatformDataPrivate); WTF_MAKE_FAST_ALLOCATED; public: FontPlatformDataPrivate() : refCount(1) @@ -62,8 +63,10 @@ public: -class FontPlatformData : public FastAllocBase { +class FontPlatformData { + WTF_MAKE_FAST_ALLOCATED; public: + FontPlatformData() { } FontPlatformData(float size, bool bold, bool oblique); FontPlatformData(const FontPlatformData &); FontPlatformData(const FontDescription&, const AtomicString& familyName, int wordSpacing = 0, int letterSpacing = 0); diff --git a/Source/WebCore/platform/graphics/qt/FontQt.cpp b/Source/WebCore/platform/graphics/qt/FontQt.cpp index f1ced2b..778a13f 100644 --- a/Source/WebCore/platform/graphics/qt/FontQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontQt.cpp @@ -31,6 +31,7 @@ #include "GraphicsContext.h" #include "NotImplemented.h" #include "Pattern.h" +#include "TextRun.h" #include <QBrush> #include <QFontInfo> diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 253cd84..4dabe09 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -8,7 +8,7 @@ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> - * Copyright (C) 2010 Sencha, Inc. + * Copyright (C) 2010, 2011 Sencha, Inc. * * All rights reserved. * @@ -174,7 +174,8 @@ static inline Qt::FillRule toQtFillRule(WindRule rule) return Qt::OddEvenFill; } -class GraphicsContextPlatformPrivate : public Noncopyable { +class GraphicsContextPlatformPrivate { + WTF_MAKE_NONCOPYABLE(GraphicsContextPlatformPrivate); WTF_MAKE_FAST_ALLOCATED; public: GraphicsContextPlatformPrivate(QPainter*, const QColor& initialSolidColor); ~GraphicsContextPlatformPrivate(); @@ -505,14 +506,19 @@ void GraphicsContext::fillPath(const Path& path) brush.setTransform(m_state.fillGradient->gradientSpaceTransform()); shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255); shadowPainter->fillPath(platformPath, brush); - } else - shadowPainter->fillPath(platformPath, QColor(shadow->m_color)); + } else { + QColor shadowColor = shadow->m_color; + shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); + shadowPainter->fillPath(platformPath, shadowColor); + } shadow->endShadowLayer(this); } } else { QPointF offset = shadow->offset(); p->translate(offset); - p->fillPath(platformPath, QColor(shadow->m_color)); + QColor shadowColor = shadow->m_color; + shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); + p->fillPath(platformPath, shadowColor); p->translate(-offset); } } @@ -550,10 +556,12 @@ void GraphicsContext::strokePath(const Path& path) shadow->endShadowLayer(this); } } else { - QPen shadowPen(pen); - shadowPen.setColor(m_data->shadow.m_color); QPointF offset = shadow->offset(); p->translate(offset); + QColor shadowColor = shadow->m_color; + shadowColor.setAlphaF(shadowColor.alphaF() * pen.color().alphaF()); + QPen shadowPen(pen); + shadowPen.setColor(shadowColor); p->strokePath(platformPath, shadowPen); p->translate(-offset); } @@ -983,11 +991,9 @@ void GraphicsContext::clearRect(const FloatRect& rect) QPainter* p = m_data->p(); QPainter::CompositionMode currentCompositionMode = p->compositionMode(); - if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - p->setCompositionMode(QPainter::CompositionMode_Source); + p->setCompositionMode(QPainter::CompositionMode_Source); p->fillRect(rect, Qt::transparent); - if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - p->setCompositionMode(currentCompositionMode); + p->setCompositionMode(currentCompositionMode); } void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth) @@ -1077,12 +1083,7 @@ void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op) if (paintingDisabled()) return; - QPainter* painter = m_data->p(); - - if (!painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - return; - - painter->setCompositionMode(toQtCompositionMode(op)); + m_data->p()->setCompositionMode(toQtCompositionMode(op)); } void GraphicsContext::clip(const Path& path) diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp index f56603d..d1567ec 100644 --- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp @@ -95,6 +95,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { ASSERT(m_data.m_painter->isActive()); diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index be6f732..0a4c0f6 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -20,7 +20,6 @@ #include "config.h" #include "MediaPlayerPrivateQt.h" -#include "FrameLoaderClientQt.h" #include "FrameView.h" #include "GraphicsContext.h" #include "HTMLMediaElement.h" @@ -205,10 +204,10 @@ void MediaPlayerPrivateQt::commitLoad(const String& url) // Grab the frame and network manager Frame* frame = document ? document->frame() : 0; - QNetworkAccessManager* manager = frame ? frame->loader()->networkingContext()->networkAccessManager() : 0; - FrameLoaderClientQt* frameLoader = frame ? static_cast<FrameLoaderClientQt*>(frame->loader()->client()) : 0; + FrameLoader* frameLoader = frame ? frame->loader() : 0; + QNetworkAccessManager* manager = frameLoader ? frameLoader->networkingContext()->networkAccessManager() : 0; - if (document && manager) { + if (manager) { // Set the cookies QtNAMThreadSafeProxy managerProxy(manager); QList<QNetworkCookie> cookies = managerProxy.cookiesForUrl(rUrl); diff --git a/Source/WebCore/platform/graphics/qt/TransparencyLayer.h b/Source/WebCore/platform/graphics/qt/TransparencyLayer.h index 5b2f8b2..ff9ef20 100644 --- a/Source/WebCore/platform/graphics/qt/TransparencyLayer.h +++ b/Source/WebCore/platform/graphics/qt/TransparencyLayer.h @@ -42,7 +42,9 @@ namespace WebCore { -struct TransparencyLayer : FastAllocBase { +struct TransparencyLayer { + WTF_MAKE_FAST_ALLOCATED; +public: TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QPixmap& alphaMask) : pixmap(rect.width(), rect.height()) , opacity(opacity) @@ -59,8 +61,7 @@ struct TransparencyLayer : FastAllocBase { painter.setTransform(p->transform(), true); painter.setOpacity(p->opacity()); painter.setFont(p->font()); - if (painter.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) - painter.setCompositionMode(p->compositionMode()); + painter.setCompositionMode(p->compositionMode()); } TransparencyLayer() diff --git a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp index e94c417..0b31dfa 100644 --- a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp +++ b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp @@ -35,8 +35,8 @@ #if OS(WINDOWS) #include "Base64.h" -#include "ChromiumBridge.h" #include "OpenTypeUtilities.h" +#include "PlatformBridge.h" #elif OS(LINUX) || OS(FREEBSD) || PLATFORM(BREWMP) #include "SkStream.h" #endif @@ -91,7 +91,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b logFont.lfStrikeOut = false; logFont.lfCharSet = DEFAULT_CHARSET; logFont.lfOutPrecision = OUT_TT_ONLY_PRECIS; - logFont.lfQuality = ChromiumBridge::layoutTestMode() ? + logFont.lfQuality = PlatformBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings. logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; diff --git a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h index e51b6b6..4228b40 100644 --- a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h @@ -49,7 +49,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: #if OS(WINDOWS) FontCustomPlatformData(HANDLE fontReference, const String& name) : m_fontReference(fontReference) diff --git a/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h b/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h index 5e12ad6..44835a4 100644 --- a/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h +++ b/Source/WebCore/platform/graphics/skia/GraphicsContextPlatformPrivate.h @@ -31,14 +31,14 @@ #ifndef GraphicsContextPlatformPrivate_h #define GraphicsContextPlatformPrivate_h -#include <wtf/Noncopyable.h> class PlatformContextSkia; namespace WebCore { // This class just holds onto a PlatformContextSkia for GraphicsContext. -class GraphicsContextPlatformPrivate : public Noncopyable { +class GraphicsContextPlatformPrivate { + WTF_MAKE_NONCOPYABLE(GraphicsContextPlatformPrivate); public: GraphicsContextPlatformPrivate(PlatformContextSkia* platformContext) : m_context(platformContext) { } diff --git a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index 51e2477..1a7112b 100644 --- a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -386,6 +386,9 @@ void GraphicsContext::canvasClip(const Path& path) if (paintingDisabled()) return; + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->clipPath(path); + const SkPath& p = *path.platformPath(); if (!isPathSkiaSafe(getCTM(), p)) return; @@ -410,6 +413,9 @@ void GraphicsContext::clipOut(const Path& p) if (paintingDisabled()) return; + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->clipOut(p); + const SkPath& path = *p.platformPath(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -422,6 +428,9 @@ void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule) if (paintingDisabled()) return; + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->clipPath(pathToClip); + // FIXME: Be smarter about this. beginPath(); addPath(pathToClip); @@ -733,6 +742,12 @@ void GraphicsContext::fillPath(const Path& pathToFill) beginPath(); addPath(pathToFill); + if (platformContext()->useGPU() && platformContext()->canAccelerate()) { + platformContext()->prepareForHardwareDraw(); + platformContext()->gpuCanvas()->fillPath(pathToFill); + return; + } + SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp index b65b5bd..2c489ef 100644 --- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp @@ -91,6 +91,11 @@ GraphicsContext* ImageBuffer::context() const return m_context.get(); } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + bool ImageBuffer::drawsUsingCopy() const { return false; diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp index d3c0e00..d852e9b 100644 --- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp @@ -702,8 +702,7 @@ void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths) bool PlatformContextSkia::canAccelerate() const { return !m_state->m_fillShader // Can't accelerate with a fill gradient or pattern. - && !m_state->m_looper // Can't accelerate with a shadow. - && !m_state->m_canvasClipApplied; // Can't accelerate with a clip to path applied. + && !m_state->m_looper; // Can't accelerate with a shadow. } bool PlatformContextSkia::canvasClipApplied() const @@ -848,7 +847,7 @@ void PlatformContextSkia::uploadSoftwareToHardware(CompositeOperator op) const m_uploadTexture->updateSubRect(bitmap.getPixels(), m_softwareDirtyRect); AffineTransform identity; - gpuCanvas()->drawTexturedRect(m_uploadTexture.get(), m_softwareDirtyRect, m_softwareDirtyRect, identity, 1.0, ColorSpaceDeviceRGB, op); + gpuCanvas()->drawTexturedRect(m_uploadTexture.get(), m_softwareDirtyRect, m_softwareDirtyRect, identity, 1.0, ColorSpaceDeviceRGB, op, false); // Clear out the region of the software canvas we just uploaded. m_canvas->save(); m_canvas->resetMatrix(); diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h index 11b311a..0304486 100644 --- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h +++ b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h @@ -67,7 +67,8 @@ class Texture; // responsible for managing the painting state which is store in separate // SkPaint objects. This class provides the adaptor that allows the painting // state to be pushed and popped along with the bitmap. -class PlatformContextSkia : public Noncopyable { +class PlatformContextSkia { + WTF_MAKE_NONCOPYABLE(PlatformContextSkia); public: // For printing, there shouldn't be any canvas. canvas can be NULL. If you // supply a NULL canvas, you can also call setCanvas later. diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp index f275526..3f88140 100644 --- a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp +++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp @@ -164,12 +164,10 @@ AffineTransform AffineTransform::inverse() const return result; } -AffineTransform& AffineTransform::multiply(const AffineTransform& other) -{ - return (*this) *= other; -} -AffineTransform& AffineTransform::multLeft(const AffineTransform& other) +// Multiplies this AffineTransform by the provided AffineTransform - i.e. +// this = this * other; +AffineTransform& AffineTransform::multiply(const AffineTransform& other) { AffineTransform trans; @@ -192,7 +190,7 @@ AffineTransform& AffineTransform::rotate(double a) double sinAngle = sin(a); AffineTransform rot(cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0); - multLeft(rot); + multiply(rot); return *this; } diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.h b/Source/WebCore/platform/graphics/transforms/AffineTransform.h index baee102..50d0655 100644 --- a/Source/WebCore/platform/graphics/transforms/AffineTransform.h +++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.h @@ -55,7 +55,8 @@ class IntPoint; class IntRect; class TransformationMatrix; -class AffineTransform : public FastAllocBase { +class AffineTransform { + WTF_MAKE_FAST_ALLOCATED; public: typedef double Transform[6]; @@ -95,8 +96,7 @@ public: void makeIdentity(); - AffineTransform& multiply(const AffineTransform&); - AffineTransform& multLeft(const AffineTransform&); + AffineTransform& multiply(const AffineTransform& other); AffineTransform& scale(double); AffineTransform& scale(double sx, double sy); AffineTransform& scaleNonUniform(double sx, double sy); @@ -147,15 +147,14 @@ public: // *this = *this * t (i.e., a multRight) AffineTransform& operator*=(const AffineTransform& t) { - *this = *this * t; - return *this; + return multiply(t); } // result = *this * t (i.e., a multRight) AffineTransform operator*(const AffineTransform& t) const { - AffineTransform result = t; - result.multLeft(*this); + AffineTransform result = *this; + result *= t; return result; } diff --git a/Source/WebCore/platform/graphics/transforms/TransformOperations.h b/Source/WebCore/platform/graphics/transforms/TransformOperations.h index c0da377..981e1f6 100644 --- a/Source/WebCore/platform/graphics/transforms/TransformOperations.h +++ b/Source/WebCore/platform/graphics/transforms/TransformOperations.h @@ -31,7 +31,8 @@ namespace WebCore { -class TransformOperations : public FastAllocBase { +class TransformOperations { + WTF_MAKE_FAST_ALLOCATED; public: TransformOperations(bool makeIdentity = false); diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp index 10c7f70..357a140 100644 --- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp +++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "TransformationMatrix.h" +#include "AffineTransform.h" #include "FloatPoint3D.h" #include "FloatRect.h" #include "FloatQuad.h" diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h index f13bcc1..c883675 100644 --- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h +++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h @@ -26,7 +26,6 @@ #ifndef TransformationMatrix_h #define TransformationMatrix_h -#include "AffineTransform.h" #include "FloatPoint.h" #include "IntPoint.h" #include <string.h> //for memcpy @@ -65,7 +64,8 @@ class FloatPoint3D; class FloatRect; class FloatQuad; -class TransformationMatrix : public FastAllocBase { +class TransformationMatrix { + WTF_MAKE_FAST_ALLOCATED; public: typedef double Matrix4[4][4]; diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h index 1bdf270..de33c63 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h @@ -34,7 +34,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: FontCustomPlatformData(HANDLE fontReference, const String& name) : m_fontReference(fontReference) , m_name(name) diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h index 3ab52b8..9c67037 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h @@ -33,7 +33,9 @@ namespace WebCore { class FontPlatformData; class SharedBuffer; -struct FontCustomPlatformData : Noncopyable { +struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); +public: FontCustomPlatformData(cairo_font_face_t* fontFace) : m_fontFace(fontFace) { diff --git a/Source/WebCore/platform/graphics/win/FontWin.cpp b/Source/WebCore/platform/graphics/win/FontWin.cpp index 2170954..2ed9eb3 100644 --- a/Source/WebCore/platform/graphics/win/FontWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontWin.cpp @@ -32,6 +32,7 @@ #include "IntRect.h" #include "Logging.h" #include "SimpleFontData.h" +#include "TextRun.h" #include "UniscribeController.h" #include <wtf/MathExtras.h> diff --git a/Source/WebCore/platform/graphics/win/LocalWindowsContext.h b/Source/WebCore/platform/graphics/win/LocalWindowsContext.h index c216140..5951e49 100644 --- a/Source/WebCore/platform/graphics/win/LocalWindowsContext.h +++ b/Source/WebCore/platform/graphics/win/LocalWindowsContext.h @@ -31,7 +31,8 @@ namespace WebCore { -class LocalWindowsContext : public Noncopyable { +class LocalWindowsContext { + WTF_MAKE_NONCOPYABLE(LocalWindowsContext); public: LocalWindowsContext(GraphicsContext* graphicsContext, const IntRect& rect, bool supportAlphaBlend = true, bool mayCreateBitmap = true) : m_graphicsContext(graphicsContext) diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp index 7abe2eb..01db7f2 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp @@ -40,7 +40,7 @@ MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow(MediaPlay : m_client(client) , m_hwnd(0) #if USE(ACCELERATED_COMPOSITING) - , m_layerRenderer(WKCACFLayerRenderer::create(0)) + , m_layerTreeHost(CACFLayerTreeHost::create()) #endif { } @@ -81,7 +81,7 @@ void MediaPlayerPrivateFullscreenWindow::createWindow(HWND parentHwnd) ASSERT(IsWindow(m_hwnd)); #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->setHostWindow(m_hwnd); + m_layerTreeHost->setWindow(m_hwnd); #endif ::SetFocus(m_hwnd); @@ -107,7 +107,7 @@ void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<PlatformCA if (!m_rootChild) return; - m_layerRenderer->setRootChildLayer(m_rootChild.get()); + m_layerTreeHost->setRootChildLayer(m_rootChild.get()); PlatformCALayer* rootLayer = m_rootChild->rootLayer(); CGRect rootBounds = m_rootChild->rootLayer()->bounds(); m_rootChild->setFrame(rootBounds); @@ -147,7 +147,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA case WM_DESTROY: m_hwnd = 0; #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->setHostWindow(0); + m_layerTreeHost->setWindow(0); #endif break; case WM_WINDOWPOSCHANGED: @@ -156,7 +156,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA if (wp->flags & SWP_NOSIZE) break; #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->resize(); + m_layerTreeHost->resize(); PlatformCALayer* rootLayer = m_rootChild->rootLayer(); CGRect rootBounds = m_rootChild->rootLayer()->bounds(); m_rootChild->setFrame(rootBounds); @@ -166,7 +166,7 @@ LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPA break; case WM_PAINT: #if USE(ACCELERATED_COMPOSITING) - m_layerRenderer->paint(); + m_layerTreeHost->paint(); ::ValidateRect(m_hwnd, 0); #endif break; diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h index a18f0cc..c1ae762 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h @@ -27,10 +27,9 @@ #define MediaPlayerPrivateFullscreenWindow_h #if USE(ACCELERATED_COMPOSITING) +#include "CACFLayerTreeHost.h" #include "PlatformCALayer.h" -#include "WKCACFLayerRenderer.h" #endif -#include <wtf/OwnPtr.h> typedef unsigned WPARAM; typedef long LPARAM; @@ -59,7 +58,7 @@ public: HWND hwnd() const { return m_hwnd; } #if USE(ACCELERATED_COMPOSITING) - WKCACFLayerRenderer* layerRenderer() const { return m_layerRenderer.get(); } + CACFLayerTreeHost* layerView() const { return m_layerTreeHost.get(); } PlatformCALayer* rootChildLayer() const { return m_rootChild.get(); } void setRootChildLayer(PassRefPtr<PlatformCALayer>); @@ -71,7 +70,7 @@ private: MediaPlayerPrivateFullscreenClient* m_client; #if USE(ACCELERATED_COMPOSITING) - OwnPtr<WKCACFLayerRenderer> m_layerRenderer; + RefPtr<CACFLayerTreeHost> m_layerTreeHost; RefPtr<PlatformCALayer> m_rootChild; #endif HWND m_hwnd; diff --git a/Source/WebCore/platform/graphics/win/QTMovie.cpp b/Source/WebCore/platform/graphics/win/QTMovie.cpp index efaf218..dfa1d36 100644 --- a/Source/WebCore/platform/graphics/win/QTMovie.cpp +++ b/Source/WebCore/platform/graphics/win/QTMovie.cpp @@ -63,7 +63,8 @@ union UppParam { static Vector<CFStringRef>* gSupportedTypes = 0; static SInt32 quickTimeVersion = 0; -class QTMoviePrivate : public Noncopyable, public QTMovieTaskClient { +class QTMoviePrivate : public QTMovieTaskClient { + WTF_MAKE_NONCOPYABLE(QTMoviePrivate); public: QTMoviePrivate(); ~QTMoviePrivate(); diff --git a/Source/WebCore/platform/graphics/win/QTTrack.cpp b/Source/WebCore/platform/graphics/win/QTTrack.cpp index 09142bc..bf80a81 100644 --- a/Source/WebCore/platform/graphics/win/QTTrack.cpp +++ b/Source/WebCore/platform/graphics/win/QTTrack.cpp @@ -31,7 +31,8 @@ using namespace std; -class QTTrackPrivate : public Noncopyable { +class QTTrackPrivate { + WTF_MAKE_NONCOPYABLE(QTTrackPrivate); public: QTTrackPrivate(); ~QTTrackPrivate(); diff --git a/Source/WebCore/platform/graphics/win/UniscribeController.cpp b/Source/WebCore/platform/graphics/win/UniscribeController.cpp index ab32150..dac6c3e 100644 --- a/Source/WebCore/platform/graphics/win/UniscribeController.cpp +++ b/Source/WebCore/platform/graphics/win/UniscribeController.cpp @@ -27,6 +27,7 @@ #include "UniscribeController.h" #include "Font.h" #include "SimpleFontData.h" +#include "TextRun.h" #include <wtf/MathExtras.h> using namespace std; diff --git a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp b/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp deleted file mode 100644 index d75c854..0000000 --- a/Source/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2009 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE 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 USE(ACCELERATED_COMPOSITING) - -#include "WKCACFContextFlusher.h" - -#include <WebKitSystemInterface/WebKitSystemInterface.h> -#include <wtf/StdLibExtras.h> - -namespace WebCore { - -WKCACFContextFlusher& WKCACFContextFlusher::shared() -{ - DEFINE_STATIC_LOCAL(WKCACFContextFlusher, flusher, ()); - return flusher; -} - -WKCACFContextFlusher::WKCACFContextFlusher() -{ -} - -WKCACFContextFlusher::~WKCACFContextFlusher() -{ -} - -void WKCACFContextFlusher::addContext(WKCACFContext* context) -{ - ASSERT(context); - - m_contexts.add(context); -} - -void WKCACFContextFlusher::removeContext(WKCACFContext* context) -{ - ASSERT(context); - - m_contexts.remove(context); -} - -void WKCACFContextFlusher::flushAllContexts() -{ - // addContext might get called beneath CACFContextFlush, and we don't want m_contexts to change while - // we're iterating over it, so we move the contexts into a local ContextSet and iterate over that instead. - ContextSet contextsToFlush; - contextsToFlush.swap(m_contexts); - - ContextSet::const_iterator end = contextsToFlush.end(); - for (ContextSet::const_iterator it = contextsToFlush.begin(); it != end; ++it) - wkCACFContextFlush(*it); -} - -} - -#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h index abdc0f2..0508246 100644 --- a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h @@ -37,7 +37,9 @@ namespace WebCore { virtual void unregisterFont(const String& fontName) = 0; }; - struct FontCustomPlatformData : Noncopyable { + struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); + public: FontCustomPlatformData(const String& name) : m_name(name) { diff --git a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp index d636517..5a4c8da 100644 --- a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp @@ -38,6 +38,7 @@ #include "GraphicsContext.h" #include "IntRect.h" #include "NotImplemented.h" +#include "TextRun.h" #include "WidthIterator.h" #include <wtf/MathExtras.h> #include <wtf/OwnPtr.h> diff --git a/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp index 2def6ab..9b672d2 100644 --- a/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp @@ -209,7 +209,7 @@ public: void concatCTM(const AffineTransform& transform) { - m_transform = transform * m_transform; + m_transform *= transform; } IntRect mapRect(const IntRect& rect) const @@ -438,7 +438,8 @@ static void rotateBitmap(SharedBitmap* destBmp, const SharedBitmap* sourceBmp, c _rotateBitmap<unsigned, false>(destBmp, sourceBmp, transform); } -class TransparentLayerDC : Noncopyable { +class TransparentLayerDC { + WTF_MAKE_NONCOPYABLE(TransparentLayerDC); public: TransparentLayerDC(GraphicsContextPlatformPrivate* data, IntRect& origRect, const IntRect* rectBeforeTransform = 0, int alpha = 255, bool paintImage = false); ~TransparentLayerDC(); @@ -558,7 +559,8 @@ void TransparentLayerDC::fillAlphaChannel() } } -class ScopeDCProvider : Noncopyable { +class ScopeDCProvider { + WTF_MAKE_NONCOPYABLE(ScopeDCProvider); public: explicit ScopeDCProvider(GraphicsContextPlatformPrivate* data) : m_data(data) diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferData.h b/Source/WebCore/platform/graphics/wince/ImageBufferData.h index 01b7d06..cbd49dc 100644 --- a/Source/WebCore/platform/graphics/wince/ImageBufferData.h +++ b/Source/WebCore/platform/graphics/wince/ImageBufferData.h @@ -20,15 +20,18 @@ #ifndef ImageBufferData_h #define ImageBufferData_h +#include "SharedBitmap.h" + namespace WebCore { - class IntSize; - class ImageBufferData { - public: - ImageBufferData(const IntSize& size); - RefPtr<SharedBitmap> m_bitmap; - }; +class IntSize; + +class ImageBufferData { +public: + ImageBufferData(const IntSize&); + RefPtr<SharedBitmap> m_bitmap; +}; -} // namespace WebCore +} // namespace WebCore -#endif // ImageBufferData_h +#endif // ImageBufferData_h diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp index 537d27d..b5118f6 100644 --- a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp @@ -88,6 +88,11 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + return m_size.width() * m_size.height() * 4; +} + GraphicsContext* ImageBuffer::context() const { return m_context.get(); diff --git a/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp b/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp index 05d1535..168a5e2 100644 --- a/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp +++ b/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp @@ -445,8 +445,7 @@ void SharedBitmap::drawPattern(HDC hdc, const AffineTransform& transform, const bmpHeight = tileRect.height(); } - AffineTransform tf = transform; - tf *= patternTransform; + AffineTransform tf = patternTransform * transform; FloatRect trRect = tf.mapRect(destRect); diff --git a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h index cc348e3..86f99b2 100644 --- a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h @@ -24,14 +24,14 @@ #include "FontOrientation.h" #include "FontRenderingMode.h" #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> namespace WebCore { class FontPlatformData; class SharedBuffer; - struct FontCustomPlatformData : Noncopyable { + struct FontCustomPlatformData { + WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); public: FontCustomPlatformData() { } ~FontCustomPlatformData(); diff --git a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp index ba33287..b603a60 100644 --- a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp +++ b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp @@ -48,6 +48,12 @@ ImageBuffer::~ImageBuffer() { } +size_t ImageBuffer::dataSize() const +{ + notImplemented(); + return 0; +} + GraphicsContext* ImageBuffer::context() const { notImplemented(); diff --git a/Source/WebCore/platform/gtk/ClipboardGtk.h b/Source/WebCore/platform/gtk/ClipboardGtk.h index e14a583..0c07c07 100644 --- a/Source/WebCore/platform/gtk/ClipboardGtk.h +++ b/Source/WebCore/platform/gtk/ClipboardGtk.h @@ -39,6 +39,7 @@ namespace WebCore { // State available during IE's events for drag and drop and copy/paste // Created from the EventHandlerGtk to be used by the dom class ClipboardGtk : public Clipboard, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, GtkClipboard* clipboard, Frame* frame) { diff --git a/Source/WebCore/platform/gtk/DragDataGtk.cpp b/Source/WebCore/platform/gtk/DragDataGtk.cpp index 3a1daf1..cc9a208 100644 --- a/Source/WebCore/platform/gtk/DragDataGtk.cpp +++ b/Source/WebCore/platform/gtk/DragDataGtk.cpp @@ -66,13 +66,21 @@ bool DragData::containsCompatibleContent() const return containsPlainText() || containsURL(0) || m_platformDragData->hasMarkup() || containsColor() || containsFiles(); } -bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const +bool DragData::containsURL(Frame* frame, FilenameConversionPolicy filenamePolicy) const { - return m_platformDragData->hasURL(); + return !asURL(frame, filenamePolicy).isEmpty(); } String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const { + if (!m_platformDragData->hasURL()) + return String(); + if (filenamePolicy != ConvertFilenames) { + KURL url(KURL(), m_platformDragData->url()); + if (url.isLocalFile()) + return String(); + } + String url(m_platformDragData->url()); if (title) *title = m_platformDragData->urlLabel(); diff --git a/Source/WebCore/platform/gtk/KeyEventGtk.cpp b/Source/WebCore/platform/gtk/KeyEventGtk.cpp index 50dfa4c..5a034d6 100644 --- a/Source/WebCore/platform/gtk/KeyEventGtk.cpp +++ b/Source/WebCore/platform/gtk/KeyEventGtk.cpp @@ -583,8 +583,7 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCom bool PlatformKeyboardEvent::currentCapsLockState() { - notImplemented(); - return false; + return gdk_keymap_get_caps_lock_state(gdk_keymap_get_default()); } void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey) diff --git a/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp b/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp index c2e24e0..d1571a5 100644 --- a/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp +++ b/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.cpp @@ -25,13 +25,14 @@ #include "GraphicsContext.h" #include "GtkVersioning.h" #include "IntRect.h" +#include "ScrollableArea.h" #include <gtk/gtk.h> using namespace WebCore; -PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollbarClient* client, ScrollbarOrientation orientation, GtkAdjustment* adj) +PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, GtkAdjustment* adj) { - return adoptRef(new MainFrameScrollbarGtk(client, orientation, adj)); + return adoptRef(new MainFrameScrollbarGtk(scrollableArea, orientation, adj)); } // Main frame scrollbars are slaves to a GtkAdjustment. If a main frame @@ -41,8 +42,8 @@ PassRefPtr<MainFrameScrollbarGtk> MainFrameScrollbarGtk::create(ScrollbarClient* // state. These scrollbars are never painted, as the container takes care of // that. They exist only to shuttle data from the GtkWidget container into // WebCore and vice-versa. -MainFrameScrollbarGtk::MainFrameScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orientation, GtkAdjustment* adjustment) - : Scrollbar(client, orientation, RegularScrollbar) +MainFrameScrollbarGtk::MainFrameScrollbarGtk(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, GtkAdjustment* adjustment) + : Scrollbar(scrollableArea, orientation, RegularScrollbar) , m_adjustment(0) { attachAdjustment(adjustment); @@ -108,7 +109,7 @@ void MainFrameScrollbarGtk::updateThumbProportion() void MainFrameScrollbarGtk::gtkValueChanged(GtkAdjustment*, MainFrameScrollbarGtk* that) { - that->setValue(static_cast<int>(gtk_adjustment_get_value(that->m_adjustment.get())), NotFromScrollAnimator); + that->scrollableArea()->scrollToOffsetWithoutAnimation(that->orientation(), static_cast<int>(gtk_adjustment_get_value(that->m_adjustment.get()))); } void MainFrameScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect) diff --git a/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.h b/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.h index f184425..f104f81 100644 --- a/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.h +++ b/Source/WebCore/platform/gtk/MainFrameScrollbarGtk.h @@ -30,18 +30,19 @@ namespace WebCore { class MainFrameScrollbarGtk : public Scrollbar { public: + static PassRefPtr<MainFrameScrollbarGtk> create(ScrollableArea*, ScrollbarOrientation, GtkAdjustment*); + ~MainFrameScrollbarGtk(); virtual void paint(GraphicsContext*, const IntRect&); void detachAdjustment(); void attachAdjustment(GtkAdjustment*); - static PassRefPtr<MainFrameScrollbarGtk> create(ScrollbarClient*, ScrollbarOrientation, GtkAdjustment*); protected: virtual void updateThumbPosition(); virtual void updateThumbProportion(); private: - MainFrameScrollbarGtk(ScrollbarClient*, ScrollbarOrientation, GtkAdjustment*); + MainFrameScrollbarGtk(ScrollableArea*, ScrollbarOrientation, GtkAdjustment*); static void gtkValueChanged(GtkAdjustment*, MainFrameScrollbarGtk*); GRefPtr<GtkAdjustment> m_adjustment; diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk.cpp b/Source/WebCore/platform/gtk/RenderThemeGtk.cpp index 97c966d..bfe3901 100644 --- a/Source/WebCore/platform/gtk/RenderThemeGtk.cpp +++ b/Source/WebCore/platform/gtk/RenderThemeGtk.cpp @@ -41,6 +41,10 @@ #include <gdk/gdk.h> #include <gtk/gtk.h> +#if ENABLE(PROGRESS_TAG) +#include "RenderProgress.h" +#endif + namespace WebCore { using namespace HTMLNames; @@ -305,6 +309,24 @@ bool RenderThemeGtk::paintSearchField(RenderObject* o, const PaintInfo& i, const return paintTextField(o, i, rect); } +bool RenderThemeGtk::paintCapsLockIndicator(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect) +{ + // The other paint methods don't need to check whether painting is disabled because RenderTheme already checks it + // before calling them, but paintCapsLockIndicator() is called by RenderTextControlSingleLine which doesn't check it. + if (paintInfo.context->paintingDisabled()) + return true; + + GRefPtr<GdkPixbuf> icon = getStockIcon(GTK_TYPE_ENTRY, GTK_STOCK_CAPS_LOCK_WARNING, + gtkTextDirection(renderObject->style()->direction()), + gtkIconState(this, renderObject), GTK_ICON_SIZE_MENU); + + // GTK+ locates the icon right aligned in the entry. The given rectangle is already + // centered vertically by RenderTextControlSingleLine. + IntPoint iconPosition(rect.x() + rect.width() - gdk_pixbuf_get_width(icon.get()), rect.y()); + paintGdkPixbuf(paintInfo.context, icon.get(), iconPosition); + return true; +} + void RenderThemeGtk::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { style->setBoxShadow(0); @@ -330,7 +352,7 @@ double RenderThemeGtk::caretBlinkInterval() const return time / 2000.; } -static double getScreenDPI() +double RenderThemeGtk::getScreenDPI() { // FIXME: Really this should be the widget's screen. GdkScreen* screen = gdk_screen_get_default(); @@ -543,6 +565,50 @@ void RenderThemeGtk::adjustProgressBarStyle(CSSStyleSelector*, RenderStyle* styl { style->setBoxShadow(0); } + +// These values have been copied from RenderThemeChromiumSkia.cpp +static const int progressActivityBlocks = 5; +static const int progressAnimationFrames = 10; +static const double progressAnimationInterval = 0.125; +double RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress*) const +{ + return progressAnimationInterval; +} + +double RenderThemeGtk::animationDurationForProgressBar(RenderProgress*) const +{ + return progressAnimationInterval * progressAnimationFrames * 2; // "2" for back and forth; +} + +IntRect RenderThemeGtk::calculateProgressRect(RenderObject* renderObject, const IntRect& fullBarRect) +{ + IntRect progressRect(fullBarRect); + RenderProgress* renderProgress = toRenderProgress(renderObject); + if (renderProgress->isDeterminate()) { + int progressWidth = progressRect.width() * renderProgress->position(); + if (renderObject->style()->direction() == RTL) + progressRect.setX(progressRect.x() + progressRect.width() - progressWidth); + progressRect.setWidth(progressWidth); + return progressRect; + } + + double animationProgress = renderProgress->animationProgress(); + + // Never let the progress rect shrink smaller than 2 pixels. + int newWidth = max(2, progressRect.width() / progressActivityBlocks); + int movableWidth = progressRect.width() - newWidth; + progressRect.setWidth(newWidth); + + // We want the first 0.5 units of the animation progress to represent the + // forward motion and the second 0.5 units to represent the backward motion, + // thus we multiply by two here to get the full sweep of the progress bar with + // each direction. + if (animationProgress < 0.5) + progressRect.setX(progressRect.x() + (animationProgress * 2 * movableWidth)); + else + progressRect.setX(progressRect.x() + ((1.0 - animationProgress) * 2 * movableWidth)); + return progressRect; +} #endif } diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk.h b/Source/WebCore/platform/gtk/RenderThemeGtk.h index 90113e5..5765782 100644 --- a/Source/WebCore/platform/gtk/RenderThemeGtk.h +++ b/Source/WebCore/platform/gtk/RenderThemeGtk.h @@ -169,13 +169,21 @@ protected: virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); #endif + virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&); + private: void platformInit(); + static void setTextInputBorders(RenderStyle*); + GRefPtr<GdkPixbuf> getStockIcon(GType, const char* iconName, gint direction, gint state, gint iconSize); + static double getScreenDPI(); + #if ENABLE(VIDEO) bool paintMediaButton(RenderObject*, GraphicsContext*, const IntRect&, const char* iconName); #endif - static void setTextInputBorders(RenderStyle*); - GRefPtr<GdkPixbuf> getStockIcon(GType, const char* iconName, gint direction, gint state, gint iconSize); + +#if ENABLE(PROGRESS_TAG) + static IntRect calculateProgressRect(RenderObject*, const IntRect&); +#endif mutable Color m_panelColor; mutable Color m_sliderColor; @@ -188,13 +196,26 @@ private: #ifdef GTK_API_VERSION_2 void setupWidgetAndAddToContainer(GtkWidget*, GtkWidget*) const; bool paintRenderObject(GtkThemeWidgetType, RenderObject*, GraphicsContext*, const IntRect&, int flags = 0); + void refreshComboBoxChildren() const; + void getComboBoxPadding(RenderStyle*, int& left, int& top, int& right, int& bottom) const; + int getComboBoxSeparatorWidth() const; + int comboBoxArrowSize(RenderStyle*) const; GtkThemeParts m_themeParts; + GtkWidget* gtkButton() const; GtkWidget* gtkEntry() const; GtkWidget* gtkTreeView() const; GtkWidget* gtkVScale() const; GtkWidget* gtkHScale() const; GtkWidget* gtkContainer() const; + GtkWidget* gtkRadioButton() const; + GtkWidget* gtkCheckButton() const; + GtkWidget* gtkProgressBar() const; + GtkWidget* gtkComboBox() const; + GtkWidget* gtkComboBoxButton() const; + GtkWidget* gtkComboBoxArrow() const; + GtkWidget* gtkComboBoxSeparator() const; + mutable GtkWidget* m_gtkWindow; mutable GtkWidget* m_gtkContainer; mutable GtkWidget* m_gtkButton; @@ -202,6 +223,13 @@ private: mutable GtkWidget* m_gtkTreeView; mutable GtkWidget* m_gtkVScale; mutable GtkWidget* m_gtkHScale; + mutable GtkWidget* m_gtkRadioButton; + mutable GtkWidget* m_gtkCheckButton; + mutable GtkWidget* m_gtkProgressBar; + mutable GtkWidget* m_gtkComboBox; + mutable GtkWidget* m_gtkComboBoxButton; + mutable GtkWidget* m_gtkComboBoxArrow; + mutable GtkWidget* m_gtkComboBoxSeparator; bool m_themePartsHaveRGBAColormap; friend class WidgetRenderingContext; #endif diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp b/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp index e01508e..de4195d 100644 --- a/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp +++ b/Source/WebCore/platform/gtk/RenderThemeGtk2.cpp @@ -27,6 +27,10 @@ #ifdef GTK_API_VERSION_2 +// We need this to allow building while using GTK_WIDGET_SET_FLAGS. It's deprecated +// but some theme engines require it to ensure proper rendering of focus indicators. +#undef GTK_DISABLE_DEPRECATED + #include "CSSValueKeywords.h" #include "GraphicsContext.h" #include "GtkVersioning.h" @@ -41,10 +45,6 @@ #include <gdk/gdk.h> #include <gtk/gtk.h> -#if ENABLE(PROGRESS_TAG) -#include "RenderProgress.h" -#endif - namespace WebCore { // This is not a static method, because we want to avoid having GTK+ headers in RenderThemeGtk.h. @@ -61,6 +61,13 @@ void RenderThemeGtk::platformInit() m_gtkTreeView = 0; m_gtkVScale = 0; m_gtkHScale = 0; + m_gtkRadioButton = 0; + m_gtkCheckButton = 0; + m_gtkProgressBar = 0; + m_gtkComboBox = 0; + m_gtkComboBoxButton = 0; + m_gtkComboBoxArrow = 0; + m_gtkComboBoxSeparator = 0; memset(&m_themeParts, 0, sizeof(GtkThemeParts)); GdkColormap* colormap = gdk_screen_get_rgba_colormap(gdk_screen_get_default()); @@ -99,8 +106,34 @@ void RenderThemeGtk::initMediaColors() } #endif -void RenderThemeGtk::adjustRepaintRect(const RenderObject*, IntRect&) +static void adjustRectForFocus(GtkWidget* widget, IntRect& rect, bool ignoreInteriorFocusProperty = false) +{ + gint focusWidth, focusPad; + gboolean interiorFocus = 0; + gtk_widget_style_get(widget, + "interior-focus", &interiorFocus, + "focus-line-width", &focusWidth, + "focus-padding", &focusPad, NULL); + if (!ignoreInteriorFocusProperty && interiorFocus) + return; + rect.inflate(focusWidth + focusPad); +} + +void RenderThemeGtk::adjustRepaintRect(const RenderObject* renderObject, IntRect& rect) { + ControlPart part = renderObject->style()->appearance(); + switch (part) { + case CheckboxPart: + case RadioPart: { + // We ignore the interior focus property and always expand the focus rect. In GTK+, the + // focus indicator is usually on the text next to a checkbox or radio button, but that doesn't + // happen in WebCore. By expanding the focus rectangle unconditionally we increase its prominence. + adjustRectForFocus(part == CheckboxPart ? gtkCheckButton() : gtkRadioButton(), rect, true); + return; + } + default: + return; + } } static GtkStateType getGtkStateType(RenderThemeGtk* theme, RenderObject* object) @@ -142,56 +175,89 @@ bool RenderThemeGtk::paintRenderObject(GtkThemeWidgetType type, RenderObject* re gtkTextDirection(renderObject->style()->direction())); } -void RenderThemeGtk::getIndicatorMetrics(ControlPart part, int& indicatorSize, int& indicatorSpacing) +static void setToggleSize(const RenderThemeGtk* theme, RenderStyle* style, GtkWidget* widget) { - ASSERT(part == CheckboxPart || part == RadioPart); - if (part == CheckboxPart) { - moz_gtk_checkbox_get_metrics(&indicatorSize, &indicatorSpacing); + // The width and height are both specified, so we shouldn't change them. + if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) return; - } - // RadioPart - moz_gtk_radio_get_metrics(&indicatorSize, &indicatorSpacing); + gint indicatorSize; + gtk_widget_style_get(widget, "indicator-size", &indicatorSize, NULL); + if (style->width().isIntrinsicOrAuto()) + style->setWidth(Length(indicatorSize, Fixed)); + if (style->height().isAuto()) + style->setHeight(Length(indicatorSize, Fixed)); } -static void setToggleSize(const RenderThemeGtk* theme, RenderStyle* style, ControlPart appearance) +static void paintToggle(RenderThemeGtk* theme, RenderObject* renderObject, const PaintInfo& info, const IntRect& rect, GtkWidget* widget) { - // The width and height are both specified, so we shouldn't change them. - if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) - return; + // We do not call gtk_toggle_button_set_active here, because some themes begin a series of + // animation frames in a "toggled" signal handler. This puts some checkboxes in a half-way + // checked state. Every GTK+ theme I tested merely looks at the shadow type (and not the + // 'active' property) to determine whether or not to draw the check. + gtk_widget_set_sensitive(widget, theme->isEnabled(renderObject) && !theme->isReadOnlyControl(renderObject)); + gtk_widget_set_direction(widget, gtkTextDirection(renderObject->style()->direction())); - // FIXME: This is probably not correct use of indicatorSize and indicatorSpacing. - gint indicatorSize, indicatorSpacing; - RenderThemeGtk::getIndicatorMetrics(appearance, indicatorSize, indicatorSpacing); + bool indeterminate = theme->isIndeterminate(renderObject); + gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(widget), indeterminate); - // Other ports hard-code this to 13, but GTK+ users tend to demand the native look. - // It could be made a configuration option values other than 13 actually break site compatibility. - int length = indicatorSize + indicatorSpacing; - if (style->width().isIntrinsicOrAuto()) - style->setWidth(Length(length, Fixed)); + GtkShadowType shadowType = GTK_SHADOW_OUT; + if (indeterminate) // This originates from the Mozilla code. + shadowType = GTK_SHADOW_ETCHED_IN; + else if (theme->isChecked(renderObject)) + shadowType = GTK_SHADOW_IN; - if (style->height().isAuto()) - style->setHeight(Length(length, Fixed)); + WidgetRenderingContext widgetContext(info.context, rect); + IntRect buttonRect(IntPoint(), rect.size()); + GtkStateType toggleState = getGtkStateType(theme, renderObject); + const char* detail = 0; + if (GTK_IS_RADIO_BUTTON(widget)) { + detail = "radiobutton"; + widgetContext.gtkPaintOption(buttonRect, widget, toggleState, shadowType, detail); + } else { + detail = "checkbutton"; + widgetContext.gtkPaintCheck(buttonRect, widget, toggleState, shadowType, detail); + } + + if (theme->isFocused(renderObject)) { + IntRect focusRect(buttonRect); + adjustRectForFocus(widget, focusRect, true); + widgetContext.gtkPaintFocus(focusRect, widget, toggleState, detail); + } } void RenderThemeGtk::setCheckboxSize(RenderStyle* style) const { - setToggleSize(this, style, RadioPart); + setToggleSize(this, style, gtkCheckButton()); } -bool RenderThemeGtk::paintCheckbox(RenderObject* object, const PaintInfo& info, const IntRect& rect) +bool RenderThemeGtk::paintCheckbox(RenderObject* renderObject, const PaintInfo& info, const IntRect& rect) { - return paintRenderObject(MOZ_GTK_CHECKBUTTON, object, info.context, rect, isChecked(object)); + paintToggle(this, renderObject, info, rect, gtkCheckButton()); + return false; } void RenderThemeGtk::setRadioSize(RenderStyle* style) const { - setToggleSize(this, style, RadioPart); + setToggleSize(this, style, gtkRadioButton()); +} + +bool RenderThemeGtk::paintRadio(RenderObject* renderObject, const PaintInfo& info, const IntRect& rect) +{ + paintToggle(this, renderObject, info, rect, gtkRadioButton()); + return false; } -bool RenderThemeGtk::paintRadio(RenderObject* object, const PaintInfo& info, const IntRect& rect) +static void setWidgetHasFocus(GtkWidget* widget, gboolean hasFocus) { - return paintRenderObject(MOZ_GTK_RADIOBUTTON, object, info.context, rect, isChecked(object)); + g_object_set(widget, "has-focus", hasFocus, NULL); + + // These functions are deprecated in GTK+ 2.22, yet theme engines still look + // at these flags when determining if a widget has focus, so we must use them. + if (hasFocus) + GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); + else + GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); } bool RenderThemeGtk::paintButton(RenderObject* object, const PaintInfo& info, const IntRect& rect) @@ -208,12 +274,7 @@ bool RenderThemeGtk::paintButton(RenderObject* object, const PaintInfo& info, co gtk_widget_set_direction(widget, gtkTextDirection(object->style()->direction())); if (isFocused(object)) { - if (isEnabled(object)) { -#if !GTK_CHECK_VERSION(2, 22, 0) - GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); -#endif - g_object_set(widget, "has-focus", TRUE, NULL); - } + setWidgetHasFocus(widget, TRUE); gboolean interiorFocus = 0, focusWidth = 0, focusPadding = 0; gtk_widget_style_get(widget, @@ -239,21 +300,74 @@ bool RenderThemeGtk::paintButton(RenderObject* object, const PaintInfo& info, co if (isFocused(object)) widgetContext.gtkPaintFocus(focusRect, widget, state, "button"); -#if !GTK_CHECK_VERSION(2, 22, 0) - GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); -#endif - g_object_set(widget, "has-focus", FALSE, NULL); + setWidgetHasFocus(widget, FALSE); return false; } -static void getComboBoxPadding(RenderStyle* style, int& left, int& top, int& right, int& bottom) +int RenderThemeGtk::getComboBoxSeparatorWidth() const +{ + GtkWidget* separator = gtkComboBoxSeparator(); + if (!separator) + return 0; + + gboolean hasWideSeparators = FALSE; + gint separatorWidth = 0; + gtk_widget_style_get(separator, + "wide-separators", &hasWideSeparators, + "separator-width", &separatorWidth, + NULL); + if (hasWideSeparators) + return separatorWidth; + return gtk_widget_get_style(separator)->xthickness; +} + +int RenderThemeGtk::comboBoxArrowSize(RenderStyle* style) const +{ + // Taking the font size and reversing the DPI conversion seems to match + // GTK+ rendering as closely as possible. + return style->font().size() * (72.0 / RenderThemeGtk::getScreenDPI()); +} + +static void getButtonInnerBorder(GtkWidget* button, int& left, int& top, int& right, int& bottom) +{ + GtkStyle* style = gtk_widget_get_style(button); + int outerBorder = gtk_container_get_border_width(GTK_CONTAINER(button)); + static GtkBorder defaultInnerBorder = {1, 1, 1, 1}; + GtkBorder* innerBorder; + gtk_widget_style_get(button, "inner-border", &innerBorder, NULL); + if (!innerBorder) + innerBorder = &defaultInnerBorder; + + left = outerBorder + innerBorder->left + style->xthickness; + right = outerBorder + innerBorder->right + style->xthickness; + top = outerBorder + innerBorder->top + style->ythickness; + bottom = outerBorder + innerBorder->bottom + style->ythickness; + + if (innerBorder != &defaultInnerBorder) + gtk_border_free(innerBorder); +} + + +void RenderThemeGtk::getComboBoxPadding(RenderStyle* style, int& left, int& top, int& right, int& bottom) const { // If this menu list button isn't drawn using the native theme, we // don't add any extra padding beyond what WebCore already uses. if (style->appearance() == NoControlPart) return; - moz_gtk_get_widget_border(MOZ_GTK_DROPDOWN, &left, &top, &right, &bottom, - gtkTextDirection(style->direction()), TRUE); + + // A combo box button is a button with widgets packed into it. + GtkStyle* buttonWidgetStyle = gtk_widget_get_style(gtkComboBoxButton()); + getButtonInnerBorder(gtkComboBoxButton(), left, top, right, bottom); + + // Add xthickness amount of padding for each side of the separator. This ensures + // that the text does not bump up against the separator. + int arrowAndSeperatorLength = comboBoxArrowSize(style) + + getComboBoxSeparatorWidth() + (3 * buttonWidgetStyle->xthickness); + + if (style->direction() == RTL) + left += arrowAndSeperatorLength; + else + right += arrowAndSeperatorLength; } int RenderThemeGtk::popupInternalPaddingLeft(RenderStyle* style) const @@ -286,12 +400,102 @@ int RenderThemeGtk::popupInternalPaddingBottom(RenderStyle* style) const bool RenderThemeGtk::paintMenuList(RenderObject* object, const PaintInfo& info, const IntRect& rect) { - return paintRenderObject(MOZ_GTK_DROPDOWN, object, info.context, rect); + if (paintButton(object, info, rect)) + return true; + + // Menu list button painting strategy. + // For buttons with appears-as-list set to false (having a separator): + // | left border | Button text | xthickness | vseparator | xthickness | arrow | xthickness | right border | + // For buttons with appears-as-list set to true (not having a separator): + // | left border | Button text | arrow | xthickness | right border | + + int leftBorder = 0, rightBorder = 0, bottomBorder = 0, topBorder = 0; + getButtonInnerBorder(gtkComboBoxButton(), leftBorder, topBorder, rightBorder, bottomBorder); + RenderStyle* style = object->style(); + int arrowSize = comboBoxArrowSize(style); + GtkStyle* buttonStyle = gtk_widget_get_style(gtkComboBoxButton()); + + IntRect arrowRect(0, (rect.height() - arrowSize) / 2, arrowSize, arrowSize); + if (style->direction() == RTL) + arrowRect.setX(leftBorder + buttonStyle->xthickness); + else + arrowRect.setX(rect.width() - rightBorder - buttonStyle->xthickness - arrowSize); + GtkShadowType shadowType = isPressed(object) ? GTK_SHADOW_IN : GTK_SHADOW_OUT; + + WidgetRenderingContext widgetContext(info.context, rect); + GtkStateType stateType = getGtkStateType(this, object); + widgetContext.gtkPaintArrow(arrowRect, gtkComboBoxArrow(), stateType, shadowType, GTK_ARROW_DOWN, "arrow"); + + // Some combo boxes do not have a separator. + GtkWidget* separator = gtkComboBoxSeparator(); + if (!separator) + return false; + + // We want to decrease the height of the separator based on the focus padding of the button. + gint focusPadding = 0, focusWidth = 0; + gtk_widget_style_get(gtkComboBoxButton(), + "focus-line-width", &focusWidth, + "focus-padding", &focusPadding, NULL); + topBorder += focusPadding + focusWidth; + bottomBorder += focusPadding + focusWidth; + int separatorWidth = getComboBoxSeparatorWidth(); + IntRect separatorRect(0, topBorder, separatorWidth, rect.height() - topBorder - bottomBorder); + if (style->direction() == RTL) + separatorRect.setX(arrowRect.x() + arrowRect.width() + buttonStyle->xthickness + separatorWidth); + else + separatorRect.setX(arrowRect.x() - buttonStyle->xthickness - separatorWidth); + + gboolean hasWideSeparators = FALSE; + gtk_widget_style_get(separator, "wide-separators", &hasWideSeparators, NULL); + if (hasWideSeparators) + widgetContext.gtkPaintBox(separatorRect, separator, GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT, "vseparator"); + else + widgetContext.gtkPaintVLine(separatorRect, separator, GTK_STATE_NORMAL, "vseparator"); + + return false; } -bool RenderThemeGtk::paintTextField(RenderObject* object, const PaintInfo& info, const IntRect& rect) +bool RenderThemeGtk::paintTextField(RenderObject* renderObject, const PaintInfo& info, const IntRect& rect) { - return paintRenderObject(MOZ_GTK_ENTRY, object, info.context, rect); + GtkWidget* widget = gtkEntry(); + + bool enabled = isEnabled(renderObject) && !isReadOnlyControl(renderObject); + GtkStateType backgroundState = enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE; + gtk_widget_set_sensitive(widget, enabled); + gtk_widget_set_direction(widget, gtkTextDirection(renderObject->style()->direction())); + setWidgetHasFocus(widget, isFocused(renderObject)); + + WidgetRenderingContext widgetContext(info.context, rect); + IntRect textFieldRect(IntPoint(), rect.size()); + + // The entry background is only painted over the interior part of the GTK+ entry, not + // the entire frame. This happens in the Mozilla theme drawing code as well. + IntRect interiorRect(textFieldRect); + GtkStyle* style = gtk_widget_get_style(widget); + interiorRect.inflateX(-style->xthickness); + interiorRect.inflateY(-style->ythickness); + widgetContext.gtkPaintFlatBox(interiorRect, widget, backgroundState, GTK_SHADOW_NONE, "entry_bg"); + + // This is responsible for drawing the actual frame. + widgetContext.gtkPaintShadow(textFieldRect, widget, GTK_STATE_NORMAL, GTK_SHADOW_IN, "entry"); + + gboolean interiorFocus; + gint focusWidth; + gtk_widget_style_get(widget, + "interior-focus", &interiorFocus, + "focus-line-width", &focusWidth, NULL); + if (isFocused(renderObject) && !interiorFocus) { + // When GTK+ paints a text entry with focus, it shrinks the size of the frame area by the + // focus width and paints over the previously unfocused text entry. We need to emulate that + // by drawing both the unfocused frame above and the focused frame here. + IntRect shadowRect(textFieldRect); + shadowRect.inflate(-focusWidth); + widgetContext.gtkPaintShadow(shadowRect, widget, GTK_STATE_NORMAL, GTK_SHADOW_IN, "entry"); + + widgetContext.gtkPaintFocus(textFieldRect, widget, GTK_STATE_NORMAL, "entry"); + } + + return false; } bool RenderThemeGtk::paintSliderTrack(RenderObject* object, const PaintInfo& info, const IntRect& rect) @@ -382,45 +586,25 @@ void RenderThemeGtk::adjustSliderThumbSize(RenderObject* o) const } #if ENABLE(PROGRESS_TAG) -double RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress*) const -{ - // FIXME: It doesn't look like there is a good way yet to support animated - // progress bars with the Mozilla theme drawing code. - return 0; -} - -double RenderThemeGtk::animationDurationForProgressBar(RenderProgress*) const -{ - // FIXME: It doesn't look like there is a good way yet to support animated - // progress bars with the Mozilla theme drawing code. - return 0; -} - bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect) { - if (!renderObject->isProgress()) - return true; + GtkWidget* widget = gtkProgressBar(); + gtk_widget_set_direction(widget, gtkTextDirection(renderObject->style()->direction())); - GtkWidget* progressBarWidget = moz_gtk_get_progress_widget(); - if (!progressBarWidget) - return true; + WidgetRenderingContext widgetContext(paintInfo.context, rect); + IntRect fullProgressBarRect(IntPoint(), rect.size()); + widgetContext.gtkPaintBox(fullProgressBarRect, widget, GTK_STATE_NORMAL, GTK_SHADOW_IN, "trough"); - if (paintRenderObject(MOZ_GTK_PROGRESSBAR, renderObject, paintInfo.context, rect)) - return true; + GtkStyle* style = gtk_widget_get_style(widget); + IntRect progressRect(fullProgressBarRect); + progressRect.inflateX(-style->xthickness); + progressRect.inflateY(-style->ythickness); + progressRect = RenderThemeGtk::calculateProgressRect(renderObject, progressRect); - IntRect chunkRect(rect); - RenderProgress* renderProgress = toRenderProgress(renderObject); + if (!progressRect.isEmpty()) + widgetContext.gtkPaintBox(progressRect, widget, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, "bar"); - GtkStyle* style = gtk_widget_get_style(progressBarWidget); - chunkRect.setHeight(chunkRect.height() - (2 * style->ythickness)); - chunkRect.setY(chunkRect.y() + style->ythickness); - chunkRect.setWidth((chunkRect.width() - (2 * style->xthickness)) * renderProgress->position()); - if (renderObject->style()->direction() == RTL) - chunkRect.setX(rect.x() + rect.width() - chunkRect.width() - style->xthickness); - else - chunkRect.setX(chunkRect.x() + style->xthickness); - - return paintRenderObject(MOZ_GTK_PROGRESS_CHUNK, renderObject, paintInfo.context, chunkRect); + return false; } #endif @@ -503,11 +687,16 @@ static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, RenderThe renderTheme->platformColorsDidChange(); } -void RenderThemeGtk::setupWidgetAndAddToContainer(GtkWidget* widget, GtkWidget* window) const +static void setupWidget(GtkWidget* widget) { - gtk_container_add(GTK_CONTAINER(window), widget); gtk_widget_realize(widget); g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); +} + +void RenderThemeGtk::setupWidgetAndAddToContainer(GtkWidget* widget, GtkWidget* window) const +{ + gtk_container_add(GTK_CONTAINER(window), widget); + setupWidget(widget); // FIXME: Perhaps this should only be called for the containing window or parent container. g_signal_connect(widget, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this)); @@ -520,7 +709,7 @@ GtkWidget* RenderThemeGtk::gtkContainer() const m_gtkWindow = gtk_window_new(GTK_WINDOW_POPUP); gtk_widget_set_colormap(m_gtkWindow, m_themeParts.colormap); - gtk_widget_realize(m_gtkWindow); + setupWidget(m_gtkWindow); gtk_widget_set_name(m_gtkWindow, "MozillaGtkWidget"); m_gtkContainer = gtk_fixed_new(); @@ -573,6 +762,126 @@ GtkWidget* RenderThemeGtk::gtkHScale() const return m_gtkHScale; } +GtkWidget* RenderThemeGtk::gtkRadioButton() const +{ + if (m_gtkRadioButton) + return m_gtkRadioButton; + m_gtkRadioButton = gtk_radio_button_new(0); + setupWidgetAndAddToContainer(m_gtkRadioButton, gtkContainer()); + return m_gtkRadioButton; +} + +GtkWidget* RenderThemeGtk::gtkCheckButton() const +{ + if (m_gtkCheckButton) + return m_gtkCheckButton; + m_gtkCheckButton = gtk_check_button_new(); + setupWidgetAndAddToContainer(m_gtkCheckButton, gtkContainer()); + return m_gtkCheckButton; +} + +GtkWidget* RenderThemeGtk::gtkProgressBar() const +{ + if (m_gtkProgressBar) + return m_gtkProgressBar; + m_gtkProgressBar = gtk_progress_bar_new(); + setupWidgetAndAddToContainer(m_gtkProgressBar, gtkContainer()); + return m_gtkProgressBar; +} + +static void getGtkComboBoxButton(GtkWidget* widget, gpointer target) +{ + if (!GTK_IS_TOGGLE_BUTTON(widget)) + return; + GtkWidget** widgetTarget = static_cast<GtkWidget**>(target); + *widgetTarget = widget; +} + +typedef struct { + GtkWidget* arrow; + GtkWidget* separator; +} ComboBoxWidgetPieces; + +static void getGtkComboBoxPieces(GtkWidget* widget, gpointer data) +{ + if (GTK_IS_ARROW(widget)) { + static_cast<ComboBoxWidgetPieces*>(data)->arrow = widget; + return; + } + if (GTK_IS_SEPARATOR(widget)) + static_cast<ComboBoxWidgetPieces*>(data)->separator = widget; +} + +GtkWidget* RenderThemeGtk::gtkComboBox() const +{ + if (m_gtkComboBox) + return m_gtkComboBox; + m_gtkComboBox = gtk_combo_box_new(); + setupWidgetAndAddToContainer(m_gtkComboBox, gtkContainer()); + return m_gtkComboBox; +} + +void RenderThemeGtk::refreshComboBoxChildren() const +{ + gtkComboBox(); // Ensure that we've initialized the combo box. + + // Some themes look at widget ancestry to determine how to render widgets, so + // get the GtkButton that is the actual child of the combo box. + gtk_container_forall(GTK_CONTAINER(m_gtkComboBox), getGtkComboBoxButton, &m_gtkComboBoxButton); + ASSERT(m_gtkComboBoxButton); + setupWidget(m_gtkComboBoxButton); + g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxButton), reinterpret_cast<gpointer*>(&m_gtkComboBoxButton)); + + ComboBoxWidgetPieces pieces = { 0, 0 }; + GtkWidget* buttonChild = gtk_bin_get_child(GTK_BIN(gtkComboBoxButton())); + if (GTK_IS_HBOX(buttonChild)) + gtk_container_forall(GTK_CONTAINER(buttonChild), getGtkComboBoxPieces, &pieces); + else if (GTK_IS_ARROW(buttonChild)) + pieces.arrow = buttonChild; + + ASSERT(pieces.arrow); + m_gtkComboBoxArrow = pieces.arrow; + setupWidget(m_gtkComboBoxArrow); + // When the style changes, the combo box may destroy its children. + g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxArrow), reinterpret_cast<gpointer*>(&m_gtkComboBoxArrow)); + + m_gtkComboBoxSeparator = pieces.separator; + if (m_gtkComboBoxSeparator) { + setupWidget(m_gtkComboBoxSeparator); + // When the style changes, the combo box may destroy its children. + g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxSeparator), reinterpret_cast<gpointer*>(&m_gtkComboBoxSeparator)); + } +} + +GtkWidget* RenderThemeGtk::gtkComboBoxButton() const +{ + if (m_gtkComboBoxButton) + return m_gtkComboBoxButton; + refreshComboBoxChildren(); + ASSERT(m_gtkComboBoxButton); + return m_gtkComboBoxButton; +} + +GtkWidget* RenderThemeGtk::gtkComboBoxArrow() const +{ + if (m_gtkComboBoxArrow) + return m_gtkComboBoxArrow; + refreshComboBoxChildren(); + ASSERT(m_gtkComboBoxArrow); + return m_gtkComboBoxArrow; +} + +GtkWidget* RenderThemeGtk::gtkComboBoxSeparator() const +{ + // m_gtkComboBoxSeparator may be null either because we haven't initialized the combo box + // or because the combo boxes in this theme don't have separators. If m_gtkComboBoxArrow + // arrow isn't null, we definitely have initialized the combo box. + if (m_gtkComboBoxArrow || m_gtkComboBoxButton) + return m_gtkComboBoxSeparator; + refreshComboBoxChildren(); + return m_gtkComboBoxSeparator; +} + GtkWidget* RenderThemeGtk::gtkScrollbar() { return moz_gtk_get_scrollbar_widget(); diff --git a/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp b/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp index 212e29d..1a9f445 100644 --- a/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp +++ b/Source/WebCore/platform/gtk/RenderThemeGtk3.cpp @@ -41,10 +41,6 @@ #include <gdk/gdk.h> #include <gtk/gtk.h> -#if ENABLE(PROGRESS_TAG) -#include "RenderProgress.h" -#endif - namespace WebCore { // This is the default value defined by GTK+, where it was defined as MIN_ARROW_SIZE in gtkarrow.c. @@ -690,20 +686,6 @@ void RenderThemeGtk::adjustSliderThumbSize(RenderObject* renderObject) const } #if ENABLE(PROGRESS_TAG) -// These values have been copied from RenderThemeChromiumSkia.cpp -static const int progressActivityBlocks = 5; -static const int progressAnimationFrames = 10; -static const double progressAnimationInterval = 0.125; -double RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress*) const -{ - return progressAnimationInterval; -} - -double RenderThemeGtk::animationDurationForProgressBar(RenderProgress*) const -{ - return progressAnimationInterval * progressAnimationFrames * 2; // "2" for back and forth; -} - bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect) { if (!renderObject->isProgress()) @@ -722,34 +704,18 @@ bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInf gtk_style_context_save(context); gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR); - RenderProgress* renderProgress = toRenderProgress(renderObject); GtkBorder padding; gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding); IntRect progressRect(rect.x() + padding.left, rect.y() + padding.top, rect.width() - (padding.left + padding.right), rect.height() - (padding.top + padding.bottom)); - - if (renderProgress->isDeterminate()) { - progressRect.setWidth(progressRect.width() * renderProgress->position()); - if (renderObject->style()->direction() == RTL) - progressRect.setX(rect.x() + rect.width() - progressRect.width() - padding.right); - } else { - double animationProgress = renderProgress->animationProgress(); - - progressRect.setWidth(max(2, progressRect.width() / progressActivityBlocks)); - int movableWidth = rect.width() - progressRect.width(); - if (animationProgress < 0.5) - progressRect.setX(progressRect.x() + (animationProgress * 2 * movableWidth)); - else - progressRect.setX(progressRect.x() + ((1.0 - animationProgress) * 2 * movableWidth)); - } + progressRect = RenderThemeGtk::calculateProgressRect(renderObject, progressRect); if (!progressRect.isEmpty()) gtk_render_activity(context, paintInfo.context->platformContext(), progressRect.x(), progressRect.y(), progressRect.width(), progressRect.height()); gtk_style_context_restore(context); - return false; } #endif diff --git a/Source/WebCore/platform/gtk/WidgetRenderingContext.cpp b/Source/WebCore/platform/gtk/WidgetRenderingContext.cpp index 6d1be31..51b32ea 100644 --- a/Source/WebCore/platform/gtk/WidgetRenderingContext.cpp +++ b/Source/WebCore/platform/gtk/WidgetRenderingContext.cpp @@ -65,21 +65,6 @@ static void scheduleScratchBufferPurge() purgeScratchBufferTimer.startOneShot(2); } -static IntSize getExtraSpaceForWidget(RenderThemeGtk* theme) -{ - // Checkboxes and scrollbar thumbs often draw outside their boundaries. Here we figure out - // the maximum amount of space we need for any type of widget and use that to increase the - // size of the scratch buffer, while preserving the final widget position. - - // The checkbox extra space is calculated by looking at the widget style. - int indicatorSize, indicatorSpacing; - theme->getIndicatorMetrics(CheckboxPart, indicatorSize, indicatorSpacing); - IntSize extraSpace(indicatorSpacing, indicatorSpacing); - - // Scrollbar thumbs need at least an extra pixel along their movement axis. - return extraSpace.expandedTo(IntSize(1, 1)); -} - WidgetRenderingContext::WidgetRenderingContext(GraphicsContext* graphicsContext, const IntRect& targetRect) : m_graphicsContext(graphicsContext) , m_targetRect(targetRect) @@ -96,8 +81,9 @@ WidgetRenderingContext::WidgetRenderingContext(GraphicsContext* graphicsContext, return; } - // Some widgets render outside their rectangles. We need to account for this. - m_extraSpace = getExtraSpaceForWidget(theme); + // Widgets sometimes need to draw outside their boundaries for things such as + // exterior focus. We want to allocate a some extra pixels in our surface for this. + m_extraSpace = IntSize(15, 15); // Offset the target rectangle so that the extra space is within the boundaries of the scratch buffer. m_paintRect = IntRect(IntPoint(m_extraSpace.width(), m_extraSpace.height()), @@ -173,10 +159,17 @@ void WidgetRenderingContext::gtkPaintBox(const IntRect& rect, GtkWidget* widget, widget, detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height); } +void WidgetRenderingContext::gtkPaintFlatBox(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail) +{ + GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() }; + gtk_paint_flat_box(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, + widget, detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height); +} + void WidgetRenderingContext::gtkPaintFocus(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, const gchar* detail) { GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() }; - gtk_paint_focus(gtk_widget_get_style(widget), m_target, stateType, &m_paintRect, widget, + gtk_paint_focus(gtk_widget_get_style(widget), m_target, stateType, &paintRect, widget, detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height); } @@ -187,6 +180,42 @@ void WidgetRenderingContext::gtkPaintSlider(const IntRect& rect, GtkWidget* widg detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height, orientation); } +void WidgetRenderingContext::gtkPaintCheck(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail) +{ + GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() }; + gtk_paint_check(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget, + detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height); +} + +void WidgetRenderingContext::gtkPaintOption(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail) +{ + GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() }; + gtk_paint_option(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget, + detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height); +} + +void WidgetRenderingContext::gtkPaintShadow(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail) +{ + GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() }; + gtk_paint_shadow(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget, + detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height); +} + +void WidgetRenderingContext::gtkPaintArrow(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, int arrowDirection, const gchar* detail) +{ + GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() }; + gtk_paint_arrow(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget, detail, + static_cast<GtkArrowType>(arrowDirection), TRUE, paintRect.x, paintRect.y, paintRect.width, paintRect.height); +} + +void WidgetRenderingContext::gtkPaintVLine(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, const gchar* detail) +{ + GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() }; + gtk_paint_vline(gtk_widget_get_style(widget), m_target, stateType, &paintRect, widget, detail, + paintRect.y, paintRect.y + paintRect.height, paintRect.x); + +} + } #endif // GTK_API_VERSION_2 diff --git a/Source/WebCore/platform/gtk/WidgetRenderingContext.h b/Source/WebCore/platform/gtk/WidgetRenderingContext.h index 8b2a0e2..e248f04 100644 --- a/Source/WebCore/platform/gtk/WidgetRenderingContext.h +++ b/Source/WebCore/platform/gtk/WidgetRenderingContext.h @@ -39,8 +39,14 @@ public: bool paintMozillaWidget(GtkThemeWidgetType, GtkWidgetState*, int flags, GtkTextDirection = GTK_TEXT_DIR_NONE); void gtkPaintBox(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*); + void gtkPaintFlatBox(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*); void gtkPaintFocus(const IntRect&, GtkWidget*, GtkStateType, const gchar*); void gtkPaintSlider(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*, GtkOrientation); + void gtkPaintCheck(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*); + void gtkPaintOption(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*); + void gtkPaintShadow(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, const gchar*); + void gtkPaintArrow(const IntRect&, GtkWidget*, GtkStateType, GtkShadowType, int arrowDirection, const gchar*); + void gtkPaintVLine(const IntRect&, GtkWidget*, GtkStateType, const gchar*); private: GraphicsContext* m_graphicsContext; diff --git a/Source/WebCore/platform/gtk/gtk2drawing.c b/Source/WebCore/platform/gtk/gtk2drawing.c index 3ebd332..3979b7f 100644 --- a/Source/WebCore/platform/gtk/gtk2drawing.c +++ b/Source/WebCore/platform/gtk/gtk2drawing.c @@ -60,7 +60,6 @@ static GtkThemeParts *gParts = NULL; static style_prop_t style_prop_func; -static gboolean have_arrow_scaling; static gboolean is_initialized; void @@ -116,61 +115,6 @@ setup_widget_prototype(GtkWidget* widget) } static gint -ensure_button_widget() -{ - if (!gParts->buttonWidget) { - gParts->buttonWidget = gtk_button_new_with_label("M"); - setup_widget_prototype(gParts->buttonWidget); - } - return MOZ_GTK_SUCCESS; -} - -static gint -ensure_toggle_button_widget() -{ - if (!gParts->toggleButtonWidget) { - gParts->toggleButtonWidget = gtk_toggle_button_new(); - setup_widget_prototype(gParts->toggleButtonWidget); - /* toggle button must be set active to get the right style on hover. */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gParts->toggleButtonWidget), TRUE); - } - return MOZ_GTK_SUCCESS; -} - -static gint -ensure_button_arrow_widget() -{ - if (!gParts->buttonArrowWidget) { - ensure_toggle_button_widget(); - - gParts->buttonArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT); - gtk_container_add(GTK_CONTAINER(gParts->toggleButtonWidget), gParts->buttonArrowWidget); - gtk_widget_realize(gParts->buttonArrowWidget); - } - return MOZ_GTK_SUCCESS; -} - -static gint -ensure_checkbox_widget() -{ - if (!gParts->checkboxWidget) { - gParts->checkboxWidget = gtk_check_button_new_with_label("M"); - setup_widget_prototype(gParts->checkboxWidget); - } - return MOZ_GTK_SUCCESS; -} - -static gint -ensure_radiobutton_widget() -{ - if (!gParts->radiobuttonWidget) { - gParts->radiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M"); - setup_widget_prototype(gParts->radiobuttonWidget); - } - return MOZ_GTK_SUCCESS; -} - -static gint ensure_scrollbar_widget() { if (!gParts->vertScrollbarWidget) { @@ -185,129 +129,6 @@ ensure_scrollbar_widget() } static gint -ensure_entry_widget() -{ - if (!gParts->entryWidget) { - gParts->entryWidget = gtk_entry_new(); - setup_widget_prototype(gParts->entryWidget); - } - return MOZ_GTK_SUCCESS; -} - -/* We need to have pointers to the inner widgets (button, separator, arrow) - * of the ComboBox to get the correct rendering from theme engines which - * special cases their look. Since the inner layout can change, we ask GTK - * to NULL our pointers when they are about to become invalid because the - * corresponding widgets don't exist anymore. It's the role of - * g_object_add_weak_pointer(). - * Note that if we don't find the inner widgets (which shouldn't happen), we - * fallback to use generic "non-inner" widgets, and they don't need that kind - * of weak pointer since they are explicit children of gParts->protoWindow and as - * such GTK holds a strong reference to them. */ -static void -moz_gtk_get_combo_box_inner_button(GtkWidget *widget, gpointer client_data) -{ - if (GTK_IS_TOGGLE_BUTTON(widget)) { - gParts->comboBoxButtonWidget = widget; - g_object_add_weak_pointer(G_OBJECT(widget), - (gpointer) &gParts->comboBoxButtonWidget); - gtk_widget_realize(widget); - g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); - } -} - -static void -moz_gtk_get_combo_box_button_inner_widgets(GtkWidget *widget, - gpointer client_data) -{ - if (GTK_IS_SEPARATOR(widget)) { - gParts->comboBoxSeparatorWidget = widget; - g_object_add_weak_pointer(G_OBJECT(widget), - (gpointer) &gParts->comboBoxSeparatorWidget); - } else if (GTK_IS_ARROW(widget)) { - gParts->comboBoxArrowWidget = widget; - g_object_add_weak_pointer(G_OBJECT(widget), - (gpointer) &gParts->comboBoxArrowWidget); - } else - return; - gtk_widget_realize(widget); - g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); -} - -static gint -ensure_combo_box_widgets() -{ - GtkWidget* buttonChild; - - if (gParts->comboBoxButtonWidget && gParts->comboBoxArrowWidget) - return MOZ_GTK_SUCCESS; - - /* Create a ComboBox if needed */ - if (!gParts->comboBoxWidget) { - gParts->comboBoxWidget = gtk_combo_box_new(); - setup_widget_prototype(gParts->comboBoxWidget); - } - - /* Get its inner Button */ - gtk_container_forall(GTK_CONTAINER(gParts->comboBoxWidget), - moz_gtk_get_combo_box_inner_button, - NULL); - - if (gParts->comboBoxButtonWidget) { - /* Get the widgets inside the Button */ - buttonChild = gtk_bin_get_child(GTK_BIN(gParts->comboBoxButtonWidget)); - if (GTK_IS_HBOX(buttonChild)) { - /* appears-as-list = FALSE, cell-view = TRUE; the button - * contains an hbox. This hbox is there because the ComboBox - * needs to place a cell renderer, a separator, and an arrow in - * the button when appears-as-list is FALSE. */ - gtk_container_forall(GTK_CONTAINER(buttonChild), - moz_gtk_get_combo_box_button_inner_widgets, - NULL); - } else if(GTK_IS_ARROW(buttonChild)) { - /* appears-as-list = TRUE, or cell-view = FALSE; - * the button only contains an arrow */ - gParts->comboBoxArrowWidget = buttonChild; - g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer) - &gParts->comboBoxArrowWidget); - gtk_widget_realize(gParts->comboBoxArrowWidget); - g_object_set_data(G_OBJECT(gParts->comboBoxArrowWidget), - "transparent-bg-hint", GINT_TO_POINTER(TRUE)); - } - } else { - /* Shouldn't be reached with current internal gtk implementation; we - * use a generic toggle button as last resort fallback to avoid - * crashing. */ - ensure_toggle_button_widget(); - gParts->comboBoxButtonWidget = gParts->toggleButtonWidget; - } - - if (!gParts->comboBoxArrowWidget) { - /* Shouldn't be reached with current internal gtk implementation; - * we gParts->buttonArrowWidget as last resort fallback to avoid - * crashing. */ - ensure_button_arrow_widget(); - gParts->comboBoxArrowWidget = gParts->buttonArrowWidget; - } - - /* We don't test the validity of gParts->comboBoxSeparatorWidget since there - * is none when "appears-as-list" = TRUE or "cell-view" = FALSE; if it - * is invalid we just won't paint it. */ - - return MOZ_GTK_SUCCESS; -} - -static gint -ensure_progress_widget() -{ - if (!gParts->progresWidget) { - gParts->progresWidget = gtk_progress_bar_new(); - setup_widget_prototype(gParts->progresWidget); - } - return MOZ_GTK_SUCCESS; -} - -static gint ensure_scrolled_window_widget() { if (!gParts->scrolledWindowWidget) { @@ -355,93 +176,12 @@ TSOffsetStyleGCs(GtkStyle* style, gint xorigin, gint yorigin) return MOZ_GTK_SUCCESS; } -static gint -moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect, - GdkRectangle* cliprect, GtkWidgetState* state, - GtkReliefStyle relief, GtkWidget* widget, - GtkTextDirection direction) -{ - GtkShadowType shadow_type; - GtkStyle* style = gtk_widget_get_style(widget); - GtkStateType button_state = ConvertGtkState(state); - gint x = rect->x, y=rect->y, width=rect->width, height=rect->height; - - gboolean interior_focus; - gint focus_width, focus_pad; - - moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width, &focus_pad); - - gtk_widget_set_state(widget, button_state); - gtk_widget_set_direction(widget, direction); - - if (state->isDefault) - GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_DEFAULT); - - gtk_button_set_relief(GTK_BUTTON(widget), relief); - - /* Some theme engines love to cause us pain in that gtk_paint_focus is a - no-op on buttons and button-like widgets. They only listen to this flag. */ - if (state->focused && !state->disabled) - GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); - - if (!interior_focus && state->focused) { - x += focus_width + focus_pad; - y += focus_width + focus_pad; - width -= 2 * (focus_width + focus_pad); - height -= 2 * (focus_width + focus_pad); - } - - shadow_type = button_state == GTK_STATE_ACTIVE || - state->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; - - if (state->isDefault && relief == GTK_RELIEF_NORMAL) { - gtk_paint_box(style, drawable, button_state, shadow_type, cliprect, - widget, "buttondefault", x, y, width, height); - } - - if (relief != GTK_RELIEF_NONE || state->depressed || - (button_state != GTK_STATE_NORMAL && - button_state != GTK_STATE_INSENSITIVE)) { - TSOffsetStyleGCs(style, x, y); - /* the following line can trigger an assertion (Crux theme) - file ../../gdk/gdkwindow.c: line 1846 (gdk_window_clear_area): - assertion `GDK_IS_WINDOW (window)' failed */ - gtk_paint_box(style, drawable, button_state, shadow_type, cliprect, - widget, "button", x, y, width, height); - } - - if (state->focused) { - if (interior_focus) { - GtkStyle* style = gtk_widget_get_style(widget); - x += style->xthickness + focus_pad; - y += style->ythickness + focus_pad; - width -= 2 * (style->xthickness + focus_pad); - height -= 2 * (style->ythickness + focus_pad); - } else { - x -= focus_width + focus_pad; - y -= focus_width + focus_pad; - width += 2 * (focus_width + focus_pad); - height += 2 * (focus_width + focus_pad); - } - - TSOffsetStyleGCs(style, x, y); - gtk_paint_focus(style, drawable, button_state, cliprect, - widget, "button", x, y, width, height); - } - - GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_DEFAULT); - GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); - return MOZ_GTK_SUCCESS; -} - gint moz_gtk_init() { GtkWidgetClass *entry_class; is_initialized = TRUE; - have_arrow_scaling = (gtk_major_version > 2 || - (gtk_major_version == 2 && gtk_minor_version >= 12)); /* Add style property to GtkEntry. * Adding the style property to the normal GtkEntry class means that it @@ -457,215 +197,6 @@ moz_gtk_init() return MOZ_GTK_SUCCESS; } -gint -moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing) -{ - ensure_checkbox_widget(); - - gtk_widget_style_get (gParts->checkboxWidget, - "indicator_size", indicator_size, - "indicator_spacing", indicator_spacing, - NULL); - - return MOZ_GTK_SUCCESS; -} - -gint -moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing) -{ - ensure_radiobutton_widget(); - - gtk_widget_style_get (gParts->radiobuttonWidget, - "indicator_size", indicator_size, - "indicator_spacing", indicator_spacing, - NULL); - - return MOZ_GTK_SUCCESS; -} - -gint -moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus, - gint* focus_width, gint* focus_pad) -{ - gtk_widget_style_get (widget, - "interior-focus", interior_focus, - "focus-line-width", focus_width, - "focus-padding", focus_pad, - NULL); - - return MOZ_GTK_SUCCESS; -} - -gint -moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border) -{ - static const GtkBorder default_inner_border = { 1, 1, 1, 1 }; - GtkBorder *tmp_border; - - gtk_widget_style_get (widget, "inner-border", &tmp_border, NULL); - - if (tmp_border) { - *inner_border = *tmp_border; - gtk_border_free(tmp_border); - } - else - *inner_border = default_inner_border; - - return MOZ_GTK_SUCCESS; -} - -static gint -moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect, - GdkRectangle* cliprect, GtkWidgetState* state, - gboolean selected, gboolean inconsistent, - gboolean isradio, GtkTextDirection direction) -{ - GtkStateType state_type = ConvertGtkState(state); - GtkShadowType shadow_type = (selected)?GTK_SHADOW_IN:GTK_SHADOW_OUT; - gint indicator_size, indicator_spacing; - gint x, y, width, height; - gint focus_x, focus_y, focus_width, focus_height; - GtkWidget *w; - GtkStyle *style; - - if (isradio) { - moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing); - w = gParts->radiobuttonWidget; - } else { - moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing); - w = gParts->checkboxWidget; - } - - // "GetMinimumWidgetSize was ignored" - // FIXME: This assert causes a build failure in WebKitGTK+ debug - // builds, because it uses 'false' in its definition. We may want - // to force this file to be built with g++, by renaming it. - // ASSERT(rect->width == indicator_size); - - /* - * vertically center in the box, since XUL sometimes ignores our - * GetMinimumWidgetSize in the vertical dimension - */ - x = rect->x; - y = rect->y + (rect->height - indicator_size) / 2; - width = indicator_size; - height = indicator_size; - - focus_x = x - indicator_spacing; - focus_y = y - indicator_spacing; - focus_width = width + 2 * indicator_spacing; - focus_height = height + 2 * indicator_spacing; - - style = gtk_widget_get_style(w); - TSOffsetStyleGCs(style, x, y); - - gtk_widget_set_sensitive(w, !state->disabled); - gtk_widget_set_direction(w, direction); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), selected); - - if (isradio) { - gtk_paint_option(style, drawable, state_type, shadow_type, cliprect, - gParts->radiobuttonWidget, "radiobutton", x, y, - width, height); - if (state->focused) { - gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect, - gParts->radiobuttonWidget, "radiobutton", focus_x, focus_y, - focus_width, focus_height); - } - } - else { - /* - * 'indeterminate' type on checkboxes. In GTK, the shadow type - * must also be changed for the state to be drawn. - */ - if (inconsistent) { - gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gParts->checkboxWidget), TRUE); - shadow_type = GTK_SHADOW_ETCHED_IN; - } else { - gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gParts->checkboxWidget), FALSE); - } - - gtk_paint_check(style, drawable, state_type, shadow_type, cliprect, - gParts->checkboxWidget, "checkbutton", x, y, width, height); - if (state->focused) { - gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect, - gParts->checkboxWidget, "checkbutton", focus_x, focus_y, - focus_width, focus_height); - } - } - - return MOZ_GTK_SUCCESS; -} - -static gint -calculate_button_inner_rect(GtkWidget* button, GdkRectangle* rect, - GdkRectangle* inner_rect, - GtkTextDirection direction, - gboolean ignore_focus) -{ - GtkBorder inner_border; - gboolean interior_focus; - gint focus_width, focus_pad; - GtkStyle* style; - - style = gtk_widget_get_style(button); - - /* This mirrors gtkbutton's child positioning */ - moz_gtk_button_get_inner_border(button, &inner_border); - moz_gtk_widget_get_focus(button, &interior_focus, - &focus_width, &focus_pad); - - if (ignore_focus) - focus_width = focus_pad = 0; - - inner_rect->x = rect->x + XTHICKNESS(style) + focus_width + focus_pad; - inner_rect->x += direction == GTK_TEXT_DIR_LTR ? - inner_border.left : inner_border.right; - inner_rect->y = rect->y + inner_border.top + YTHICKNESS(style) + - focus_width + focus_pad; - inner_rect->width = MAX(1, rect->width - inner_border.left - - inner_border.right - (XTHICKNESS(style) + focus_pad + focus_width) * 2); - inner_rect->height = MAX(1, rect->height - inner_border.top - - inner_border.bottom - (YTHICKNESS(style) + focus_pad + focus_width) * 2); - - return MOZ_GTK_SUCCESS; -} - - -static gint -calculate_arrow_rect(GtkWidget* arrow, GdkRectangle* rect, - GdkRectangle* arrow_rect, GtkTextDirection direction) -{ - /* defined in gtkarrow.c */ - gfloat arrow_scaling = 0.7; - gfloat xalign, xpad; - gint extent; - GtkMisc* misc = GTK_MISC(arrow); - gfloat misc_xalign, misc_yalign; - gint misc_xpad, misc_ypad; - - if (have_arrow_scaling) - gtk_widget_style_get(arrow, "arrow_scaling", &arrow_scaling, NULL); - - gtk_misc_get_padding(misc, &misc_xpad, &misc_ypad); - gtk_misc_get_alignment(misc, &misc_xalign, &misc_yalign); - - extent = MIN((rect->width - misc_xpad * 2), - (rect->height - misc_ypad * 2)) * arrow_scaling; - - xalign = direction == GTK_TEXT_DIR_LTR ? misc_xalign : 1.0 - misc_xalign; - xpad = misc_xpad + (rect->width - extent) * xalign; - - arrow_rect->x = direction == GTK_TEXT_DIR_LTR ? - floor(rect->x + xpad) : ceil(rect->x + xpad); - arrow_rect->y = floor(rect->y + misc_ypad + - ((rect->height - extent) * misc_yalign)); - - arrow_rect->width = arrow_rect->height = extent; - - return MOZ_GTK_SUCCESS; -} - static gint moz_gtk_scrolled_window_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state) @@ -906,226 +437,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget, return MOZ_GTK_SUCCESS; } -static gint -moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect, - GdkRectangle* cliprect, GtkWidgetState* state, - GtkWidget* widget, GtkTextDirection direction) -{ - GtkStateType bg_state = state->disabled ? - GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL; - gint x, y, width = rect->width, height = rect->height; - GtkStyle* style; - gboolean interior_focus; - gboolean theme_honors_transparency = FALSE; - gint focus_width; - - gtk_widget_set_direction(widget, direction); - - style = gtk_widget_get_style(widget); - - gtk_widget_style_get(widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "honors-transparent-bg-hint", &theme_honors_transparency, - NULL); - - /* gtkentry.c uses two windows, one for the entire widget and one for the - * text area inside it. The background of both windows is set to the "base" - * color of the new state in gtk_entry_state_changed, but only the inner - * textarea window uses gtk_paint_flat_box when exposed */ - - TSOffsetStyleGCs(style, rect->x, rect->y); - - /* This gets us a lovely greyish disabledish look */ - gtk_widget_set_sensitive(widget, !state->disabled); - - /* GTK fills the outer widget window with the base color before drawing the widget. - * Some older themes rely on this behavior, but many themes nowadays use rounded - * corners on their widgets. While most GTK apps are blissfully unaware of this - * problem due to their use of the default window background, we render widgets on - * many kinds of backgrounds on the web. - * If the theme is able to cope with transparency, then we can skip pre-filling - * and notify the theme it will paint directly on the canvas. */ - if (theme_honors_transparency) { - g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); - } else { - gdk_draw_rectangle(drawable, style->base_gc[bg_state], TRUE, - cliprect->x, cliprect->y, cliprect->width, cliprect->height); - g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(FALSE)); - } - - /* Get the position of the inner window, see _gtk_entry_get_borders */ - x = XTHICKNESS(style); - y = YTHICKNESS(style); - - if (!interior_focus) { - x += focus_width; - y += focus_width; - } - - /* Simulate an expose of the inner window */ - gtk_paint_flat_box(style, drawable, bg_state, GTK_SHADOW_NONE, - cliprect, widget, "entry_bg", rect->x + x, - rect->y + y, rect->width - 2*x, rect->height - 2*y); - - /* Now paint the shadow and focus border. - * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad - * smaller when focused if the focus is not interior, then the focus. */ - x = rect->x; - y = rect->y; - - if (state->focused && !state->disabled) { - /* This will get us the lit borders that focused textboxes enjoy on - * some themes. */ - GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); - - if (!interior_focus) { - /* Indent the border a little bit if we have exterior focus - (this is what GTK does to draw native entries) */ - x += focus_width; - y += focus_width; - width -= 2 * focus_width; - height -= 2 * focus_width; - } - } - - gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, - cliprect, widget, "entry", x, y, width, height); - - if (state->focused && !state->disabled) { - if (!interior_focus) { - gtk_paint_focus(style, drawable, GTK_STATE_NORMAL, cliprect, - widget, "entry", - rect->x, rect->y, rect->width, rect->height); - } - - /* Now unset the focus flag. We don't want other entries to look - * like they're focused too! */ - GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); - } - - return MOZ_GTK_SUCCESS; -} - -static gint -moz_gtk_combo_box_paint(GdkDrawable* drawable, GdkRectangle* rect, - GdkRectangle* cliprect, GtkWidgetState* state, - gboolean ishtml, GtkTextDirection direction) -{ - GdkRectangle arrow_rect, real_arrow_rect; - gint /* arrow_size, */ separator_width; - gboolean wide_separators; - GtkStateType state_type = ConvertGtkState(state); - GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT; - GtkStyle* style; - GtkRequisition arrow_req; - - ensure_combo_box_widgets(); - - /* Also sets the direction on gParts->comboBoxButtonWidget, which is then - * inherited by the separator and arrow */ - moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL, - gParts->comboBoxButtonWidget, direction); - - calculate_button_inner_rect(gParts->comboBoxButtonWidget, - rect, &arrow_rect, direction, ishtml); - /* Now arrow_rect contains the inner rect ; we want to correct the width - * to what the arrow needs (see gtk_combo_box_size_allocate) */ - gtk_widget_size_request(gParts->comboBoxArrowWidget, &arrow_req); - if (direction == GTK_TEXT_DIR_LTR) - arrow_rect.x += arrow_rect.width - arrow_req.width; - arrow_rect.width = arrow_req.width; - - calculate_arrow_rect(gParts->comboBoxArrowWidget, - &arrow_rect, &real_arrow_rect, direction); - - style = gtk_widget_get_style(gParts->comboBoxArrowWidget); - TSOffsetStyleGCs(style, rect->x, rect->y); - - gtk_widget_size_allocate(gParts->comboBoxWidget, rect); - - gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect, - gParts->comboBoxArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE, - real_arrow_rect.x, real_arrow_rect.y, - real_arrow_rect.width, real_arrow_rect.height); - - - /* If there is no separator in the theme, there's nothing left to do. */ - if (!gParts->comboBoxSeparatorWidget) - return MOZ_GTK_SUCCESS; - - style = gtk_widget_get_style(gParts->comboBoxSeparatorWidget); - TSOffsetStyleGCs(style, rect->x, rect->y); - - gtk_widget_style_get(gParts->comboBoxSeparatorWidget, - "wide-separators", &wide_separators, - "separator-width", &separator_width, - NULL); - - if (wide_separators) { - if (direction == GTK_TEXT_DIR_LTR) - arrow_rect.x -= separator_width; - else - arrow_rect.x += arrow_rect.width; - - gtk_paint_box(style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT, - cliprect, gParts->comboBoxSeparatorWidget, "vseparator", - arrow_rect.x, arrow_rect.y, - separator_width, arrow_rect.height); - } else { - if (direction == GTK_TEXT_DIR_LTR) - arrow_rect.x -= XTHICKNESS(style); - else - arrow_rect.x += arrow_rect.width; - - gtk_paint_vline(style, drawable, GTK_STATE_NORMAL, cliprect, - gParts->comboBoxSeparatorWidget, "vseparator", - arrow_rect.y, arrow_rect.y + arrow_rect.height, - arrow_rect.x); - } - - return MOZ_GTK_SUCCESS; -} - -static gint -moz_gtk_progressbar_paint(GdkDrawable* drawable, GdkRectangle* rect, - GdkRectangle* cliprect, GtkTextDirection direction) -{ - GtkStyle* style; - - ensure_progress_widget(); - gtk_widget_set_direction(gParts->progresWidget, direction); - - style = gtk_widget_get_style(gParts->progresWidget); - - TSOffsetStyleGCs(style, rect->x, rect->y); - gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, - cliprect, gParts->progresWidget, "trough", rect->x, rect->y, - rect->width, rect->height); - - return MOZ_GTK_SUCCESS; -} - -static gint -moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect, - GdkRectangle* cliprect, GtkTextDirection direction) -{ - GtkStyle* style; - - ensure_progress_widget(); - gtk_widget_set_direction(gParts->progresWidget, direction); - - style = gtk_widget_get_style(gParts->progresWidget); - - TSOffsetStyleGCs(style, rect->x, rect->y); - gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - cliprect, gParts->progresWidget, "bar", rect->x, rect->y, - rect->width, rect->height); - - return MOZ_GTK_SUCCESS; -} - gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, gint* right, gint* bottom, GtkTextDirection direction, @@ -1135,99 +446,12 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, GtkStyle *style; switch (widget) { - case MOZ_GTK_BUTTON: - { - GtkBorder inner_border; - gboolean interior_focus; - gint focus_width, focus_pad; - GtkStyle *style; - - ensure_button_widget(); - *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gParts->buttonWidget)); - - /* Don't add this padding in HTML, otherwise the buttons will - become too big and stuff the layout. */ - if (!inhtml) { - moz_gtk_widget_get_focus(gParts->buttonWidget, &interior_focus, &focus_width, &focus_pad); - moz_gtk_button_get_inner_border(gParts->buttonWidget, &inner_border); - *left += focus_width + focus_pad + inner_border.left; - *right += focus_width + focus_pad + inner_border.right; - *top += focus_width + focus_pad + inner_border.top; - *bottom += focus_width + focus_pad + inner_border.bottom; - } - - style = gtk_widget_get_style(gParts->buttonWidget); - *left += style->xthickness; - *right += style->xthickness; - *top += style->ythickness; - *bottom += style->ythickness; - return MOZ_GTK_SUCCESS; - } - case MOZ_GTK_ENTRY: - ensure_entry_widget(); - w = gParts->entryWidget; - break; - case MOZ_GTK_DROPDOWN: - { - /* We need to account for the arrow on the dropdown, so text - * doesn't come too close to the arrow, or in some cases spill - * into the arrow. */ - gboolean ignored_interior_focus, wide_separators; - gint focus_width, focus_pad, separator_width; - GtkRequisition arrow_req; - GtkStyle* style; - - ensure_combo_box_widgets(); - - *left = gtk_container_get_border_width(GTK_CONTAINER(gParts->comboBoxButtonWidget)); - - if (!inhtml) { - moz_gtk_widget_get_focus(gParts->comboBoxButtonWidget, - &ignored_interior_focus, - &focus_width, &focus_pad); - *left += focus_width + focus_pad; - } - - style = gtk_widget_get_style(gParts->comboBoxButtonWidget); - *top = *left + style->ythickness; - *left += style->xthickness; - - *right = *left; *bottom = *top; - - /* If there is no separator, don't try to count its width. */ - separator_width = 0; - if (gParts->comboBoxSeparatorWidget) { - gtk_widget_style_get(gParts->comboBoxSeparatorWidget, - "wide-separators", &wide_separators, - "separator-width", &separator_width, - NULL); - - if (!wide_separators) - separator_width = - XTHICKNESS(style); - } - - gtk_widget_size_request(gParts->comboBoxArrowWidget, &arrow_req); - if (direction == GTK_TEXT_DIR_RTL) - *left += separator_width + arrow_req.width; - else - *right += separator_width + arrow_req.width; - - return MOZ_GTK_SUCCESS; - } - case MOZ_GTK_PROGRESSBAR: - ensure_progress_widget(); - w = gParts->progresWidget; - break; /* These widgets have no borders, since they are not containers. */ - case MOZ_GTK_CHECKBUTTON: - case MOZ_GTK_RADIOBUTTON: case MOZ_GTK_SCROLLBAR_BUTTON: case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL: case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL: case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL: case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL: - case MOZ_GTK_PROGRESS_CHUNK: *left = *top = *right = *bottom = 0; return MOZ_GTK_SUCCESS; default: @@ -1269,26 +493,6 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, GtkTextDirection direction) { switch (widget) { - case MOZ_GTK_BUTTON: - if (state->depressed) { - ensure_toggle_button_widget(); - return moz_gtk_button_paint(drawable, rect, cliprect, state, - (GtkReliefStyle) flags, - gParts->toggleButtonWidget, direction); - } - ensure_button_widget(); - return moz_gtk_button_paint(drawable, rect, cliprect, state, - (GtkReliefStyle) flags, gParts->buttonWidget, - direction); - break; - case MOZ_GTK_CHECKBUTTON: - case MOZ_GTK_RADIOBUTTON: - return moz_gtk_toggle_paint(drawable, rect, cliprect, state, - !!(flags & MOZ_GTK_WIDGET_CHECKED), - !!(flags & MOZ_GTK_WIDGET_INCONSISTENT), - (widget == MOZ_GTK_RADIOBUTTON), - direction); - break; case MOZ_GTK_SCROLLBAR_BUTTON: return moz_gtk_scrollbar_button_paint(drawable, rect, cliprect, state, (GtkScrollbarButtonFlags) flags, @@ -1307,22 +511,6 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, case MOZ_GTK_SCROLLED_WINDOW: return moz_gtk_scrolled_window_paint(drawable, rect, cliprect, state); break; - case MOZ_GTK_ENTRY: - ensure_entry_widget(); - return moz_gtk_entry_paint(drawable, rect, cliprect, state, - gParts->entryWidget, direction); - break; - case MOZ_GTK_DROPDOWN: - return moz_gtk_combo_box_paint(drawable, rect, cliprect, state, - (gboolean) flags, direction); - break; - case MOZ_GTK_PROGRESSBAR: - return moz_gtk_progressbar_paint(drawable, rect, cliprect, direction); - break; - case MOZ_GTK_PROGRESS_CHUNK: - return moz_gtk_progress_chunk_paint(drawable, rect, cliprect, - direction); - break; default: g_warning("Unknown widget type: %d", widget); } @@ -1361,12 +549,4 @@ void moz_gtk_destroy_theme_parts_widgets(GtkThemeParts* parts) } } -GtkWidget* moz_gtk_get_progress_widget() -{ - if (!is_initialized) - return NULL; - ensure_progress_widget(); - return gParts->progresWidget; -} - #endif // GTK_API_VERSION_2 diff --git a/Source/WebCore/platform/gtk/gtkdrawing.h b/Source/WebCore/platform/gtk/gtkdrawing.h index 412a1f7..cdb343c 100644 --- a/Source/WebCore/platform/gtk/gtkdrawing.h +++ b/Source/WebCore/platform/gtk/gtkdrawing.h @@ -48,6 +48,8 @@ #ifndef _GTK_DRAWING_H_ #define _GTK_DRAWING_H_ +#undef GTK_DISABLE_DEPRECATED + #include <gtk/gtk.h> #ifdef __cplusplus @@ -84,23 +86,8 @@ typedef struct _GtkThemeParts { GdkColormap* colormap; GtkWidget* protoWindow; GtkWidget* protoLayout; - GtkWidget* buttonWidget; - GtkWidget* toggleButtonWidget; - GtkWidget* buttonArrowWidget; - GtkWidget* checkboxWidget; - GtkWidget* radiobuttonWidget; GtkWidget* horizScrollbarWidget; GtkWidget* vertScrollbarWidget; - GtkWidget* entryWidget; - GtkWidget* comboBoxWidget; - GtkWidget* comboBoxButtonWidget; - GtkWidget* comboBoxArrowWidget; - GtkWidget* comboBoxSeparatorWidget; - GtkWidget* comboBoxEntryWidget; - GtkWidget* comboBoxEntryTextareaWidget; - GtkWidget* comboBoxEntryButtonWidget; - GtkWidget* comboBoxEntryArrowWidget; - GtkWidget* progresWidget; GtkWidget* scrolledWindowWidget; } GtkThemeParts; @@ -118,18 +105,10 @@ typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint); #define MOZ_GTK_UNKNOWN_WIDGET -1 #define MOZ_GTK_UNSAFE_THEME -2 -/*** checkbox/radio flags ***/ -#define MOZ_GTK_WIDGET_CHECKED 1 -#define MOZ_GTK_WIDGET_INCONSISTENT (1 << 1) - /*** widget type constants ***/ typedef enum { /* Paints a GtkButton. flags is a GtkReliefStyle. */ MOZ_GTK_BUTTON, - /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */ - MOZ_GTK_CHECKBUTTON, - /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */ - MOZ_GTK_RADIOBUTTON, /** * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving * the arrow direction. @@ -143,13 +122,6 @@ typedef enum { MOZ_GTK_SCROLLBAR_THUMB_VERTICAL, /* Paints the background of a scrolled window */ MOZ_GTK_SCROLLED_WINDOW, - MOZ_GTK_ENTRY, - /* Paints a GtkOptionMenu. */ - MOZ_GTK_DROPDOWN, - /* Paints a GtkProgressBar. */ - MOZ_GTK_PROGRESSBAR, - /* Paints a progress chunk of a GtkProgressBar. */ - MOZ_GTK_PROGRESS_CHUNK } GtkThemeWidgetType; /*** General library functions ***/ @@ -223,42 +195,6 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, gint* right, gint* bottom, GtkTextDirection direction, gboolean inhtml); - -/** - * Get the desired size of a GtkCheckButton - * indicator_size: [OUT] the indicator size - * indicator_spacing: [OUT] the spacing between the indicator and its - * container - * - * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise - */ -gint -moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing); - -/** - * Get the desired size of a GtkRadioButton - * indicator_size: [OUT] the indicator size - * indicator_spacing: [OUT] the spacing between the indicator and its - * container - * - * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise - */ -gint -moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing); - -/** Get the focus metrics for a treeheadercell, button, checkbox, or radio button. - * widget: [IN] the widget to get the focus metrics for - * interior_focus: [OUT] whether the focus is drawn around the - * label (TRUE) or around the whole container (FALSE) - * focus_width: [OUT] the width of the focus line - * focus_pad: [OUT] the padding between the focus line and children - * - * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise - */ -gint -moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus, - gint* focus_width, gint* focus_pad); - /** * Get the desired metrics for a GtkScrollbar * metrics: [IN] struct which will contain the metrics @@ -274,12 +210,6 @@ moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics); */ GtkWidget* moz_gtk_get_scrollbar_widget(void); -/** - * Retrieve an actual GTK progress bar widget for style analysis. It will not - * be modified. - */ -GtkWidget* moz_gtk_get_progress_widget(void); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/Source/WebCore/platform/image-decoders/ImageDecoder.h b/Source/WebCore/platform/image-decoders/ImageDecoder.h index 13069de..c581ba1 100644 --- a/Source/WebCore/platform/image-decoders/ImageDecoder.h +++ b/Source/WebCore/platform/image-decoders/ImageDecoder.h @@ -231,7 +231,8 @@ namespace WebCore { // setMaxNumPixels() to specify the biggest size that decoded images can // have. Image decoders will deflate those images that are bigger than // m_maxNumPixels. (Not supported by all image decoders yet) - class ImageDecoder : public Noncopyable { + class ImageDecoder { + WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED; public: ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) : m_scaled(false) diff --git a/Source/WebCore/platform/mac/ClipboardMac.h b/Source/WebCore/platform/mac/ClipboardMac.h index 7187ecf..39eadda 100644 --- a/Source/WebCore/platform/mac/ClipboardMac.h +++ b/Source/WebCore/platform/mac/ClipboardMac.h @@ -44,6 +44,7 @@ class Frame; class FileList; class ClipboardMac : public Clipboard, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<ClipboardMac> create(ClipboardType clipboardType, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame* frame) { diff --git a/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h b/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h index 90beb40..8fde2cf 100644 --- a/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h +++ b/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h @@ -31,7 +31,8 @@ class GraphicsContext; // This class automatically saves and restores the current NSGraphicsContext for // functions which call out into AppKit and rely on the currentContext being set -class LocalCurrentGraphicsContext : public Noncopyable { +class LocalCurrentGraphicsContext { + WTF_MAKE_NONCOPYABLE(LocalCurrentGraphicsContext); public: LocalCurrentGraphicsContext(GraphicsContext* graphicsContext); ~LocalCurrentGraphicsContext(); diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.h b/Source/WebCore/platform/mac/ScrollAnimatorMac.h index 234e43c..f05db40 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.h +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.h @@ -28,7 +28,6 @@ #if ENABLE(SMOOTH_SCROLLING) -#include "FloatPoint.h" #include "ScrollAnimator.h" #include <wtf/RetainPtr.h> @@ -42,14 +41,13 @@ namespace WebCore { class ScrollAnimatorMac : public ScrollAnimator { public: - ScrollAnimatorMac(ScrollbarClient*); + ScrollAnimatorMac(ScrollableArea*); virtual ~ScrollAnimatorMac(); virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier); - virtual void setScrollPositionAndStopAnimation(ScrollbarOrientation, float position); + virtual void scrollToOffsetWithoutAnimation(const FloatPoint&); // Called by the ScrollAnimationHelperDelegate. - FloatPoint currentPosition() const; void immediateScrollToPoint(const FloatPoint& newPosition); private: diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm index ca71bd3..59b333b 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -28,7 +28,10 @@ #if ENABLE(SMOOTH_SCROLLING) #include "ScrollAnimatorMac.h" -#include "ScrollbarClient.h" + +#include "FloatPoint.h" +#include "ScrollableArea.h" +#include <wtf/PassOwnPtr.h> @interface NSObject (NSScrollAnimationHelperDetails) - (id)initWithDelegate:(id)delegate; @@ -121,13 +124,13 @@ static NSSize abs(NSSize size) namespace WebCore { -ScrollAnimator* ScrollAnimator::create(ScrollbarClient* client) +PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea) { - return new ScrollAnimatorMac(client); + return adoptPtr(new ScrollAnimatorMac(scrollableArea)); } -ScrollAnimatorMac::ScrollAnimatorMac(ScrollbarClient* client) - : ScrollAnimator(client) +ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea) + : ScrollAnimator(scrollableArea) { m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate alloc] initWithScrollAnimator:this]); m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelper") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]); @@ -146,7 +149,7 @@ bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranulari return ScrollAnimator::scroll(orientation, granularity, step, multiplier); float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_currentPosY; - float newPos = std::max<float>(std::min<float>(currentPos + (step * multiplier), static_cast<float>(m_client->scrollSize(orientation))), 0); + float newPos = std::max<float>(std::min<float>(currentPos + (step * multiplier), static_cast<float>(m_scrollableArea->scrollSize(orientation))), 0); if (currentPos == newPos) return false; @@ -161,23 +164,17 @@ bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranulari return true; } -void ScrollAnimatorMac::setScrollPositionAndStopAnimation(ScrollbarOrientation orientation, float pos) +void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset) { [m_scrollAnimationHelper.get() _stopRun]; - ScrollAnimator::setScrollPositionAndStopAnimation(orientation, pos); -} - -FloatPoint ScrollAnimatorMac::currentPosition() const -{ - return FloatPoint(m_currentPosX, m_currentPosY); + ScrollAnimator::scrollToOffsetWithoutAnimation(offset); } void ScrollAnimatorMac::immediateScrollToPoint(const FloatPoint& newPosition) { m_currentPosX = newPosition.x(); m_currentPosY = newPosition.y(); - - m_client->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_currentPosY)); + notityPositionChanged(); } } // namespace WebCore diff --git a/Source/WebCore/platform/mac/ScrollbarThemeMac.h b/Source/WebCore/platform/mac/ScrollbarThemeMac.h index c833ee7..8b5412d 100644 --- a/Source/WebCore/platform/mac/ScrollbarThemeMac.h +++ b/Source/WebCore/platform/mac/ScrollbarThemeMac.h @@ -40,6 +40,7 @@ public: virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar); virtual bool supportsControlTints() const { return true; } + virtual bool usesOverlayScrollbars() const; virtual double initialAutoscrollTimerDelay(); virtual double autoscrollTimerDelay(); diff --git a/Source/WebCore/platform/mac/ScrollbarThemeMac.mm b/Source/WebCore/platform/mac/ScrollbarThemeMac.mm index ce3be1a..032d9f3 100644 --- a/Source/WebCore/platform/mac/ScrollbarThemeMac.mm +++ b/Source/WebCore/platform/mac/ScrollbarThemeMac.mm @@ -27,18 +27,39 @@ #include "ScrollbarThemeMac.h" #include "ImageBuffer.h" +#include "LocalCurrentGraphicsContext.h" #include "PlatformMouseEvent.h" #include "ScrollView.h" +#include "WebCoreSystemInterface.h" #include <Carbon/Carbon.h> +#include <wtf/HashMap.h> #include <wtf/StdLibExtras.h> #include <wtf/UnusedParam.h> +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#define USE_WK_SCROLLBAR_PAINTER +#endif + // FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow. using namespace std; using namespace WebCore; -static HashSet<Scrollbar*>* gScrollbars; +namespace WebCore { + +#if defined(USE_WK_SCROLLBAR_PAINTER) +typedef HashMap<Scrollbar*, RetainPtr<WKScrollbarPainterRef> > ScrollbarPainterMap; +#else +typedef HashSet<Scrollbar*> ScrollbarPainterMap; +#endif + +static ScrollbarPainterMap* scrollbarMap() +{ + static ScrollbarPainterMap* map = new ScrollbarPainterMap; + return map; +} + +} @interface ScrollbarPrefsObserver : NSObject { @@ -58,12 +79,17 @@ static HashSet<Scrollbar*>* gScrollbars; UNUSED_PARAM(unusedNotification); static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged(); - if (!gScrollbars) + if (scrollbarMap()->isEmpty()) return; - HashSet<Scrollbar*>::iterator end = gScrollbars->end(); - for (HashSet<Scrollbar*>::iterator it = gScrollbars->begin(); it != end; ++it) { + ScrollbarPainterMap::iterator end = scrollbarMap()->end(); + for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) { +#if defined(USE_WK_SCROLLBAR_PAINTER) + it->first->styleChanged(); + it->first->invalidate(); +#else (*it)->styleChanged(); (*it)->invalidate(); +#endif } } @@ -109,6 +135,9 @@ static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd; static void updateArrowPlacement() { +#if defined(USE_WK_SCROLLBAR_PAINTER) + gButtonPlacement = ScrollbarButtonsNone; +#else NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"]; if ([buttonPlacement isEqualToString:@"Single"]) gButtonPlacement = ScrollbarButtonsSingle; @@ -118,22 +147,23 @@ static void updateArrowPlacement() gButtonPlacement = ScrollbarButtonsDoubleBoth; else gButtonPlacement = ScrollbarButtonsDoubleEnd; // The default is ScrollbarButtonsDoubleEnd. +#endif } void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar) { - if (!gScrollbars) - gScrollbars = new HashSet<Scrollbar*>; - gScrollbars->add(scrollbar); +#if defined(USE_WK_SCROLLBAR_PAINTER) + WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(), + scrollbar->orientation() == HorizontalScrollbar); + scrollbarMap()->add(scrollbar, scrollbarPainter); +#else + scrollbarMap()->add(scrollbar); +#endif } void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar) { - gScrollbars->remove(scrollbar); - if (gScrollbars->isEmpty()) { - delete gScrollbars; - gScrollbars = 0; - } + scrollbarMap()->remove(scrollbar); } ScrollbarThemeMac::ScrollbarThemeMac() @@ -165,6 +195,12 @@ int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize) return cScrollbarThickness[controlSize]; } +bool ScrollbarThemeMac::usesOverlayScrollbars() const +{ + // FIXME: This should be enabled when <rdar://problem/8492788> is resolved. + return false; +} + double ScrollbarThemeMac::initialAutoscrollTimerDelay() { return gInitialButtonDelay; @@ -355,6 +391,20 @@ static int scrollbarPartToHIPressedState(ScrollbarPart part) bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect) { +#if defined(USE_WK_SCROLLBAR_PAINTER) + context->save(); + context->clip(damageRect); + context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y()); + LocalCurrentGraphicsContext localContext(context); + wkScrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(), + scrollbar->enabled(), + scrollbar->currentPos() / scrollbar->maximum(), + static_cast<CGFloat>(scrollbar->visibleSize()) / scrollbar->totalSize(), + scrollbar->frameRect()); + context->restore(); + return true; +#endif + HIThemeTrackDrawInfo trackInfo; trackInfo.version = 0; trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMediumScrollBar : kThemeSmallScrollBar; @@ -370,7 +420,7 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co if (!scrollbar->enabled()) trackInfo.enableState = kThemeTrackDisabled; else - trackInfo.enableState = scrollbar->client()->isActive() ? kThemeTrackActive : kThemeTrackInactive; + trackInfo.enableState = scrollbar->scrollableArea()->isActive() ? kThemeTrackActive : kThemeTrackInactive; if (hasThumb(scrollbar)) trackInfo.attributes |= kThemeTrackShowThumb; diff --git a/Source/WebCore/platform/mac/WebCoreSystemInterface.h b/Source/WebCore/platform/mac/WebCoreSystemInterface.h index 0c78c23..045864a 100644 --- a/Source/WebCore/platform/mac/WebCoreSystemInterface.h +++ b/Source/WebCore/platform/mac/WebCoreSystemInterface.h @@ -186,6 +186,10 @@ extern CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(cons extern CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace); extern CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context); + +typedef struct __WKScrollbarPainter *WKScrollbarPainterRef; +extern WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal); +extern void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect); #endif } diff --git a/Source/WebCore/platform/mac/WebCoreSystemInterface.mm b/Source/WebCore/platform/mac/WebCoreSystemInterface.mm index df3c77c..047827f 100644 --- a/Source/WebCore/platform/mac/WebCoreSystemInterface.mm +++ b/Source/WebCore/platform/mac/WebCoreSystemInterface.mm @@ -125,4 +125,7 @@ CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniCh CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace); CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context); + +WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal); +void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect); #endif diff --git a/Source/WebCore/platform/mock/SpeechInputClientMock.cpp b/Source/WebCore/platform/mock/SpeechInputClientMock.cpp index 16a7c76..9aa3113 100644 --- a/Source/WebCore/platform/mock/SpeechInputClientMock.cpp +++ b/Source/WebCore/platform/mock/SpeechInputClientMock.cpp @@ -33,6 +33,7 @@ #if ENABLE(INPUT_SPEECH) +#include "SecurityOrigin.h" #include "SpeechInputListener.h" namespace WebCore { @@ -50,7 +51,7 @@ void SpeechInputClientMock::setListener(SpeechInputListener* listener) m_listener = listener; } -bool SpeechInputClientMock::startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar) +bool SpeechInputClientMock::startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin* origin) { if (m_timer.isActive()) return false; diff --git a/Source/WebCore/platform/mock/SpeechInputClientMock.h b/Source/WebCore/platform/mock/SpeechInputClientMock.h index 6f72191..4e13242 100644 --- a/Source/WebCore/platform/mock/SpeechInputClientMock.h +++ b/Source/WebCore/platform/mock/SpeechInputClientMock.h @@ -54,7 +54,7 @@ public: // SpeechInputClient methods. void setListener(SpeechInputListener*); - bool startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar); + bool startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin*); void stopRecording(int); void cancelRecognition(int); diff --git a/Source/WebCore/platform/network/BlobData.h b/Source/WebCore/platform/network/BlobData.h index 1ff6344..c1f5522 100644 --- a/Source/WebCore/platform/network/BlobData.h +++ b/Source/WebCore/platform/network/BlobData.h @@ -145,6 +145,7 @@ private: typedef Vector<BlobDataItem> BlobDataItemList; class BlobData { + WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<BlobData> create(); diff --git a/Source/WebCore/platform/network/FormDataBuilder.h b/Source/WebCore/platform/network/FormDataBuilder.h index 87d0ef3..112e315 100644 --- a/Source/WebCore/platform/network/FormDataBuilder.h +++ b/Source/WebCore/platform/network/FormDataBuilder.h @@ -23,14 +23,14 @@ #include "PlatformString.h" #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> namespace WebCore { class Document; class TextEncoding; -class FormDataBuilder : public Noncopyable { +class FormDataBuilder { + WTF_MAKE_NONCOPYABLE(FormDataBuilder); public: static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document* document); diff --git a/Source/WebCore/platform/network/NetworkStateNotifier.h b/Source/WebCore/platform/network/NetworkStateNotifier.h index 21d0067..08ab0bd 100644 --- a/Source/WebCore/platform/network/NetworkStateNotifier.h +++ b/Source/WebCore/platform/network/NetworkStateNotifier.h @@ -26,6 +26,7 @@ #ifndef NetworkStateNotifier_h #define NetworkStateNotifier_h +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> #if PLATFORM(ANDROID) // TODO: Upstream to webkit.org @@ -65,7 +66,8 @@ namespace WebCore { class NetworkStateNotifierPrivate; #endif -class NetworkStateNotifier : public Noncopyable { +class NetworkStateNotifier { + WTF_MAKE_NONCOPYABLE(NetworkStateNotifier); WTF_MAKE_FAST_ALLOCATED; public: NetworkStateNotifier(); void setNetworkStateChangedFunction(void (*)()); diff --git a/Source/WebCore/platform/network/ResourceHandleInternal.h b/Source/WebCore/platform/network/ResourceHandleInternal.h index d833e32..ed66944 100644 --- a/Source/WebCore/platform/network/ResourceHandleInternal.h +++ b/Source/WebCore/platform/network/ResourceHandleInternal.h @@ -80,7 +80,8 @@ class NSURLConnection; namespace WebCore { class ResourceHandleClient; - class ResourceHandleInternal : public Noncopyable { + class ResourceHandleInternal { + WTF_MAKE_NONCOPYABLE(ResourceHandleInternal); WTF_MAKE_FAST_ALLOCATED; public: ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, bool defersLoading, bool shouldContentSniff) : m_client(c) diff --git a/Source/WebCore/platform/network/ResourceRequestBase.h b/Source/WebCore/platform/network/ResourceRequestBase.h index 5cb7ee3..dce33db 100644 --- a/Source/WebCore/platform/network/ResourceRequestBase.h +++ b/Source/WebCore/platform/network/ResourceRequestBase.h @@ -49,7 +49,8 @@ namespace WebCore { struct CrossThreadResourceRequestData; // Do not use this type directly. Use ResourceRequest instead. - class ResourceRequestBase : public FastAllocBase { + class ResourceRequestBase { + WTF_MAKE_FAST_ALLOCATED; public: // The type of this ResourceRequest, based on how the resource will be used. enum TargetType { @@ -207,7 +208,10 @@ namespace WebCore { inline bool operator==(const ResourceRequest& a, const ResourceRequest& b) { return ResourceRequestBase::compare(a, b); } inline bool operator!=(ResourceRequest& a, const ResourceRequest& b) { return !(a == b); } - struct CrossThreadResourceRequestDataBase : Noncopyable { + struct CrossThreadResourceRequestDataBase { + WTF_MAKE_NONCOPYABLE(CrossThreadResourceRequestDataBase); WTF_MAKE_FAST_ALLOCATED; + public: + CrossThreadResourceRequestDataBase() { } KURL m_url; ResourceRequestCachePolicy m_cachePolicy; diff --git a/Source/WebCore/platform/network/ResourceResponseBase.h b/Source/WebCore/platform/network/ResourceResponseBase.h index 9c54bab..e0774c2 100644 --- a/Source/WebCore/platform/network/ResourceResponseBase.h +++ b/Source/WebCore/platform/network/ResourceResponseBase.h @@ -41,7 +41,8 @@ class ResourceResponse; struct CrossThreadResourceResponseData; // Do not use this class directly, use the class ResponseResponse instead -class ResourceResponseBase : public FastAllocBase { +class ResourceResponseBase { + WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<ResourceResponse> adopt(PassOwnPtr<CrossThreadResourceResponseData>); @@ -175,7 +176,10 @@ private: inline bool operator==(const ResourceResponse& a, const ResourceResponse& b) { return ResourceResponseBase::compare(a, b); } inline bool operator!=(const ResourceResponse& a, const ResourceResponse& b) { return !(a == b); } -struct CrossThreadResourceResponseDataBase : Noncopyable { +struct CrossThreadResourceResponseDataBase { + WTF_MAKE_NONCOPYABLE(CrossThreadResourceResponseDataBase); +public: + CrossThreadResourceResponseDataBase() { } KURL m_url; String m_mimeType; long long m_expectedContentLength; diff --git a/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp b/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp index 659b719..c6d513a 100644 --- a/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp +++ b/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp @@ -34,6 +34,7 @@ #include "KURL.h" #include "PlatformString.h" #include "ResourceHandle.h" +#include "SoftLinking.h" #include <CFNetwork/CFHTTPCookiesPriv.h> #include <CoreFoundation/CoreFoundation.h> #include <WebKitSystemInterface/WebKitSystemInterface.h> @@ -44,6 +45,53 @@ namespace WebCore { static const CFStringRef s_setCookieKeyCF = CFSTR("Set-Cookie"); static const CFStringRef s_cookieCF = CFSTR("Cookie"); +#ifdef DEBUG_ALL +SOFT_LINK_DEBUG_LIBRARY(CFNetwork) +#else +SOFT_LINK_LIBRARY(CFNetwork) +#endif + +SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyDomain, CFStringRef, __cdecl, (CFHTTPCookieRef)) +SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieGetExpirationTime, CFAbsoluteTime, __cdecl, (CFHTTPCookieRef)) +SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyName, CFStringRef, __cdecl, (CFHTTPCookieRef)) +SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyPath, CFStringRef, __cdecl, (CFHTTPCookieRef)) +SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyValue, CFStringRef, __cdecl, (CFHTTPCookieRef)) + +static inline RetainPtr<CFStringRef> cookieDomain(CFHTTPCookieRef cookie) +{ + if (CFHTTPCookieCopyDomainPtr()) + return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyDomainPtr()(cookie)); + return CFHTTPCookieGetDomain(cookie); +} + +static inline CFAbsoluteTime cookieExpirationTime(CFHTTPCookieRef cookie) +{ + if (CFHTTPCookieGetExpirationTimePtr()) + return CFHTTPCookieGetExpirationTimePtr()(cookie); + return CFDateGetAbsoluteTime(CFHTTPCookieGetExpiratonDate(cookie)); +} + +static inline RetainPtr<CFStringRef> cookieName(CFHTTPCookieRef cookie) +{ + if (CFHTTPCookieCopyNamePtr()) + return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyNamePtr()(cookie)); + return CFHTTPCookieGetName(cookie); +} + +static inline RetainPtr<CFStringRef> cookiePath(CFHTTPCookieRef cookie) +{ + if (CFHTTPCookieCopyPathPtr()) + return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyPathPtr()(cookie)); + return CFHTTPCookieGetPath(cookie); +} + +static inline RetainPtr<CFStringRef> cookieValue(CFHTTPCookieRef cookie) +{ + if (CFHTTPCookieCopyValuePtr()) + return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyValuePtr()(cookie)); + return CFHTTPCookieGetValue(cookie); +} + static RetainPtr<CFArrayRef> filterCookies(CFArrayRef unfilteredCookies) { CFIndex count = CFArrayGetCount(unfilteredCookies); @@ -55,7 +103,7 @@ static RetainPtr<CFArrayRef> filterCookies(CFArrayRef unfilteredCookies) // which would be sent as "Cookie: =". We have a workaround in setCookies() to prevent // that, but we also need to avoid sending cookies that were previously stored, and // there's no harm to doing this check because such a cookie is never valid. - if (!CFStringGetLength(CFHTTPCookieGetName(cookie))) + if (!CFStringGetLength(cookieName(cookie).get())) continue; if (CFHTTPCookieIsHTTPOnly(cookie)) @@ -147,12 +195,12 @@ bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies) for (CFIndex i = 0; i < count; i++) { CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i); - String name = CFHTTPCookieGetName(cookie); - String value = CFHTTPCookieGetValue(cookie); - String domain = CFHTTPCookieGetDomain(cookie); - String path = CFHTTPCookieGetPath(cookie); + String name = cookieName(cookie).get(); + String value = cookieValue(cookie).get(); + String domain = cookieDomain(cookie).get(); + String path = cookiePath(cookie).get(); - double expires = (CFDateGetAbsoluteTime(CFHTTPCookieGetExpiratonDate(cookie)) + kCFAbsoluteTimeIntervalSince1970) * 1000; + double expires = (cookieExpirationTime(cookie) + kCFAbsoluteTimeIntervalSince1970) * 1000; bool httpOnly = CFHTTPCookieIsHTTPOnly(cookie); bool secure = CFHTTPCookieIsSecure(cookie); @@ -178,8 +226,7 @@ void deleteCookie(const Document*, const KURL& url, const String& name) CFIndex count = CFArrayGetCount(cookiesCF.get()); for (CFIndex i = 0; i < count; i++) { CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i); - String cookieName = CFHTTPCookieGetName(cookie); - if (cookieName == name) { + if (String(cookieName(cookie).get()) == name) { CFHTTPCookieStorageDeleteCookie(cookieStorage, cookie); break; } diff --git a/Source/WebCore/platform/network/chromium/CookieJarChromium.cpp b/Source/WebCore/platform/network/chromium/CookieJarChromium.cpp index e17816a..2f2489b 100644 --- a/Source/WebCore/platform/network/chromium/CookieJarChromium.cpp +++ b/Source/WebCore/platform/network/chromium/CookieJarChromium.cpp @@ -32,39 +32,39 @@ #include "CookieJar.h" #include "Cookie.h" -#include "ChromiumBridge.h" #include "Document.h" +#include "PlatformBridge.h" namespace WebCore { void setCookies(Document* document, const KURL& url, const String& value) { - ChromiumBridge::setCookies(document, url, value); + PlatformBridge::setCookies(document, url, value); } String cookies(const Document* document, const KURL& url) { - return ChromiumBridge::cookies(document, url); + return PlatformBridge::cookies(document, url); } String cookieRequestHeaderFieldValue(const Document* document, const KURL& url) { - return ChromiumBridge::cookieRequestHeaderFieldValue(document, url); + return PlatformBridge::cookieRequestHeaderFieldValue(document, url); } bool cookiesEnabled(const Document* document) { - return ChromiumBridge::cookiesEnabled(document); + return PlatformBridge::cookiesEnabled(document); } bool getRawCookies(const Document* document, const KURL& url, Vector<Cookie>& rawCookies) { - return ChromiumBridge::rawCookies(document, url, rawCookies); + return PlatformBridge::rawCookies(document, url, rawCookies); } void deleteCookie(const Document* document, const KURL& url, const String& cookieName) { - return ChromiumBridge::deleteCookie(document, url, cookieName); + return PlatformBridge::deleteCookie(document, url, cookieName); } } // namespace WebCore diff --git a/Source/WebCore/platform/network/chromium/DNSChromium.cpp b/Source/WebCore/platform/network/chromium/DNSChromium.cpp index 21fcd46..7b9eac5 100644 --- a/Source/WebCore/platform/network/chromium/DNSChromium.cpp +++ b/Source/WebCore/platform/network/chromium/DNSChromium.cpp @@ -26,14 +26,14 @@ #include "config.h" #include "DNS.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "ResourceHandle.h" namespace WebCore { void prefetchDNS(const String& hostname) { - ChromiumBridge::prefetchDNS(hostname); + PlatformBridge::prefetchDNS(hostname); } void ResourceHandle::prepareForURL(const KURL& url) diff --git a/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp b/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp index ebb6c5f..a7170fe 100644 --- a/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp +++ b/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp @@ -60,7 +60,8 @@ namespace WebCore { #define READ_BUFFER_SIZE 8192 -class WebCoreSynchronousLoader : public ResourceHandleClient, public Noncopyable { +class WebCoreSynchronousLoader : public ResourceHandleClient { + WTF_MAKE_NONCOPYABLE(WebCoreSynchronousLoader); public: WebCoreSynchronousLoader(ResourceError&, ResourceResponse &, Vector<char>&); ~WebCoreSynchronousLoader(); diff --git a/Source/WebCore/platform/network/win/ResourceHandleWin.cpp b/Source/WebCore/platform/network/win/ResourceHandleWin.cpp index 38d9cd1..f50540c 100644 --- a/Source/WebCore/platform/network/win/ResourceHandleWin.cpp +++ b/Source/WebCore/platform/network/win/ResourceHandleWin.cpp @@ -76,7 +76,8 @@ static String queryHTTPHeader(HINTERNET requestHandle, DWORD infoLevel) } -class WebCoreSynchronousLoader : public ResourceHandleClient, public Noncopyable { +class WebCoreSynchronousLoader : public ResourceHandleClient { + WTF_MAKE_NONCOPYABLE(WebCoreSynchronousLoader); public: WebCoreSynchronousLoader(ResourceError&, ResourceResponse&, Vector<char>&, const String& userAgent); ~WebCoreSynchronousLoader(); diff --git a/Source/WebCore/platform/qt/ClipboardQt.h b/Source/WebCore/platform/qt/ClipboardQt.h index 5aca1a6..fb5abef 100644 --- a/Source/WebCore/platform/qt/ClipboardQt.h +++ b/Source/WebCore/platform/qt/ClipboardQt.h @@ -39,6 +39,7 @@ namespace WebCore { // State available during IE's events for drag and drop and copy/paste class ClipboardQt : public Clipboard, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<ClipboardQt> create(ClipboardAccessPolicy policy, const QMimeData* readableClipboard) { diff --git a/Source/WebCore/platform/qt/PlatformBridge.h b/Source/WebCore/platform/qt/PlatformBridge.h index e478d8f..9647507 100644 --- a/Source/WebCore/platform/qt/PlatformBridge.h +++ b/Source/WebCore/platform/qt/PlatformBridge.h @@ -86,7 +86,7 @@ class Widget; // An interface to the embedding layer, which has the ability to answer // questions about the system and so on... -// This is very similar to ChromiumBridge and the two are likely to converge +// This is very similar to chromium/PlatformBridge and the two are likely to converge // in the future. class PlatformBridge { public: diff --git a/Source/WebCore/platform/qt/ScrollbarQt.cpp b/Source/WebCore/platform/qt/ScrollbarQt.cpp index a517064..dda82e9 100644 --- a/Source/WebCore/platform/qt/ScrollbarQt.cpp +++ b/Source/WebCore/platform/qt/ScrollbarQt.cpp @@ -34,6 +34,7 @@ #include "GraphicsContext.h" #include "IntRect.h" #include "PlatformMouseEvent.h" +#include "ScrollableArea.h" #include "ScrollbarTheme.h" #include <QApplication> @@ -76,17 +77,17 @@ bool Scrollbar::contextMenu(const PlatformMouseEvent& event) const QPoint pos = convertFromContainingWindow(event.pos()); moveThumb(horizontal ? pos.x() : pos.y()); } else if (actionSelected == actScrollTop) - scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByDocument); + scrollableArea()->scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByDocument); else if (actionSelected == actScrollBottom) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByDocument); + scrollableArea()->scroll(horizontal ? ScrollRight : ScrollDown, ScrollByDocument); else if (actionSelected == actPageUp) - scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByPage); + scrollableArea()->scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByPage); else if (actionSelected == actPageDown) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByPage); + scrollableArea()->scroll(horizontal ? ScrollRight : ScrollDown, ScrollByPage); else if (actionSelected == actScrollUp) - scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByLine); + scrollableArea()->scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByLine); else if (actionSelected == actScrollDown) - scroll(horizontal ? ScrollRight : ScrollDown, ScrollByLine); + scrollableArea()->scroll(horizontal ? ScrollRight : ScrollDown, ScrollByLine); #endif // QT_NO_CONTEXTMENU return true; } diff --git a/Source/WebCore/platform/sql/SQLiteDatabase.h b/Source/WebCore/platform/sql/SQLiteDatabase.h index c329273..da53acc 100644 --- a/Source/WebCore/platform/sql/SQLiteDatabase.h +++ b/Source/WebCore/platform/sql/SQLiteDatabase.h @@ -50,7 +50,8 @@ extern const int SQLResultSchema; extern const int SQLResultFull; extern const int SQLResultInterrupt; -class SQLiteDatabase : public Noncopyable { +class SQLiteDatabase { + WTF_MAKE_NONCOPYABLE(SQLiteDatabase); friend class SQLiteTransaction; public: SQLiteDatabase(); diff --git a/Source/WebCore/platform/sql/SQLiteStatement.h b/Source/WebCore/platform/sql/SQLiteStatement.h index 1444f0e..fd1abfb 100644 --- a/Source/WebCore/platform/sql/SQLiteStatement.h +++ b/Source/WebCore/platform/sql/SQLiteStatement.h @@ -34,7 +34,8 @@ namespace WebCore { class SQLValue; -class SQLiteStatement : public Noncopyable { +class SQLiteStatement { + WTF_MAKE_NONCOPYABLE(SQLiteStatement); WTF_MAKE_FAST_ALLOCATED; public: SQLiteStatement(SQLiteDatabase&, const String&); ~SQLiteStatement(); diff --git a/Source/WebCore/platform/sql/SQLiteTransaction.h b/Source/WebCore/platform/sql/SQLiteTransaction.h index 924241f..ba686ba 100644 --- a/Source/WebCore/platform/sql/SQLiteTransaction.h +++ b/Source/WebCore/platform/sql/SQLiteTransaction.h @@ -26,14 +26,15 @@ #ifndef SQLiteTransaction_h #define SQLiteTransaction_h +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> namespace WebCore { class SQLiteDatabase; -class SQLiteTransaction : public Noncopyable -{ +class SQLiteTransaction { + WTF_MAKE_NONCOPYABLE(SQLiteTransaction); WTF_MAKE_FAST_ALLOCATED; public: SQLiteTransaction(SQLiteDatabase& db, bool readOnly = false); ~SQLiteTransaction(); diff --git a/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp b/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp index 0a09888..b79eb1a 100644 --- a/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp +++ b/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "SQLiteFileSystem.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "SQLiteDatabase.h" #include <sqlite3.h> #include <wtf/text/CString.h> @@ -92,12 +92,12 @@ bool SQLiteFileSystem::deleteEmptyDatabaseDirectory(const String&) bool SQLiteFileSystem::deleteDatabaseFile(const String& fileName) { - return (ChromiumBridge::databaseDeleteFile(fileName) == SQLITE_OK); + return (PlatformBridge::databaseDeleteFile(fileName) == SQLITE_OK); } long long SQLiteFileSystem::getDatabaseFileSize(const String& fileName) { - return ChromiumBridge::databaseGetFileSize(fileName); + return PlatformBridge::databaseGetFileSize(fileName); } } // namespace WebCore diff --git a/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp b/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp index 1102df5..37f96be 100644 --- a/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp +++ b/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumPosix.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "SQLiteFileSystem.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include <sqlite3.h> #include <errno.h> @@ -996,10 +996,10 @@ static int chromiumOpen(sqlite3_vfs* vfs, const char* fileName, } if (fd < 0) { - fd = ChromiumBridge::databaseOpenFile(fileName, desiredFlags); + fd = PlatformBridge::databaseOpenFile(fileName, desiredFlags); if ((fd < 0) && (desiredFlags & SQLITE_OPEN_READWRITE)) { int newFlags = (desiredFlags & ~(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)) | SQLITE_OPEN_READONLY; - fd = ChromiumBridge::databaseOpenFile(fileName, newFlags); + fd = PlatformBridge::databaseOpenFile(fileName, newFlags); } } if (fd < 0) { @@ -1031,7 +1031,7 @@ static int chromiumOpen(sqlite3_vfs* vfs, const char* fileName, // should be synched after the file is deleted. static int chromiumDelete(sqlite3_vfs*, const char* fileName, int syncDir) { - return ChromiumBridge::databaseDeleteFile(fileName, syncDir); + return PlatformBridge::databaseDeleteFile(fileName, syncDir); } // Check the existance and status of the given file. @@ -1042,7 +1042,7 @@ static int chromiumDelete(sqlite3_vfs*, const char* fileName, int syncDir) // res - the result. static int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res) { - int attr = static_cast<int>(ChromiumBridge::databaseGetFileAttributes(fileName)); + int attr = static_cast<int>(PlatformBridge::databaseGetFileAttributes(fileName)); if (attr < 0) { *res = 0; return SQLITE_OK; diff --git a/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumWin.cpp b/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumWin.cpp index d846af7..47e01d0 100644 --- a/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumWin.cpp +++ b/Source/WebCore/platform/sql/chromium/SQLiteFileSystemChromiumWin.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "SQLiteFileSystem.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include <sqlite3.h> #include <windows.h> @@ -55,7 +55,7 @@ namespace { int chromiumOpen(sqlite3_vfs*, const char* fileName, sqlite3_file* id, int desiredFlags, int* usedFlags) { - HANDLE h = ChromiumBridge::databaseOpenFile(fileName, desiredFlags); + HANDLE h = PlatformBridge::databaseOpenFile(fileName, desiredFlags); if (h == INVALID_HANDLE_VALUE) { if (desiredFlags & SQLITE_OPEN_READWRITE) { int newFlags = (desiredFlags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE; @@ -82,7 +82,7 @@ int chromiumOpen(sqlite3_vfs*, const char* fileName, // should be synched after the file is deleted. int chromiumDelete(sqlite3_vfs*, const char* fileName, int) { - return ChromiumBridge::databaseDeleteFile(fileName); + return PlatformBridge::databaseDeleteFile(fileName); } // Check the existance and status of the given file. @@ -93,7 +93,7 @@ int chromiumDelete(sqlite3_vfs*, const char* fileName, int) // res - the result. int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res) { - DWORD attr = ChromiumBridge::databaseGetFileAttributes(fileName); + DWORD attr = PlatformBridge::databaseGetFileAttributes(fileName); switch (flag) { case SQLITE_ACCESS_READ: case SQLITE_ACCESS_EXISTS: diff --git a/Source/WebCore/platform/text/BidiResolver.h b/Source/WebCore/platform/text/BidiResolver.h index 1f87115..8abd698 100644 --- a/Source/WebCore/platform/text/BidiResolver.h +++ b/Source/WebCore/platform/text/BidiResolver.h @@ -126,7 +126,8 @@ struct BidiCharacterRun { BidiCharacterRun* m_next; }; -template <class Iterator, class Run> class BidiResolver : public Noncopyable { +template <class Iterator, class Run> class BidiResolver { + WTF_MAKE_NONCOPYABLE(BidiResolver); public : BidiResolver() : m_direction(WTF::Unicode::OtherNeutral) @@ -314,23 +315,13 @@ void BidiResolver<Iterator, Run>::checkDirectionInLowerRaiseEmbeddingLevel() using namespace WTF::Unicode; ASSERT(m_status.eor != OtherNeutral || eor.atEnd()); - // bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last - // Bidi control characters are included into BidiRun, so last direction - // could be one of the bidi embeddings when there are nested embeddings. - // For example: "‪‫....." - ASSERT(m_status.last == EuropeanNumberSeparator - || m_status.last == EuropeanNumberTerminator - || m_status.last == CommonNumberSeparator - || m_status.last == BoundaryNeutral - || m_status.last == BlockSeparator - || m_status.last == SegmentSeparator - || m_status.last == WhiteSpaceNeutral - || m_status.last == OtherNeutral - || m_status.last == RightToLeftEmbedding - || m_status.last == LeftToRightEmbedding - || m_status.last == RightToLeftOverride - || m_status.last == LeftToRightOverride - || m_status.last == PopDirectionalFormat); + ASSERT(m_status.last != NonSpacingMark + && m_status.last != BoundaryNeutral + && m_status.last != RightToLeftEmbedding + && m_status.last != LeftToRightEmbedding + && m_status.last != RightToLeftOverride + && m_status.last != LeftToRightOverride + && m_status.last != PopDirectionalFormat); if (m_direction == OtherNeutral) m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : RightToLeft; } @@ -342,6 +333,7 @@ void BidiResolver<Iterator, Run>::lowerExplicitEmbeddingLevel(WTF::Unicode::Dire if (!emptyRun && eor != last) { checkDirectionInLowerRaiseEmbeddingLevel(); + // bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last if (from == LeftToRight) { // bidi.sor ... bidi.eor ... bidi.last L if (m_status.eor == EuropeanNumber) { @@ -377,6 +369,7 @@ void BidiResolver<Iterator, Run>::raiseExplicitEmbeddingLevel(WTF::Unicode::Dire if (!emptyRun && eor != last) { checkDirectionInLowerRaiseEmbeddingLevel(); + // bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last if (to == LeftToRight) { // bidi.sor ... bidi.eor ... bidi.last L if (m_status.eor == EuropeanNumber) { @@ -866,6 +859,11 @@ void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, boo break; case NonSpacingMark: case BoundaryNeutral: + case RightToLeftEmbedding: + case LeftToRightEmbedding: + case RightToLeftOverride: + case LeftToRightOverride: + case PopDirectionalFormat: // ignore these break; case EuropeanNumber: diff --git a/Source/WebCore/platform/text/RegularExpression.h b/Source/WebCore/platform/text/RegularExpression.h index f1611e5..536ed48 100644 --- a/Source/WebCore/platform/text/RegularExpression.h +++ b/Source/WebCore/platform/text/RegularExpression.h @@ -30,7 +30,8 @@ namespace WebCore { -class RegularExpression : public FastAllocBase { +class RegularExpression { + WTF_MAKE_FAST_ALLOCATED; public: RegularExpression(const String&, TextCaseSensitivity); ~RegularExpression(); diff --git a/Source/WebCore/platform/text/SegmentedString.cpp b/Source/WebCore/platform/text/SegmentedString.cpp index a371582..5e9755b 100644 --- a/Source/WebCore/platform/text/SegmentedString.cpp +++ b/Source/WebCore/platform/text/SegmentedString.cpp @@ -246,7 +246,8 @@ void SegmentedString::advanceSlowCase(int& lineNumber) if (*m_currentString.m_current++ == '\n' && m_currentString.doNotExcludeLineNumbers()) { ++lineNumber; ++m_currentLine; - m_numberOfCharactersConsumedPriorToCurrentLine = numberOfCharactersConsumed(); + // Plus 1 because numberOfCharactersConsumed value hasn't incremented yet; it does with m_length decrement below. + m_numberOfCharactersConsumedPriorToCurrentLine = numberOfCharactersConsumed() + 1; } if (--m_currentString.m_length == 0) advanceSubstring(); diff --git a/Source/WebCore/platform/text/SegmentedString.h b/Source/WebCore/platform/text/SegmentedString.h index 5f548c7..30c899d 100644 --- a/Source/WebCore/platform/text/SegmentedString.h +++ b/Source/WebCore/platform/text/SegmentedString.h @@ -164,7 +164,7 @@ public: lineNumber += newLineFlag; m_currentLine += newLineFlag; if (newLineFlag) - m_numberOfCharactersConsumedPriorToCurrentLine = numberOfCharactersConsumed(); + m_numberOfCharactersConsumedPriorToCurrentLine = numberOfCharactersConsumed() + 1; --m_currentString.m_length; m_currentChar = ++m_currentString.m_current; return; diff --git a/Source/WebCore/platform/text/TextCodec.h b/Source/WebCore/platform/text/TextCodec.h index c6af38a..35229a3 100644 --- a/Source/WebCore/platform/text/TextCodec.h +++ b/Source/WebCore/platform/text/TextCodec.h @@ -57,8 +57,10 @@ namespace WebCore { typedef char UnencodableReplacementArray[32]; - class TextCodec : public Noncopyable { + class TextCodec { + WTF_MAKE_NONCOPYABLE(TextCodec); WTF_MAKE_FAST_ALLOCATED; public: + TextCodec() { } virtual ~TextCodec(); String decode(const char* str, size_t length, bool flush = false) diff --git a/Source/WebCore/platform/text/transcoder/FontTranscoder.h b/Source/WebCore/platform/text/transcoder/FontTranscoder.h index 67db977..6990a10 100644 --- a/Source/WebCore/platform/text/transcoder/FontTranscoder.h +++ b/Source/WebCore/platform/text/transcoder/FontTranscoder.h @@ -40,7 +40,8 @@ namespace WebCore { class FontDescription; class TextEncoding; -class FontTranscoder : public Noncopyable { +class FontTranscoder { + WTF_MAKE_NONCOPYABLE(FontTranscoder); WTF_MAKE_FAST_ALLOCATED; public: void convert(String& text, const FontDescription&, const TextEncoding* = 0) const; bool needsTranscoding(const FontDescription&, const TextEncoding* = 0) const; diff --git a/Source/WebCore/platform/win/ClipboardWin.h b/Source/WebCore/platform/win/ClipboardWin.h index ce64b85..779da26 100644 --- a/Source/WebCore/platform/win/ClipboardWin.h +++ b/Source/WebCore/platform/win/ClipboardWin.h @@ -41,6 +41,7 @@ class WCDataObject; // State available during IE's events for drag and drop and copy/paste class ClipboardWin : public Clipboard, public CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<ClipboardWin> create(ClipboardType clipboardType, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) { diff --git a/Source/WebCore/platform/win/PopupMenuWin.cpp b/Source/WebCore/platform/win/PopupMenuWin.cpp index e86aef9..15871e6 100644 --- a/Source/WebCore/platform/win/PopupMenuWin.cpp +++ b/Source/WebCore/platform/win/PopupMenuWin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. * Copyright (C) 2007-2009 Torch Mobile Inc. * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * @@ -40,6 +40,7 @@ #include "Scrollbar.h" #include "ScrollbarTheme.h" #include "SimpleFontData.h" +#include "TextRun.h" #include "WebCoreInstanceHandle.h" #include <tchar.h> #include <windows.h> @@ -531,12 +532,12 @@ bool PopupMenuWin::scrollToRevealSelection() int index = focusedIndex(); if (index < m_scrollOffset) { - m_scrollbar->setValue(index, Scrollbar::NotFromScrollAnimator); + ScrollableArea::scrollToYOffsetWithoutAnimation(index); return true; } if (index >= m_scrollOffset + visibleItems()) { - m_scrollbar->setValue(index - visibleItems() + 1, Scrollbar::NotFromScrollAnimator); + ScrollableArea::scrollToYOffsetWithoutAnimation(index - visibleItems() + 1); return true; } @@ -669,21 +670,23 @@ int PopupMenuWin::scrollSize(ScrollbarOrientation orientation) const return ((orientation == VerticalScrollbar) && m_scrollbar) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0; } -void PopupMenuWin::setScrollOffsetFromAnimation(const IntPoint& offset) +int PopupMenuWin::scrollPosition(Scrollbar*) const { - if (m_scrollbar) - m_scrollbar->setValue(offset.y(), Scrollbar::FromScrollAnimator); + return m_scrollOffset; +} + +void PopupMenuWin::setScrollOffset(const IntPoint& offset) +{ + scrollTo(offset.y()); } -void PopupMenuWin::valueChanged(Scrollbar* scrollBar) +void PopupMenuWin::scrollTo(int offset) { ASSERT(m_scrollbar); if (!m_popup) return; - int offset = scrollBar->value(); - if (m_scrollOffset == offset) return; @@ -990,7 +993,8 @@ LRESULT PopupMenuWin::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa else --i; } - scrollbar()->scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i)); + + ScrollableArea::scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i)); break; } diff --git a/Source/WebCore/platform/win/PopupMenuWin.h b/Source/WebCore/platform/win/PopupMenuWin.h index bfec7aa..0d7630c 100644 --- a/Source/WebCore/platform/win/PopupMenuWin.h +++ b/Source/WebCore/platform/win/PopupMenuWin.h @@ -1,4 +1,5 @@ /* + * Copyright (C) 2011 Apple Inc. All rights reserved. * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * This library is free software; you can redistribute it and/or @@ -23,8 +24,8 @@ #include "IntRect.h" #include "PopupMenu.h" #include "PopupMenuClient.h" +#include "ScrollableArea.h" #include "Scrollbar.h" -#include "ScrollbarClient.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> @@ -38,7 +39,7 @@ namespace WebCore { class FrameView; class Scrollbar; -class PopupMenuWin : public PopupMenu, private ScrollbarClient { +class PopupMenuWin : public PopupMenu, private ScrollableArea { public: PopupMenuWin(PopupMenuClient*); ~PopupMenuWin(); @@ -78,7 +79,6 @@ private: void setWasClicked(bool b = true) { m_wasClicked = b; } bool wasClicked() const { return m_wasClicked; } - void setScrollOffset(int offset) { m_scrollOffset = offset; } int scrollOffset() const { return m_scrollOffset; } bool scrollToRevealSelection(); @@ -90,13 +90,17 @@ private: bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; } void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; } - // ScrollBarClient + // ScrollableArea virtual int scrollSize(ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const IntPoint&); - virtual void valueChanged(Scrollbar*); + virtual int scrollPosition(Scrollbar*) const; + virtual void setScrollOffset(const IntPoint&); virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); virtual bool isActive() const { return true; } virtual bool scrollbarCornerPresent() const { return false; } + virtual Scrollbar* verticalScrollbar() const { return m_scrollbar.get(); } + + // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. + void scrollTo(int offset); void calculatePositionAndSize(const IntRect&, FrameView*); void invalidateItem(int index); @@ -120,6 +124,6 @@ private: bool m_showPopup; }; -} +} // namespace WebCore #endif // PopupMenuWin_h diff --git a/Source/WebCore/platform/win/ScrollbarThemeSafari.cpp b/Source/WebCore/platform/win/ScrollbarThemeSafari.cpp index 4e979f2..343bbb2 100644 --- a/Source/WebCore/platform/win/ScrollbarThemeSafari.cpp +++ b/Source/WebCore/platform/win/ScrollbarThemeSafari.cpp @@ -32,8 +32,8 @@ #include "IntRect.h" #include "Page.h" #include "PlatformMouseEvent.h" +#include "ScrollableArea.h" #include "Scrollbar.h" -#include "ScrollbarClient.h" #include "ScrollbarThemeWin.h" #include "Settings.h" #include "SoftLinking.h" @@ -209,7 +209,7 @@ void ScrollbarThemeSafari::paintTrackBackground(GraphicsContext* graphicsContext return; NSControlSize size = scrollbar->controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize; ThemeControlState state = 0; - if (scrollbar->client()->isActive()) + if (scrollbar->scrollableArea()->isActive()) state |= ActiveState; if (hasButtons(scrollbar)) state |= EnabledState; @@ -222,7 +222,7 @@ void ScrollbarThemeSafari::paintButton(GraphicsContext* graphicsContext, Scrollb return; NSControlSize size = scrollbar->controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize; ThemeControlState state = 0; - if (scrollbar->client()->isActive()) + if (scrollbar->scrollableArea()->isActive()) state |= ActiveState; if (hasButtons(scrollbar)) state |= EnabledState; @@ -242,7 +242,7 @@ void ScrollbarThemeSafari::paintThumb(GraphicsContext* graphicsContext, Scrollba return; NSControlSize size = scrollbar->controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize; ThemeControlState state = 0; - if (scrollbar->client()->isActive()) + if (scrollbar->scrollableArea()->isActive()) state |= ActiveState; if (hasThumb(scrollbar)) state |= EnabledState; diff --git a/Source/WebCore/platform/win/WebCoreTextRenderer.cpp b/Source/WebCore/platform/win/WebCoreTextRenderer.cpp index a32fa4f..e96ba31 100644 --- a/Source/WebCore/platform/win/WebCoreTextRenderer.cpp +++ b/Source/WebCore/platform/win/WebCoreTextRenderer.cpp @@ -29,6 +29,7 @@ #include "FontDescription.h" #include "GraphicsContext.h" #include "StringTruncator.h" +#include "TextRun.h" #include <wtf/unicode/Unicode.h> namespace WebCore { diff --git a/Source/WebCore/platform/win/WindowMessageBroadcaster.h b/Source/WebCore/platform/win/WindowMessageBroadcaster.h index e7856e7..d36c233 100644 --- a/Source/WebCore/platform/win/WindowMessageBroadcaster.h +++ b/Source/WebCore/platform/win/WindowMessageBroadcaster.h @@ -31,13 +31,13 @@ #include <wtf/HashMap.h> #include <wtf/HashSet.h> -#include <wtf/Noncopyable.h> namespace WebCore { class WindowMessageListener; - class WindowMessageBroadcaster : public Noncopyable { + class WindowMessageBroadcaster { + WTF_MAKE_NONCOPYABLE(WindowMessageBroadcaster); public: static void addListener(HWND, WindowMessageListener*); static void removeListener(HWND, WindowMessageListener*); diff --git a/Source/WebCore/platform/wx/ScrollbarThemeWx.cpp b/Source/WebCore/platform/wx/ScrollbarThemeWx.cpp index 82e4a15..957f958 100644 --- a/Source/WebCore/platform/wx/ScrollbarThemeWx.cpp +++ b/Source/WebCore/platform/wx/ScrollbarThemeWx.cpp @@ -29,8 +29,8 @@ #include "HostWindow.h" #include "NotImplemented.h" #include "PlatformMouseEvent.h" +#include "ScrollableArea.h" #include "Scrollbar.h" -#include "ScrollbarClient.h" #include "scrollbar_render.h" #include "ScrollbarThemeComposite.h" #include "ScrollView.h" @@ -185,7 +185,7 @@ bool ScrollbarThemeWx::paint(Scrollbar* scrollbar, GraphicsContext* context, con { wxOrientation orientation = (scrollbar->orientation() == HorizontalScrollbar) ? wxHORIZONTAL : wxVERTICAL; int flags = 0; - if (scrollbar->client()->isActive()) + if (scrollbar->scrollableArea()->isActive()) flags |= wxCONTROL_FOCUSED; if (!scrollbar->enabled()) diff --git a/Source/WebCore/plugins/PluginDatabase.h b/Source/WebCore/plugins/PluginDatabase.h index b1e1525..275e47f 100644 --- a/Source/WebCore/plugins/PluginDatabase.h +++ b/Source/WebCore/plugins/PluginDatabase.h @@ -50,7 +50,8 @@ namespace WebCore { typedef HashSet<RefPtr<PluginPackage>, PluginPackageHash> PluginSet; - class PluginDatabase : public Noncopyable { + class PluginDatabase { + WTF_MAKE_NONCOPYABLE(PluginDatabase); WTF_MAKE_FAST_ALLOCATED; public: PluginDatabase(); diff --git a/Source/WebCore/plugins/PluginMainThreadScheduler.h b/Source/WebCore/plugins/PluginMainThreadScheduler.h index 610e89c..29bc4e6 100644 --- a/Source/WebCore/plugins/PluginMainThreadScheduler.h +++ b/Source/WebCore/plugins/PluginMainThreadScheduler.h @@ -36,7 +36,8 @@ typedef NPP_t* NPP; namespace WebCore { -class PluginMainThreadScheduler : public Noncopyable { +class PluginMainThreadScheduler { + WTF_MAKE_NONCOPYABLE(PluginMainThreadScheduler); WTF_MAKE_FAST_ALLOCATED; public: typedef void MainThreadFunction(void*); diff --git a/Source/WebCore/plugins/PluginView.h b/Source/WebCore/plugins/PluginView.h index a58d217..03e7189 100644 --- a/Source/WebCore/plugins/PluginView.h +++ b/Source/WebCore/plugins/PluginView.h @@ -108,7 +108,8 @@ namespace WebCore { PluginStatusLoadedSuccessfully }; - class PluginRequest : public Noncopyable { + class PluginRequest { + WTF_MAKE_NONCOPYABLE(PluginRequest); WTF_MAKE_FAST_ALLOCATED; public: PluginRequest(const FrameLoadRequest& frameLoadRequest, bool sendNotification, void* notifyData, bool shouldAllowPopups) : m_frameLoadRequest(frameLoadRequest) diff --git a/Source/WebCore/plugins/chromium/PluginDataChromium.cpp b/Source/WebCore/plugins/chromium/PluginDataChromium.cpp index c924063..77cdbbf 100644 --- a/Source/WebCore/plugins/chromium/PluginDataChromium.cpp +++ b/Source/WebCore/plugins/chromium/PluginDataChromium.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "PluginDataChromium.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" namespace WebCore { @@ -50,7 +50,7 @@ public: const Vector<PluginInfo>& plugins() { if (!m_loaded) { - ChromiumBridge::plugins(m_refresh, &m_plugins); + PlatformBridge::plugins(m_refresh, &m_plugins); m_loaded = true; m_refresh = false; } diff --git a/Source/WebCore/rendering/ColumnInfo.h b/Source/WebCore/rendering/ColumnInfo.h index 5e6f619..d77d6ca 100644 --- a/Source/WebCore/rendering/ColumnInfo.h +++ b/Source/WebCore/rendering/ColumnInfo.h @@ -31,7 +31,8 @@ namespace WebCore { -class ColumnInfo : public Noncopyable { +class ColumnInfo { + WTF_MAKE_NONCOPYABLE(ColumnInfo); WTF_MAKE_FAST_ALLOCATED; public: ColumnInfo() : m_desiredColumnWidth(0) diff --git a/Source/WebCore/rendering/EllipsisBox.cpp b/Source/WebCore/rendering/EllipsisBox.cpp index 39fa205..d367c07 100644 --- a/Source/WebCore/rendering/EllipsisBox.cpp +++ b/Source/WebCore/rendering/EllipsisBox.cpp @@ -25,6 +25,7 @@ #include "HitTestResult.h" #include "PaintInfo.h" #include "RootInlineBox.h" +#include "TextRun.h" namespace WebCore { diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp index ae5be0f..8992964 100644 --- a/Source/WebCore/rendering/InlineTextBox.cpp +++ b/Source/WebCore/rendering/InlineTextBox.cpp @@ -40,6 +40,7 @@ #include "RenderRubyText.h" #include "RenderTheme.h" #include "Text.h" +#include "TextRun.h" #include "break_lines.h" #include <wtf/AlwaysInline.h> diff --git a/Source/WebCore/rendering/LayoutState.h b/Source/WebCore/rendering/LayoutState.h index 0d06cb1..c499435 100644 --- a/Source/WebCore/rendering/LayoutState.h +++ b/Source/WebCore/rendering/LayoutState.h @@ -37,7 +37,8 @@ class RenderArena; class RenderBox; class RenderObject; -class LayoutState : public Noncopyable { +class LayoutState { + WTF_MAKE_NONCOPYABLE(LayoutState); public: LayoutState() : m_clipped(false) diff --git a/Source/WebCore/rendering/RenderArena.h b/Source/WebCore/rendering/RenderArena.h index edf052a..5d2559a 100644 --- a/Source/WebCore/rendering/RenderArena.h +++ b/Source/WebCore/rendering/RenderArena.h @@ -36,13 +36,15 @@ #define RenderArena_h #include "Arena.h" +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> namespace WebCore { static const size_t gMaxRecycledSize = 400; -class RenderArena : public Noncopyable { +class RenderArena { + WTF_MAKE_NONCOPYABLE(RenderArena); WTF_MAKE_FAST_ALLOCATED; public: RenderArena(unsigned arenaSize = 4096); ~RenderArena(); diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index 794bafc..7275461 100644 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -48,6 +48,7 @@ #include "RenderView.h" #include "SelectionController.h" #include "Settings.h" +#include "TextRun.h" #include "TransformState.h" #include <wtf/StdLibExtras.h> @@ -5265,9 +5266,8 @@ void RenderBlock::updateFirstLetter() if (remainingText->node()) remainingText->node()->setRenderer(remainingText); - RenderObject* nextObj = textObj->nextSibling(); + firstLetterContainer->addChild(remainingText, textObj); firstLetterContainer->removeChild(textObj); - firstLetterContainer->addChild(remainingText, nextObj); remainingText->setFirstLetter(firstLetter); // construct text fragment for the first letter diff --git a/Source/WebCore/rendering/RenderBlock.h b/Source/WebCore/rendering/RenderBlock.h index 9529bd6..f8829ee 100644 --- a/Source/WebCore/rendering/RenderBlock.h +++ b/Source/WebCore/rendering/RenderBlock.h @@ -360,7 +360,9 @@ private: bool everHadLayout; }; - struct FloatingObject : Noncopyable { + struct FloatingObject { + WTF_MAKE_NONCOPYABLE(FloatingObject); WTF_MAKE_FAST_ALLOCATED; + public: // Note that Type uses bits so you can use FloatBoth as a mask to query for both left and right. enum Type { FloatLeft = 1, FloatRight = 2, FloatBoth = 3 }; @@ -678,7 +680,9 @@ private: PositionedObjectsListHashSet* m_positionedObjects; // Allocated only when some of these fields have non-default values - struct RenderBlockRareData : Noncopyable { + struct RenderBlockRareData { + WTF_MAKE_NONCOPYABLE(RenderBlockRareData); WTF_MAKE_FAST_ALLOCATED; + public: RenderBlockRareData(const RenderBlock* block) : m_margins(positiveMarginBeforeDefault(block), negativeMarginBeforeDefault(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(block)) , m_paginationStrut(0) diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp index 1d909a3..5e16931 100644 --- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp +++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp @@ -34,6 +34,7 @@ #include "RenderListMarker.h" #include "RenderView.h" #include "Settings.h" +#include "TextRun.h" #include "TrailingFloatsRootInlineBox.h" #include "VerticalPositionCache.h" #include "break_lines.h" diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp index e218d85..265c46a 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -50,6 +50,7 @@ #include "Settings.h" #endif #include "RenderView.h" +#include "ScrollbarTheme.h" #include "TransformState.h" #include <algorithm> #include <math.h> @@ -573,6 +574,18 @@ IntRect RenderBox::reflectedRect(const IntRect& r) const return result; } +bool RenderBox::includeVerticalScrollbarSize() const +{ + return !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars() + && hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); +} + +bool RenderBox::includeHorizontalScrollbarSize() const +{ + return !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars() + && hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); +} + int RenderBox::verticalScrollbarWidth() const { return includeVerticalScrollbarSize() ? layer()->verticalScrollbarWidth() : 0; @@ -1078,14 +1091,8 @@ bool RenderBox::pushContentsClip(PaintInfo& paintInfo, int tx, int ty) } IntRect clipRect(isControlClip ? controlClipRect(tx, ty) : overflowClipRect(tx, ty)); paintInfo.context->save(); - if (style()->hasBorderRadius()) { - IntSize topLeft, topRight, bottomLeft, bottomRight; - IntRect borderRect = IntRect(tx, ty, width(), height()); - style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); - - paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); - } - + if (style()->hasBorderRadius()) + paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(IntRect(tx, ty, width(), height()))); paintInfo.context->clip(clipRect); return true; } @@ -3164,14 +3171,12 @@ VisiblePosition RenderBox::positionForPoint(const IntPoint& point) bool RenderBox::shrinkToAvoidFloats() const { - // FIXME: Technically we should be able to shrink replaced elements on a line, but this is difficult to accomplish, since this - // involves doing a relayout during findNextLineBreak and somehow overriding the containingBlockWidth method to return the - // current remaining width on a line. - if ((isInline() && !isHTMLMarquee()) || !avoidsFloats()) + // Floating objects don't shrink. Objects that don't avoid floats don't shrink. Marquees don't shrink. + if ((isInline() && !isHTMLMarquee()) || !avoidsFloats() || isFloating()) return false; // All auto-width objects that avoid floats should always use lineWidth. - return style()->width().isAuto(); + return style()->width().isAuto(); } bool RenderBox::avoidsFloats() const diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h index 0a7b175..acbcc29 100644 --- a/Source/WebCore/rendering/RenderBox.h +++ b/Source/WebCore/rendering/RenderBox.h @@ -414,8 +414,8 @@ protected: virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const; private: - bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); } - bool includeHorizontalScrollbarSize() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); } + bool includeVerticalScrollbarSize() const; + bool includeHorizontalScrollbarSize() const; void paintRootBoxDecorations(PaintInfo&, int tx, int ty); // Returns true if we did a full repaint diff --git a/Source/WebCore/rendering/RenderBoxModelObject.cpp b/Source/WebCore/rendering/RenderBoxModelObject.cpp index 5098306..f2412a1 100644 --- a/Source/WebCore/rendering/RenderBoxModelObject.cpp +++ b/Source/WebCore/rendering/RenderBoxModelObject.cpp @@ -63,7 +63,8 @@ typedef HashMap<LastPaintSizeMapKey, IntSize> LastPaintSizeMap; typedef HashMap<const RenderBoxModelObject*, RenderBoxModelObject*> ContinuationMap; static ContinuationMap* continuationMap = 0; -class ImageQualityController : public Noncopyable { +class ImageQualityController { + WTF_MAKE_NONCOPYABLE(ImageQualityController); WTF_MAKE_FAST_ALLOCATED; public: ImageQualityController(); bool shouldPaintAtLowQuality(GraphicsContext*, RenderBoxModelObject*, Image*, const void* layer, const IntSize&); @@ -547,26 +548,9 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co context->save(); - IntSize topLeft, topRight, bottomLeft, bottomRight; - style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); - - if (!includeLeftEdge) { - topLeft = IntSize(); - if (box->isHorizontal()) - bottomLeft = IntSize(); - else - topRight = IntSize(); - } - - if (!includeRightEdge) { - if (box->isHorizontal()) - topRight = IntSize(); - else - bottomLeft = IntSize(); - bottomRight = IntSize(); - } - - context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); + RoundedIntRect border = style()->getRoundedBorderFor(borderRect); + border.excludeLogicalEdges(box && box->isHorizontal(), !includeLeftEdge, !includeRightEdge); + context->addRoundedRectClip(border); clippedToBorderRadius = true; } @@ -1024,62 +1008,32 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, bool renderRight = rightStyle > BHIDDEN && !rightTransparent && (!horizontal || includeLogicalRightEdge); bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent && (horizontal || includeLogicalRightEdge); - bool renderRadii = false; Path roundedPath; - IntSize topLeft, topRight, bottomLeft, bottomRight; - IntRect borderRect(tx, ty, w, h); + RoundedIntRect border(tx, ty, w, h); if (style->hasBorderRadius()) { - IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius; - style->getBorderRadiiForRect(borderRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); + border.includeLogicalEdges(style->getRoundedBorderFor(border.rect()).radii(), + horizontal, includeLogicalLeftEdge, includeLogicalRightEdge); int leftWidth = (!horizontal || includeLogicalLeftEdge) ? style->borderLeftWidth() : 0; int rightWidth = (!horizontal || includeLogicalRightEdge) ? style->borderRightWidth() : 0; int topWidth = (horizontal || includeLogicalLeftEdge) ? style->borderTopWidth() : 0; int bottomWidth = (horizontal || includeLogicalRightEdge) ? style->borderBottomWidth() : 0; - IntRect innerBorderRect = borderInnerRect(borderRect, topWidth, bottomWidth, leftWidth, rightWidth); - IntSize innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius; - - style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderRect, topWidth, bottomWidth, leftWidth, rightWidth, innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius); - - IntSize innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight; - - if (includeLogicalLeftEdge) { - topLeft = topLeftRadius; - innerTopLeft = innerTopLeftRadius; - if (horizontal) { - bottomLeft = bottomLeftRadius; - innerBottomLeft = innerBottomLeftRadius; - } else { - topRight = topRightRadius; - innerTopRight = innerTopRightRadius; - } - } - - if (includeLogicalRightEdge) { - if (horizontal) { - topRight = topRightRadius; - innerTopRight = innerTopRightRadius; - } else { - bottomLeft = bottomLeftRadius; - innerBottomLeft = innerBottomLeftRadius; - } - bottomRight = bottomRightRadius; - innerBottomRight = innerBottomRightRadius; - } + RoundedIntRect inner(borderInnerRect(border.rect(), topWidth, bottomWidth, leftWidth, rightWidth)); + inner.includeLogicalEdges(style->getRoundedInnerBorderWithBorderWidths(inner.rect(), topWidth, bottomWidth, leftWidth, rightWidth).radii(), + horizontal, includeLogicalLeftEdge, includeLogicalRightEdge); - renderRadii = !topLeft.isZero() || !topRight.isZero() || !bottomLeft.isZero() || !bottomRight.isZero(); - - if (renderRadii) { + if (border.isRounded()) { // Clip to the inner and outer radii rects. graphicsContext->save(); - graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); - graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight); - roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); + graphicsContext->addRoundedRectClip(border); + graphicsContext->clipOutRoundedRect(inner); + roundedPath.addRoundedRect(border.rect(), border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight()); } } + bool renderRadii = border.isRounded(); bool upperLeftBorderStylesMatch = renderLeft && (topStyle == leftStyle) && (topColor == leftColor); bool upperRightBorderStylesMatch = renderRight && (topStyle == rightStyle) && (topColor == rightColor) && (topStyle != OUTSET) && (topStyle != RIDGE) && (topStyle != INSET) && (topStyle != GROOVE); bool lowerLeftBorderStylesMatch = renderLeft && (bottomStyle == leftStyle) && (bottomColor == leftColor) && (bottomStyle != OUTSET) && (bottomStyle != RIDGE) && (bottomStyle != INSET) && (bottomStyle != GROOVE); @@ -1089,11 +1043,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int x = tx; int x2 = tx + w; - if (renderRadii && borderWillArcInnerEdge(topLeft, topRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderTopWidth())) { + if (renderRadii && borderWillArcInnerEdge(border.radii().topLeft(), border.radii().topRight(), style->borderLeftWidth(), style->borderRightWidth(), style->borderTopWidth())) { graphicsContext->save(); - clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSTop, upperLeftBorderStylesMatch, upperRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); + clipBorderSidePolygon(graphicsContext, border, BSTop, upperLeftBorderStylesMatch, upperRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); float thickness = max(max(style->borderTopWidth(), style->borderLeftWidth()), style->borderRightWidth()); - drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderTopWidth(), thickness, BSTop, style, topColor, topStyle); + drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderTopWidth(), thickness, BSTop, style, topColor, topStyle); graphicsContext->restore(); } else { bool ignoreLeft = (topColor == leftColor && topTransparent == leftTransparent && topStyle >= OUTSET @@ -1110,11 +1064,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int x = tx; int x2 = tx + w; - if (renderRadii && borderWillArcInnerEdge(bottomLeft, bottomRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderBottomWidth())) { + if (renderRadii && borderWillArcInnerEdge(border.radii().bottomLeft(), border.radii().bottomRight(), style->borderLeftWidth(), style->borderRightWidth(), style->borderBottomWidth())) { graphicsContext->save(); - clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSBottom, lowerLeftBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); + clipBorderSidePolygon(graphicsContext, border, BSBottom, lowerLeftBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); float thickness = max(max(style->borderBottomWidth(), style->borderLeftWidth()), style->borderRightWidth()); - drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderBottomWidth(), thickness, BSBottom, style, bottomColor, bottomStyle); + drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderBottomWidth(), thickness, BSBottom, style, bottomColor, bottomStyle); graphicsContext->restore(); } else { bool ignoreLeft = (bottomColor == leftColor && bottomTransparent == leftTransparent && bottomStyle >= OUTSET @@ -1133,11 +1087,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int y = ty; int y2 = ty + h; - if (renderRadii && borderWillArcInnerEdge(bottomLeft, topLeft, style->borderBottomWidth(), style->borderTopWidth(), style->borderLeftWidth())) { + if (renderRadii && borderWillArcInnerEdge(border.radii().bottomLeft(), border.radii().topLeft(), style->borderBottomWidth(), style->borderTopWidth(), style->borderLeftWidth())) { graphicsContext->save(); - clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSLeft, upperLeftBorderStylesMatch, lowerLeftBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); + clipBorderSidePolygon(graphicsContext, border, BSLeft, upperLeftBorderStylesMatch, lowerLeftBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); float thickness = max(max(style->borderLeftWidth(), style->borderTopWidth()), style->borderBottomWidth()); - drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderLeftWidth(), thickness, BSLeft, style, leftColor, leftStyle); + drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderLeftWidth(), thickness, BSLeft, style, leftColor, leftStyle); graphicsContext->restore(); } else { bool ignoreTop = (topColor == leftColor && topTransparent == leftTransparent && leftStyle >= OUTSET @@ -1152,11 +1106,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, } if (renderRight) { - if (renderRadii && borderWillArcInnerEdge(bottomRight, topRight, style->borderBottomWidth(), style->borderTopWidth(), style->borderRightWidth())) { + if (renderRadii && borderWillArcInnerEdge(border.radii().bottomRight(), border.radii().topRight(), style->borderBottomWidth(), style->borderTopWidth(), style->borderRightWidth())) { graphicsContext->save(); - clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSRight, upperRightBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); + clipBorderSidePolygon(graphicsContext, border, BSRight, upperRightBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge); float thickness = max(max(style->borderRightWidth(), style->borderTopWidth()), style->borderBottomWidth()); - drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderRightWidth(), thickness, BSRight, style, rightColor, rightStyle); + drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderRightWidth(), thickness, BSRight, style, rightColor, rightStyle); graphicsContext->restore(); } else { bool ignoreTop = ((topColor == rightColor) && (topTransparent == rightTransparent) @@ -1209,65 +1163,43 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, bool renderRight = rightStyle > BHIDDEN && !rightTransparent && (!horizontal || includeLogicalRightEdge); bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent && (horizontal || includeLogicalRightEdge); - bool renderRadii = false; - IntSize topLeft, topRight, bottomLeft, bottomRight; + RoundedIntRect border(tx, ty, w, h); if (style->hasBorderRadius()) { - IntRect borderRect = IntRect(tx, ty, w, h); - - IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius; - style->getBorderRadiiForRect(borderRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); - - if (includeLogicalLeftEdge) { - topLeft = topLeftRadius; - if (horizontal) - bottomLeft = bottomLeftRadius; - else - topRight = topRightRadius; - } - - if (includeLogicalRightEdge) { - if (horizontal) - topRight = topRightRadius; - else - bottomLeft = bottomLeftRadius; - bottomRight = bottomRightRadius; - } - - renderRadii = !topLeft.isZero() || !topRight.isZero() || !bottomLeft.isZero() || !bottomRight.isZero(); - - if (renderRadii) { - // Clip to the rounded rectangle. + border.includeLogicalEdges(style->getRoundedBorderFor(border.rect()).radii(), + horizontal, includeLogicalLeftEdge, includeLogicalRightEdge); + if (border.isRounded()) { graphicsContext->save(); - graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); + graphicsContext->addRoundedRectClip(border); } } int firstAngleStart, secondAngleStart, firstAngleSpan, secondAngleSpan; float thickness; + bool renderRadii = border.isRounded(); bool upperLeftBorderStylesMatch = renderLeft && (topStyle == leftStyle) && (topColor == leftColor); bool upperRightBorderStylesMatch = renderRight && (topStyle == rightStyle) && (topColor == rightColor) && (topStyle != OUTSET) && (topStyle != RIDGE) && (topStyle != INSET) && (topStyle != GROOVE); bool lowerLeftBorderStylesMatch = renderLeft && (bottomStyle == leftStyle) && (bottomColor == leftColor) && (bottomStyle != OUTSET) && (bottomStyle != RIDGE) && (bottomStyle != INSET) && (bottomStyle != GROOVE); bool lowerRightBorderStylesMatch = renderRight && (bottomStyle == rightStyle) && (bottomColor == rightColor); if (renderTop) { - bool ignore_left = (renderRadii && topLeft.width() > 0) || - (topColor == leftColor && topTransparent == leftTransparent && topStyle >= OUTSET && - (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET)); - - bool ignore_right = (renderRadii && topRight.width() > 0) || - (topColor == rightColor && topTransparent == rightTransparent && topStyle >= OUTSET && - (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET)); + bool ignoreLeft = (renderRadii && border.radii().topLeft().width() > 0) + || (topColor == leftColor && topTransparent == leftTransparent && topStyle >= OUTSET + && (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET)); + + bool ignoreRight = (renderRadii && border.radii().topRight().width() > 0) + || (topColor == rightColor && topTransparent == rightTransparent && topStyle >= OUTSET + && (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET)); int x = tx; int x2 = tx + w; if (renderRadii) { - x += topLeft.width(); - x2 -= topRight.width(); + x += border.radii().topLeft().width(); + x2 -= border.radii().topRight().width(); } drawLineForBoxSide(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, topColor, topStyle, - ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth()); + ignoreLeft ? 0 : style->borderLeftWidth(), ignoreRight ? 0 : style->borderRightWidth()); if (renderRadii) { int leftY = ty; @@ -1277,15 +1209,15 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // with the arc-drawing function. thickness = style->borderTopWidth() * 2; - if (topLeft.width()) { + if (border.radii().topLeft().width()) { int leftX = tx; // The inner clip clips inside the arc. This is especially important for 1px borders. - bool applyLeftInnerClip = (style->borderLeftWidth() < topLeft.width()) - && (style->borderTopWidth() < topLeft.height()) + bool applyLeftInnerClip = (style->borderLeftWidth() < border.radii().topLeft().width()) + && (style->borderTopWidth() < border.radii().topLeft().height()) && (topStyle != DOUBLE || style->borderTopWidth() > 6); if (applyLeftInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, topLeft.width() * 2, topLeft.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, border.radii().topLeft().width() * 2, border.radii().topLeft().height() * 2), style->borderTopWidth()); } @@ -1293,20 +1225,20 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, firstAngleSpan = upperLeftBorderStylesMatch ? 90 : 45; // Draw upper left arc - drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, topLeft, firstAngleStart, firstAngleSpan, + drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, border.radii().topLeft(), firstAngleStart, firstAngleSpan, BSTop, topColor, topStyle, true); if (applyLeftInnerClip) graphicsContext->restore(); } - if (topRight.width()) { - int rightX = tx + w - topRight.width() * 2; - bool applyRightInnerClip = (style->borderRightWidth() < topRight.width()) - && (style->borderTopWidth() < topRight.height()) + if (border.radii().topRight().width()) { + int rightX = tx + w - border.radii().topRight().width() * 2; + bool applyRightInnerClip = (style->borderRightWidth() < border.radii().topRight().width()) + && (style->borderTopWidth() < border.radii().topRight().height()) && (topStyle != DOUBLE || style->borderTopWidth() > 6); if (applyRightInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(rightX, leftY, topRight.width() * 2, topRight.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(rightX, leftY, border.radii().topRight().width() * 2, border.radii().topRight().height() * 2), style->borderTopWidth()); } @@ -1319,7 +1251,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, } // Draw upper right arc - drawArcForBoxSide(graphicsContext, rightX, leftY, thickness, topRight, secondAngleStart, secondAngleSpan, + drawArcForBoxSide(graphicsContext, rightX, leftY, thickness, border.radii().topRight(), secondAngleStart, secondAngleSpan, BSTop, topColor, topStyle, false); if (applyRightInnerClip) graphicsContext->restore(); @@ -1328,36 +1260,36 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, } if (renderBottom) { - bool ignore_left = (renderRadii && bottomLeft.width() > 0) || - (bottomColor == leftColor && bottomTransparent == leftTransparent && bottomStyle >= OUTSET && - (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET)); + bool ignoreLeft = (renderRadii && border.radii().bottomLeft().width() > 0) + || (bottomColor == leftColor && bottomTransparent == leftTransparent && bottomStyle >= OUTSET + && (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET)); - bool ignore_right = (renderRadii && bottomRight.width() > 0) || - (bottomColor == rightColor && bottomTransparent == rightTransparent && bottomStyle >= OUTSET && - (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET)); + bool ignoreRight = (renderRadii && border.radii().bottomRight().width() > 0) + || (bottomColor == rightColor && bottomTransparent == rightTransparent && bottomStyle >= OUTSET + && (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET)); int x = tx; int x2 = tx + w; if (renderRadii) { - x += bottomLeft.width(); - x2 -= bottomRight.width(); + x += border.radii().bottomLeft().width(); + x2 -= border.radii().bottomRight().width(); } drawLineForBoxSide(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bottomColor, bottomStyle, - ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth()); + ignoreLeft ? 0 : style->borderLeftWidth(), ignoreRight ? 0 : style->borderRightWidth()); if (renderRadii) { thickness = style->borderBottomWidth() * 2; - if (bottomLeft.width()) { + if (border.radii().bottomLeft().width()) { int leftX = tx; - int leftY = ty + h - bottomLeft.height() * 2; - bool applyLeftInnerClip = (style->borderLeftWidth() < bottomLeft.width()) - && (style->borderBottomWidth() < bottomLeft.height()) + int leftY = ty + h - border.radii().bottomLeft().height() * 2; + bool applyLeftInnerClip = (style->borderLeftWidth() < border.radii().bottomLeft().width()) + && (style->borderBottomWidth() < border.radii().bottomLeft().height()) && (bottomStyle != DOUBLE || style->borderBottomWidth() > 6); if (applyLeftInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, bottomLeft.width() * 2, bottomLeft.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, border.radii().bottomLeft().width() * 2, border.radii().bottomLeft().height() * 2), style->borderBottomWidth()); } @@ -1370,21 +1302,21 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, } // Draw lower left arc - drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, bottomLeft, firstAngleStart, firstAngleSpan, + drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, border.radii().bottomLeft(), firstAngleStart, firstAngleSpan, BSBottom, bottomColor, bottomStyle, true); if (applyLeftInnerClip) graphicsContext->restore(); } - if (bottomRight.width()) { - int rightY = ty + h - bottomRight.height() * 2; - int rightX = tx + w - bottomRight.width() * 2; - bool applyRightInnerClip = (style->borderRightWidth() < bottomRight.width()) - && (style->borderBottomWidth() < bottomRight.height()) + if (border.radii().bottomRight().width()) { + int rightY = ty + h - border.radii().bottomRight().height() * 2; + int rightX = tx + w - border.radii().bottomRight().width() * 2; + bool applyRightInnerClip = (style->borderRightWidth() < border.radii().bottomRight().width()) + && (style->borderBottomWidth() < border.radii().bottomRight().height()) && (bottomStyle != DOUBLE || style->borderBottomWidth() > 6); if (applyRightInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(rightX, rightY, bottomRight.width() * 2, bottomRight.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(rightX, rightY, border.radii().bottomRight().width() * 2, border.radii().bottomRight().height() * 2), style->borderBottomWidth()); } @@ -1392,7 +1324,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, secondAngleSpan = lowerRightBorderStylesMatch ? 90 : 45; // Draw lower right arc - drawArcForBoxSide(graphicsContext, rightX, rightY, thickness, bottomRight, secondAngleStart, secondAngleSpan, + drawArcForBoxSide(graphicsContext, rightX, rightY, thickness, border.radii().bottomRight(), secondAngleStart, secondAngleSpan, BSBottom, bottomColor, bottomStyle, false); if (applyRightInnerClip) graphicsContext->restore(); @@ -1401,36 +1333,36 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, } if (renderLeft) { - bool ignore_top = (renderRadii && topLeft.height() > 0) || - (topColor == leftColor && topTransparent == leftTransparent && leftStyle >= OUTSET && - (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET)); + bool ignoreTop = (renderRadii && border.radii().topLeft().height() > 0) + || (topColor == leftColor && topTransparent == leftTransparent && leftStyle >= OUTSET + && (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET)); - bool ignore_bottom = (renderRadii && bottomLeft.height() > 0) || - (bottomColor == leftColor && bottomTransparent == leftTransparent && leftStyle >= OUTSET && - (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET)); + bool ignoreBottom = (renderRadii && border.radii().bottomLeft().height() > 0) + || (bottomColor == leftColor && bottomTransparent == leftTransparent && leftStyle >= OUTSET + && (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET)); int y = ty; int y2 = ty + h; if (renderRadii) { - y += topLeft.height(); - y2 -= bottomLeft.height(); + y += border.radii().topLeft().height(); + y2 -= border.radii().bottomLeft().height(); } drawLineForBoxSide(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, leftColor, leftStyle, - ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth()); + ignoreTop ? 0 : style->borderTopWidth(), ignoreBottom ? 0 : style->borderBottomWidth()); if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) { int topX = tx; thickness = style->borderLeftWidth() * 2; - if (!upperLeftBorderStylesMatch && topLeft.width()) { + if (!upperLeftBorderStylesMatch && border.radii().topLeft().width()) { int topY = ty; - bool applyTopInnerClip = (style->borderLeftWidth() < topLeft.width()) - && (style->borderTopWidth() < topLeft.height()) + bool applyTopInnerClip = (style->borderLeftWidth() < border.radii().topLeft().width()) + && (style->borderTopWidth() < border.radii().topLeft().height()) && (leftStyle != DOUBLE || style->borderLeftWidth() > 6); if (applyTopInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topLeft.width() * 2, topLeft.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, border.radii().topLeft().width() * 2, border.radii().topLeft().height() * 2), style->borderLeftWidth()); } @@ -1438,20 +1370,20 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, firstAngleSpan = 45; // Draw top left arc - drawArcForBoxSide(graphicsContext, topX, topY, thickness, topLeft, firstAngleStart, firstAngleSpan, + drawArcForBoxSide(graphicsContext, topX, topY, thickness, border.radii().topLeft(), firstAngleStart, firstAngleSpan, BSLeft, leftColor, leftStyle, true); if (applyTopInnerClip) graphicsContext->restore(); } - if (!lowerLeftBorderStylesMatch && bottomLeft.width()) { - int bottomY = ty + h - bottomLeft.height() * 2; - bool applyBottomInnerClip = (style->borderLeftWidth() < bottomLeft.width()) - && (style->borderBottomWidth() < bottomLeft.height()) + if (!lowerLeftBorderStylesMatch && border.radii().bottomLeft().width()) { + int bottomY = ty + h - border.radii().bottomLeft().height() * 2; + bool applyBottomInnerClip = (style->borderLeftWidth() < border.radii().bottomLeft().width()) + && (style->borderBottomWidth() < border.radii().bottomLeft().height()) && (leftStyle != DOUBLE || style->borderLeftWidth() > 6); if (applyBottomInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomLeft.width() * 2, bottomLeft.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, border.radii().bottomLeft().width() * 2, border.radii().bottomLeft().height() * 2), style->borderLeftWidth()); } @@ -1459,7 +1391,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, secondAngleSpan = 45; // Draw bottom left arc - drawArcForBoxSide(graphicsContext, topX, bottomY, thickness, bottomLeft, secondAngleStart, secondAngleSpan, + drawArcForBoxSide(graphicsContext, topX, bottomY, thickness, border.radii().bottomLeft(), secondAngleStart, secondAngleSpan, BSLeft, leftColor, leftStyle, false); if (applyBottomInnerClip) graphicsContext->restore(); @@ -1468,38 +1400,38 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, } if (renderRight) { - bool ignore_top = (renderRadii && topRight.height() > 0) || - ((topColor == rightColor) && (topTransparent == rightTransparent) && - (rightStyle >= DOTTED || rightStyle == INSET) && - (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET)); + bool ignoreTop = (renderRadii && border.radii().topRight().height() > 0) + || ((topColor == rightColor) && (topTransparent == rightTransparent) + && (rightStyle >= DOTTED || rightStyle == INSET) + && (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET)); - bool ignore_bottom = (renderRadii && bottomRight.height() > 0) || - ((bottomColor == rightColor) && (bottomTransparent == rightTransparent) && - (rightStyle >= DOTTED || rightStyle == INSET) && - (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET)); + bool ignoreBottom = (renderRadii && border.radii().bottomRight().height() > 0) + || ((bottomColor == rightColor) && (bottomTransparent == rightTransparent) + && (rightStyle >= DOTTED || rightStyle == INSET) + && (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET)); int y = ty; int y2 = ty + h; if (renderRadii) { - y += topRight.height(); - y2 -= bottomRight.height(); + y += border.radii().topRight().height(); + y2 -= border.radii().bottomRight().height(); } drawLineForBoxSide(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rightColor, rightStyle, - ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth()); + ignoreTop ? 0 : style->borderTopWidth(), ignoreBottom ? 0 : style->borderBottomWidth()); if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) { thickness = style->borderRightWidth() * 2; - if (!upperRightBorderStylesMatch && topRight.width()) { - int topX = tx + w - topRight.width() * 2; + if (!upperRightBorderStylesMatch && border.radii().topRight().width()) { + int topX = tx + w - border.radii().topRight().width() * 2; int topY = ty; - bool applyTopInnerClip = (style->borderRightWidth() < topRight.width()) - && (style->borderTopWidth() < topRight.height()) + bool applyTopInnerClip = (style->borderRightWidth() < border.radii().topRight().width()) + && (style->borderTopWidth() < border.radii().topRight().height()) && (rightStyle != DOUBLE || style->borderRightWidth() > 6); if (applyTopInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topRight.width() * 2, topRight.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, border.radii().topRight().width() * 2, border.radii().topRight().height() * 2), style->borderRightWidth()); } @@ -1507,21 +1439,21 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, firstAngleSpan = 45; // Draw top right arc - drawArcForBoxSide(graphicsContext, topX, topY, thickness, topRight, firstAngleStart, firstAngleSpan, + drawArcForBoxSide(graphicsContext, topX, topY, thickness, border.radii().topRight(), firstAngleStart, firstAngleSpan, BSRight, rightColor, rightStyle, true); if (applyTopInnerClip) graphicsContext->restore(); } - if (!lowerRightBorderStylesMatch && bottomRight.width()) { - int bottomX = tx + w - bottomRight.width() * 2; - int bottomY = ty + h - bottomRight.height() * 2; - bool applyBottomInnerClip = (style->borderRightWidth() < bottomRight.width()) - && (style->borderBottomWidth() < bottomRight.height()) + if (!lowerRightBorderStylesMatch && border.radii().bottomRight().width()) { + int bottomX = tx + w - border.radii().bottomRight().width() * 2; + int bottomY = ty + h - border.radii().bottomRight().height() * 2; + bool applyBottomInnerClip = (style->borderRightWidth() < border.radii().bottomRight().width()) + && (style->borderBottomWidth() < border.radii().bottomRight().height()) && (rightStyle != DOUBLE || style->borderRightWidth() > 6); if (applyBottomInnerClip) { graphicsContext->save(); - graphicsContext->addInnerRoundedRectClip(IntRect(bottomX, bottomY, bottomRight.width() * 2, bottomRight.height() * 2), + graphicsContext->addInnerRoundedRectClip(IntRect(bottomX, bottomY, border.radii().bottomRight().width() * 2, border.radii().bottomRight().height() * 2), style->borderRightWidth()); } @@ -1529,7 +1461,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, secondAngleSpan = 45; // Draw bottom right arc - drawArcForBoxSide(graphicsContext, bottomX, bottomY, thickness, bottomRight, secondAngleStart, secondAngleSpan, + drawArcForBoxSide(graphicsContext, bottomX, bottomY, thickness, border.radii().bottomRight(), secondAngleStart, secondAngleSpan, BSRight, rightColor, rightStyle, false); if (applyBottomInnerClip) graphicsContext->restore(); @@ -1542,15 +1474,15 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, } #endif -void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const IntRect& box, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, +void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const RoundedIntRect& border, const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) { FloatPoint quad[4]; - int tx = box.x(); - int ty = box.y(); - int w = box.width(); - int h = box.height(); + int tx = border.rect().x(); + int ty = border.rect().y(); + int w = border.rect().width(); + int h = border.rect().height(); bool horizontal = style->isHorizontalWritingMode(); int leftWidth = (!horizontal || includeLogicalLeftEdge) ? style->borderLeftWidth() : 0; @@ -1563,26 +1495,26 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContex switch (side) { case BSTop: quad[0] = FloatPoint(tx, ty); - quad[1] = FloatPoint(tx + max(topLeft.width(), leftWidth), ty + max(topLeft.height(), topWidth)); - quad[2] = FloatPoint(tx + w - max(topRight.width(), rightWidth), ty + max(topRight.height(), topWidth)); + quad[1] = FloatPoint(tx + max(border.radii().topLeft().width(), leftWidth), ty + max(border.radii().topLeft().height(), topWidth)); + quad[2] = FloatPoint(tx + w - max(border.radii().topRight().width(), rightWidth), ty + max(border.radii().topRight().height(), topWidth)); quad[3] = FloatPoint(tx + w, ty); break; case BSLeft: quad[0] = FloatPoint(tx, ty); - quad[1] = FloatPoint(tx + max(topLeft.width(), leftWidth), ty + max(topLeft.height(), topWidth)); - quad[2] = FloatPoint(tx + max(bottomLeft.width(), leftWidth), ty + h - max(bottomLeft.height(), bottomWidth)); + quad[1] = FloatPoint(tx + max(border.radii().topLeft().width(), leftWidth), ty + max(border.radii().topLeft().height(), topWidth)); + quad[2] = FloatPoint(tx + max(border.radii().bottomLeft().width(), leftWidth), ty + h - max(border.radii().bottomLeft().height(), bottomWidth)); quad[3] = FloatPoint(tx, ty + h); break; case BSBottom: quad[0] = FloatPoint(tx, ty + h); - quad[1] = FloatPoint(tx + max(bottomLeft.width(), leftWidth), ty + h - max(bottomLeft.height(), bottomWidth)); - quad[2] = FloatPoint(tx + w - max(bottomRight.width(), rightWidth), ty + h - max(bottomRight.height(), bottomWidth)); + quad[1] = FloatPoint(tx + max(border.radii().bottomLeft().width(), leftWidth), ty + h - max(border.radii().bottomLeft().height(), bottomWidth)); + quad[2] = FloatPoint(tx + w - max(border.radii().bottomRight().width(), rightWidth), ty + h - max(border.radii().bottomRight().height(), bottomWidth)); quad[3] = FloatPoint(tx + w, ty + h); break; case BSRight: quad[0] = FloatPoint(tx + w, ty); - quad[1] = FloatPoint(tx + w - max(topRight.width(), rightWidth), ty + max(topRight.height(), topWidth)); - quad[2] = FloatPoint(tx + w - max(bottomRight.width(), rightWidth), ty + h - max(bottomRight.height(), bottomWidth)); + quad[1] = FloatPoint(tx + w - max(border.radii().topRight().width(), rightWidth), ty + max(border.radii().topRight().height(), topWidth)); + quad[2] = FloatPoint(tx + w - max(border.radii().bottomRight().width(), rightWidth), ty + h - max(border.radii().bottomRight().height(), bottomWidth)); quad[3] = FloatPoint(tx + w, ty + h); break; default: @@ -1613,18 +1545,6 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContex graphicsContext->clipConvexPolygon(4, secondQuad, !secondEdgeMatches); } -static inline void uniformlyExpandBorderRadii(int delta, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) -{ - topLeft.expand(delta, delta); - topLeft.clampNegativeToZero(); - topRight.expand(delta, delta); - topRight.clampNegativeToZero(); - bottomLeft.expand(delta, delta); - bottomLeft.clampNegativeToZero(); - bottomRight.expand(delta, delta); - bottomRight.clampNegativeToZero(); -} - void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) { // FIXME: Deal with border-image. Would be great to use border-image as a mask. @@ -1632,61 +1552,19 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int if (context->paintingDisabled()) return; - IntRect rect(tx, ty, w, h); - IntSize topLeft; - IntSize topRight; - IntSize bottomLeft; - IntSize bottomRight; - + RoundedIntRect border(tx, ty, w, h); bool hasBorderRadius = s->hasBorderRadius(); bool isHorizontal = s->isHorizontalWritingMode(); if (hasBorderRadius && (includeLogicalLeftEdge || includeLogicalRightEdge)) { - IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius; - s->getBorderRadiiForRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); - - if (includeLogicalLeftEdge) { - if (shadowStyle == Inset) { - topLeftRadius.expand(-borderLeft(), -borderTop()); - topLeftRadius.clampNegativeToZero(); - if (isHorizontal) { - bottomLeftRadius.expand(-borderLeft(), -borderBottom()); - bottomLeftRadius.clampNegativeToZero(); - } else { - topRightRadius.expand(-borderRight(), -borderTop()); - topRightRadius.clampNegativeToZero(); - } - } - topLeft = topLeftRadius; - if (isHorizontal) - bottomLeft = bottomLeftRadius; - else - topRight = topRightRadius; - } - if (includeLogicalRightEdge) { - if (shadowStyle == Inset) { - if (isHorizontal) { - topRightRadius.expand(-borderRight(), -borderTop()); - topRightRadius.clampNegativeToZero(); - } else { - bottomLeftRadius.expand(-borderLeft(), -borderBottom()); - bottomLeftRadius.clampNegativeToZero(); - } - bottomRightRadius.expand(-borderRight(), -borderBottom()); - bottomRightRadius.clampNegativeToZero(); - } - if (isHorizontal) - topRight = topRightRadius; - else - bottomLeft = bottomLeftRadius; - bottomRight = bottomRightRadius; - } - } - - if (shadowStyle == Inset) { - rect.move(includeLogicalLeftEdge || !isHorizontal ? borderLeft() : 0, includeLogicalLeftEdge || isHorizontal ? borderTop() : 0); - rect.setWidth(rect.width() - ((includeLogicalLeftEdge || !isHorizontal) ? borderLeft() : 0) - ((includeLogicalRightEdge || !isHorizontal) ? borderRight() : 0)); - rect.setHeight(rect.height() - ((includeLogicalLeftEdge || isHorizontal) ? borderTop() : 0) - ((includeLogicalRightEdge || isHorizontal) ? borderBottom() : 0)); + RoundedIntRect::Radii radii = ((shadowStyle == Inset) ? s->getRoundedInnerBorderWithBorderWidths(border.rect(), borderTop(), borderBottom(), borderLeft(), borderRight()) : s->getRoundedBorderFor(border.rect())).radii(); + border.includeLogicalEdges(radii, isHorizontal, includeLogicalLeftEdge, includeLogicalRightEdge); } + + if (shadowStyle == Inset) + border.setRect(IntRect(border.rect().x() + (includeLogicalLeftEdge || !isHorizontal ? borderLeft() : 0), + border.rect().y() + (includeLogicalLeftEdge || isHorizontal ? borderTop() : 0), + border.rect().width() - ((includeLogicalLeftEdge || !isHorizontal) ? borderLeft() : 0) - ((includeLogicalRightEdge || !isHorizontal) ? borderRight() : 0), + border.rect().height() - ((includeLogicalLeftEdge || isHorizontal) ? borderTop() : 0) - ((includeLogicalRightEdge || isHorizontal) ? borderBottom() : 0))); bool hasOpaqueBackground = s->visitedDependentColor(CSSPropertyBackgroundColor).isValid() && s->visitedDependentColor(CSSPropertyBackgroundColor).alpha() == 255; for (const ShadowData* shadow = s->boxShadow(); shadow; shadow = shadow->next()) { @@ -1699,12 +1577,12 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int const Color& shadowColor = shadow->color(); if (shadow->style() == Normal) { - IntRect fillRect(rect); + RoundedIntRect fillRect = border; fillRect.inflate(shadowSpread); if (fillRect.isEmpty()) continue; - IntRect shadowRect(rect); + IntRect shadowRect(border.rect()); shadowRect.inflate(shadowBlur + shadowSpread); shadowRect.move(shadowOffset); @@ -1719,32 +1597,23 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace()); if (hasBorderRadius) { - IntRect rectToClipOut = rect; - IntSize topLeftToClipOut = topLeft; - IntSize topRightToClipOut = topRight; - IntSize bottomLeftToClipOut = bottomLeft; - IntSize bottomRightToClipOut = bottomRight; - - IntSize topLeftToFill = topLeft; - IntSize topRightToFill = topRight; - IntSize bottomLeftToFill = bottomLeft; - IntSize bottomRightToFill = bottomRight; - if (shadowSpread < 0) - uniformlyExpandBorderRadii(shadowSpread, topLeftToFill, topRightToFill, bottomLeftToFill, bottomRightToFill); + RoundedIntRect rectToClipOut = border; // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time // when painting the shadow. On the other hand, it introduces subpixel gaps along the // corners. Those are avoided by insetting the clipping path by one pixel. if (hasOpaqueBackground) { - rectToClipOut.inflate(-1); - uniformlyExpandBorderRadii(-1, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut); + rectToClipOut.inflateWithRadii(-1); } if (!rectToClipOut.isEmpty()) - context->clipOutRoundedRect(rectToClipOut, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut); - context->fillRoundedRect(fillRect, topLeftToFill, topRightToFill, bottomLeftToFill, bottomRightToFill, Color::black, s->colorSpace()); + context->clipOutRoundedRect(rectToClipOut); + + if (shadowSpread < 0) + fillRect.expandRadii(shadowSpread); + context->fillRoundedRect(fillRect, Color::black, s->colorSpace()); } else { - IntRect rectToClipOut = rect; + IntRect rectToClipOut = border.rect(); // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time // when painting the shadow. On the other hand, it introduces subpixel gaps along the @@ -1759,20 +1628,20 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int if (!rectToClipOut.isEmpty()) context->clipOut(rectToClipOut); - context->fillRect(fillRect, Color::black, s->colorSpace()); + context->fillRect(fillRect.rect(), Color::black, s->colorSpace()); } context->restore(); } else { // Inset shadow. - IntRect holeRect(rect); + IntRect holeRect(border.rect()); holeRect.inflate(-shadowSpread); if (holeRect.isEmpty()) { if (hasBorderRadius) - context->fillRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight, shadowColor, s->colorSpace()); + context->fillRoundedRect(border, shadowColor, s->colorSpace()); else - context->fillRect(rect, shadowColor, s->colorSpace()); + context->fillRect(border.rect(), shadowColor, s->colorSpace()); continue; } @@ -1794,7 +1663,7 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), 255); - IntRect outerRect(rect); + IntRect outerRect(border.rect()); outerRect.inflateX(w - 2 * shadowSpread); outerRect.inflateY(h - 2 * shadowSpread); @@ -1802,11 +1671,11 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int Path path; if (hasBorderRadius) { - path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); + path.addRoundedRect(border.rect(), border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight()); context->clip(path); path.clear(); } else - context->clip(rect); + context->clip(border.rect()); IntSize extraOffset(2 * w + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0); context->translate(extraOffset.width(), extraOffset.height()); @@ -1816,8 +1685,8 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int if (hasBorderRadius) { if (shadowSpread > 0) - uniformlyExpandBorderRadii(-shadowSpread, topLeft, topRight, bottomLeft, bottomRight); - path.addRoundedRect(holeRect, topLeft, topRight, bottomLeft, bottomRight); + border.shrinkRadii(shadowSpread); + path.addRoundedRect(holeRect, border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight()); } else path.addRect(holeRect); diff --git a/Source/WebCore/rendering/RenderBoxModelObject.h b/Source/WebCore/rendering/RenderBoxModelObject.h index 8f9f465..f6bcb94 100644 --- a/Source/WebCore/rendering/RenderBoxModelObject.h +++ b/Source/WebCore/rendering/RenderBoxModelObject.h @@ -134,8 +134,8 @@ private: IntSize calculateFillTileSize(const FillLayer*, IntSize scaledSize) const; - void clipBorderSidePolygon(GraphicsContext*, const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, - const IntSize& bottomRight, const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style, + void clipBorderSidePolygon(GraphicsContext*, const RoundedIntRect& border, + const BoxSide, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle*, bool includeLogicalLeftEdge, bool includeLogicalRightEdge); friend class RenderView; diff --git a/Source/WebCore/rendering/RenderDataGrid.h b/Source/WebCore/rendering/RenderDataGrid.h index 1492d26..852010c 100644 --- a/Source/WebCore/rendering/RenderDataGrid.h +++ b/Source/WebCore/rendering/RenderDataGrid.h @@ -30,14 +30,14 @@ #include "HTMLDataGridElement.h" #include "RenderBlock.h" -#include "ScrollbarClient.h" +#include "ScrollableArea.h" #include "StyleImage.h" #include <wtf/RefPtr.h> #include <wtf/Vector.h> namespace WebCore { -class RenderDataGrid : public RenderBlock, private ScrollbarClient { +class RenderDataGrid : public RenderBlock, private ScrollableArea { public: RenderDataGrid(Element*); ~RenderDataGrid(); @@ -66,7 +66,7 @@ private: HTMLDataGridElement* gridElement() const { return static_cast<HTMLDataGridElement*>(node()); } - // ScrollbarClient interface. + // ScrollableArea interface. virtual int scrollSize(ScrollbarOrientation orientation) const; virtual void setScrollOffsetFromAnimation(const IntPoint&); virtual void valueChanged(Scrollbar*); diff --git a/Source/WebCore/rendering/RenderEmbeddedObject.cpp b/Source/WebCore/rendering/RenderEmbeddedObject.cpp index ac72fe1..5486d51 100644 --- a/Source/WebCore/rendering/RenderEmbeddedObject.cpp +++ b/Source/WebCore/rendering/RenderEmbeddedObject.cpp @@ -49,6 +49,7 @@ #include "RenderWidgetProtector.h" #include "Settings.h" #include "Text.h" +#include "TextRun.h" #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) #include "HTMLVideoElement.h" diff --git a/Source/WebCore/rendering/RenderFileUploadControl.cpp b/Source/WebCore/rendering/RenderFileUploadControl.cpp index 3e4d216..aec55a8 100644 --- a/Source/WebCore/rendering/RenderFileUploadControl.cpp +++ b/Source/WebCore/rendering/RenderFileUploadControl.cpp @@ -37,6 +37,7 @@ #include "RenderText.h" #include "RenderTheme.h" #include "RenderView.h" +#include "TextRun.h" #include <math.h> using namespace std; diff --git a/Source/WebCore/rendering/RenderFlexibleBox.cpp b/Source/WebCore/rendering/RenderFlexibleBox.cpp index 5d96adb..5af5733 100644 --- a/Source/WebCore/rendering/RenderFlexibleBox.cpp +++ b/Source/WebCore/rendering/RenderFlexibleBox.cpp @@ -28,6 +28,7 @@ #include "CharacterNames.h" #include "RenderLayer.h" #include "RenderView.h" +#include "TextRun.h" #include <wtf/StdLibExtras.h> #ifdef ANDROID_LAYOUT diff --git a/Source/WebCore/rendering/RenderFrameSet.h b/Source/WebCore/rendering/RenderFrameSet.h index cdc7b5a..4d14410 100644 --- a/Source/WebCore/rendering/RenderFrameSet.h +++ b/Source/WebCore/rendering/RenderFrameSet.h @@ -77,7 +77,8 @@ public: private: static const int noSplit = -1; - class GridAxis : public Noncopyable { + class GridAxis { + WTF_MAKE_NONCOPYABLE(GridAxis); public: GridAxis(); void resize(int); diff --git a/Source/WebCore/rendering/RenderImage.cpp b/Source/WebCore/rendering/RenderImage.cpp index 7f4c41e..839328e 100644 --- a/Source/WebCore/rendering/RenderImage.cpp +++ b/Source/WebCore/rendering/RenderImage.cpp @@ -41,6 +41,7 @@ #include "RenderTheme.h" #include "RenderView.h" #include "SelectionController.h" +#include "TextRun.h" #include <wtf/CurrentTime.h> #include <wtf/UnusedParam.h> diff --git a/Source/WebCore/rendering/RenderImageResource.h b/Source/WebCore/rendering/RenderImageResource.h index 2346712..a20c55a 100644 --- a/Source/WebCore/rendering/RenderImageResource.h +++ b/Source/WebCore/rendering/RenderImageResource.h @@ -29,13 +29,13 @@ #include "CachedImage.h" #include "CachedResourceHandle.h" #include "StyleImage.h" -#include <wtf/Noncopyable.h> namespace WebCore { class RenderObject; -class RenderImageResource : public Noncopyable { +class RenderImageResource { + WTF_MAKE_NONCOPYABLE(RenderImageResource); WTF_MAKE_FAST_ALLOCATED; public: virtual ~RenderImageResource(); diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index 3613d95..29a6fc9 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -1322,23 +1322,36 @@ void RenderLayer::scrollByRecursively(int xDelta, int yDelta) } } -void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repaint) +void RenderLayer::scrollToOffset(int x, int y) +{ + ScrollableArea::scrollToOffsetWithoutAnimation(IntPoint(x, y)); +} + +void RenderLayer::scrollTo(int x, int y) { RenderBox* box = renderBox(); if (!box) return; if (box->style()->overflowX() != OMARQUEE) { - if (x < 0) x = 0; - if (y < 0) y = 0; + if (x < 0) + x = 0; + if (y < 0) + y = 0; // Call the scrollWidth/Height functions so that the dimensions will be computed if they need // to be (for overflow:hidden blocks). int maxX = scrollWidth() - box->clientWidth(); + if (maxX < 0) + maxX = 0; int maxY = scrollHeight() - box->clientHeight(); - - if (x > maxX) x = maxX; - if (y > maxY) y = maxY; + if (maxY < 0) + maxY = 0; + + if (x > maxX) + x = maxX; + if (y > maxY) + y = maxY; } // FIXME: Eventually, we will want to perform a blit. For now never @@ -1402,16 +1415,9 @@ void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repai } // Just schedule a full repaint of our object. - if (view && repaint) + if (view) renderer()->repaintUsingContainer(repaintContainer, rectForRepaint); - if (updateScrollbars) { - if (m_hBar) - m_hBar->setValue(scrollXOffset(), Scrollbar::NotFromScrollAnimator); - if (m_vBar) - m_vBar->setValue(m_scrollY, Scrollbar::NotFromScrollAnimator); - } - // Schedule the scroll DOM event. renderer()->node()->document()->eventQueue()->enqueueScrollEvent(renderer()->node(), EventQueue::ScrollEventElementTarget); } @@ -1665,36 +1671,18 @@ int RenderLayer::scrollSize(ScrollbarOrientation orientation) const return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; } -void RenderLayer::setScrollOffsetFromAnimation(const IntPoint& offset) +void RenderLayer::setScrollOffset(const IntPoint& offset) { - if (m_hBar) - m_hBar->setValue(offset.x(), Scrollbar::FromScrollAnimator); - if (m_vBar) - m_vBar->setValue(offset.y(), Scrollbar::FromScrollAnimator); + scrollTo(offset.x(), offset.y()); } -void RenderLayer::valueChanged(Scrollbar*) +int RenderLayer::scrollPosition(Scrollbar* scrollbar) const { - // Update scroll position from scrollbars. - - bool needUpdate = false; - int newX = scrollXOffset(); - int newY = m_scrollY; - - if (m_hBar) { - newX = m_hBar->value(); - if (newX != scrollXOffset()) - needUpdate = true; - } - - if (m_vBar) { - newY = m_vBar->value(); - if (newY != m_scrollY) - needUpdate = true; - } - - if (needUpdate) - scrollToOffset(newX, newY, false); + if (scrollbar->orientation() == HorizontalScrollbar) + return scrollXOffset(); + if (scrollbar->orientation() == VerticalScrollbar) + return m_scrollY; + return 0; } bool RenderLayer::isActive() const @@ -1703,7 +1691,6 @@ bool RenderLayer::isActive() const return page && page->focusController()->isActive(); } - static IntRect cornerRect(const RenderLayer* layer, const IntRect& bounds) { int horizontalThickness; @@ -1849,7 +1836,7 @@ void RenderLayer::destroyScrollbar(ScrollbarOrientation orientation) static_cast<RenderScrollbar*>(scrollbar.get())->clearOwningRenderer(); scrollbar->removeFromParent(); - scrollbar->setClient(0); + scrollbar->disconnectFromScrollableArea(); scrollbar = 0; } } @@ -1902,14 +1889,14 @@ void RenderLayer::setHasVerticalScrollbar(bool hasScrollbar) int RenderLayer::verticalScrollbarWidth() const { - if (!m_vBar) + if (!m_vBar || ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()) return 0; return m_vBar->width(); } int RenderLayer::horizontalScrollbarHeight() const { - if (!m_hBar) + if (!m_hBar || ScrollbarTheme::nativeTheme()->usesOverlayScrollbars()) return 0; return m_hBar->height(); } @@ -2076,8 +2063,7 @@ void RenderLayer::updateOverflowStatus(bool horizontalOverflow, bool verticalOve } } -void -RenderLayer::updateScrollInfoAfterLayout() +void RenderLayer::updateScrollInfoAfterLayout() { RenderBox* box = renderBox(); if (!box) @@ -2169,28 +2155,16 @@ RenderLayer::updateScrollInfoAfterLayout() int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1); m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_hBar->setProportion(clientWidth, m_scrollWidth); - // Explicitly set the horizontal scroll value. This ensures that when a - // right-to-left scrollable area's width (or content width) changes, the - // top right corner of the content doesn't shift with respect to the top - // right corner of the area. Conceptually, right-to-left areas have - // their origin at the top-right, but RenderLayer is top-left oriented, - // so this is needed to keep everything working. - m_hBar->setValue(scrollXOffset(), Scrollbar::NotFromScrollAnimator); } if (m_vBar) { int clientHeight = box->clientHeight(); int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_vBar->setProportion(clientHeight, m_scrollHeight); - // Explicitly set the vertical scroll value. This ensures that when a - // right-to-left vertical writing-mode scrollable area's height (or content height) changes, the - // bottom right corner of the content doesn't shift with respect to the bottom - // right corner of the area. Conceptually, right-to-left vertical writing-mode areas have - // their origin at the bottom-right, but RenderLayer is top-left oriented, - // so this is needed to keep everything working. - m_vBar->setValue(scrollYOffset(), Scrollbar::NotFromScrollAnimator); } + scrollToOffset(scrollXOffset(), scrollYOffset()); + if (renderer()->node() && renderer()->document()->hasListenerType(Document::OVERFLOWCHANGED_LISTENER)) updateOverflowStatus(horizontalOverflow, verticalOverflow); @@ -2359,15 +2333,7 @@ bool RenderLayer::hitTestOverflowControls(HitTestResult& result, const IntPoint& bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) { - bool didHorizontalScroll = false; - bool didVerticalScroll = false; - - if (m_hBar) - didHorizontalScroll = m_hBar->scroll(direction, granularity, multiplier); - if (m_vBar) - didVerticalScroll = m_vBar->scroll(direction, granularity, multiplier); - - return (didHorizontalScroll || didVerticalScroll); + return ScrollableArea::scroll(direction, granularity, multiplier); } void RenderLayer::paint(GraphicsContext* p, const IntRect& damageRect, PaintBehavior paintBehavior, RenderObject *paintingRoot) diff --git a/Source/WebCore/rendering/RenderLayer.h b/Source/WebCore/rendering/RenderLayer.h index 8245c2f..57cb4de 100644 --- a/Source/WebCore/rendering/RenderLayer.h +++ b/Source/WebCore/rendering/RenderLayer.h @@ -47,7 +47,7 @@ #include "PaintInfo.h" #include "RenderBox.h" #include "ScrollBehavior.h" -#include "ScrollbarClient.h" +#include "ScrollableArea.h" #include <wtf/OwnPtr.h> namespace WebCore { @@ -176,7 +176,7 @@ private: bool m_fixed : 1; }; -class RenderLayer : public ScrollbarClient { +class RenderLayer : public ScrollableArea { public: friend class RenderReplica; @@ -266,7 +266,7 @@ public: int scrollXOffset() const { return m_scrollX + m_scrollOrigin.x(); } int scrollYOffset() const { return m_scrollY + m_scrollOrigin.y(); } - void scrollToOffset(int x, int y, bool updateScrollbars = true, bool repaint = true); + void scrollToOffset(int x, int y); void scrollToXOffset(int x) { scrollToOffset(x, m_scrollY + m_scrollOrigin.y()); } void scrollToYOffset(int y) { scrollToOffset(m_scrollX + m_scrollOrigin.x(), y); } void scrollRectToVisible(const IntRect&, bool scrollToAnchor = false, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded); @@ -560,10 +560,10 @@ private: bool shouldBeNormalFlowOnly() const; - // ScrollBarClient interface + // ScrollableArea interface virtual int scrollSize(ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const IntPoint&); - virtual void valueChanged(Scrollbar*); + virtual void setScrollOffset(const IntPoint&); + virtual int scrollPosition(Scrollbar*) const; virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); virtual bool isActive() const; virtual bool scrollbarCornerPresent() const; @@ -571,7 +571,10 @@ private: virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const; virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const; virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const; - + + // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. + void scrollTo(int x, int y); + IntSize scrollbarOffset(const Scrollbar*) const; void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); diff --git a/Source/WebCore/rendering/RenderLayerBacking.h b/Source/WebCore/rendering/RenderLayerBacking.h index 5c6ed12..726b777 100644 --- a/Source/WebCore/rendering/RenderLayerBacking.h +++ b/Source/WebCore/rendering/RenderLayerBacking.h @@ -53,7 +53,8 @@ enum CompositingLayerType { // // There is one RenderLayerBacking for each RenderLayer that is composited. -class RenderLayerBacking : public GraphicsLayerClient, public Noncopyable { +class RenderLayerBacking : public GraphicsLayerClient { + WTF_MAKE_NONCOPYABLE(RenderLayerBacking); WTF_MAKE_FAST_ALLOCATED; public: RenderLayerBacking(RenderLayer*); ~RenderLayerBacking(); diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp index 15bb8ec..9a5dda7 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.cpp +++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp @@ -108,6 +108,7 @@ RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) , m_compositingDependsOnGeometry(false) , m_compositing(false) , m_compositingLayersNeedRebuild(false) + , m_flushingLayers(false) , m_rootLayerAttachment(RootLayerUnattached) #if PROFILE_LAYER_REBUILD , m_rootLayerUpdateCount(0) @@ -188,12 +189,32 @@ void RenderLayerCompositor::scheduleLayerFlush() void RenderLayerCompositor::flushPendingLayerChanges() { + ASSERT(!m_flushingLayers); + m_flushingLayers = true; + // FIXME: FrameView::syncCompositingStateRecursive() calls this for each // frame, so when compositing layers are connected between frames, we'll // end up syncing subframe's layers multiple times. // https://bugs.webkit.org/show_bug.cgi?id=52489 if (GraphicsLayer* rootLayer = rootPlatformLayer()) rootLayer->syncCompositingState(); + + ASSERT(m_flushingLayers); + m_flushingLayers = false; +} + +RenderLayerCompositor* RenderLayerCompositor::enclosingCompositorFlushingLayers() const +{ + if (!m_renderView->frameView()) + return 0; + + for (Frame* frame = m_renderView->frameView()->frame(); frame; frame = frame->tree()->parent()) { + RenderLayerCompositor* compositor = frame->contentRenderer() ? frame->contentRenderer()->compositor() : 0; + if (compositor->isFlushingLayers()) + return compositor; + } + + return 0; } void RenderLayerCompositor::scheduleCompositingLayerUpdate() diff --git a/Source/WebCore/rendering/RenderLayerCompositor.h b/Source/WebCore/rendering/RenderLayerCompositor.h index 24e182c..1cf9ea9 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.h +++ b/Source/WebCore/rendering/RenderLayerCompositor.h @@ -88,6 +88,11 @@ public: // at specific times. void scheduleLayerFlush(); void flushPendingLayerChanges(); + bool isFlushingLayers() const { return m_flushingLayers; } + + // flushPendingLayerChanges() flushes the entire GraphicsLayer tree, which can cross frame boundaries. + // This call returns the rootmost compositor that is being flushed (including self). + RenderLayerCompositor* enclosingCompositorFlushingLayers() const; // Rebuild the tree of compositing layers void updateCompositingLayers(CompositingUpdateType = CompositingUpdateAfterLayoutOrStyleChange, RenderLayer* updateRoot = 0); @@ -271,6 +276,7 @@ private: bool m_compositing; bool m_compositingLayersNeedRebuild; + bool m_flushingLayers; RootLayerAttachment m_rootLayerAttachment; diff --git a/Source/WebCore/rendering/RenderListBox.cpp b/Source/WebCore/rendering/RenderListBox.cpp index e6ce340..90f13da 100644 --- a/Source/WebCore/rendering/RenderListBox.cpp +++ b/Source/WebCore/rendering/RenderListBox.cpp @@ -43,6 +43,7 @@ #include "GraphicsContext.h" #include "HTMLNames.h" #include "HitTestResult.h" +#include "NodeRenderStyle.h" #include "OptionGroupElement.h" #include "OptionElement.h" #include "Page.h" @@ -51,9 +52,10 @@ #include "RenderTheme.h" #include "RenderView.h" #include "Scrollbar.h" +#include "ScrollbarTheme.h" #include "SelectElement.h" #include "SelectionController.h" -#include "NodeRenderStyle.h" +#include "TextRun.h" #include <math.h> using namespace std; @@ -493,9 +495,7 @@ bool RenderListBox::scrollToRevealElementAtListIndex(int index) else newOffset = index - numVisibleItems() + 1; - m_indexOffset = newOffset; - if (m_vBar) - m_vBar->setValue(m_indexOffset, Scrollbar::NotFromScrollAnimator); + ScrollableArea::scrollToYOffsetWithoutAnimation(newOffset); return true; } @@ -507,12 +507,12 @@ bool RenderListBox::listIndexIsVisible(int index) bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node**) { - return m_vBar && m_vBar->scroll(direction, granularity, multiplier); + return ScrollableArea::scroll(direction, granularity, multiplier); } bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node**) { - return m_vBar && m_vBar->scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier); + return ScrollableArea::scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier); } void RenderListBox::valueChanged(unsigned listIndex) @@ -528,20 +528,24 @@ int RenderListBox::scrollSize(ScrollbarOrientation orientation) const return ((orientation == VerticalScrollbar) && m_vBar) ? (m_vBar->totalSize() - m_vBar->visibleSize()) : 0; } -void RenderListBox::setScrollOffsetFromAnimation(const IntPoint& offset) +int RenderListBox::scrollPosition(Scrollbar*) const { - if (m_vBar) - m_vBar->setValue(offset.y(), Scrollbar::FromScrollAnimator); + return m_indexOffset; } -void RenderListBox::valueChanged(Scrollbar*) +void RenderListBox::setScrollOffset(const IntPoint& offset) { - int newOffset = m_vBar->value(); - if (newOffset != m_indexOffset) { - m_indexOffset = newOffset; - repaint(); - node()->document()->eventQueue()->enqueueScrollEvent(node(), EventQueue::ScrollEventElementTarget); - } + scrollTo(offset.y()); +} + +void RenderListBox::scrollTo(int newOffset) +{ + if (newOffset == m_indexOffset) + return; + + m_indexOffset = newOffset; + repaint(); + node()->document()->eventQueue()->enqueueScrollEvent(node(), EventQueue::ScrollEventElementTarget); } int RenderListBox::itemHeight() const @@ -551,7 +555,7 @@ int RenderListBox::itemHeight() const int RenderListBox::verticalScrollbarWidth() const { - return m_vBar ? m_vBar->width() : 0; + return m_vBar && !ScrollbarTheme::nativeTheme()->usesOverlayScrollbars() ? m_vBar->width() : 0; } // FIXME: We ignore padding in the vertical direction as far as these values are concerned, since that's @@ -587,9 +591,8 @@ void RenderListBox::setScrollTop(int newTop) int index = newTop / itemHeight(); if (index < 0 || index >= numItems() || index == m_indexOffset) return; - m_indexOffset = index; - if (m_vBar) - m_vBar->setValue(index, Scrollbar::NotFromScrollAnimator); + + ScrollableArea::scrollToYOffsetWithoutAnimation(index); } bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction) @@ -711,7 +714,7 @@ void RenderListBox::destroyScrollbar() return; m_vBar->removeFromParent(); - m_vBar->setClient(0); + m_vBar->disconnectFromScrollableArea(); m_vBar = 0; } diff --git a/Source/WebCore/rendering/RenderListBox.h b/Source/WebCore/rendering/RenderListBox.h index 243fcbe..1ba2b94 100644 --- a/Source/WebCore/rendering/RenderListBox.h +++ b/Source/WebCore/rendering/RenderListBox.h @@ -32,11 +32,11 @@ #define RenderListBox_h #include "RenderBlock.h" -#include "ScrollbarClient.h" +#include "ScrollableArea.h" namespace WebCore { -class RenderListBox : public RenderBlock, private ScrollbarClient { +class RenderListBox : public RenderBlock, private ScrollableArea { public: RenderListBox(Element*); virtual ~RenderListBox(); @@ -94,10 +94,10 @@ private: virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); - // ScrollbarClient interface. + // ScrollableArea interface. virtual int scrollSize(ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const IntPoint&); - virtual void valueChanged(Scrollbar*); + virtual int scrollPosition(Scrollbar*) const; + virtual void setScrollOffset(const IntPoint&); virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); virtual bool isActive() const; virtual bool scrollbarCornerPresent() const { return false; } // We don't support resize on list boxes yet. If we did this would have to change. @@ -105,6 +105,10 @@ private: virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const; virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const; virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const; + virtual Scrollbar* verticalScrollbar() const { return m_vBar.get(); } + + // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. + void scrollTo(int newOffset); void setHasVerticalScrollbar(bool hasScrollbar); PassRefPtr<Scrollbar> createScrollbar(); diff --git a/Source/WebCore/rendering/RenderListMarker.cpp b/Source/WebCore/rendering/RenderListMarker.cpp index 71b1eae..cd41c75 100644 --- a/Source/WebCore/rendering/RenderListMarker.cpp +++ b/Source/WebCore/rendering/RenderListMarker.cpp @@ -32,6 +32,7 @@ #include "RenderLayer.h" #include "RenderListItem.h" #include "RenderView.h" +#include "TextRun.h" using namespace std; using namespace WTF; diff --git a/Source/WebCore/rendering/RenderMarquee.cpp b/Source/WebCore/rendering/RenderMarquee.cpp index 1c08831..9b58118 100644 --- a/Source/WebCore/rendering/RenderMarquee.cpp +++ b/Source/WebCore/rendering/RenderMarquee.cpp @@ -171,9 +171,9 @@ void RenderMarquee::start() if (!m_suspended && !m_stopped) { if (isHorizontal()) - m_layer->scrollToOffset(m_start, 0, false, false); + m_layer->scrollToOffset(m_start, 0); else - m_layer->scrollToOffset(0, m_start, false, false); + m_layer->scrollToOffset(0, m_start); } else { m_suspended = false; diff --git a/Source/WebCore/rendering/RenderMarquee.h b/Source/WebCore/rendering/RenderMarquee.h index 79998ed..98fddb9 100644 --- a/Source/WebCore/rendering/RenderMarquee.h +++ b/Source/WebCore/rendering/RenderMarquee.h @@ -53,7 +53,8 @@ namespace WebCore { class RenderLayer; // This class handles the auto-scrolling of layers with overflow: marquee. -class RenderMarquee : public Noncopyable { +class RenderMarquee { + WTF_MAKE_NONCOPYABLE(RenderMarquee); WTF_MAKE_FAST_ALLOCATED; public: explicit RenderMarquee(RenderLayer*); virtual ~RenderMarquee(); diff --git a/Source/WebCore/rendering/RenderMenuList.cpp b/Source/WebCore/rendering/RenderMenuList.cpp index 61f1084..e55b5ca 100644 --- a/Source/WebCore/rendering/RenderMenuList.cpp +++ b/Source/WebCore/rendering/RenderMenuList.cpp @@ -39,6 +39,7 @@ #include "RenderScrollbar.h" #include "RenderTheme.h" #include "SelectElement.h" +#include "TextRun.h" #include <math.h> using namespace std; @@ -455,14 +456,14 @@ HostWindow* RenderMenuList::hostWindow() const return document()->view()->hostWindow(); } -PassRefPtr<Scrollbar> RenderMenuList::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) +PassRefPtr<Scrollbar> RenderMenuList::createScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) { RefPtr<Scrollbar> widget; bool hasCustomScrollbarStyle = style()->hasPseudoStyle(SCROLLBAR); if (hasCustomScrollbarStyle) - widget = RenderScrollbar::createCustomScrollbar(client, orientation, this); + widget = RenderScrollbar::createCustomScrollbar(scrollableArea, orientation, this); else - widget = Scrollbar::createNativeScrollbar(client, orientation, controlSize); + widget = Scrollbar::createNativeScrollbar(scrollableArea, orientation, controlSize); return widget.release(); } diff --git a/Source/WebCore/rendering/RenderMenuList.h b/Source/WebCore/rendering/RenderMenuList.h index 2c99b1e..b84b799 100644 --- a/Source/WebCore/rendering/RenderMenuList.h +++ b/Source/WebCore/rendering/RenderMenuList.h @@ -107,7 +107,7 @@ private: virtual void selectionCleared() {} virtual FontSelector* fontSelector() const; virtual HostWindow* hostWindow() const; - virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize); + virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize); #if ENABLE(NO_LISTBOX_RENDERING) virtual void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true); diff --git a/Source/WebCore/rendering/RenderObject.cpp b/Source/WebCore/rendering/RenderObject.cpp index 670f818..9a1233e 100644 --- a/Source/WebCore/rendering/RenderObject.cpp +++ b/Source/WebCore/rendering/RenderObject.cpp @@ -982,36 +982,24 @@ void RenderObject::drawBoxSideFromPath(GraphicsContext* graphicsContext, IntRect innerBorderLeftWidth += 1; // Get the inner border rects for both the outer border line and the inner border line - IntRect outerBorderInnerRect = borderInnerRect(borderRect, outerBorderTopWidth, outerBorderBottomWidth, - outerBorderLeftWidth, outerBorderRightWidth); - IntRect innerBorderInnerRect = borderInnerRect(borderRect, innerBorderTopWidth, innerBorderBottomWidth, - innerBorderLeftWidth, innerBorderRightWidth); - - // Get the inner radii for the outer border line - IntSize outerBorderTopLeftInnerRadius, outerBorderTopRightInnerRadius, outerBorderBottomLeftInnerRadius, - outerBorderBottomRightInnerRadius; - style->getInnerBorderRadiiForRectWithBorderWidths(outerBorderInnerRect, outerBorderTopWidth, outerBorderBottomWidth, - outerBorderLeftWidth, outerBorderRightWidth, outerBorderTopLeftInnerRadius, outerBorderTopRightInnerRadius, - outerBorderBottomLeftInnerRadius, outerBorderBottomRightInnerRadius); - - // Get the inner radii for the inner border line - IntSize innerBorderTopLeftInnerRadius, innerBorderTopRightInnerRadius, innerBorderBottomLeftInnerRadius, - innerBorderBottomRightInnerRadius; - style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderInnerRect, innerBorderTopWidth, innerBorderBottomWidth, - innerBorderLeftWidth, innerBorderRightWidth, innerBorderTopLeftInnerRadius, innerBorderTopRightInnerRadius, - innerBorderBottomLeftInnerRadius, innerBorderBottomRightInnerRadius); // Draw inner border line graphicsContext->save(); - graphicsContext->addRoundedRectClip(innerBorderInnerRect, innerBorderTopLeftInnerRadius, - innerBorderTopRightInnerRadius, innerBorderBottomLeftInnerRadius, innerBorderBottomRightInnerRadius); + IntRect innerBorderInnerRect = borderInnerRect(borderRect, innerBorderTopWidth, innerBorderBottomWidth, + innerBorderLeftWidth, innerBorderRightWidth); + RoundedIntRect innerClip = style->getRoundedInnerBorderWithBorderWidths(innerBorderInnerRect, innerBorderTopWidth, innerBorderBottomWidth, + innerBorderLeftWidth, innerBorderRightWidth); + graphicsContext->addRoundedRectClip(innerClip); drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, SOLID); graphicsContext->restore(); // Draw outer border line graphicsContext->save(); - graphicsContext->clipOutRoundedRect(outerBorderInnerRect, outerBorderTopLeftInnerRadius, - outerBorderTopRightInnerRadius, outerBorderBottomLeftInnerRadius, outerBorderBottomRightInnerRadius); + IntRect outerBorderInnerRect = borderInnerRect(borderRect, outerBorderTopWidth, outerBorderBottomWidth, + outerBorderLeftWidth, outerBorderRightWidth); + RoundedIntRect outerClip = style->getRoundedInnerBorderWithBorderWidths(outerBorderInnerRect, outerBorderTopWidth, outerBorderBottomWidth, + outerBorderLeftWidth, outerBorderRightWidth); + graphicsContext->clipOutRoundedRect(outerClip); drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, SOLID); graphicsContext->restore(); @@ -1033,18 +1021,14 @@ void RenderObject::drawBoxSideFromPath(GraphicsContext* graphicsContext, IntRect IntRect halfBorderRect = borderInnerRect(borderRect, style->borderLeftWidth() / 2, style->borderBottomWidth() / 2, style->borderLeftWidth() / 2, style->borderRightWidth() / 2); - IntSize topLeftHalfRadius, topRightHalfRadius, bottomLeftHalfRadius, bottomRightHalfRadius; - style->getInnerBorderRadiiForRectWithBorderWidths(halfBorderRect, style->borderLeftWidth() / 2, - style->borderBottomWidth() / 2, style->borderLeftWidth() / 2, style->borderRightWidth() / 2, - topLeftHalfRadius, topRightHalfRadius, bottomLeftHalfRadius, bottomRightHalfRadius); - // Paint full border drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, s1); // Paint inner only graphicsContext->save(); - graphicsContext->addRoundedRectClip(halfBorderRect, topLeftHalfRadius, topRightHalfRadius, - bottomLeftHalfRadius, bottomRightHalfRadius); + RoundedIntRect clipRect = style->getRoundedInnerBorderWithBorderWidths(halfBorderRect, style->borderLeftWidth() / 2, style->borderBottomWidth() / 2, + style->borderLeftWidth() / 2, style->borderRightWidth() / 2); + graphicsContext->addRoundedRectClip(clipRect); drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, s2); graphicsContext->restore(); diff --git a/Source/WebCore/rendering/RenderObject.h b/Source/WebCore/rendering/RenderObject.h index cf08a0d..f2e7f13 100644 --- a/Source/WebCore/rendering/RenderObject.h +++ b/Source/WebCore/rendering/RenderObject.h @@ -26,7 +26,6 @@ #ifndef RenderObject_h #define RenderObject_h -#include "AffineTransform.h" #include "CachedResourceClient.h" #include "Document.h" #include "Element.h" @@ -44,6 +43,7 @@ namespace WebCore { +class AffineTransform; class AnimationController; class HitTestResult; class InlineBox; diff --git a/Source/WebCore/rendering/RenderOverflow.h b/Source/WebCore/rendering/RenderOverflow.h index 7dc2bcb..33e8cff 100644 --- a/Source/WebCore/rendering/RenderOverflow.h +++ b/Source/WebCore/rendering/RenderOverflow.h @@ -37,7 +37,8 @@ namespace WebCore // Examples of visual overflow are shadows, text stroke (and eventually outline and border-image). // This object is allocated only when some of these fields have non-default values in the owning box. -class RenderOverflow : public Noncopyable { +class RenderOverflow { + WTF_MAKE_NONCOPYABLE(RenderOverflow); WTF_MAKE_FAST_ALLOCATED; public: RenderOverflow(const IntRect& layoutRect, const IntRect& visualRect) : m_topLayoutOverflow(layoutRect.y()) diff --git a/Source/WebCore/rendering/RenderReplaced.cpp b/Source/WebCore/rendering/RenderReplaced.cpp index 974a8d0..0d72f95 100644 --- a/Source/WebCore/rendering/RenderReplaced.cpp +++ b/Source/WebCore/rendering/RenderReplaced.cpp @@ -135,11 +135,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty) else { // Push a clip if we have a border radius, since we want to round the foreground content that gets painted. paintInfo.context->save(); - - IntSize topLeft, topRight, bottomLeft, bottomRight; - style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); - - paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); + paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(borderRect)); } } diff --git a/Source/WebCore/rendering/RenderScrollbar.cpp b/Source/WebCore/rendering/RenderScrollbar.cpp index 44a0126..4091d51 100644 --- a/Source/WebCore/rendering/RenderScrollbar.cpp +++ b/Source/WebCore/rendering/RenderScrollbar.cpp @@ -34,13 +34,13 @@ namespace WebCore { -PassRefPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderBox* renderer, Frame* owningFrame) +PassRefPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, RenderBox* renderer, Frame* owningFrame) { - return adoptRef(new RenderScrollbar(client, orientation, renderer, owningFrame)); + return adoptRef(new RenderScrollbar(scrollableArea, orientation, renderer, owningFrame)); } -RenderScrollbar::RenderScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, RenderBox* renderer, Frame* owningFrame) - : Scrollbar(client, orientation, RegularScrollbar, RenderScrollbarTheme::renderScrollbarTheme()) +RenderScrollbar::RenderScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, RenderBox* renderer, Frame* owningFrame) + : Scrollbar(scrollableArea, orientation, RegularScrollbar, RenderScrollbarTheme::renderScrollbarTheme()) , m_owner(renderer) , m_owningFrame(owningFrame) { diff --git a/Source/WebCore/rendering/RenderScrollbar.h b/Source/WebCore/rendering/RenderScrollbar.h index de70624..8f4de4f 100644 --- a/Source/WebCore/rendering/RenderScrollbar.h +++ b/Source/WebCore/rendering/RenderScrollbar.h @@ -39,11 +39,11 @@ class RenderStyle; class RenderScrollbar : public Scrollbar { protected: - RenderScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderBox*, Frame*); + RenderScrollbar(ScrollableArea*, ScrollbarOrientation, RenderBox*, Frame*); public: friend class Scrollbar; - static PassRefPtr<Scrollbar> createCustomScrollbar(ScrollbarClient*, ScrollbarOrientation, RenderBox*, Frame* owningFrame = 0); + static PassRefPtr<Scrollbar> createCustomScrollbar(ScrollableArea*, ScrollbarOrientation, RenderBox*, Frame* owningFrame = 0); virtual ~RenderScrollbar(); static ScrollbarPart partForStyleResolve(); diff --git a/Source/WebCore/rendering/RenderSelectionInfo.h b/Source/WebCore/rendering/RenderSelectionInfo.h index a09fc1a..45ca813 100644 --- a/Source/WebCore/rendering/RenderSelectionInfo.h +++ b/Source/WebCore/rendering/RenderSelectionInfo.h @@ -30,7 +30,8 @@ namespace WebCore { -class RenderSelectionInfoBase : public Noncopyable { +class RenderSelectionInfoBase { + WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED; public: RenderSelectionInfoBase() : m_object(0) diff --git a/Source/WebCore/rendering/RenderSlider.cpp b/Source/WebCore/rendering/RenderSlider.cpp index b0dc0d9..49da396 100644 --- a/Source/WebCore/rendering/RenderSlider.cpp +++ b/Source/WebCore/rendering/RenderSlider.cpp @@ -181,116 +181,6 @@ SliderThumbElement* RenderSlider::sliderThumbElement() const return toSliderThumbElement(static_cast<Element*>(node())->shadowRoot()); } -bool RenderSlider::mouseEventIsInThumb(MouseEvent* evt) -{ - SliderThumbElement* thumbElement = sliderThumbElement(); - if (!thumbElement || !thumbElement->renderer()) - return false; - -#if ENABLE(VIDEO) - if (style()->appearance() == MediaSliderPart || style()->appearance() == MediaVolumeSliderPart) { - MediaControlInputElement* sliderThumb = static_cast<MediaControlInputElement*>(thumbElement->renderer()->node()); - return sliderThumb->hitTest(evt->absoluteLocation()); - } -#endif - - FloatPoint localPoint = thumbElement->renderBox()->absoluteToLocal(evt->absoluteLocation(), false, true); - IntRect thumbBounds = thumbElement->renderBox()->borderBoxRect(); - return thumbBounds.contains(roundedIntPoint(localPoint)); -} - -FloatPoint RenderSlider::mouseEventOffsetToThumb(MouseEvent* evt) -{ - SliderThumbElement* thumbElement = sliderThumbElement(); - ASSERT(thumbElement && thumbElement->renderer()); - FloatPoint localPoint = thumbElement->renderBox()->absoluteToLocal(evt->absoluteLocation(), false, true); - IntRect thumbBounds = thumbElement->renderBox()->borderBoxRect(); - FloatPoint offset; - offset.setX(thumbBounds.x() + thumbBounds.width() / 2 - localPoint.x()); - offset.setY(thumbBounds.y() + thumbBounds.height() / 2 - localPoint.y()); - return offset; -} - -void RenderSlider::setValueForPosition(int position) -{ - SliderThumbElement* thumbElement = sliderThumbElement(); - if (!thumbElement || !thumbElement->renderer()) - return; - - HTMLInputElement* element = static_cast<HTMLInputElement*>(node()); - - // Calculate the new value based on the position, and send it to the element. - StepRange range(element); - double fraction = static_cast<double>(position) / trackSize(); - if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) - fraction = 1 - fraction; - double value = range.clampValue(range.valueFromProportion(fraction)); - element->setValueFromRenderer(serializeForNumberType(value)); - - // Also update the position if appropriate. - if (position != currentPosition()) { - setNeedsLayout(true); - - // FIXME: It seems like this could send extra change events if the same value is set - // multiple times with no layout in between. - element->dispatchFormControlChangeEvent(); - } -} - -int RenderSlider::positionForOffset(const IntPoint& p) -{ - SliderThumbElement* thumbElement = sliderThumbElement(); - if (!thumbElement || !thumbElement->renderer()) - return 0; - - int position; - if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) - position = p.y() - thumbElement->renderBox()->height() / 2; - else - position = p.x() - thumbElement->renderBox()->width() / 2; - - return max(0, min(position, trackSize())); -} - -int RenderSlider::currentPosition() -{ - SliderThumbElement* thumbElement = sliderThumbElement(); - ASSERT(thumbElement && thumbElement->renderer()); - - if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) - return toRenderBox(thumbElement->renderer())->y() - contentBoxRect().y(); - return toRenderBox(thumbElement->renderer())->x() - contentBoxRect().x(); -} - -int RenderSlider::trackSize() -{ - SliderThumbElement* thumbElement = sliderThumbElement(); - ASSERT(thumbElement && thumbElement->renderer()); - - if (style()->appearance() == SliderVerticalPart || style()->appearance() == MediaVolumeSliderPart) - return contentHeight() - thumbElement->renderBox()->height(); - return contentWidth() - thumbElement->renderBox()->width(); -} - -void RenderSlider::forwardEvent(Event* event) -{ - SliderThumbElement* thumbElement = sliderThumbElement(); - if (!thumbElement) - return; - - if (event->isMouseEvent()) { - MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); - if (event->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) { - if (!mouseEventIsInThumb(mouseEvent)) { - IntPoint eventOffset = roundedIntPoint(absoluteToLocal(mouseEvent->absoluteLocation(), false, true)); - setValueForPosition(positionForOffset(eventOffset)); - } - } - } - - thumbElement->defaultEventHandler(event); -} - bool RenderSlider::inDragMode() const { SliderThumbElement* thumbElement = sliderThumbElement(); diff --git a/Source/WebCore/rendering/RenderSlider.h b/Source/WebCore/rendering/RenderSlider.h index 5fb5921..0162b71 100644 --- a/Source/WebCore/rendering/RenderSlider.h +++ b/Source/WebCore/rendering/RenderSlider.h @@ -34,7 +34,6 @@ namespace WebCore { RenderSlider(HTMLInputElement*); virtual ~RenderSlider(); - void forwardEvent(Event*); bool inDragMode() const; IntRect thumbRect(); @@ -49,20 +48,8 @@ namespace WebCore { // FIXME: Eventually, the logic of manipulating slider thumb should move to // SliderThumbElement and accessing sliderThumbElement should not be necessary in this class. SliderThumbElement* sliderThumbElement() const; - bool mouseEventIsInThumb(MouseEvent*); - FloatPoint mouseEventOffsetToThumb(MouseEvent*); - - void setValueForPosition(int position); - void setPositionFromValue(); - int positionForOffset(const IntPoint&); - - int currentPosition(); virtual bool requiresForcedStyleRecalcPropagation() const { return true; } - - int trackSize(); - - friend class SliderThumbElement; }; inline RenderSlider* toRenderSlider(RenderObject* object) diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp index 7aaad62..265d2ef 100644 --- a/Source/WebCore/rendering/RenderTableSection.cpp +++ b/Source/WebCore/rendering/RenderTableSection.cpp @@ -1192,6 +1192,13 @@ void RenderTableSection::recalcCells() setNeedsLayout(true); } +void RenderTableSection::setNeedsCellRecalc() +{ + m_needsCellRecalc = true; + if (RenderTable* t = table()) + t->setNeedsSectionRecalc(); +} + void RenderTableSection::clearGrid() { int rows = m_gridRows; diff --git a/Source/WebCore/rendering/RenderTableSection.h b/Source/WebCore/rendering/RenderTableSection.h index fac6a84..cc969e8 100644 --- a/Source/WebCore/rendering/RenderTableSection.h +++ b/Source/WebCore/rendering/RenderTableSection.h @@ -114,11 +114,7 @@ public: } bool needsCellRecalc() const { return m_needsCellRecalc; } - void setNeedsCellRecalc() - { - m_needsCellRecalc = true; - table()->setNeedsSectionRecalc(); - } + void setNeedsCellRecalc(); int getBaseline(int row) { return m_grid[row].baseline; } diff --git a/Source/WebCore/rendering/RenderText.cpp b/Source/WebCore/rendering/RenderText.cpp index 78c5684..86b32d5 100644 --- a/Source/WebCore/rendering/RenderText.cpp +++ b/Source/WebCore/rendering/RenderText.cpp @@ -40,6 +40,7 @@ #include "Text.h" #include "TextBreakIterator.h" #include "TextResourceDecoder.h" +#include "TextRun.h" #include "VisiblePosition.h" #include "break_lines.h" #include <wtf/AlwaysInline.h> diff --git a/Source/WebCore/rendering/RenderTextControl.cpp b/Source/WebCore/rendering/RenderTextControl.cpp index 40aa4c2..cac8113 100644 --- a/Source/WebCore/rendering/RenderTextControl.cpp +++ b/Source/WebCore/rendering/RenderTextControl.cpp @@ -41,6 +41,7 @@ #include "Text.h" #include "TextControlInnerElements.h" #include "TextIterator.h" +#include "TextRun.h" using namespace std; diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp index b54c45b..95f209a 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -1083,14 +1083,14 @@ bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction return RenderBlock::logicalScroll(direction, granularity, multiplier, stopNode); } -PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) +PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) { RefPtr<Scrollbar> widget; bool hasCustomScrollbarStyle = style()->hasPseudoStyle(SCROLLBAR); if (hasCustomScrollbarStyle) - widget = RenderScrollbar::createCustomScrollbar(client, orientation, this); + widget = RenderScrollbar::createCustomScrollbar(scrollableArea, orientation, this); else - widget = Scrollbar::createNativeScrollbar(client, orientation, controlSize); + widget = Scrollbar::createNativeScrollbar(scrollableArea, orientation, controlSize); return widget.release(); } diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.h b/Source/WebCore/rendering/RenderTextControlSingleLine.h index 16ce1e4..6b99f59 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.h +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.h @@ -140,7 +140,7 @@ private: virtual void setTextFromItem(unsigned listIndex); virtual FontSelector* fontSelector() const; virtual HostWindow* hostWindow() const; - virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize); + virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize); InputElement* inputElement() const; diff --git a/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp b/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp index 90736c7..3a2874d 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp +++ b/Source/WebCore/rendering/RenderThemeChromiumLinux.cpp @@ -28,8 +28,10 @@ #include "CSSValueKeywords.h" #include "Color.h" #include "PaintInfo.h" -#include "PlatformThemeChromiumGtk.h" +#include "PlatformBridge.h" #include "RenderObject.h" +#include "RenderProgress.h" +#include "RenderSlider.h" #include "ScrollbarTheme.h" #include "UserAgentStyleSheets.h" @@ -46,6 +48,21 @@ unsigned RenderThemeChromiumLinux::m_inactiveSelectionForegroundColor = double RenderThemeChromiumLinux::m_caretBlinkInterval; +static const unsigned defaultButtonBackgroundColor = 0xffdddddd; + +static PlatformBridge::ThemePaintState getWebThemeState(const RenderTheme* theme, const RenderObject* o) +{ + if (!theme->isEnabled(o)) + return PlatformBridge::StateDisabled; + if (theme->isPressed(o)) + return PlatformBridge::StatePressed; + if (theme->isHovered(o)) + return PlatformBridge::StateHover; + + return PlatformBridge::StateNormal; +} + + PassRefPtr<RenderTheme> RenderThemeChromiumLinux::create() { return adoptRef(new RenderThemeChromiumLinux()); @@ -128,15 +145,14 @@ Color RenderThemeChromiumLinux::platformInactiveSelectionForegroundColor() const void RenderThemeChromiumLinux::adjustSliderThumbSize(RenderObject* o) const { - // These sizes match the sizes in Chromium Win. - const int sliderThumbAlongAxis = 11; - const int sliderThumbAcrossAxis = 21; + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartSliderThumb); + if (o->style()->appearance() == SliderThumbHorizontalPart) { - o->style()->setWidth(Length(sliderThumbAlongAxis, Fixed)); - o->style()->setHeight(Length(sliderThumbAcrossAxis, Fixed)); + o->style()->setWidth(Length(size.width(), Fixed)); + o->style()->setHeight(Length(size.height(), Fixed)); } else if (o->style()->appearance() == SliderThumbVerticalPart) { - o->style()->setWidth(Length(sliderThumbAcrossAxis, Fixed)); - o->style()->setHeight(Length(sliderThumbAlongAxis, Fixed)); + o->style()->setWidth(Length(size.height(), Fixed)); + o->style()->setHeight(Length(size.width(), Fixed)); } else RenderThemeChromiumSkia::adjustSliderThumbSize(o); } @@ -168,29 +184,154 @@ void RenderThemeChromiumLinux::setSelectionColors( m_inactiveSelectionForegroundColor = inactiveForegroundColor; } +bool RenderThemeChromiumLinux::paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.button.checked = isChecked(o); + extraParams.button.indeterminate = isIndeterminate(o); + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartCheckbox, getWebThemeState(this, o), rect, &extraParams); + return false; +} + +void RenderThemeChromiumLinux::setCheckboxSize(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; + + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartCheckbox); + setSizeIfAuto(style, size); +} + +bool RenderThemeChromiumLinux::paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.button.checked = isChecked(o); + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartRadio, getWebThemeState(this, o), rect, &extraParams); + return false; +} + +void RenderThemeChromiumLinux::setRadioSize(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; + + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartRadio); + setSizeIfAuto(style, size); +} + +bool RenderThemeChromiumLinux::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.button.isDefault = isDefault(o); + extraParams.button.backgroundColor = defaultButtonBackgroundColor; + if (o->hasBackground()) + extraParams.button.backgroundColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor).rgb(); + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartButton, getWebThemeState(this, o), rect, &extraParams); + return false; +} + +bool RenderThemeChromiumLinux::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + // WebThemeEngine does not handle border rounded corner and background image + // so return true to draw CSS border and background. + if (o->style()->hasBorderRadius() || o->style()->hasBackgroundImage()) + return true; + + ControlPart part = o->style()->appearance(); + + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.textField.isTextArea = part == TextAreaPart; + extraParams.textField.isListbox = part == ListboxPart; + + // Fallback to white if the specified color object is invalid. + Color backgroundColor(Color::white); + if (o->style()->visitedDependentColor(CSSPropertyBackgroundColor).isValid()) + backgroundColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor); + extraParams.textField.backgroundColor = backgroundColor.rgb(); + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartTextField, getWebThemeState(this, o), rect, &extraParams); + return false; +} + +bool RenderThemeChromiumLinux::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + const int right = rect.x() + rect.width(); + const int middle = rect.y() + rect.height() / 2; + + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x() + 7 : right - 13; + extraParams.menuList.arrowY = middle; + extraParams.menuList.backgroundColor = SkColorSetRGB(0xdd, 0xdd, 0xdd); + if (o->hasBackground()) + extraParams.menuList.backgroundColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor).rgb(); + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartMenuList, getWebThemeState(this, o), rect, &extraParams); + return false; +} + +bool RenderThemeChromiumLinux::paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.slider.vertical = o->style()->appearance() == SliderVerticalPart; + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartSliderTrack, getWebThemeState(this, o), rect, &extraParams); + return false; +} + +bool RenderThemeChromiumLinux::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.slider.vertical = o->style()->appearance() == SliderThumbVerticalPart; + extraParams.slider.inDrag = toRenderSlider(o->parent())->inDragMode(); + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartSliderThumb, getWebThemeState(this, o), rect, &extraParams); + return false; +} + void RenderThemeChromiumLinux::adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { - int width = ScrollbarTheme::nativeTheme()->scrollbarThickness(); - style->setWidth(Length(width, Fixed)); - style->setMinWidth(Length(width, Fixed)); + IntSize size = PlatformBridge::getThemePartSize(PlatformBridge::PartInnerSpinButton); + + style->setWidth(Length(size.width(), Fixed)); + style->setMinWidth(Length(size.width(), Fixed)); } -bool RenderThemeChromiumLinux::paintInnerSpinButton(RenderObject* object, const PaintInfo& info, const IntRect& rect) +bool RenderThemeChromiumLinux::paintInnerSpinButton(RenderObject* o, const PaintInfo& i, const IntRect& rect) { - ControlStates northStates = controlStatesForRenderer(object); - ControlStates southStates = northStates; - if (northStates & SpinUpState) - southStates &= ~(HoverState | PressedState); - else - northStates &= ~(HoverState | PressedState); + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.innerSpin.spinUp = (controlStatesForRenderer(o) & SpinUpState); + extraParams.innerSpin.readOnly = isReadOnlyControl(o); - IntRect half = rect; - half.setHeight(rect.height() / 2); - PlatformThemeChromiumGtk::paintArrowButton(info.context, half, PlatformThemeChromiumGtk::North, northStates); + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartInnerSpinButton, getWebThemeState(this, o), rect, &extraParams); + return false; +} + +#if ENABLE(PROGRESS_TAG) + +bool RenderThemeChromiumLinux::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) +{ + if (!o->isProgress()) + return true; - half.setY(rect.y() + rect.height() / 2); - PlatformThemeChromiumGtk::paintArrowButton(info.context, half, PlatformThemeChromiumGtk::South, southStates); + RenderProgress* renderProgress = toRenderProgress(o); + IntRect valueRect = progressValueRectFor(renderProgress, rect); + + PlatformBridge::ThemePaintExtraParams extraParams; + extraParams.progressBar.determinate = renderProgress->isDeterminate(); + extraParams.progressBar.valueRectX = valueRect.x(); + extraParams.progressBar.valueRectY = valueRect.y(); + extraParams.progressBar.valueRectWidth = valueRect.width(); + extraParams.progressBar.valueRectHeight = valueRect.height(); + + PlatformBridge::paintThemePart(i.context, PlatformBridge::PartProgressBar, getWebThemeState(this, o), rect, &extraParams); return false; } +#endif + } // namespace WebCore diff --git a/Source/WebCore/rendering/RenderThemeChromiumLinux.h b/Source/WebCore/rendering/RenderThemeChromiumLinux.h index 9eeca97..8f3eb98 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumLinux.h +++ b/Source/WebCore/rendering/RenderThemeChromiumLinux.h @@ -59,9 +59,25 @@ namespace WebCore { static void setCaretBlinkInterval(double interval); virtual double caretBlinkIntervalInternal() const; + virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&); + virtual void setCheckboxSize(RenderStyle*) const; + + virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&); + virtual void setRadioSize(RenderStyle*) const; + + virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); + virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); + virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&); +#if ENABLE(PROGRESS_TAG) + virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); +#endif + static void setSelectionColors(unsigned activeBackgroundColor, unsigned activeForegroundColor, unsigned inactiveBackgroundColor, diff --git a/Source/WebCore/rendering/RenderThemeChromiumMac.mm b/Source/WebCore/rendering/RenderThemeChromiumMac.mm index 02eb134..10285ac 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumMac.mm +++ b/Source/WebCore/rendering/RenderThemeChromiumMac.mm @@ -20,8 +20,8 @@ #import "config.h" #import "RenderThemeChromiumMac.h" -#import "ChromiumBridge.h" #import "PaintInfo.h" +#import "PlatformBridge.h" #import "RenderMediaControlsChromium.h" #import "UserAgentStyleSheets.h" #import <Carbon/Carbon.h> @@ -71,7 +71,7 @@ PassRefPtr<RenderTheme> RenderThemeChromiumMac::create() bool RenderThemeChromiumMac::usesTestModeFocusRingColor() const { - return ChromiumBridge::layoutTestMode(); + return PlatformBridge::layoutTestMode(); } NSView* RenderThemeChromiumMac::documentViewFor(RenderObject*) const diff --git a/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp b/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp index bb60c1f..9691876 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp +++ b/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp @@ -24,7 +24,6 @@ #include "config.h" #include "RenderThemeChromiumSkia.h" -#include "ChromiumBridge.h" #include "CSSValueKeywords.h" #include "CurrentTime.h" #include "GraphicsContext.h" @@ -33,6 +32,7 @@ #include "Image.h" #include "MediaControlElements.h" #include "PaintInfo.h" +#include "PlatformBridge.h" #include "PlatformContextSkia.h" #include "RenderBox.h" #include "RenderMediaControlsChromium.h" @@ -68,38 +68,6 @@ static const float minSearchFieldResultsDecorationSize = 9; static const float maxSearchFieldResultsDecorationSize = 30; static const float defaultSearchFieldResultsButtonWidth = 18; -static void setSizeIfAuto(RenderStyle* style, const IntSize& size) -{ - if (style->width().isIntrinsicOrAuto()) - style->setWidth(Length(size.width(), Fixed)); - if (style->height().isAuto()) - style->setHeight(Length(size.height(), Fixed)); -} - -static void drawVertLine(SkCanvas* canvas, int x, int y1, int y2, const SkPaint& paint) -{ - SkIRect skrect; - skrect.set(x, y1, x + 1, y2 + 1); - canvas->drawIRect(skrect, paint); -} - -static void drawHorizLine(SkCanvas* canvas, int x1, int x2, int y, const SkPaint& paint) -{ - SkIRect skrect; - skrect.set(x1, y, x2 + 1, y + 1); - canvas->drawIRect(skrect, paint); -} - -static void drawBox(SkCanvas* canvas, const IntRect& rect, const SkPaint& paint) -{ - const int right = rect.x() + rect.width() - 1; - const int bottom = rect.y() + rect.height() - 1; - drawHorizLine(canvas, rect.x(), right, rect.y(), paint); - drawVertLine(canvas, right, rect.y(), bottom, paint); - drawHorizLine(canvas, rect.x(), right, bottom, paint); - drawVertLine(canvas, rect.x(), rect.y(), bottom, paint); -} - // We aim to match IE here. // -IE uses a font based on the encoding as the default font for form controls. // -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT), @@ -185,7 +153,7 @@ double RenderThemeChromiumSkia::caretBlinkInterval() const { // Disable the blinking caret in layout test mode, as it introduces // a race condition for the pixel tests. http://b/1198440 - if (ChromiumBridge::layoutTestMode()) + if (PlatformBridge::layoutTestMode()) return 0; return caretBlinkIntervalInternal(); @@ -237,28 +205,6 @@ IntRect center(const IntRect& original, int width, int height) return IntRect(x, y, width, height); } -bool RenderThemeChromiumSkia::paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& rect) -{ - static Image* const checkedImage = Image::loadPlatformResource("linuxCheckboxOn").releaseRef(); - static Image* const uncheckedImage = Image::loadPlatformResource("linuxCheckboxOff").releaseRef(); - static Image* const indeterminateImage = Image::loadPlatformResource("linuxCheckboxIndeterminate").releaseRef(); - static Image* const disabledCheckedImage = Image::loadPlatformResource("linuxCheckboxDisabledOn").releaseRef(); - static Image* const disabledUncheckedImage = Image::loadPlatformResource("linuxCheckboxDisabledOff").releaseRef(); - static Image* const disabledIndeterminateImage = Image::loadPlatformResource("linuxCheckboxDisabledIndeterminate").releaseRef(); - - Image* image; - - if (isIndeterminate(o)) - image = isEnabled(o) ? indeterminateImage : disabledIndeterminateImage; - else if (isChecked(o)) - image = isEnabled(o) ? checkedImage : disabledCheckedImage; - else - image = isEnabled(o) ? uncheckedImage : disabledUncheckedImage; - - i.context->drawImage(image, o->style()->colorSpace(), center(rect, widgetStandardHeight, widgetStandardWidth)); - return false; -} - void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const { // If the width and height are both specified, then we have nothing to do. @@ -270,108 +216,16 @@ void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const // querying the theme gives you a larger size that accounts for the higher // DPI. Until our entire engine honors a DPI setting other than 96, we // can't rely on the theme's metrics. - const IntSize size(widgetStandardHeight, widgetStandardWidth); + const IntSize size(widgetStandardWidth, widgetStandardHeight); setSizeIfAuto(style, size); } -bool RenderThemeChromiumSkia::paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& rect) -{ - static Image* const checkedImage = Image::loadPlatformResource("linuxRadioOn").releaseRef(); - static Image* const uncheckedImage = Image::loadPlatformResource("linuxRadioOff").releaseRef(); - static Image* const disabledCheckedImage = Image::loadPlatformResource("linuxRadioDisabledOn").releaseRef(); - static Image* const disabledUncheckedImage = Image::loadPlatformResource("linuxRadioDisabledOff").releaseRef(); - - Image* image; - if (this->isEnabled(o)) - image = this->isChecked(o) ? checkedImage : uncheckedImage; - else - image = this->isChecked(o) ? disabledCheckedImage : disabledUncheckedImage; - - i.context->drawImage(image, o->style()->colorSpace(), center(rect, widgetStandardHeight, widgetStandardWidth)); - return false; -} - void RenderThemeChromiumSkia::setRadioSize(RenderStyle* style) const { // Use same sizing for radio box as checkbox. setCheckboxSize(style); } -static SkColor brightenColor(double h, double s, double l, float brightenAmount) -{ - l += brightenAmount; - if (l > 1.0) - l = 1.0; - if (l < 0.0) - l = 0.0; - - return makeRGBAFromHSLA(h, s, l, 1.0); -} - -static void paintButtonLike(RenderTheme* theme, RenderObject* o, const PaintInfo& i, const IntRect& rect) -{ - SkCanvas* const canvas = i.context->platformContext()->canvas(); - SkPaint paint; - SkRect skrect; - const int right = rect.x() + rect.width(); - const int bottom = rect.y() + rect.height(); - SkColor baseColor = SkColorSetARGB(0xff, 0xdd, 0xdd, 0xdd); - if (o->hasBackground()) - baseColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor).rgb(); - double h, s, l; - Color(baseColor).getHSL(h, s, l); - // Our standard gradient is from 0xdd to 0xf8. This is the amount of - // increased luminance between those values. - SkColor lightColor(brightenColor(h, s, l, 0.105)); - - // If the button is too small, fallback to drawing a single, solid color - if (rect.width() < 5 || rect.height() < 5) { - paint.setColor(baseColor); - skrect.set(rect.x(), rect.y(), right, bottom); - canvas->drawRect(skrect, paint); - return; - } - - const int borderAlpha = theme->isHovered(o) ? 0x80 : 0x55; - paint.setARGB(borderAlpha, 0, 0, 0); - canvas->drawLine(rect.x() + 1, rect.y(), right - 1, rect.y(), paint); - canvas->drawLine(right - 1, rect.y() + 1, right - 1, bottom - 1, paint); - canvas->drawLine(rect.x() + 1, bottom - 1, right - 1, bottom - 1, paint); - canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), bottom - 1, paint); - - paint.setColor(SK_ColorBLACK); - SkPoint p[2]; - const int lightEnd = theme->isPressed(o) ? 1 : 0; - const int darkEnd = !lightEnd; - p[lightEnd].set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y())); - p[darkEnd].set(SkIntToScalar(rect.x()), SkIntToScalar(bottom - 1)); - SkColor colors[2]; - colors[0] = lightColor; - colors[1] = baseColor; - - SkShader* shader = SkGradientShader::CreateLinear( - p, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); - paint.setStyle(SkPaint::kFill_Style); - paint.setShader(shader); - shader->unref(); - - skrect.set(rect.x() + 1, rect.y() + 1, right - 1, bottom - 1); - canvas->drawRect(skrect, paint); - - paint.setShader(NULL); - paint.setColor(brightenColor(h, s, l, -0.0588)); - canvas->drawPoint(rect.x() + 1, rect.y() + 1, paint); - canvas->drawPoint(right - 2, rect.y() + 1, paint); - canvas->drawPoint(rect.x() + 1, bottom - 2, paint); - canvas->drawPoint(right - 2, bottom - 2, paint); -} - -bool RenderThemeChromiumSkia::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& rect) -{ - paintButtonLike(this, o, i, rect); - return false; -} - void RenderThemeChromiumSkia::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { if (style->appearance() == PushButtonPart) { @@ -380,12 +234,6 @@ void RenderThemeChromiumSkia::adjustButtonStyle(CSSStyleSelector*, RenderStyle* } } - -bool RenderThemeChromiumSkia::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& rect) -{ - return true; -} - bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); @@ -622,30 +470,6 @@ void RenderThemeChromiumSkia::adjustMenuListStyle(CSSStyleSelector* selector, Re style->setLineHeight(RenderStyle::initialLineHeight()); } -bool RenderThemeChromiumSkia::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& rect) -{ - SkCanvas* const canvas = i.context->platformContext()->canvas(); - const int right = rect.x() + rect.width(); - const int middle = rect.y() + rect.height() / 2; - - paintButtonLike(this, o, i, rect); - - SkPaint paint; - paint.setColor(SK_ColorBLACK); - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kFill_Style); - - int arrowXPosition = (o->style()->direction() == RTL) ? rect.x() + 7 : right - 13; - SkPath path; - path.moveTo(arrowXPosition, middle - 3); - path.rLineTo(6, 0); - path.rLineTo(-3, 6); - path.close(); - canvas->drawPath(path, paint); - - return false; -} - void RenderThemeChromiumSkia::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const { adjustMenuListStyle(selector, style, e); @@ -657,69 +481,6 @@ bool RenderThemeChromiumSkia::paintMenuListButton(RenderObject* o, const PaintIn return paintMenuList(o, i, rect); } -bool RenderThemeChromiumSkia::paintSliderTrack(RenderObject*, const PaintInfo& i, const IntRect& rect) -{ - // Just paint a grey box for now (matches the color of a scrollbar background. - SkCanvas* const canvas = i.context->platformContext()->canvas(); - int verticalCenter = rect.y() + rect.height() / 2; - int top = std::max(rect.y(), verticalCenter - 2); - int bottom = std::min(rect.y() + rect.height(), verticalCenter + 2); - - SkPaint paint; - const SkColor grey = SkColorSetARGB(0xff, 0xe3, 0xdd, 0xd8); - paint.setColor(grey); - - SkRect skrect; - skrect.set(rect.x(), top, rect.x() + rect.width(), bottom); - canvas->drawRect(skrect, paint); - - return false; -} - -bool RenderThemeChromiumSkia::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& rect) -{ - // Make a thumb similar to the scrollbar thumb. - const bool hovered = isHovered(o) || toRenderSlider(o->parent())->inDragMode(); - const int midx = rect.x() + rect.width() / 2; - const int midy = rect.y() + rect.height() / 2; - const bool vertical = (o->style()->appearance() == SliderThumbVerticalPart); - SkCanvas* const canvas = i.context->platformContext()->canvas(); - - const SkColor thumbLightGrey = SkColorSetARGB(0xff, 0xf4, 0xf2, 0xef); - const SkColor thumbDarkGrey = SkColorSetARGB(0xff, 0xea, 0xe5, 0xe0); - SkPaint paint; - paint.setColor(hovered ? SK_ColorWHITE : thumbLightGrey); - - SkIRect skrect; - if (vertical) - skrect.set(rect.x(), rect.y(), midx + 1, rect.bottom()); - else - skrect.set(rect.x(), rect.y(), rect.right(), midy + 1); - - canvas->drawIRect(skrect, paint); - - paint.setColor(hovered ? thumbLightGrey : thumbDarkGrey); - - if (vertical) - skrect.set(midx + 1, rect.y(), rect.right(), rect.bottom()); - else - skrect.set(rect.x(), midy + 1, rect.right(), rect.bottom()); - - canvas->drawIRect(skrect, paint); - - const SkColor borderDarkGrey = SkColorSetARGB(0xff, 0x9d, 0x96, 0x8e); - paint.setColor(borderDarkGrey); - drawBox(canvas, rect, paint); - - if (rect.height() > 10 && rect.width() > 10) { - drawHorizLine(canvas, midx - 2, midx + 2, midy, paint); - drawHorizLine(canvas, midx - 2, midx + 2, midy - 3, paint); - drawHorizLine(canvas, midx - 2, midx + 2, midy + 3, paint); - } - - return false; -} - int RenderThemeChromiumSkia::popupInternalPaddingLeft(RenderStyle* style) const { return menuListInternalPadding(style, LeftPadding); @@ -758,6 +519,15 @@ double RenderThemeChromiumSkia::caretBlinkIntervalInternal() const return RenderTheme::caretBlinkInterval(); } +// static +void RenderThemeChromiumSkia::setSizeIfAuto(RenderStyle* style, const IntSize& size) +{ + if (style->width().isIntrinsicOrAuto()) + style->setWidth(Length(size.width(), Fixed)); + if (style->height().isAuto()) + style->setHeight(Length(size.height(), Fixed)); +} + int RenderThemeChromiumSkia::menuListInternalPadding(RenderStyle* style, int paddingType) const { // This internal padding is in addition to the user-supplied padding. @@ -801,7 +571,7 @@ IntRect RenderThemeChromiumSkia::indeterminateProgressValueRectFor(RenderProgres int movableWidth = rect.width() - valueWidth; if (movableWidth <= 0) return IntRect(); - + double progress = renderProgress->animationProgress(); if (progress < 0.5) return IntRect(rect.x() + progress * 2 * movableWidth, rect.y(), valueWidth, rect.height()); @@ -818,67 +588,6 @@ double RenderThemeChromiumSkia::animationDurationForProgressBar(RenderProgress* return progressAnimationInterval * progressAnimationFrmaes * 2; // "2" for back and forth } -bool RenderThemeChromiumSkia::paintProgressBar(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect) -{ - static Image* barImage = Image::loadPlatformResource("linuxProgressBar").releaseRef(); - static Image* valueImage = Image::loadPlatformResource("linuxProgressValue").releaseRef(); - static Image* leftBorderImage = Image::loadPlatformResource("linuxProgressBorderLeft").releaseRef(); - static Image* rightBorderImage = Image::loadPlatformResource("linuxProgressBorderRight").releaseRef(); - ASSERT(barImage->height() == valueImage->height()); - - if (!renderObject->isProgress()) - return true; - - paintInfo.context->platformContext()->setImageResamplingHint(barImage->size(), rect.size()); - - RenderProgress* renderProgress = toRenderProgress(renderObject); - double tileScale = static_cast<double>(rect.height()) / barImage->height(); - IntSize barTileSize(static_cast<int>(barImage->width() * tileScale), rect.height()); - ColorSpace colorSpace = renderObject->style()->colorSpace(); - - paintInfo.context->drawTiledImage(barImage, colorSpace, rect, IntPoint(0, 0), barTileSize); - - IntRect valueRect = progressValueRectFor(renderProgress, rect); - if (valueRect.width()) { - - IntSize valueTileSize(std::max(1, static_cast<int>(valueImage->width() * tileScale)), valueRect.height()); - - int leftOffset = valueRect.x() - rect.x(); - int roundedLeftOffset= (leftOffset / valueTileSize.width()) * valueTileSize.width(); - int dstLeftValueWidth = roundedLeftOffset - leftOffset + (leftOffset % valueImage->width()) ? valueTileSize.width() : 0; - - IntRect dstLeftValueRect(valueRect.x(), valueRect.y(), dstLeftValueWidth, valueRect.height()); - int srcLeftValueWidth = dstLeftValueWidth / tileScale; - IntRect srcLeftValueRect(valueImage->width() - srcLeftValueWidth, 0, srcLeftValueWidth, valueImage->height()); - paintInfo.context->drawImage(valueImage, colorSpace, dstLeftValueRect, srcLeftValueRect); - - int rightOffset = valueRect.right() - rect.x(); - int roundedRightOffset = (rightOffset / valueTileSize.width()) * valueTileSize.width(); - int dstRightValueWidth = rightOffset - roundedRightOffset; - IntRect dstRightValueRect(rect.x() + roundedRightOffset, valueRect.y(), dstRightValueWidth, valueTileSize.height()); - int srcRightValueWidth = dstRightValueWidth / tileScale; - IntRect srcRightValueRect(0, 0, srcRightValueWidth, valueImage->height()); - paintInfo.context->drawImage(valueImage, colorSpace, dstRightValueRect, srcRightValueRect); - - IntRect alignedValueRect(dstLeftValueRect.right(), dstLeftValueRect.y(), - dstRightValueRect.x() - dstLeftValueRect.right(), dstLeftValueRect.height()); - paintInfo.context->drawTiledImage(valueImage, colorSpace, alignedValueRect, IntPoint(0, 0), valueTileSize); - } - - int dstLeftBorderWidth = leftBorderImage->width() * tileScale; - IntRect dstLeftBorderRect(rect.x(), rect.y(), dstLeftBorderWidth, rect.height()); - paintInfo.context->drawImage(leftBorderImage, colorSpace, dstLeftBorderRect, leftBorderImage->rect()); - - int dstRightBorderWidth = rightBorderImage->width() * tileScale; - IntRect dstRightBorderRect(rect.right() - dstRightBorderWidth, rect.y(), dstRightBorderWidth, rect.height()); - paintInfo.context->drawImage(rightBorderImage, colorSpace, dstRightBorderRect, rightBorderImage->rect()); - - paintInfo.context->platformContext()->clearImageResamplingHint(); - - return false; -} - - IntRect RenderThemeChromiumSkia::progressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const { return renderProgress->isDeterminate() ? determinateProgressValueRectFor(renderProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect); diff --git a/Source/WebCore/rendering/RenderThemeChromiumSkia.h b/Source/WebCore/rendering/RenderThemeChromiumSkia.h index a11046d..bf0af34 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumSkia.h +++ b/Source/WebCore/rendering/RenderThemeChromiumSkia.h @@ -34,7 +34,7 @@ namespace WebCore { class RenderProgress; - class RenderThemeChromiumSkia : public RenderTheme { +class RenderThemeChromiumSkia : public RenderTheme { public: RenderThemeChromiumSkia(); virtual ~RenderThemeChromiumSkia(); @@ -66,17 +66,12 @@ class RenderProgress; virtual int minimumMenuListSize(RenderStyle*) const; - virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&); virtual void setCheckboxSize(RenderStyle*) const; - virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&); virtual void setRadioSize(RenderStyle*) const; - virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); - virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; @@ -112,17 +107,12 @@ class RenderProgress; // codepath. We never go down both. And in both cases, they render the // entire menulist. virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; - virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); - virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); - virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); - #if ENABLE(PROGRESS_TAG) virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const; virtual double animationDurationForProgressBar(RenderProgress*) const; - virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); #endif // These methods define the padding for the MenuList's inner block. @@ -153,6 +143,8 @@ class RenderProgress; virtual double caretBlinkIntervalInternal() const; + static void setSizeIfAuto(RenderStyle*, const IntSize&); + #if ENABLE(PROGRESS_TAG) IntRect determinateProgressValueRectFor(RenderProgress*, const IntRect&) const; IntRect indeterminateProgressValueRectFor(RenderProgress*, const IntRect&) const; diff --git a/Source/WebCore/rendering/RenderThemeChromiumWin.cpp b/Source/WebCore/rendering/RenderThemeChromiumWin.cpp index 5b41ea2..bba0520 100644 --- a/Source/WebCore/rendering/RenderThemeChromiumWin.cpp +++ b/Source/WebCore/rendering/RenderThemeChromiumWin.cpp @@ -30,7 +30,6 @@ #include <vssym32.h> #include "CSSValueKeywords.h" -#include "ChromiumBridge.h" #include "CurrentTime.h" #include "FontSelector.h" #include "FontUtilsChromiumWin.h" @@ -39,6 +38,7 @@ #include "HTMLNames.h" #include "MediaControlElements.h" #include "PaintInfo.h" +#include "PlatformBridge.h" #include "RenderBox.h" #include "RenderProgress.h" #include "RenderSlider.h" @@ -238,7 +238,7 @@ bool RenderThemeChromiumWin::supportsFocusRing(const RenderStyle* style) const Color RenderThemeChromiumWin::platformActiveSelectionBackgroundColor() const { - if (ChromiumBridge::layoutTestMode()) + if (PlatformBridge::layoutTestMode()) return Color(0x00, 0x00, 0xff); // Royal blue. COLORREF color = GetSysColor(COLOR_HIGHLIGHT); return Color(GetRValue(color), GetGValue(color), GetBValue(color), 0xff); @@ -246,7 +246,7 @@ Color RenderThemeChromiumWin::platformActiveSelectionBackgroundColor() const Color RenderThemeChromiumWin::platformInactiveSelectionBackgroundColor() const { - if (ChromiumBridge::layoutTestMode()) + if (PlatformBridge::layoutTestMode()) return Color(0x99, 0x99, 0x99); // Medium gray. COLORREF color = GetSysColor(COLOR_GRAYTEXT); return Color(GetRValue(color), GetGValue(color), GetBValue(color), 0xff); @@ -254,7 +254,7 @@ Color RenderThemeChromiumWin::platformInactiveSelectionBackgroundColor() const Color RenderThemeChromiumWin::platformActiveSelectionForegroundColor() const { - if (ChromiumBridge::layoutTestMode()) + if (PlatformBridge::layoutTestMode()) return Color(0xff, 0xff, 0xcc); // Pale yellow. COLORREF color = GetSysColor(COLOR_HIGHLIGHTTEXT); return Color(GetRValue(color), GetGValue(color), GetBValue(color), 0xff); @@ -375,7 +375,7 @@ static int cssValueIdToSysColorIndex(int cssValueId) Color RenderThemeChromiumWin::systemColor(int cssValueId) const { int sysColorIndex = cssValueIdToSysColorIndex(cssValueId); - if (ChromiumBridge::layoutTestMode() || (sysColorIndex == -1)) + if (PlatformBridge::layoutTestMode() || (sysColorIndex == -1)) return RenderTheme::systemColor(cssValueId); COLORREF color = GetSysColor(sysColorIndex); @@ -411,7 +411,7 @@ bool RenderThemeChromiumWin::paintButton(RenderObject* o, const PaintInfo& i, co const ThemeData& themeData = getThemeData(o); ThemePainter painter(i.context, r); - ChromiumBridge::paintButton(painter.context(), + PlatformBridge::paintButton(painter.context(), themeData.m_part, themeData.m_state, themeData.m_classicState, @@ -429,7 +429,7 @@ bool RenderThemeChromiumWin::paintSliderTrack(RenderObject* o, const PaintInfo& const ThemeData& themeData = getThemeData(o); ThemePainter painter(i.context, r); - ChromiumBridge::paintTrackbar(painter.context(), + PlatformBridge::paintTrackbar(painter.context(), themeData.m_part, themeData.m_state, themeData.m_classicState, @@ -444,7 +444,7 @@ bool RenderThemeChromiumWin::paintSliderThumb(RenderObject* o, const PaintInfo& static int menuListButtonWidth() { - static int width = ChromiumBridge::layoutTestMode() ? kStandardMenuListButtonWidth : GetSystemMetrics(SM_CXVSCROLL); + static int width = PlatformBridge::layoutTestMode() ? kStandardMenuListButtonWidth : GetSystemMetrics(SM_CXVSCROLL); return width; } @@ -492,7 +492,7 @@ bool RenderThemeChromiumWin::paintMenuList(RenderObject* o, const PaintInfo& i, // Get the correct theme data for a textfield and paint the menu. ThemePainter painter(i.context, rect); - ChromiumBridge::paintMenuList(painter.context(), + PlatformBridge::paintMenuList(painter.context(), CP_DROPDOWNBUTTON, determineState(o), determineClassicState(o), @@ -657,7 +657,7 @@ bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o, bool drawEdges) { // Fallback to white if the specified color object is invalid. - // (Note ChromiumBridge::paintTextField duplicates this check). + // (Note PlatformBridge::paintTextField duplicates this check). Color backgroundColor(Color::white); if (o->style()->visitedDependentColor(CSSPropertyBackgroundColor).isValid()) backgroundColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor); @@ -676,14 +676,12 @@ bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o, // background (themed or filled) appropriately. // FIXME: make sure we do the right thing if css background-clip is set. i.context->save(); - IntSize topLeft, topRight, bottomLeft, bottomRight; - o->style()->getBorderRadiiForRect(r, topLeft, topRight, bottomLeft, bottomRight); - i.context->addRoundedRectClip(r, topLeft, topRight, bottomLeft, bottomRight); + i.context->addRoundedRectClip(o->style()->getRoundedBorderFor(r)); } { const ThemeData& themeData = getThemeData(o); ThemePainter painter(i.context, r); - ChromiumBridge::paintTextField(painter.context(), + PlatformBridge::paintTextField(painter.context(), themeData.m_part, themeData.m_state, themeData.m_classicState, @@ -712,7 +710,7 @@ bool RenderThemeChromiumWin::paintInnerSpinButton(RenderObject* object, const Pa half.setHeight(rect.height() / 2); const ThemeData& upThemeData = getThemeData(object, SpinButtonUp); ThemePainter upPainter(info.context, half); - ChromiumBridge::paintSpinButton(upPainter.context(), + PlatformBridge::paintSpinButton(upPainter.context(), upThemeData.m_part, upThemeData.m_state, upThemeData.m_classicState, @@ -721,7 +719,7 @@ bool RenderThemeChromiumWin::paintInnerSpinButton(RenderObject* object, const Pa half.setY(rect.y() + rect.height() / 2); const ThemeData& downThemeData = getThemeData(object, SpinButtonDown); ThemePainter downPainter(info.context, half); - ChromiumBridge::paintSpinButton(downPainter.context(), + PlatformBridge::paintSpinButton(downPainter.context(), downThemeData.m_part, downThemeData.m_state, downThemeData.m_classicState, @@ -762,7 +760,7 @@ bool RenderThemeChromiumWin::paintProgressBar(RenderObject* o, const PaintInfo& IntRect valueRect = renderProgress->isDeterminate() ? determinateProgressValueRectFor(renderProgress, r) : IntRect(0, 0, 0, 0); double animatedSeconds = renderProgress->animationStartTime() ? WTF::currentTime() - renderProgress->animationStartTime() : 0; ThemePainter painter(i.context, r); - ChromiumBridge::paintProgressBar(painter.context(), r, valueRect, renderProgress->isDeterminate(), animatedSeconds); + PlatformBridge::paintProgressBar(painter.context(), r, valueRect, renderProgress->isDeterminate(), animatedSeconds); return false; } diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm index 0764093..605e958 100644 --- a/Source/WebCore/rendering/RenderThemeMac.mm +++ b/Source/WebCore/rendering/RenderThemeMac.mm @@ -1033,14 +1033,8 @@ void RenderThemeMac::paintMenuListButtonGradients(RenderObject* o, const PaintIn paintInfo.context->save(); - IntSize topLeftRadius; - IntSize topRightRadius; - IntSize bottomLeftRadius; - IntSize bottomRightRadius; - - o->style()->getBorderRadiiForRect(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); - - int radius = topLeftRadius.width(); + RoundedIntRect border = o->style()->getRoundedBorderFor(r); + int radius = border.radii().topLeft().width(); CGColorSpaceRef cspace = deviceRGBColorSpaceRef(); @@ -1063,27 +1057,27 @@ void RenderThemeMac::paintMenuListButtonGradients(RenderObject* o, const PaintIn RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.right(), r.y()), CGPointMake(r.right() - radius, r.y()), mainFunction.get(), false, false)); paintInfo.context->save(); CGContextClipToRect(context, r); - paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); + paintInfo.context->addRoundedRectClip(border); CGContextDrawShading(context, mainShading.get()); paintInfo.context->restore(); paintInfo.context->save(); CGContextClipToRect(context, topGradient); - paintInfo.context->addRoundedRectClip(enclosingIntRect(topGradient), topLeftRadius, topRightRadius, IntSize(), IntSize()); + paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(topGradient), border.radii().topLeft(), border.radii().topRight(), IntSize(), IntSize())); CGContextDrawShading(context, topShading.get()); paintInfo.context->restore(); if (!bottomGradient.isEmpty()) { paintInfo.context->save(); CGContextClipToRect(context, bottomGradient); - paintInfo.context->addRoundedRectClip(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bottomLeftRadius, bottomRightRadius); + paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), border.radii().bottomLeft(), border.radii().bottomRight())); CGContextDrawShading(context, bottomShading.get()); paintInfo.context->restore(); } paintInfo.context->save(); CGContextClipToRect(context, r); - paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); + paintInfo.context->addRoundedRectClip(border); CGContextDrawShading(context, leftShading.get()); CGContextDrawShading(context, rightShading.get()); paintInfo.context->restore(); @@ -1304,9 +1298,7 @@ bool RenderThemeMac::paintSliderTrack(RenderObject* o, const PaintInfo& paintInf mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.x(), bounds.y()), CGPointMake(bounds.x(), bounds.bottom()), mainFunction.get(), false, false)); IntSize radius(trackRadius, trackRadius); - paintInfo.context->addRoundedRectClip(bounds, - radius, radius, - radius, radius); + paintInfo.context->addRoundedRectClip(RoundedIntRect(bounds, radius, radius, radius, radius)); CGContextDrawShading(context, mainShading.get()); paintInfo.context->restore(); diff --git a/Source/WebCore/rendering/RenderThemeSafari.cpp b/Source/WebCore/rendering/RenderThemeSafari.cpp index 3c1dedc..47f627e 100644 --- a/Source/WebCore/rendering/RenderThemeSafari.cpp +++ b/Source/WebCore/rendering/RenderThemeSafari.cpp @@ -752,14 +752,8 @@ void RenderThemeSafari::paintMenuListButtonGradients(RenderObject* o, const Pain paintInfo.context->save(); - IntSize topLeftRadius; - IntSize topRightRadius; - IntSize bottomLeftRadius; - IntSize bottomRightRadius; - - o->style()->getBorderRadiiForRect(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); - - int radius = topLeftRadius.width(); + RoundedIntRect bound = o->style()->getRoundedBorderFor(r); + int radius = bound.radii().topLeft().width(); CGColorSpaceRef cspace = deviceRGBColorSpaceRef(); @@ -781,28 +775,28 @@ void RenderThemeSafari::paintMenuListButtonGradients(RenderObject* o, const Pain RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.right(), r.y()), CGPointMake(r.right() - radius, r.y()), mainFunction.get(), false, false)); paintInfo.context->save(); - CGContextClipToRect(context, r); - paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); + CGContextClipToRect(context, bound.rect()); + paintInfo.context->addRoundedRectClip(bound); CGContextDrawShading(context, mainShading.get()); paintInfo.context->restore(); paintInfo.context->save(); CGContextClipToRect(context, topGradient); - paintInfo.context->addRoundedRectClip(enclosingIntRect(topGradient), topLeftRadius, topRightRadius, IntSize(), IntSize()); + paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(topGradient), bound.radii().topLeft(), bound.radii().topRight(), IntSize(), IntSize())); CGContextDrawShading(context, topShading.get()); paintInfo.context->restore(); if (!bottomGradient.isEmpty()) { paintInfo.context->save(); CGContextClipToRect(context, bottomGradient); - paintInfo.context->addRoundedRectClip(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bottomLeftRadius, bottomRightRadius); + paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bound.radii().bottomLeft(), bound.radii().bottomRight())); CGContextDrawShading(context, bottomShading.get()); paintInfo.context->restore(); } paintInfo.context->save(); - CGContextClipToRect(context, r); - paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); + CGContextClipToRect(context, bound.rect()); + paintInfo.context->addRoundedRectClip(bound); CGContextDrawShading(context, leftShading.get()); CGContextDrawShading(context, rightShading.get()); paintInfo.context->restore(); @@ -958,34 +952,35 @@ const int trackRadius = 2; bool RenderThemeSafari::paintSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { - IntRect bounds = r; - - if (o->style()->appearance() == SliderHorizontalPart) { - bounds.setHeight(trackWidth); - bounds.setY(r.y() + r.height() / 2 - trackWidth / 2); - } else if (o->style()->appearance() == SliderVerticalPart) { - bounds.setWidth(trackWidth); - bounds.setX(r.x() + r.width() / 2 - trackWidth / 2); - } + IntSize radius(trackRadius, trackRadius); + RoundedIntRect bounds(r, radius, radius, radius, radius); + + if (o->style()->appearance() == SliderHorizontalPart) + bounds.setRect(IntRect(r.x(), + r.y() + r.height() / 2 - trackWidth / 2, + r.width(), + trackWidth)); + else if (o->style()->appearance() == SliderVerticalPart) + bounds.setRect(IntRect(r.x() + r.width() / 2 - trackWidth / 2, + r.y(), + trackWidth, + r.height())); CGContextRef context = paintInfo.context->platformContext(); CGColorSpaceRef cspace = deviceRGBColorSpaceRef(); paintInfo.context->save(); - CGContextClipToRect(context, bounds); + CGContextClipToRect(context, bounds.rect()); struct CGFunctionCallbacks mainCallbacks = { 0, TrackGradientInterpolate, NULL }; RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks)); RetainPtr<CGShadingRef> mainShading; if (o->style()->appearance() == SliderVerticalPart) - mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.x(), bounds.bottom()), CGPointMake(bounds.right(), bounds.bottom()), mainFunction.get(), false, false)); + mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().bottom()), CGPointMake(bounds.rect().right(), bounds.rect().bottom()), mainFunction.get(), false, false)); else - mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.x(), bounds.y()), CGPointMake(bounds.x(), bounds.bottom()), mainFunction.get(), false, false)); + mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().y()), CGPointMake(bounds.rect().x(), bounds.rect().bottom()), mainFunction.get(), false, false)); - IntSize radius(trackRadius, trackRadius); - paintInfo.context->addRoundedRectClip(bounds, - radius, radius, - radius, radius); + paintInfo.context->addRoundedRectClip(bounds); CGContextDrawShading(context, mainShading.get()); paintInfo.context->restore(); diff --git a/Source/WebCore/rendering/RenderThemeWinCE.cpp b/Source/WebCore/rendering/RenderThemeWinCE.cpp index 2c55f31..d4bff96 100644 --- a/Source/WebCore/rendering/RenderThemeWinCE.cpp +++ b/Source/WebCore/rendering/RenderThemeWinCE.cpp @@ -378,7 +378,7 @@ bool RenderThemeWinCE::paintSearchFieldCancelButton(RenderObject* o, const Paint int y = r.y() + (r.height() - cancelSize.height()) / 2 + 1; IntRect cancelBounds(IntPoint(x, y), cancelSize); paintInfo.context->save(); - paintInfo.context->addRoundedRectClip(cancelBounds, cancelRadius, cancelRadius, cancelRadius, cancelRadius); + paintInfo.context->addRoundedRectClip(RoundedIntRect(cancelBounds, cancelRadius, cancelRadius, cancelRadius, cancelRadius)); paintInfo.context->fillRect(cancelBounds, buttonColor, ColorSpaceDeviceRGB); // Draw the 'x' diff --git a/Source/WebCore/rendering/RenderView.h b/Source/WebCore/rendering/RenderView.h index 2915998..14b94ec 100644 --- a/Source/WebCore/rendering/RenderView.h +++ b/Source/WebCore/rendering/RenderView.h @@ -267,7 +267,8 @@ void toRenderView(const RenderView*); // Stack-based class to assist with LayoutState push/pop -class LayoutStateMaintainer : public Noncopyable { +class LayoutStateMaintainer { + WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer); public: // ctor to push now LayoutStateMaintainer(RenderView* view, RenderBox* root, IntSize offset, bool disableState = false, int pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) diff --git a/Source/WebCore/rendering/RenderWidget.cpp b/Source/WebCore/rendering/RenderWidget.cpp index 22283a0..d4b8ba6 100644 --- a/Source/WebCore/rendering/RenderWidget.cpp +++ b/Source/WebCore/rendering/RenderWidget.cpp @@ -275,11 +275,7 @@ void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty) // Push a clip if we have a border radius, since we want to round the foreground content that gets painted. paintInfo.context->save(); - - IntSize topLeft, topRight, bottomLeft, bottomRight; - style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); - - paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); + paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(borderRect)); } if (m_widget) { diff --git a/Source/WebCore/rendering/RenderWidgetProtector.h b/Source/WebCore/rendering/RenderWidgetProtector.h index 788304c..8bf6ac9 100644 --- a/Source/WebCore/rendering/RenderWidgetProtector.h +++ b/Source/WebCore/rendering/RenderWidgetProtector.h @@ -30,7 +30,8 @@ namespace WebCore { -class RenderWidgetProtector : private Noncopyable { +class RenderWidgetProtector { + WTF_MAKE_NONCOPYABLE(RenderWidgetProtector); public: RenderWidgetProtector(RenderWidget* object) : m_object(object) diff --git a/Source/WebCore/rendering/RootInlineBox.cpp b/Source/WebCore/rendering/RootInlineBox.cpp index 65130e7..e9e2029 100644 --- a/Source/WebCore/rendering/RootInlineBox.cpp +++ b/Source/WebCore/rendering/RootInlineBox.cpp @@ -266,6 +266,8 @@ int RootInlineBox::alignBoxesInBlockDirection(int heightOfBlock, GlyphOverflowAn heightOfBlock += annotationsAdjustment; } + maxHeight = max(0, maxHeight); + // Detect integer overflow. if (heightOfBlock > numeric_limits<int>::max() - maxHeight) return numeric_limits<int>::max(); diff --git a/Source/WebCore/rendering/ShadowElement.h b/Source/WebCore/rendering/ShadowElement.h index 2c1a69e..8bcb34e 100644 --- a/Source/WebCore/rendering/ShadowElement.h +++ b/Source/WebCore/rendering/ShadowElement.h @@ -39,16 +39,12 @@ class ShadowElement : public BaseElement { protected: ShadowElement(const QualifiedName& name, HTMLElement* shadowParent) : BaseElement(name, shadowParent->document()) - , m_shadowParent(shadowParent) { BaseElement::setShadowHost(shadowParent); } public: virtual void detach(); - -private: - RefPtr<HTMLElement> m_shadowParent; }; template<class BaseElement> diff --git a/Source/WebCore/rendering/TableLayout.h b/Source/WebCore/rendering/TableLayout.h index e0fa8ee..c5f61f6 100644 --- a/Source/WebCore/rendering/TableLayout.h +++ b/Source/WebCore/rendering/TableLayout.h @@ -21,13 +21,15 @@ #ifndef TableLayout_h #define TableLayout_h +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> namespace WebCore { class RenderTable; -class TableLayout : public Noncopyable { +class TableLayout { + WTF_MAKE_NONCOPYABLE(TableLayout); WTF_MAKE_FAST_ALLOCATED; public: TableLayout(RenderTable* table) : m_table(table) diff --git a/Source/WebCore/rendering/TextControlInnerElements.cpp b/Source/WebCore/rendering/TextControlInnerElements.cpp index 5b8712d..7b1b36f 100644 --- a/Source/WebCore/rendering/TextControlInnerElements.cpp +++ b/Source/WebCore/rendering/TextControlInnerElements.cpp @@ -119,7 +119,8 @@ void TextControlInnerElement::detach() { HTMLDivElement::detach(); // FIXME: Remove once shadow DOM uses Element::setShadowRoot(). - setShadowHost(0); + if (shadowHost()) + setShadowHost(0); } // ---------------------------- @@ -243,7 +244,7 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event) input->setValue(""); if (!oldValue.isEmpty()) { toRenderTextControl(input->renderer())->setChangedSinceLastChangeEvent(true); - input->dispatchEvent(Event::create(eventNames().inputEvent, true, false)); + input->dispatchFormControlInputEvent(); } input->onSearch(); event->setDefaultHandled(); @@ -433,9 +434,13 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event) if (event->type() == eventNames().clickEvent) { switch (m_state) { - case Idle: - if (speechInput()->startRecognition(m_listenerId, input->renderer()->absoluteBoundingBoxRect(), input->computeInheritedLanguage(), input->getAttribute(webkitgrammarAttr))) - setState(Recording); + case Idle: { + AtomicString language = input->computeInheritedLanguage(); + String grammar = input->getAttribute(webkitgrammarAttr); + IntRect rect = input->renderer()->absoluteBoundingBoxRect(); + if (speechInput()->startRecognition(m_listenerId, rect, language, grammar, document()->securityOrigin())) + setState(Recording); + } break; case Recording: speechInput()->stopRecording(m_listenerId); diff --git a/Source/WebCore/rendering/TransformState.h b/Source/WebCore/rendering/TransformState.h index 0b4ca46..36fc6ec 100644 --- a/Source/WebCore/rendering/TransformState.h +++ b/Source/WebCore/rendering/TransformState.h @@ -31,14 +31,14 @@ #include "FloatQuad.h" #include "IntSize.h" #include "TransformationMatrix.h" -#include <wtf/Noncopyable.h> #include <wtf/PassRefPtr.h> #include <wtf/OwnPtr.h> #include <wtf/RefCounted.h> namespace WebCore { -class TransformState : public Noncopyable { +class TransformState { + WTF_MAKE_NONCOPYABLE(TransformState); public: enum TransformDirection { ApplyTransformDirection, UnapplyInverseTransformDirection }; enum TransformAccumulation { FlattenTransform, AccumulateTransform }; diff --git a/Source/WebCore/rendering/VerticalPositionCache.h b/Source/WebCore/rendering/VerticalPositionCache.h index 4deaef5..b25b2f6 100644 --- a/Source/WebCore/rendering/VerticalPositionCache.h +++ b/Source/WebCore/rendering/VerticalPositionCache.h @@ -38,7 +38,8 @@ const int PositionTop = -0x7fffffff; const int PositionBottom = 0x7fffffff; const int PositionUndefined = 0x80000000; -class VerticalPositionCache : public Noncopyable { +class VerticalPositionCache { + WTF_MAKE_NONCOPYABLE(VerticalPositionCache); public: VerticalPositionCache() { } diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp index 7117618..9d80fbe 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp @@ -39,12 +39,12 @@ namespace WebCore { using namespace MathMLNames; -static const double gHorizontalPad = 0.2; -static const double gLineThin = 0.33; -static const double gLineMedium = 1.; -static const double gLineThick = 3.; -static const double gFractionBarWidth = 0.05; -static const double gDenominatorPad = 0.1; +static const float gHorizontalPad = 0.2f; +static const float gLineThin = 0.33f; +static const float gLineMedium = 1.f; +static const float gLineThick = 3.f; +static const float gFractionBarWidth = 0.05f; +static const float gDenominatorPad = 0.1f; RenderMathMLFraction::RenderMathMLFraction(Element* fraction) : RenderMathMLBlock(fraction) @@ -125,7 +125,7 @@ void RenderMathMLFraction::layout() // Adjust the fraction line thickness for the zoom if (lastChild() && lastChild()->isRenderBlock()) - m_lineThickness *= ceil(gFractionBarWidth * style()->fontSize()); + m_lineThickness *= ceilf(gFractionBarWidth * style()->fontSize()); RenderBlock::layout(); @@ -158,7 +158,7 @@ void RenderMathMLFraction::paint(PaintInfo& info, int tx, int ty) info.context->save(); - info.context->setStrokeThickness(static_cast<float>(m_lineThickness)); + info.context->setStrokeThickness(m_lineThickness); info.context->setStrokeStyle(SolidStroke); info.context->setStrokeColor(style()->visitedDependentColor(CSSPropertyColor), ColorSpaceSRGB); diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFraction.h b/Source/WebCore/rendering/mathml/RenderMathMLFraction.h index 2a03f81..c96d56d 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLFraction.h +++ b/Source/WebCore/rendering/mathml/RenderMathMLFraction.h @@ -43,7 +43,7 @@ public: protected: virtual void layout(); private: - double m_lineThickness; + float m_lineThickness; }; } diff --git a/Source/WebCore/rendering/style/BorderData.h b/Source/WebCore/rendering/style/BorderData.h index 03635d9..0e50edb 100644 --- a/Source/WebCore/rendering/style/BorderData.h +++ b/Source/WebCore/rendering/style/BorderData.h @@ -26,6 +26,7 @@ #define BorderData_h #include "BorderValue.h" +#include "IntRect.h" #include "LengthSize.h" #include "NinePieceImage.h" @@ -109,7 +110,7 @@ public: const LengthSize& topRight() const { return m_topRight; } const LengthSize& bottomLeft() const { return m_bottomLeft; } const LengthSize& bottomRight() const { return m_bottomRight; } - + private: BorderValue m_left; BorderValue m_right; diff --git a/Source/WebCore/rendering/style/ContentData.h b/Source/WebCore/rendering/style/ContentData.h index 4f964a2..15f6912 100644 --- a/Source/WebCore/rendering/style/ContentData.h +++ b/Source/WebCore/rendering/style/ContentData.h @@ -33,7 +33,8 @@ namespace WebCore { class StyleImage; -struct ContentData : Noncopyable { +struct ContentData { + WTF_MAKE_NONCOPYABLE(ContentData); WTF_MAKE_FAST_ALLOCATED; public: ContentData() : m_type(CONTENT_NONE) diff --git a/Source/WebCore/rendering/style/CounterContent.h b/Source/WebCore/rendering/style/CounterContent.h index 52757ad..814039e 100644 --- a/Source/WebCore/rendering/style/CounterContent.h +++ b/Source/WebCore/rendering/style/CounterContent.h @@ -30,7 +30,8 @@ namespace WebCore { -class CounterContent : public FastAllocBase { +class CounterContent { + WTF_MAKE_FAST_ALLOCATED; public: CounterContent(const AtomicString& identifier, EListStyleType style, const AtomicString& separator) : m_identifier(identifier) diff --git a/Source/WebCore/rendering/style/FillLayer.h b/Source/WebCore/rendering/style/FillLayer.h index 49fb294..847e8df 100644 --- a/Source/WebCore/rendering/style/FillLayer.h +++ b/Source/WebCore/rendering/style/FillLayer.h @@ -59,7 +59,8 @@ struct FillSize { LengthSize size; }; -class FillLayer : public FastAllocBase { +class FillLayer { + WTF_MAKE_FAST_ALLOCATED; public: FillLayer(EFillLayerType); ~FillLayer(); diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp index 4665e52..2836fb9 100644 --- a/Source/WebCore/rendering/style/RenderStyle.cpp +++ b/Source/WebCore/rendering/style/RenderStyle.cpp @@ -744,7 +744,19 @@ void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add) rareData->m_boxShadow.set(shadowData); } -static void constrainCornerRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) +static RoundedIntRect::Radii calcRadiiFor(const BorderData& border, int width, int height) +{ + return RoundedIntRect::Radii(IntSize(border.topLeft().width().calcValue(width), + border.topLeft().height().calcValue(height)), + IntSize(border.topRight().width().calcValue(width), + border.topRight().height().calcValue(height)), + IntSize(border.bottomLeft().width().calcValue(width), + border.bottomLeft().height().calcValue(height)), + IntSize(border.bottomRight().width().calcValue(width), + border.bottomRight().height().calcValue(height))); +} + +static float calcConstraintScaleFor(const IntRect& rect, const RoundedIntRect::Radii& radii) { // Constrain corner radii using CSS3 rules: // http://www.w3.org/TR/css3-background/#the-border-radius @@ -753,75 +765,43 @@ static void constrainCornerRadiiForRect(const IntRect& r, IntSize& topLeft, IntS unsigned radiiSum; // top - radiiSum = static_cast<unsigned>(topLeft.width()) + static_cast<unsigned>(topRight.width()); // Casts to avoid integer overflow. - if (radiiSum > static_cast<unsigned>(r.width())) - factor = min(static_cast<float>(r.width()) / radiiSum, factor); + radiiSum = static_cast<unsigned>(radii.topLeft().width()) + static_cast<unsigned>(radii.topRight().width()); // Casts to avoid integer overflow. + if (radiiSum > static_cast<unsigned>(rect.width())) + factor = std::min(static_cast<float>(rect.width()) / radiiSum, factor); // bottom - radiiSum = static_cast<unsigned>(bottomLeft.width()) + static_cast<unsigned>(bottomRight.width()); - if (radiiSum > static_cast<unsigned>(r.width())) - factor = min(static_cast<float>(r.width()) / radiiSum, factor); + radiiSum = static_cast<unsigned>(radii.bottomLeft().width()) + static_cast<unsigned>(radii.bottomRight().width()); + if (radiiSum > static_cast<unsigned>(rect.width())) + factor = std::min(static_cast<float>(rect.width()) / radiiSum, factor); // left - radiiSum = static_cast<unsigned>(topLeft.height()) + static_cast<unsigned>(bottomLeft.height()); - if (radiiSum > static_cast<unsigned>(r.height())) - factor = min(static_cast<float>(r.height()) / radiiSum, factor); + radiiSum = static_cast<unsigned>(radii.topLeft().height()) + static_cast<unsigned>(radii.bottomLeft().height()); + if (radiiSum > static_cast<unsigned>(rect.height())) + factor = std::min(static_cast<float>(rect.height()) / radiiSum, factor); // right - radiiSum = static_cast<unsigned>(topRight.height()) + static_cast<unsigned>(bottomRight.height()); - if (radiiSum > static_cast<unsigned>(r.height())) - factor = min(static_cast<float>(r.height()) / radiiSum, factor); + radiiSum = static_cast<unsigned>(radii.topRight().height()) + static_cast<unsigned>(radii.bottomRight().height()); + if (radiiSum > static_cast<unsigned>(rect.height())) + factor = std::min(static_cast<float>(rect.height()) / radiiSum, factor); - // Scale all radii by f if necessary. - if (factor < 1) { - // If either radius on a corner becomes zero, reset both radii on that corner. - topLeft.scale(factor); - if (!topLeft.width() || !topLeft.height()) - topLeft = IntSize(); - topRight.scale(factor); - if (!topRight.width() || !topRight.height()) - topRight = IntSize(); - bottomLeft.scale(factor); - if (!bottomLeft.width() || !bottomLeft.height()) - bottomLeft = IntSize(); - bottomRight.scale(factor); - if (!bottomRight.width() || !bottomRight.height()) - bottomRight = IntSize(); - } + ASSERT(factor <= 1); + return factor; } -void RenderStyle::getBorderRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const +RoundedIntRect RenderStyle::getRoundedBorderFor(const IntRect& rect) const { - topLeft = IntSize(surround->border.topLeft().width().calcValue(r.width()), surround->border.topLeft().height().calcValue(r.height())); - topRight = IntSize(surround->border.topRight().width().calcValue(r.width()), surround->border.topRight().height().calcValue(r.height())); - - bottomLeft = IntSize(surround->border.bottomLeft().width().calcValue(r.width()), surround->border.bottomLeft().height().calcValue(r.height())); - bottomRight = IntSize(surround->border.bottomRight().width().calcValue(r.width()), surround->border.bottomRight().height().calcValue(r.height())); - - constrainCornerRadiiForRect(r, topLeft, topRight, bottomLeft, bottomRight); + RoundedIntRect::Radii radii = calcRadiiFor(surround->border, rect.width(), rect.height()); + radii.scale(calcConstraintScaleFor(rect, radii)); + return RoundedIntRect(rect, radii); } -void RenderStyle::getInnerBorderRadiiForRectWithBorderWidths(const IntRect& innerRect, unsigned short topWidth, unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth, IntSize& innerTopLeft, IntSize& innerTopRight, IntSize& innerBottomLeft, IntSize& innerBottomRight) const +RoundedIntRect RenderStyle::getRoundedInnerBorderWithBorderWidths(const IntRect& innerRect, unsigned short topWidth, + unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth) const { - innerTopLeft = IntSize(surround->border.topLeft().width().calcValue(innerRect.width()), surround->border.topLeft().height().calcValue(innerRect.height())); - innerTopRight = IntSize(surround->border.topRight().width().calcValue(innerRect.width()), surround->border.topRight().height().calcValue(innerRect.height())); - innerBottomLeft = IntSize(surround->border.bottomLeft().width().calcValue(innerRect.width()), surround->border.bottomLeft().height().calcValue(innerRect.height())); - innerBottomRight = IntSize(surround->border.bottomRight().width().calcValue(innerRect.width()), surround->border.bottomRight().height().calcValue(innerRect.height())); - - - innerTopLeft.setWidth(max(0, innerTopLeft.width() - leftWidth)); - innerTopLeft.setHeight(max(0, innerTopLeft.height() - topWidth)); - - innerTopRight.setWidth(max(0, innerTopRight.width() - rightWidth)); - innerTopRight.setHeight(max(0, innerTopRight.height() - topWidth)); - - innerBottomLeft.setWidth(max(0, innerBottomLeft.width() - leftWidth)); - innerBottomLeft.setHeight(max(0, innerBottomLeft.height() - bottomWidth)); - - innerBottomRight.setWidth(max(0, innerBottomRight.width() - rightWidth)); - innerBottomRight.setHeight(max(0, innerBottomRight.height() - bottomWidth)); - - constrainCornerRadiiForRect(innerRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight); + RoundedIntRect::Radii radii = calcRadiiFor(surround->border, innerRect.width(), innerRect.height()); + radii.shrink(topWidth, bottomWidth, leftWidth, rightWidth); + radii.scale(calcConstraintScaleFor(innerRect, radii)); + return RoundedIntRect(innerRect, radii); } const CounterDirectiveMap* RenderStyle::counterDirectives() const diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 14329bc..9d5239b 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -43,6 +43,8 @@ #include "NinePieceImage.h" #include "OutlineValue.h" #include "RenderStyleConstants.h" +#include "RoundedIntRect.h" +#include "ShadowData.h" #include "StyleBackgroundData.h" #include "StyleBoxData.h" #include "StyleFlexibleBoxData.h" @@ -862,13 +864,10 @@ public: { setBorderRadius(LengthSize(Length(s.width(), Fixed), Length(s.height(), Fixed))); } - - void getBorderRadiiForRect(const IntRect&, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const; - void getInnerBorderRadiiForRectWithBorderWidths(const IntRect&, unsigned short topWidth, - unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth, - IntSize& innerTopLeft, IntSize& innerTopRight, IntSize& innerBottomLeft, - IntSize& innerBottomRight) const; + RoundedIntRect getRoundedBorderFor(const IntRect&) const; + RoundedIntRect getRoundedInnerBorderWithBorderWidths(const IntRect&, unsigned short topWidth, + unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth) const; void setBorderLeftWidth(unsigned short v) { SET_VAR(surround, border.m_left.m_width, v) } void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.m_left.m_style, v) } @@ -1212,11 +1211,11 @@ public: bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; } void setChildrenAffectedByBackwardPositionalRules() { m_childrenAffectedByBackwardPositionalRules = true; } bool firstChildState() const { return m_firstChildState; } - void setFirstChildState() { m_firstChildState = true; } + void setFirstChildState() { m_unique = true; m_firstChildState = true; } bool lastChildState() const { return m_lastChildState; } - void setLastChildState() { m_lastChildState = true; } + void setLastChildState() { m_unique = true; m_lastChildState = true; } unsigned childIndex() const { return m_childIndex; } - void setChildIndex(unsigned index) { m_childIndex = index; } + void setChildIndex(unsigned index) { m_unique = true; m_childIndex = index; } const Color visitedDependentColor(int colorProperty) const; diff --git a/Source/WebCore/rendering/style/ShadowData.h b/Source/WebCore/rendering/style/ShadowData.h index fb5926d..0be3fc1 100644 --- a/Source/WebCore/rendering/style/ShadowData.h +++ b/Source/WebCore/rendering/style/ShadowData.h @@ -26,7 +26,6 @@ #define ShadowData_h #include "Color.h" -#include <wtf/FastAllocBase.h> namespace WebCore { @@ -37,7 +36,8 @@ enum ShadowStyle { Normal, Inset }; // This struct holds information about shadows for the text-shadow and box-shadow properties. -class ShadowData : public FastAllocBase { +class ShadowData { + WTF_MAKE_FAST_ALLOCATED; public: ShadowData() : m_x(0) diff --git a/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h index 7f862a7..99861d8 100644 --- a/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h +++ b/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h @@ -35,7 +35,9 @@ namespace WebCore { -struct ClipperData : FastAllocBase { +struct ClipperData { + WTF_MAKE_FAST_ALLOCATED; +public: OwnPtr<ImageBuffer> clipMaskImage; }; diff --git a/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp index 2a8a47f..0215e8e 100644 --- a/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp @@ -182,8 +182,8 @@ AffineTransform RenderSVGResourceContainer::transformOnNonScalingStroke(RenderOb return resourceTransform; SVGStyledTransformableElement* element = static_cast<SVGStyledTransformableElement*>(object->node()); - AffineTransform transform = resourceTransform; - transform.multiply(element->getScreenCTM(SVGLocatable::DisallowStyleUpdate)); + AffineTransform transform = element->getScreenCTM(SVGLocatable::DisallowStyleUpdate); + transform *= resourceTransform; return transform; } diff --git a/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp b/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp index 5ad5d84..9f2bb8d 100644 --- a/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp @@ -133,7 +133,7 @@ static inline AffineTransform clipToTextMask(GraphicsContext* context, matrix.translate(maskBoundingBox.x(), maskBoundingBox.y()); matrix.scaleNonUniform(maskBoundingBox.width(), maskBoundingBox.height()); } - matrix.multLeft(gradientTransform); + matrix *= gradientTransform; return matrix; } #endif @@ -190,7 +190,7 @@ bool RenderSVGResourceGradient::applyResource(RenderObject* object, RenderStyle* AffineTransform gradientTransform; calculateGradientTransform(gradientTransform); - gradientData->userspaceTransform.multLeft(gradientTransform); + gradientData->userspaceTransform *= gradientTransform; gradientData->gradient->setGradientSpaceTransform(gradientData->userspaceTransform); } diff --git a/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp index 330a21a..1b14ce4 100644 --- a/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp @@ -139,7 +139,7 @@ bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle* AffineTransform patternTransform = m_attributes.patternTransform(); if (!patternTransform.isIdentity()) - patternData->transform.multiply(patternTransform); + patternData->transform = patternTransform * patternData->transform; patternData->pattern->setPatternSpaceTransform(patternData->transform); } @@ -228,7 +228,7 @@ bool RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer, if (patternBoundaries.width() <= 0 || patternBoundaries.height() <= 0) return false; - AffineTransform viewBoxCTM = patternElement->viewBoxToViewTransform(patternElement->viewBox(), patternElement->preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height()); + AffineTransform viewBoxCTM = patternElement->viewBoxToViewTransform(attributes.viewBox(), attributes.preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height()); // Apply viewBox/objectBoundingBox transformations. if (!viewBoxCTM.isIdentity()) diff --git a/Source/WebCore/rendering/svg/RenderSVGRoot.cpp b/Source/WebCore/rendering/svg/RenderSVGRoot.cpp index aa87b09..3a8dce9 100644 --- a/Source/WebCore/rendering/svg/RenderSVGRoot.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGRoot.cpp @@ -246,7 +246,7 @@ AffineTransform RenderSVGRoot::localToBorderBoxTransform() const float scale = svg->currentScale(); FloatPoint translate = svg->currentTranslate(); AffineTransform ctm(scale, 0, 0, scale, borderAndPadding.width() + translate.x(), borderAndPadding.height() + translate.y()); - return svg->viewBoxToViewTransform(width() / scale, height() / scale) * ctm; + return ctm * svg->viewBoxToViewTransform(width() / scale, height() / scale); } IntSize RenderSVGRoot::parentOriginToBorderBox() const diff --git a/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp b/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp index f0657af..6726694 100644 --- a/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp +++ b/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp @@ -43,7 +43,7 @@ void SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem( absoluteTransform = currentContentTransformation(); while (current) { - absoluteTransform.multiply(current->localToParentTransform()); + absoluteTransform = current->localToParentTransform() * absoluteTransform; if (current->isSVGRoot()) break; current = current->parent(); @@ -83,7 +83,7 @@ void SVGImageBufferTools::renderSubtreeToImageBuffer(ImageBuffer* image, RenderO AffineTransform& contentTransformation = currentContentTransformation(); AffineTransform savedContentTransformation = contentTransformation; - contentTransformation.multiply(subtreeContentTransformation); + contentTransformation = subtreeContentTransformation * contentTransformation; item->layoutIfNeeded(); item->paint(info, 0, 0); diff --git a/Source/WebCore/rendering/svg/SVGImageBufferTools.h b/Source/WebCore/rendering/svg/SVGImageBufferTools.h index cfb15b2..11577c0 100644 --- a/Source/WebCore/rendering/svg/SVGImageBufferTools.h +++ b/Source/WebCore/rendering/svg/SVGImageBufferTools.h @@ -32,7 +32,8 @@ class FloatSize; class GraphicsContext; class RenderObject; -class SVGImageBufferTools : public Noncopyable { +class SVGImageBufferTools { + WTF_MAKE_NONCOPYABLE(SVGImageBufferTools); public: static bool createImageBuffer(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ColorSpace); static void renderSubtreeToImageBuffer(ImageBuffer*, RenderObject*, const AffineTransform&); diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp index f370310..2879f20 100644 --- a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp +++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp @@ -31,6 +31,7 @@ #include "RenderSVGResource.h" #include "RenderSVGResourceSolidColor.h" #include "SVGRootInlineBox.h" +#include "TextRun.h" using namespace std; diff --git a/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h b/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h index 0eb3689..32317b9 100644 --- a/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h +++ b/Source/WebCore/rendering/svg/SVGMarkerLayoutInfo.h @@ -21,6 +21,7 @@ #define SVGMarkerLayoutInfo_h #if ENABLE(SVG) +#include "AffineTransform.h" #include "RenderObject.h" #include "SVGMarkerData.h" #include <wtf/Noncopyable.h> @@ -42,7 +43,8 @@ struct MarkerLayout { AffineTransform matrix; }; -class SVGMarkerLayoutInfo : public Noncopyable { +class SVGMarkerLayoutInfo { + WTF_MAKE_NONCOPYABLE(SVGMarkerLayoutInfo); public: SVGMarkerLayoutInfo(); ~SVGMarkerLayoutInfo(); diff --git a/Source/WebCore/rendering/svg/SVGResources.h b/Source/WebCore/rendering/svg/SVGResources.h index dd328b8..48cca23 100644 --- a/Source/WebCore/rendering/svg/SVGResources.h +++ b/Source/WebCore/rendering/svg/SVGResources.h @@ -38,7 +38,8 @@ class RenderSVGResourceMasker; class SVGRenderStyle; // Holds a set of resources associated with a RenderObject -class SVGResources : public Noncopyable { +class SVGResources { + WTF_MAKE_NONCOPYABLE(SVGResources); WTF_MAKE_FAST_ALLOCATED; public: SVGResources(); diff --git a/Source/WebCore/rendering/svg/SVGResourcesCache.h b/Source/WebCore/rendering/svg/SVGResourcesCache.h index 30eaeca..bc73f4d 100644 --- a/Source/WebCore/rendering/svg/SVGResourcesCache.h +++ b/Source/WebCore/rendering/svg/SVGResourcesCache.h @@ -31,7 +31,8 @@ class RenderStyle; class RenderSVGResourceContainer; class SVGResources; -class SVGResourcesCache : public Noncopyable { +class SVGResourcesCache { + WTF_MAKE_NONCOPYABLE(SVGResourcesCache); WTF_MAKE_FAST_ALLOCATED; public: SVGResourcesCache(); ~SVGResourcesCache(); diff --git a/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h b/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h index 0653304..099f91c 100644 --- a/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h +++ b/Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h @@ -29,7 +29,8 @@ class RenderObject; class RenderSVGResourceContainer; class SVGResources; -class SVGResourcesCycleSolver : public Noncopyable { +class SVGResourcesCycleSolver { + WTF_MAKE_NONCOPYABLE(SVGResourcesCycleSolver); public: SVGResourcesCycleSolver(RenderObject*, SVGResources*); ~SVGResourcesCycleSolver(); diff --git a/Source/WebCore/rendering/svg/SVGTextChunkBuilder.h b/Source/WebCore/rendering/svg/SVGTextChunkBuilder.h index 36342e7..321f391 100644 --- a/Source/WebCore/rendering/svg/SVGTextChunkBuilder.h +++ b/Source/WebCore/rendering/svg/SVGTextChunkBuilder.h @@ -35,7 +35,8 @@ struct SVGTextFragment; // Phase two performed the actual per-character layout, computing the final positions for each character, stored in the SVGInlineTextBox objects (SVGTextFragment). // Phase three performs all modifications that have to be applied to each individual text chunk (text-anchor & textLength). -class SVGTextChunkBuilder : public Noncopyable { +class SVGTextChunkBuilder { + WTF_MAKE_NONCOPYABLE(SVGTextChunkBuilder); public: SVGTextChunkBuilder(); diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h b/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h index f29ac64..c68185b 100644 --- a/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h +++ b/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h @@ -38,7 +38,8 @@ class RenderSVGText; // to create the InlineBox tree based on text chunk boundaries & BiDi information. // The second layout phase is carried out by SVGTextLayoutEngine. -class SVGTextLayoutAttributesBuilder : public Noncopyable { +class SVGTextLayoutAttributesBuilder { + WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder); public: SVGTextLayoutAttributesBuilder(); void buildLayoutAttributesForTextSubtree(RenderSVGText*); diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp b/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp index 7eefad6..3b28d2b 100644 --- a/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp +++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp @@ -321,7 +321,7 @@ void SVGTextLayoutEngine::finalizeTransformMatrices(Vector<SVGInlineTextBox*>& b if (transform.isIdentity()) transform = textBoxTransformation; else - transform.multiply(textBoxTransformation); + transform = textBoxTransformation * transform; } } diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngine.h b/Source/WebCore/rendering/svg/SVGTextLayoutEngine.h index ad058d8..631e4cd 100644 --- a/Source/WebCore/rendering/svg/SVGTextLayoutEngine.h +++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngine.h @@ -44,7 +44,8 @@ class SVGRenderStyle; // RenderSVGInlineText renderers to compute the final positions for each character // which are stored in the SVGInlineTextBox objects. -class SVGTextLayoutEngine : public Noncopyable { +class SVGTextLayoutEngine { + WTF_MAKE_NONCOPYABLE(SVGTextLayoutEngine); public: SVGTextLayoutEngine(); SVGTextChunkBuilder& chunkLayoutBuilder() { return m_chunkLayoutBuilder; } diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h index d753b39..6794bf3 100644 --- a/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h +++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h @@ -33,7 +33,8 @@ class SVGRenderStyle; class SVGTextMetrics; // Helper class used by SVGTextLayoutEngine to handle 'alignment-baseline' / 'dominant-baseline' and 'baseline-shift'. -class SVGTextLayoutEngineBaseline : public Noncopyable { +class SVGTextLayoutEngineBaseline { + WTF_MAKE_NONCOPYABLE(SVGTextLayoutEngineBaseline); public: SVGTextLayoutEngineBaseline(const Font&); diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.h b/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.h index 0a6d736..71d4707 100644 --- a/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.h +++ b/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.h @@ -30,7 +30,8 @@ class SVGRenderStyle; class SVGElement; // Helper class used by SVGTextLayoutEngine to handle 'kerning' / 'letter-spacing' and 'word-spacing'. -class SVGTextLayoutEngineSpacing : public Noncopyable { +class SVGTextLayoutEngineSpacing { + WTF_MAKE_NONCOPYABLE(SVGTextLayoutEngineSpacing); public: SVGTextLayoutEngineSpacing(const Font&); diff --git a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp b/Source/WebCore/rendering/svg/SVGTextMetrics.cpp index 58d0ad9..ec8c2c6 100644 --- a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp +++ b/Source/WebCore/rendering/svg/SVGTextMetrics.cpp @@ -23,6 +23,7 @@ #include "SVGTextMetrics.h" #include "RenderSVGInlineText.h" +#include "TextRun.h" namespace WebCore { diff --git a/Source/WebCore/storage/DatabaseTask.h b/Source/WebCore/storage/DatabaseTask.h index b61e465..e1df591 100644 --- a/Source/WebCore/storage/DatabaseTask.h +++ b/Source/WebCore/storage/DatabaseTask.h @@ -43,7 +43,8 @@ namespace WebCore { // Can be used to wait until DatabaseTask is completed. // Has to be passed into DatabaseTask::create to be associated with the task. -class DatabaseTaskSynchronizer : public Noncopyable { +class DatabaseTaskSynchronizer { + WTF_MAKE_NONCOPYABLE(DatabaseTaskSynchronizer); public: DatabaseTaskSynchronizer(); @@ -67,7 +68,8 @@ private: #endif }; -class DatabaseTask : public Noncopyable { +class DatabaseTask { + WTF_MAKE_NONCOPYABLE(DatabaseTask); WTF_MAKE_FAST_ALLOCATED; public: virtual ~DatabaseTask(); diff --git a/Source/WebCore/storage/DatabaseTracker.h b/Source/WebCore/storage/DatabaseTracker.h index 7145e6b..a1a5bdf 100644 --- a/Source/WebCore/storage/DatabaseTracker.h +++ b/Source/WebCore/storage/DatabaseTracker.h @@ -56,7 +56,8 @@ class DatabaseTrackerClient; struct SecurityOriginTraits; #endif // !PLATFORM(CHROMIUM) -class DatabaseTracker : public Noncopyable { +class DatabaseTracker { + WTF_MAKE_NONCOPYABLE(DatabaseTracker); WTF_MAKE_FAST_ALLOCATED; public: static void initializeTracker(const String& databasePath); static DatabaseTracker& tracker(); diff --git a/Source/WebCore/storage/IDBDatabase.cpp b/Source/WebCore/storage/IDBDatabase.cpp index 7a9141a..33f004b 100644 --- a/Source/WebCore/storage/IDBDatabase.cpp +++ b/Source/WebCore/storage/IDBDatabase.cpp @@ -73,12 +73,6 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co options.getKeyBool("autoIncrement", autoIncrement); // FIXME: Look up evictable and pass that on as well. - if (autoIncrement) { - // FIXME: Implement support for auto increment. - ec = IDBDatabaseException::UNKNOWN_ERR; - return 0; - } - RefPtr<IDBObjectStoreBackendInterface> objectStore = m_backend->createObjectStore(name, keyPath, autoIncrement, m_setVersionTransaction.get(), ec); if (!objectStore) { ASSERT(ec); diff --git a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp index 396f544..6b162ef 100644 --- a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp +++ b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp @@ -59,6 +59,7 @@ IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBSQLiteDatabase* database , m_name(name) , m_keyPath(keyPath) , m_autoIncrement(autoIncrement) + , m_autoIncrementNumber(-1) { loadIndexes(); } @@ -69,6 +70,7 @@ IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBSQLiteDatabase* database , m_name(name) , m_keyPath(keyPath) , m_autoIncrement(autoIncrement) + , m_autoIncrementNumber(-1) { } @@ -108,12 +110,12 @@ void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr< bindWhereClause(query, objectStore->id(), key.get()); if (query.step() != SQLResultRow) { - callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the object store.")); + callbacks->onSuccess(SerializedScriptValue::undefinedValue()); return; } ASSERT((key->type() == IDBKey::StringType) != query.isColumnNull(0)); - // FIXME: Implement date. + ASSERT((key->type() == IDBKey::DateType) != query.isColumnNull(1)); ASSERT((key->type() == IDBKey::NumberType) != query.isColumnNull(2)); callbacks->onSuccess(SerializedScriptValue::createFromWire(query.getColumnText(3))); @@ -200,22 +202,36 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr< RefPtr<SerializedScriptValue> value = prpValue; RefPtr<IDBKey> key = prpKey; - // FIXME: Support auto-increment. + if (!objectStore->m_keyPath.isNull() && key) { + callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "A key was supplied for an objectStore that has a keyPath.")); + return; + } + + if (objectStore->autoIncrement() && key) { + callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "A key was supplied for an objectStore that is using auto increment.")); + return; + } + + if (objectStore->autoIncrement()) { + key = objectStore->genAutoIncrementKey(); - if (!objectStore->m_keyPath.isNull()) { - if (key) { - callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "A key was supplied for an objectStore that has a keyPath.")); + if (!objectStore->m_keyPath.isNull()) { + // FIXME: Inject the generated key into the object. + callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Adding data to object stores with auto increment and in-line keys not yet supported.")); return; } + } else if (!objectStore->m_keyPath.isNull()) { key = fetchKeyFromKeyPath(value.get(), objectStore->m_keyPath); + if (!key) { - callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "The key could not be fetched from the keyPath.")); + callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "The key could not be fetched from the keyPath.")); return; } } else if (!key) { callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "No key supplied.")); return; } + if (key->type() == IDBKey::NullType) { callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "NULL key is not allowed.")); return; @@ -511,6 +527,27 @@ void IDBObjectStoreBackendImpl::addIndexToMap(ScriptExecutionContext*, PassRefPt objectStore->m_indexes.set(indexPtr->name(), indexPtr); } +PassRefPtr<IDBKey> IDBObjectStoreBackendImpl::genAutoIncrementKey() +{ + if (m_autoIncrementNumber > 0) + return IDBKey::createNumber(m_autoIncrementNumber++); + + String sql = "SELECT max(keyNumber) + 1 FROM ObjectStoreData WHERE objectStoreId = ? AND keyString IS NULL AND keyDate IS NULL"; + + SQLiteStatement query(sqliteDatabase(), sql); + bool ok = query.prepare() == SQLResultOk; + ASSERT_UNUSED(ok, ok); + + query.bindInt64(1, id()); + + if (query.step() != SQLResultRow || query.isColumnNull(0)) + m_autoIncrementNumber = 1; + else + m_autoIncrementNumber = static_cast<int>(query.getColumnDouble(0)); + + return IDBKey::createNumber(m_autoIncrementNumber++); +} + } // namespace WebCore diff --git a/Source/WebCore/storage/IDBObjectStoreBackendImpl.h b/Source/WebCore/storage/IDBObjectStoreBackendImpl.h index 2ab42f2..9fb1b7c 100644 --- a/Source/WebCore/storage/IDBObjectStoreBackendImpl.h +++ b/Source/WebCore/storage/IDBObjectStoreBackendImpl.h @@ -82,6 +82,7 @@ private: void loadIndexes(); SQLiteDatabase& sqliteDatabase() const; + PassRefPtr<IDBKey> genAutoIncrementKey(); static void getInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>); static void putInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, bool addOnly, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); @@ -103,6 +104,7 @@ private: typedef HashMap<String, RefPtr<IDBIndexBackendImpl> > IndexMap; IndexMap m_indexes; + int m_autoIncrementNumber; }; } // namespace WebCore diff --git a/Source/WebCore/storage/IDBPendingTransactionMonitor.h b/Source/WebCore/storage/IDBPendingTransactionMonitor.h index 783a731..5bc6acd 100644 --- a/Source/WebCore/storage/IDBPendingTransactionMonitor.h +++ b/Source/WebCore/storage/IDBPendingTransactionMonitor.h @@ -44,7 +44,8 @@ class IDBTransactionBackendInterface; // FIXME: move the vector of transactions to TLS. Keeping it static // will not work once we add support for workers. Another possible // solution is to keep the vector in the ScriptExecutionContext. -class IDBPendingTransactionMonitor : public Noncopyable { +class IDBPendingTransactionMonitor { + WTF_MAKE_NONCOPYABLE(IDBPendingTransactionMonitor); public: static void addPendingTransaction(IDBTransactionBackendInterface*); static void removePendingTransaction(IDBTransactionBackendInterface*); diff --git a/Source/WebCore/storage/LocalStorageTask.h b/Source/WebCore/storage/LocalStorageTask.h index a2e35ea..27a8eb5 100644 --- a/Source/WebCore/storage/LocalStorageTask.h +++ b/Source/WebCore/storage/LocalStorageTask.h @@ -37,7 +37,8 @@ namespace WebCore { class LocalStorageThread; // FIXME: Rename this class to StorageTask - class LocalStorageTask : public Noncopyable { + class LocalStorageTask { + WTF_MAKE_NONCOPYABLE(LocalStorageTask); WTF_MAKE_FAST_ALLOCATED; public: enum Type { AreaImport, AreaSync, DeleteEmptyDatabase, TerminateThread }; diff --git a/Source/WebCore/storage/LocalStorageThread.h b/Source/WebCore/storage/LocalStorageThread.h index 6f05911..a2c78c6 100644 --- a/Source/WebCore/storage/LocalStorageThread.h +++ b/Source/WebCore/storage/LocalStorageThread.h @@ -40,7 +40,8 @@ namespace WebCore { class LocalStorageTask; // FIXME: Rename this class to StorageThread - class LocalStorageThread : public Noncopyable { + class LocalStorageThread { + WTF_MAKE_NONCOPYABLE(LocalStorageThread); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<LocalStorageThread> create(); ~LocalStorageThread(); diff --git a/Source/WebCore/storage/OriginQuotaManager.h b/Source/WebCore/storage/OriginQuotaManager.h index ec9620c..82d7c74 100644 --- a/Source/WebCore/storage/OriginQuotaManager.h +++ b/Source/WebCore/storage/OriginQuotaManager.h @@ -41,7 +41,8 @@ namespace WebCore { class AbstractDatabase; class OriginUsageRecord; -class OriginQuotaManager : public Noncopyable { +class OriginQuotaManager { + WTF_MAKE_NONCOPYABLE(OriginQuotaManager); WTF_MAKE_FAST_ALLOCATED; public: OriginQuotaManager(); diff --git a/Source/WebCore/storage/OriginUsageRecord.h b/Source/WebCore/storage/OriginUsageRecord.h index a830e68..7557eaa 100644 --- a/Source/WebCore/storage/OriginUsageRecord.h +++ b/Source/WebCore/storage/OriginUsageRecord.h @@ -39,7 +39,8 @@ namespace WebCore { // Objects of this class can be used from multiple threads with external synchronization. // String arguments are also supposed to be deeply copied by the caller when necessary. -class OriginUsageRecord : public Noncopyable { +class OriginUsageRecord { + WTF_MAKE_NONCOPYABLE(OriginUsageRecord); WTF_MAKE_FAST_ALLOCATED; public: OriginUsageRecord(); diff --git a/Source/WebCore/storage/SQLTransactionClient.h b/Source/WebCore/storage/SQLTransactionClient.h index fed0657..3c5ec2d 100644 --- a/Source/WebCore/storage/SQLTransactionClient.h +++ b/Source/WebCore/storage/SQLTransactionClient.h @@ -33,6 +33,7 @@ #if ENABLE(DATABASE) +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> namespace WebCore { @@ -41,8 +42,10 @@ class AbstractDatabase; // A client to the SQLTransaction class. Allows SQLTransaction to notify interested // parties that certain things have happened in a transaction. -class SQLTransactionClient : public Noncopyable { +class SQLTransactionClient { + WTF_MAKE_NONCOPYABLE(SQLTransactionClient); WTF_MAKE_FAST_ALLOCATED; public: + SQLTransactionClient() { } void didCommitWriteTransaction(AbstractDatabase*); void didExecuteStatement(AbstractDatabase*); bool didExceedQuota(AbstractDatabase*); diff --git a/Source/WebCore/storage/SQLTransactionCoordinator.h b/Source/WebCore/storage/SQLTransactionCoordinator.h index 94360c0..fd76782 100644 --- a/Source/WebCore/storage/SQLTransactionCoordinator.h +++ b/Source/WebCore/storage/SQLTransactionCoordinator.h @@ -43,8 +43,10 @@ namespace WebCore { class SQLTransaction; - class SQLTransactionCoordinator : public Noncopyable { + class SQLTransactionCoordinator { + WTF_MAKE_NONCOPYABLE(SQLTransactionCoordinator); WTF_MAKE_FAST_ALLOCATED; public: + SQLTransactionCoordinator() { } void acquireLock(SQLTransaction*); void releaseLock(SQLTransaction*); void shutdown(); diff --git a/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp b/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp index c0fb444..92e9a7b 100644 --- a/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp +++ b/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp @@ -28,7 +28,7 @@ #include "config.h" #include "IDBFactoryBackendInterface.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #if ENABLE(INDEXED_DATABASE) @@ -36,12 +36,12 @@ namespace WebCore { PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendInterface::create() { - return ChromiumBridge::idbFactory(); + return PlatformBridge::idbFactory(); } IDBFactoryBackendInterface::~IDBFactoryBackendInterface() { - ChromiumBridge::idbShutdown(); + PlatformBridge::idbShutdown(); } } // namespace WebCore diff --git a/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp b/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp index 0f10875..38b2983 100644 --- a/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp +++ b/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp @@ -28,13 +28,13 @@ #if ENABLE(INDEXED_DATABASE) -#include "ChromiumBridge.h" +#include "PlatformBridge.h" namespace WebCore { void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const String& keyPath, Vector<RefPtr<IDBKey>, 0>& keys) { - ChromiumBridge::createIDBKeysFromSerializedValuesAndKeyPath(values, keyPath, keys); + PlatformBridge::createIDBKeysFromSerializedValuesAndKeyPath(values, keyPath, keys); } } // namespace WebCore diff --git a/Source/WebCore/svg/PatternAttributes.h b/Source/WebCore/svg/PatternAttributes.h index 613ab94..28a29c4 100644 --- a/Source/WebCore/svg/PatternAttributes.h +++ b/Source/WebCore/svg/PatternAttributes.h @@ -22,6 +22,7 @@ #if ENABLE(SVG) #include "SVGLength.h" +#include "SVGPreserveAspectRatio.h" namespace WebCore { @@ -33,6 +34,8 @@ struct PatternAttributes { , m_y() , m_width() , m_height() + , m_viewBox() + , m_preserveAspectRatio() , m_boundingBoxMode(true) , m_boundingBoxModeContent(false) , m_patternContentElement(0) @@ -40,6 +43,8 @@ struct PatternAttributes { , m_ySet(false) , m_widthSet(false) , m_heightSet(false) + , m_viewBoxSet(false) + , m_preserveAspectRatioSet(false) , m_boundingBoxModeSet(false) , m_boundingBoxModeContentSet(false) , m_patternTransformSet(false) @@ -51,6 +56,8 @@ struct PatternAttributes { SVGLength y() const { return m_y; } SVGLength width() const { return m_width; } SVGLength height() const { return m_height; } + FloatRect viewBox() const { return m_viewBox; } + SVGPreserveAspectRatio preserveAspectRatio() const { return m_preserveAspectRatio; } bool boundingBoxMode() const { return m_boundingBoxMode; } bool boundingBoxModeContent() const { return m_boundingBoxModeContent; } AffineTransform patternTransform() const { return m_patternTransform; } @@ -79,6 +86,18 @@ struct PatternAttributes { m_height = value; m_heightSet = true; } + + void setViewBox(const FloatRect& value) + { + m_viewBox = value; + m_viewBoxSet = true; + } + + void setPreserveAspectRatio(const SVGPreserveAspectRatio& value) + { + m_preserveAspectRatio = value; + m_preserveAspectRatioSet = true; + } void setBoundingBoxMode(bool value) { @@ -108,6 +127,8 @@ struct PatternAttributes { bool hasY() const { return m_ySet; } bool hasWidth() const { return m_widthSet; } bool hasHeight() const { return m_heightSet; } + bool hasViewBox() const { return m_viewBoxSet; } + bool hasPreserveAspectRatio() const { return m_preserveAspectRatioSet; } bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; } bool hasBoundingBoxModeContent() const { return m_boundingBoxModeContentSet; } bool hasPatternTransform() const { return m_patternTransformSet; } @@ -119,6 +140,8 @@ private: SVGLength m_y; SVGLength m_width; SVGLength m_height; + FloatRect m_viewBox; + SVGPreserveAspectRatio m_preserveAspectRatio; bool m_boundingBoxMode; bool m_boundingBoxModeContent; AffineTransform m_patternTransform; @@ -129,6 +152,8 @@ private: bool m_ySet : 1; bool m_widthSet : 1; bool m_heightSet : 1; + bool m_viewBoxSet : 1; + bool m_preserveAspectRatioSet : 1; bool m_boundingBoxModeSet : 1; bool m_boundingBoxModeContentSet : 1; bool m_patternTransformSet : 1; diff --git a/Source/WebCore/svg/SVGDocumentExtensions.h b/Source/WebCore/svg/SVGDocumentExtensions.h index a0cf2bb..0ed62a9 100644 --- a/Source/WebCore/svg/SVGDocumentExtensions.h +++ b/Source/WebCore/svg/SVGDocumentExtensions.h @@ -38,7 +38,8 @@ class SVGStyledElement; class SVGSMILElement; class SVGSVGElement; -class SVGDocumentExtensions : public Noncopyable { +class SVGDocumentExtensions { + WTF_MAKE_NONCOPYABLE(SVGDocumentExtensions); WTF_MAKE_FAST_ALLOCATED; public: typedef HashSet<RefPtr<SVGStyledElement> > SVGPendingElements; SVGDocumentExtensions(Document*); @@ -68,9 +69,6 @@ private: HashMap<AtomicString, SVGPendingElements*> m_pendingResources; OwnPtr<SVGResourcesCache> m_resourcesCache; - SVGDocumentExtensions(const SVGDocumentExtensions&); - SVGDocumentExtensions& operator=(const SVGDocumentExtensions&); - public: // This HashMap contains a list of pending resources. Pending resources, are such // which are referenced by any object in the SVG document, but do NOT exist yet. diff --git a/Source/WebCore/svg/SVGElementRareData.h b/Source/WebCore/svg/SVGElementRareData.h index 4276c4a..3318dee 100644 --- a/Source/WebCore/svg/SVGElementRareData.h +++ b/Source/WebCore/svg/SVGElementRareData.h @@ -31,7 +31,8 @@ class SVGCursorElement; class SVGElement; class SVGElementInstance; -class SVGElementRareData : public Noncopyable { +class SVGElementRareData { + WTF_MAKE_NONCOPYABLE(SVGElementRareData); WTF_MAKE_FAST_ALLOCATED; public: SVGElementRareData() : m_cursorElement(0) diff --git a/Source/WebCore/svg/SVGFEImageElement.cpp b/Source/WebCore/svg/SVGFEImageElement.cpp index 04ea14c..0fd4763 100644 --- a/Source/WebCore/svg/SVGFEImageElement.cpp +++ b/Source/WebCore/svg/SVGFEImageElement.cpp @@ -29,6 +29,7 @@ #include "CachedResourceLoader.h" #include "ColorSpace.h" #include "Document.h" +#include "Image.h" #include "RenderObject.h" #include "RenderSVGResource.h" #include "SVGImageBufferTools.h" diff --git a/Source/WebCore/svg/SVGFont.cpp b/Source/WebCore/svg/SVGFont.cpp index dd99ac5..e5164c0 100644 --- a/Source/WebCore/svg/SVGFont.cpp +++ b/Source/WebCore/svg/SVGFont.cpp @@ -36,6 +36,7 @@ #include "SVGMissingGlyphElement.h" #include "SVGNames.h" #include "SimpleFontData.h" +#include "TextRun.h" #include "XMLNames.h" using namespace WTF::Unicode; diff --git a/Source/WebCore/svg/SVGFontData.h b/Source/WebCore/svg/SVGFontData.h index e897a59..f202d26 100644 --- a/Source/WebCore/svg/SVGFontData.h +++ b/Source/WebCore/svg/SVGFontData.h @@ -25,7 +25,8 @@ namespace WebCore { -class SVGFontData : public Noncopyable { +class SVGFontData { + WTF_MAKE_NONCOPYABLE(SVGFontData); WTF_MAKE_FAST_ALLOCATED; public: SVGFontData(SVGFontFaceElement*); virtual ~SVGFontData() { } diff --git a/Source/WebCore/svg/SVGLocatable.cpp b/Source/WebCore/svg/SVGLocatable.cpp index 43961d9..2a7c9be 100644 --- a/Source/WebCore/svg/SVGLocatable.cpp +++ b/Source/WebCore/svg/SVGLocatable.cpp @@ -91,7 +91,8 @@ AffineTransform SVGLocatable::computeCTM(const SVGElement* element, CTMScope mod while (current && current->isSVGElement()) { SVGElement* currentElement = static_cast<SVGElement*>(current); if (currentElement->isStyled()) - ctm = static_cast<SVGStyledElement*>(currentElement)->localCoordinateSpaceTransform(mode).multLeft(ctm); + // note that this modifies the AffineTransform returned by localCoordinateSpaceTransform(mode) too. + ctm = static_cast<SVGStyledElement*>(currentElement)->localCoordinateSpaceTransform(mode).multiply(ctm); // For getCTM() computation, stop at the nearest viewport element if (currentElement == stopAtElement) @@ -113,7 +114,7 @@ AffineTransform SVGLocatable::getTransformToElement(SVGElement* target, Exceptio ec = SVGException::SVG_MATRIX_NOT_INVERTABLE; return ctm; } - ctm *= targetCTM.inverse(); + ctm = targetCTM.inverse() * ctm; } return ctm; diff --git a/Source/WebCore/svg/SVGMatrix.h b/Source/WebCore/svg/SVGMatrix.h index 807b703..077eb03 100644 --- a/Source/WebCore/svg/SVGMatrix.h +++ b/Source/WebCore/svg/SVGMatrix.h @@ -96,11 +96,10 @@ public: return static_cast<SVGMatrix>(copy); } - // SVGMatrix::multiply needs to call SVGMatrix::multLeft. SVGMatrix multiply(const SVGMatrix& other) { AffineTransform copy = *this; - copy.multLeft(static_cast<const AffineTransform&>(other)); + copy *= static_cast<const AffineTransform&>(other); return static_cast<SVGMatrix>(copy); } diff --git a/Source/WebCore/svg/SVGPathBlender.h b/Source/WebCore/svg/SVGPathBlender.h index c0ae7f3..8e43b94 100644 --- a/Source/WebCore/svg/SVGPathBlender.h +++ b/Source/WebCore/svg/SVGPathBlender.h @@ -23,11 +23,11 @@ #if ENABLE(SVG) #include "SVGPathConsumer.h" #include "SVGPathSource.h" -#include <wtf/Noncopyable.h> namespace WebCore { -class SVGPathBlender : public Noncopyable { +class SVGPathBlender { + WTF_MAKE_NONCOPYABLE(SVGPathBlender); WTF_MAKE_FAST_ALLOCATED; public: SVGPathBlender(); diff --git a/Source/WebCore/svg/SVGPathByteStream.h b/Source/WebCore/svg/SVGPathByteStream.h index b8882b6..a444ac0 100644 --- a/Source/WebCore/svg/SVGPathByteStream.h +++ b/Source/WebCore/svg/SVGPathByteStream.h @@ -43,7 +43,8 @@ typedef union { unsigned char bytes[sizeof(unsigned short)]; } UnsignedShortByte; -class SVGPathByteStream : public Noncopyable { +class SVGPathByteStream { + WTF_MAKE_NONCOPYABLE(SVGPathByteStream); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<SVGPathByteStream> create() { diff --git a/Source/WebCore/svg/SVGPathConsumer.h b/Source/WebCore/svg/SVGPathConsumer.h index b7c5e73..af3f79b 100644 --- a/Source/WebCore/svg/SVGPathConsumer.h +++ b/Source/WebCore/svg/SVGPathConsumer.h @@ -26,6 +26,7 @@ #if ENABLE(SVG) #include "FloatPoint.h" +#include <wtf/FastAllocBase.h> #include <wtf/Noncopyable.h> namespace WebCore { @@ -40,8 +41,10 @@ enum PathParsingMode { UnalteredParsing }; -class SVGPathConsumer : public Noncopyable { +class SVGPathConsumer { + WTF_MAKE_NONCOPYABLE(SVGPathConsumer); WTF_MAKE_FAST_ALLOCATED; public: + SVGPathConsumer() { } virtual void incrementPathSegmentCount() = 0; virtual bool continueConsuming() = 0; virtual void cleanup() = 0; diff --git a/Source/WebCore/svg/SVGPathParser.h b/Source/WebCore/svg/SVGPathParser.h index 7679a95..096131c 100644 --- a/Source/WebCore/svg/SVGPathParser.h +++ b/Source/WebCore/svg/SVGPathParser.h @@ -29,12 +29,12 @@ #include "SVGPathConsumer.h" #include "SVGPathSeg.h" #include "SVGPathSource.h" -#include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> namespace WebCore { -class SVGPathParser : public Noncopyable { +class SVGPathParser { + WTF_MAKE_NONCOPYABLE(SVGPathParser); WTF_MAKE_FAST_ALLOCATED; public: SVGPathParser(); diff --git a/Source/WebCore/svg/SVGPathSource.h b/Source/WebCore/svg/SVGPathSource.h index d1a6149..77bf9fa 100644 --- a/Source/WebCore/svg/SVGPathSource.h +++ b/Source/WebCore/svg/SVGPathSource.h @@ -25,8 +25,10 @@ namespace WebCore { -class SVGPathSource : public Noncopyable { +class SVGPathSource { + WTF_MAKE_NONCOPYABLE(SVGPathSource); WTF_MAKE_FAST_ALLOCATED; public: + SVGPathSource() { } virtual ~SVGPathSource() { } virtual bool hasMoreData() const = 0; diff --git a/Source/WebCore/svg/SVGPatternElement.cpp b/Source/WebCore/svg/SVGPatternElement.cpp index 29723e7..60dfeaf 100644 --- a/Source/WebCore/svg/SVGPatternElement.cpp +++ b/Source/WebCore/svg/SVGPatternElement.cpp @@ -228,6 +228,12 @@ void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAttr)) attributes.setHeight(current->height()); + if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxAttr)) + attributes.setViewBox(current->viewBox()); + + if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNames::preserveAspectRatioAttr)) + attributes.setPreserveAspectRatio(current->preserveAspectRatio()); + if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::patternUnitsAttr)) attributes.setBoundingBoxMode(current->patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); diff --git a/Source/WebCore/svg/SVGSVGElement.cpp b/Source/WebCore/svg/SVGSVGElement.cpp index 7e04f5d..483e45f 100644 --- a/Source/WebCore/svg/SVGSVGElement.cpp +++ b/Source/WebCore/svg/SVGSVGElement.cpp @@ -502,7 +502,7 @@ AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMSc } } - return transform.multLeft(viewBoxTransform); + return transform.multiply(viewBoxTransform); } RenderObject* SVGSVGElement::createRenderer(RenderArena* arena, RenderStyle*) @@ -587,12 +587,11 @@ AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie viewBoxRect = viewBox(); AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(viewBoxRect, preserveAspectRatio(), viewWidth, viewHeight); + if (useCurrentView() && currentView()) { AffineTransform transform; - if (!currentView()->transform().concatenate(transform)) - return ctm; - - return transform * ctm; + if (currentView()->transform().concatenate(transform)) + ctm *= transform; } return ctm; diff --git a/Source/WebCore/svg/SVGStyledTransformableElement.cpp b/Source/WebCore/svg/SVGStyledTransformableElement.cpp index 2334943..15528e0 100644 --- a/Source/WebCore/svg/SVGStyledTransformableElement.cpp +++ b/Source/WebCore/svg/SVGStyledTransformableElement.cpp @@ -56,7 +56,9 @@ AffineTransform SVGStyledTransformableElement::animatedLocalTransform() const { AffineTransform matrix; transform().concatenate(matrix); - return m_supplementalTransform ? *m_supplementalTransform * matrix : matrix; + if (m_supplementalTransform) + matrix *= *m_supplementalTransform; + return matrix; } AffineTransform* SVGStyledTransformableElement::supplementalTransform() diff --git a/Source/WebCore/svg/SVGTextElement.cpp b/Source/WebCore/svg/SVGTextElement.cpp index 7229824..b6094c9 100644 --- a/Source/WebCore/svg/SVGTextElement.cpp +++ b/Source/WebCore/svg/SVGTextElement.cpp @@ -89,7 +89,9 @@ AffineTransform SVGTextElement::animatedLocalTransform() const { AffineTransform matrix; transform().concatenate(matrix); - return m_supplementalTransform ? *m_supplementalTransform * matrix : matrix; + if (m_supplementalTransform) + matrix *= *m_supplementalTransform; + return matrix; } AffineTransform* SVGTextElement::supplementalTransform() diff --git a/Source/WebCore/svg/SVGTransformList.cpp b/Source/WebCore/svg/SVGTransformList.cpp index 52bfc85..1800b1e 100644 --- a/Source/WebCore/svg/SVGTransformList.cpp +++ b/Source/WebCore/svg/SVGTransformList.cpp @@ -56,7 +56,7 @@ bool SVGTransformList::concatenate(AffineTransform& result) const return false; for (unsigned i = 0; i < size; ++i) - result = at(i).matrix() * result; + result *= at(i).matrix(); return true; } diff --git a/Source/WebCore/svg/SVGUseElement.cpp b/Source/WebCore/svg/SVGUseElement.cpp index 589a560..9f43f82 100644 --- a/Source/WebCore/svg/SVGUseElement.cpp +++ b/Source/WebCore/svg/SVGUseElement.cpp @@ -330,7 +330,7 @@ void SVGUseElement::updateContainerOffsets() void SVGUseElement::recalcStyle(StyleChange change) { // Eventually mark shadow root element needing style recalc - if (needsStyleRecalc() && m_targetElementInstance && !m_updatesBlocked) { + if ((change >= Inherit || needsStyleRecalc() || childNeedsStyleRecalc()) && m_targetElementInstance && !m_updatesBlocked) { if (SVGElement* shadowRoot = m_targetElementInstance->shadowTreeElement()) shadowRoot->setNeedsStyleRecalc(); } diff --git a/Source/WebCore/svg/SVGViewSpec.h b/Source/WebCore/svg/SVGViewSpec.h index 686cec3..cd10ca4 100644 --- a/Source/WebCore/svg/SVGViewSpec.h +++ b/Source/WebCore/svg/SVGViewSpec.h @@ -32,8 +32,8 @@ namespace WebCore { class SVGElement; class SVGViewSpec : public SVGFitToViewBox, - public SVGZoomAndPan, - public Noncopyable { + public SVGZoomAndPan { + WTF_MAKE_NONCOPYABLE(SVGViewSpec); public: SVGViewSpec(SVGElement*); diff --git a/Source/WebCore/svg/graphics/SVGImage.cpp b/Source/WebCore/svg/graphics/SVGImage.cpp index 97f86be..fc2fd08 100644 --- a/Source/WebCore/svg/graphics/SVGImage.cpp +++ b/Source/WebCore/svg/graphics/SVGImage.cpp @@ -55,7 +55,8 @@ namespace WebCore { -class SVGImageChromeClient : public EmptyChromeClient, public Noncopyable { +class SVGImageChromeClient : public EmptyChromeClient { + WTF_MAKE_NONCOPYABLE(SVGImageChromeClient); WTF_MAKE_FAST_ALLOCATED; public: SVGImageChromeClient(SVGImage* image) : m_image(image) diff --git a/Source/WebCore/thirdparty/glu/README.webkit b/Source/WebCore/thirdparty/glu/README.webkit index 3fcac84..57c4772 100644 --- a/Source/WebCore/thirdparty/glu/README.webkit +++ b/Source/WebCore/thirdparty/glu/README.webkit @@ -31,3 +31,12 @@ The following changes were made in order to incorporate this code: of the unused Normalize function. - In priorityq-heap.c, an #include of <limits.h> was added. + + - In sweep.c, IsWindingInside() was given a return value to silence a + warning-as-error in release builds. + + - In sweep.c, DoneEdgeDict()'s fixedEdges was wrapped in #indef NDEBUG, to + silence a warning-as-error in release builds. + + - In priorityq.c, render.c, and others: the construct "if(1)...else" was + replaced with "do{...}while(1)" to silence a warning-as-error in Mac builds. diff --git a/Source/WebCore/thirdparty/glu/gluos.h b/Source/WebCore/thirdparty/glu/gluos.h index 600dc0b..6380cb2 100644 --- a/Source/WebCore/thirdparty/glu/gluos.h +++ b/Source/WebCore/thirdparty/glu/gluos.h @@ -42,4 +42,7 @@ typedef unsigned int GLenum; typedef float GLfloat; typedef void GLvoid; +#undef MIN +#undef MAX + #endif // GLUOS_H_ diff --git a/Source/WebCore/thirdparty/glu/libtess/geom.c b/Source/WebCore/thirdparty/glu/libtess/geom.c index 2db2699..ce578dd 100644 --- a/Source/WebCore/thirdparty/glu/libtess/geom.c +++ b/Source/WebCore/thirdparty/glu/libtess/geom.c @@ -205,7 +205,7 @@ printf("*********************%d\n",RandomInterpolate); #endif -#define Swap(a,b) if (1) { GLUvertex *t = a; a = b; b = t; } else +#define Swap(a,b) do { GLUvertex *t = a; a = b; b = t; } while(0) void __gl_edgeIntersect( GLUvertex *o1, GLUvertex *d1, GLUvertex *o2, GLUvertex *d2, diff --git a/Source/WebCore/thirdparty/glu/libtess/priorityq.c b/Source/WebCore/thirdparty/glu/libtess/priorityq.c index 4b0bea1..6614db0 100644 --- a/Source/WebCore/thirdparty/glu/libtess/priorityq.c +++ b/Source/WebCore/thirdparty/glu/libtess/priorityq.c @@ -92,7 +92,7 @@ void pqDeletePriorityQ( PriorityQ *pq ) #define LT(x,y) (! LEQ(y,x)) #define GT(x,y) (! LEQ(x,y)) -#define Swap(a,b) if(1){PQkey *tmp = *a; *a = *b; *b = tmp;}else +#define Swap(a,b) do{PQkey *tmp = *a; *a = *b; *b = tmp;}while(0) /* really __gl_pqSortInit */ int pqInit( PriorityQ *pq ) diff --git a/Source/WebCore/thirdparty/glu/libtess/render.c b/Source/WebCore/thirdparty/glu/libtess/render.c index 0e944a2..79386e8 100644 --- a/Source/WebCore/thirdparty/glu/libtess/render.c +++ b/Source/WebCore/thirdparty/glu/libtess/render.c @@ -150,11 +150,11 @@ static void RenderMaximumFaceGroup( GLUtesselator *tess, GLUface *fOrig ) #define AddToTrail(f,t) ((f)->trail = (t), (t) = (f), (f)->marked = TRUE) -#define FreeTrail(t) if( 1 ) { \ +#define FreeTrail(t) do { \ while( (t) != NULL ) { \ (t)->marked = FALSE; t = (t)->trail; \ } \ - } else /* absorb trailing semicolon */ + } while(0) /* absorb trailing semicolon */ diff --git a/Source/WebCore/thirdparty/glu/libtess/sweep.c b/Source/WebCore/thirdparty/glu/libtess/sweep.c index e85757c..233b2da 100644 --- a/Source/WebCore/thirdparty/glu/libtess/sweep.c +++ b/Source/WebCore/thirdparty/glu/libtess/sweep.c @@ -253,6 +253,7 @@ static GLboolean IsWindingInside( GLUtesselator *tess, int n ) /*LINTED*/ assert( FALSE ); /*NOTREACHED*/ + return 0; } @@ -1173,7 +1174,9 @@ static void InitEdgeDict( GLUtesselator *tess ) static void DoneEdgeDict( GLUtesselator *tess ) { ActiveRegion *reg; +#ifndef NDEBUG int fixedEdges = 0; +#endif /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */ while( (reg = (ActiveRegion *)dictKey( dictMin( tess->dict ))) != NULL ) { diff --git a/Source/WebCore/webaudio/RealtimeAnalyser.h b/Source/WebCore/webaudio/RealtimeAnalyser.h index 686c17c..c6ec2c0 100644 --- a/Source/WebCore/webaudio/RealtimeAnalyser.h +++ b/Source/WebCore/webaudio/RealtimeAnalyser.h @@ -26,7 +26,7 @@ #define RealtimeAnalyser_h #include "AudioArray.h" -#include <wtf/NonCopyable.h> +#include <wtf/Noncopyable.h> #include <wtf/OwnPtr.h> namespace WebCore { @@ -39,7 +39,8 @@ class Float32Array; class Uint8Array; #endif -class RealtimeAnalyser : public Noncopyable { +class RealtimeAnalyser { + WTF_MAKE_NONCOPYABLE(RealtimeAnalyser); public: RealtimeAnalyser(); virtual ~RealtimeAnalyser(); diff --git a/Source/WebCore/websockets/ThreadableWebSocketChannel.h b/Source/WebCore/websockets/ThreadableWebSocketChannel.h index 05b3767..956e0fe 100644 --- a/Source/WebCore/websockets/ThreadableWebSocketChannel.h +++ b/Source/WebCore/websockets/ThreadableWebSocketChannel.h @@ -43,8 +43,10 @@ class KURL; class ScriptExecutionContext; class WebSocketChannelClient; -class ThreadableWebSocketChannel : public Noncopyable { +class ThreadableWebSocketChannel { + WTF_MAKE_NONCOPYABLE(ThreadableWebSocketChannel); public: + ThreadableWebSocketChannel() { } static PassRefPtr<ThreadableWebSocketChannel> create(ScriptExecutionContext*, WebSocketChannelClient*, const KURL&, const String& protocol); virtual void connect() = 0; diff --git a/Source/WebCore/websockets/WebSocket.cpp b/Source/WebCore/websockets/WebSocket.cpp index 358a742..e15d079 100644 --- a/Source/WebCore/websockets/WebSocket.cpp +++ b/Source/WebCore/websockets/WebSocket.cpp @@ -41,6 +41,7 @@ #include "EventNames.h" #include "Logging.h" #include "MessageEvent.h" +#include "ScriptCallStack.h" #include "ScriptExecutionContext.h" #include "ThreadableWebSocketChannel.h" #include "WebSocketChannel.h" @@ -116,32 +117,32 @@ void WebSocket::connect(const KURL& url, const String& protocol, ExceptionCode& m_protocol = protocol; if (!m_url.isValid()) { - scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString()); + scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); m_state = CLOSED; ec = SYNTAX_ERR; return; } if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) { - scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString()); + scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); m_state = CLOSED; ec = SYNTAX_ERR; return; } if (m_url.hasFragmentIdentifier()) { - scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString()); + scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); m_state = CLOSED; ec = SYNTAX_ERR; return; } if (!isValidProtocolString(m_protocol)) { - scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(m_protocol) + "'", 0, scriptExecutionContext()->securityOrigin()->toString()); + scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(m_protocol) + "'", 0, scriptExecutionContext()->securityOrigin()->toString(), 0); m_state = CLOSED; ec = SYNTAX_ERR; return; } if (!portAllowed(url)) { - scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number(url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString()); + scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number(url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); m_state = CLOSED; ec = SECURITY_ERR; return; diff --git a/Source/WebCore/websockets/WebSocketChannel.cpp b/Source/WebCore/websockets/WebSocketChannel.cpp index 09fcd6b..c4cb2e2 100644 --- a/Source/WebCore/websockets/WebSocketChannel.cpp +++ b/Source/WebCore/websockets/WebSocketChannel.cpp @@ -41,6 +41,7 @@ #include "Page.h" #include "PlatformString.h" #include "ProgressTracker.h" +#include "ScriptCallStack.h" #include "ScriptExecutionContext.h" #include "SocketStreamError.h" #include "SocketStreamHandle.h" @@ -155,7 +156,7 @@ void WebSocketChannel::didOpen(SocketStreamHandle* handle) InspectorInstrumentation::willSendWebSocketHandshakeRequest(m_context, m_identifier, m_handshake.clientHandshakeRequest()); CString handshakeMessage = m_handshake.clientHandshakeMessage(); if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin(), 0); handle->close(); } } @@ -218,7 +219,7 @@ void WebSocketChannel::didFail(SocketStreamHandle* handle, const SocketStreamErr message = makeString("WebSocket network error: error code ", String::number(error.errorCode())); else message = makeString("WebSocket network error: ", error.localizedDescription()); - m_context->addMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, 0, error.failingURL()); + m_context->addMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, 0, error.failingURL(), 0); } m_shouldDiscardReceivedData = true; handle->close(); @@ -249,7 +250,7 @@ bool WebSocketChannel::appendToBuffer(const char* data, size_t len) m_bufferSize = newBufferSize; return true; } - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket frame (at ", String::number(static_cast<unsigned long>(newBufferSize)), " bytes) is too long."), 0, m_handshake.clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket frame (at ", String::number(static_cast<unsigned long>(newBufferSize)), " bytes) is too long."), 0, m_handshake.clientOrigin(), 0); return false; } diff --git a/Source/WebCore/websockets/WebSocketChannel.h b/Source/WebCore/websockets/WebSocketChannel.h index 9c52377..a39cd0e 100644 --- a/Source/WebCore/websockets/WebSocketChannel.h +++ b/Source/WebCore/websockets/WebSocketChannel.h @@ -49,6 +49,7 @@ namespace WebCore { class WebSocketChannelClient; class WebSocketChannel : public RefCounted<WebSocketChannel>, public SocketStreamHandleClient, public ThreadableWebSocketChannel { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<WebSocketChannel> create(ScriptExecutionContext* context, WebSocketChannelClient* client, const KURL& url, const String& protocol) { return adoptRef(new WebSocketChannel(context, client, url, protocol)); } virtual ~WebSocketChannel(); diff --git a/Source/WebCore/websockets/WebSocketHandshake.cpp b/Source/WebCore/websockets/WebSocketHandshake.cpp index 9506ad4..f653415 100644 --- a/Source/WebCore/websockets/WebSocketHandshake.cpp +++ b/Source/WebCore/websockets/WebSocketHandshake.cpp @@ -42,6 +42,7 @@ #include "HTTPHeaderMap.h" #include "KURL.h" #include "Logging.h" +#include "ScriptCallStack.h" #include "ScriptExecutionContext.h" #include "SecurityOrigin.h" @@ -320,7 +321,7 @@ int WebSocketHandshake::readServerHandshake(const char* header, size_t len) m_response.setStatusText(statusText); if (statusCode != 101) { m_mode = Failed; - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("Unexpected response code: ", String::number(statusCode)), 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("Unexpected response code: ", String::number(statusCode)), 0, clientOrigin(), 0); return len; } m_mode = Normal; @@ -450,7 +451,7 @@ int WebSocketHandshake::readStatusLine(const char* header, size_t headerLength, // The caller isn't prepared to deal with null bytes in status // line. WebSockets specification doesn't prohibit this, but HTTP // does, so we'll just treat this as an error. - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line contains embedded null", 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line contains embedded null", 0, clientOrigin(), 0); return p + 1 - header; } else if (*p == '\n') break; @@ -460,19 +461,19 @@ int WebSocketHandshake::readStatusLine(const char* header, size_t headerLength, const char* end = p + 1; if (end - header > maximumLength) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line is too long", 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line is too long", 0, clientOrigin(), 0); return maximumLength; } int lineLength = end - header; if (!space1 || !space2) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "No response code found: " + trimConsoleMessage(header, lineLength - 1), 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "No response code found: " + trimConsoleMessage(header, lineLength - 1), 0, clientOrigin(), 0); return lineLength; } // The line must end with "\r\n". if (*(end - 2) != '\r') { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line does not end with CRLF", 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line does not end with CRLF", 0, clientOrigin(), 0); return lineLength; } @@ -481,7 +482,7 @@ int WebSocketHandshake::readStatusLine(const char* header, size_t headerLength, return lineLength; for (int i = 0; i < 3; ++i) if (statusCodeString[i] < '0' || statusCodeString[i] > '9') { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid status code: " + statusCodeString, 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid status code: " + statusCodeString, 0, clientOrigin(), 0); return lineLength; } @@ -509,13 +510,13 @@ const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e if (name.isEmpty()) { if (p + 1 < end && *(p + 1) == '\n') return p + 2; - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF at " + trimConsoleMessage(p, end - p), 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF at " + trimConsoleMessage(p, end - p), 0, clientOrigin(), 0); return 0; } - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected CR in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected CR in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin(), 0); return 0; case '\n': - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin(), 0); return 0; case ':': break; @@ -536,7 +537,7 @@ const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e case '\r': break; case '\n': - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in value at " + trimConsoleMessage(value.data(), value.size()), 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in value at " + trimConsoleMessage(value.data(), value.size()), 0, clientOrigin(), 0); return 0; default: value.append(*p); @@ -547,17 +548,17 @@ const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e } } if (p >= end || *p != '\n') { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF after value at " + trimConsoleMessage(p, end - p), 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF after value at " + trimConsoleMessage(p, end - p), 0, clientOrigin(), 0); return 0; } AtomicString nameStr(String::fromUTF8(name.data(), name.size())); String valueStr = String::fromUTF8(value.data(), value.size()); if (nameStr.isNull()) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header name", 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header name", 0, clientOrigin(), 0); return 0; } if (valueStr.isNull()) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header value", 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header value", 0, clientOrigin(), 0); return 0; } LOG(Network, "name=%s value=%s", nameStr.string().utf8().data(), valueStr.utf8().data()); @@ -581,24 +582,24 @@ void WebSocketHandshake::processHeaders() bool WebSocketHandshake::checkResponseHeaders() { if (m_wsOrigin.isNull()) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-origin' header is missing", 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-origin' header is missing", 0, clientOrigin(), 0); return false; } if (m_wsLocation.isNull()) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-location' header is missing", 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-location' header is missing", 0, clientOrigin(), 0); return false; } if (clientOrigin() != m_wsOrigin) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: origin mismatch: " + clientOrigin() + " != " + m_wsOrigin, 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: origin mismatch: " + clientOrigin() + " != " + m_wsOrigin, 0, clientOrigin(), 0); return false; } if (clientLocation() != m_wsLocation) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin(), 0); return false; } if (!m_clientProtocol.isEmpty() && m_clientProtocol != m_wsProtocol) { - m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin()); + m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin(), 0); return false; } return true; diff --git a/Source/WebCore/websockets/WebSocketHandshake.h b/Source/WebCore/websockets/WebSocketHandshake.h index a5b4260..371d852 100644 --- a/Source/WebCore/websockets/WebSocketHandshake.h +++ b/Source/WebCore/websockets/WebSocketHandshake.h @@ -37,13 +37,13 @@ #include "PlatformString.h" #include "WebSocketHandshakeRequest.h" #include "WebSocketHandshakeResponse.h" -#include <wtf/Noncopyable.h> namespace WebCore { class ScriptExecutionContext; - class WebSocketHandshake : public Noncopyable { + class WebSocketHandshake { + WTF_MAKE_NONCOPYABLE(WebSocketHandshake); public: enum Mode { Incomplete, Normal, Failed, Connected diff --git a/Source/WebCore/websockets/WorkerThreadableWebSocketChannel.h b/Source/WebCore/websockets/WorkerThreadableWebSocketChannel.h index 366e4fa..9f0b01a 100644 --- a/Source/WebCore/websockets/WorkerThreadableWebSocketChannel.h +++ b/Source/WebCore/websockets/WorkerThreadableWebSocketChannel.h @@ -52,6 +52,7 @@ class WorkerLoaderProxy; class WorkerRunLoop; class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSocketChannel>, public ThreadableWebSocketChannel { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<ThreadableWebSocketChannel> create(WorkerContext* workerContext, WebSocketChannelClient* client, const String& taskMode, const KURL& url, const String& protocol) { @@ -77,7 +78,8 @@ protected: private: // Generated by the bridge. The Peer and its bridge should have identical // lifetimes. - class Peer : public WebSocketChannelClient, public Noncopyable { + class Peer : public WebSocketChannelClient { + WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED; public: static Peer* create(RefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode, const KURL& url, const String& protocol) { diff --git a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp index 3a14b62..c20cd30 100644 --- a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp +++ b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp @@ -42,6 +42,7 @@ #include "MessagePort.h" #include "NotImplemented.h" #include "PlatformString.h" +#include "ScriptCallStack.h" #include "SecurityOrigin.h" #include "SecurityOriginHash.h" #include "SharedWorker.h" @@ -155,7 +156,7 @@ void SharedWorkerProxy::postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutio static void postExceptionTask(ScriptExecutionContext* context, const String& errorMessage, int lineNumber, const String& sourceURL) { - context->reportException(errorMessage, lineNumber, sourceURL); + context->reportException(errorMessage, lineNumber, sourceURL, 0); } void SharedWorkerProxy::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) @@ -167,7 +168,7 @@ void SharedWorkerProxy::postExceptionToWorkerObject(const String& errorMessage, static void postConsoleMessageTask(ScriptExecutionContext* document, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL) { - document->addMessage(source, type, level, message, lineNumber, sourceURL); + document->addMessage(source, type, level, message, lineNumber, sourceURL, 0); } void SharedWorkerProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageType type, MessageLevel level, const String& message, int lineNumber, const String& sourceURL) diff --git a/Source/WebCore/workers/DefaultSharedWorkerRepository.h b/Source/WebCore/workers/DefaultSharedWorkerRepository.h index 21e14a1..435b613 100644 --- a/Source/WebCore/workers/DefaultSharedWorkerRepository.h +++ b/Source/WebCore/workers/DefaultSharedWorkerRepository.h @@ -53,7 +53,8 @@ namespace WebCore { class SharedWorkerProxy; // Platform-specific implementation of the SharedWorkerRepository static interface. - class DefaultSharedWorkerRepository : public Noncopyable { + class DefaultSharedWorkerRepository { + WTF_MAKE_NONCOPYABLE(DefaultSharedWorkerRepository); WTF_MAKE_FAST_ALLOCATED; public: // Invoked once the worker script has been loaded to fire up the worker thread. void workerScriptLoaded(SharedWorkerProxy&, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel>); diff --git a/Source/WebCore/workers/WorkerContext.cpp b/Source/WebCore/workers/WorkerContext.cpp index d5d1ccc..36c4215 100644 --- a/Source/WebCore/workers/WorkerContext.cpp +++ b/Source/WebCore/workers/WorkerContext.cpp @@ -47,6 +47,7 @@ #include "KURL.h" #include "MessagePort.h" #include "NotImplemented.h" +#include "ScriptCallStack.h" #include "ScriptSourceCode.h" #include "ScriptValue.h" #include "SecurityOrigin.h" @@ -103,7 +104,6 @@ WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThr , m_script(new WorkerScriptController(this)) , m_thread(thread) , m_closing(false) - , m_reportingException(false) { setSecurityOrigin(SecurityOrigin::create(url)); } @@ -257,23 +257,17 @@ void WorkerContext::importScripts(const Vector<String>& urls, ExceptionCode& ec) } } -void WorkerContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL) +EventTarget* WorkerContext::errorEventTarget() { - bool errorHandled = false; - if (!m_reportingException) { - if (onerror()) { - m_reportingException = true; - RefPtr<ErrorEvent> errorEvent(ErrorEvent::create(errorMessage, sourceURL, lineNumber)); - onerror()->handleEvent(this, errorEvent.get()); - errorHandled = errorEvent->defaultPrevented(); - m_reportingException = false; - } - } - if (!errorHandled) - thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL); + return this; +} + +void WorkerContext::logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) +{ + thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL); } -void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL) +void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) { thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, type, level, message, lineNumber, sourceURL); } diff --git a/Source/WebCore/workers/WorkerContext.h b/Source/WebCore/workers/WorkerContext.h index a0dbaae..2e802f2 100644 --- a/Source/WebCore/workers/WorkerContext.h +++ b/Source/WebCore/workers/WorkerContext.h @@ -101,8 +101,7 @@ namespace WebCore { void clearInterval(int timeoutId); // ScriptExecutionContext - virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL); - virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL); + virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); #if ENABLE(NOTIFICATIONS) NotificationCenter* webkitNotifications() const; @@ -145,7 +144,8 @@ namespace WebCore { bool isClosing() { return m_closing; } // An observer interface to be notified when the worker thread is getting stopped. - class Observer : public Noncopyable { + class Observer { + WTF_MAKE_NONCOPYABLE(Observer); public: Observer(WorkerContext*); virtual ~Observer(); @@ -174,6 +174,9 @@ namespace WebCore { virtual const KURL& virtualURL() const; virtual KURL virtualCompleteURL(const String&) const; + virtual EventTarget* errorEventTarget(); + virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); + KURL m_url; String m_userAgent; @@ -190,7 +193,6 @@ namespace WebCore { mutable RefPtr<DOMURL> m_domURL; #endif bool m_closing; - bool m_reportingException; EventTargetData m_eventTargetData; HashSet<Observer*> m_workerObservers; diff --git a/Source/WebCore/workers/WorkerMessagingProxy.cpp b/Source/WebCore/workers/WorkerMessagingProxy.cpp index e89ccb4..eca8e2e 100644 --- a/Source/WebCore/workers/WorkerMessagingProxy.cpp +++ b/Source/WebCore/workers/WorkerMessagingProxy.cpp @@ -39,6 +39,7 @@ #include "ErrorEvent.h" #include "ExceptionCode.h" #include "MessageEvent.h" +#include "ScriptCallStack.h" #include "ScriptExecutionContext.h" #include "Worker.h" @@ -130,7 +131,7 @@ private: bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_errorMessage, m_sourceURL, m_lineNumber)); if (!errorHandled) - context->reportException(m_errorMessage, m_lineNumber, m_sourceURL); + context->reportException(m_errorMessage, m_lineNumber, m_sourceURL, 0); } String m_errorMessage; @@ -282,7 +283,7 @@ static void postConsoleMessageTask(ScriptExecutionContext* context, WorkerMessag { if (messagingProxy->askedToTerminate()) return; - context->addMessage(source, type, level, message, lineNumber, sourceURL); + context->addMessage(source, type, level, message, lineNumber, sourceURL, 0); } void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageType type, MessageLevel level, const String& message, int lineNumber, const String& sourceURL) diff --git a/Source/WebCore/workers/WorkerMessagingProxy.h b/Source/WebCore/workers/WorkerMessagingProxy.h index 33937ce..ab6113a 100644 --- a/Source/WebCore/workers/WorkerMessagingProxy.h +++ b/Source/WebCore/workers/WorkerMessagingProxy.h @@ -46,7 +46,8 @@ namespace WebCore { class ScriptExecutionContext; class Worker; - class WorkerMessagingProxy : public WorkerContextProxy, public WorkerObjectProxy, public WorkerLoaderProxy, public Noncopyable { + class WorkerMessagingProxy : public WorkerContextProxy, public WorkerObjectProxy, public WorkerLoaderProxy { + WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED; public: WorkerMessagingProxy(Worker*); diff --git a/Source/WebCore/workers/WorkerRunLoop.cpp b/Source/WebCore/workers/WorkerRunLoop.cpp index 83f243f..7b3149c 100644 --- a/Source/WebCore/workers/WorkerRunLoop.cpp +++ b/Source/WebCore/workers/WorkerRunLoop.cpp @@ -104,7 +104,8 @@ String WorkerRunLoop::defaultMode() return String(); } -class RunLoopSetup : public Noncopyable { +class RunLoopSetup { + WTF_MAKE_NONCOPYABLE(RunLoopSetup); public: RunLoopSetup(WorkerRunLoop& runLoop) : m_runLoop(runLoop) diff --git a/Source/WebCore/workers/WorkerRunLoop.h b/Source/WebCore/workers/WorkerRunLoop.h index 9d4edfd..3feb4e8 100644 --- a/Source/WebCore/workers/WorkerRunLoop.h +++ b/Source/WebCore/workers/WorkerRunLoop.h @@ -65,7 +65,8 @@ namespace WebCore { static String defaultMode(); - class Task : public Noncopyable { + class Task { + WTF_MAKE_NONCOPYABLE(Task); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<Task> create(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode); ~Task() { } diff --git a/Source/WebCore/workers/WorkerThread.cpp b/Source/WebCore/workers/WorkerThread.cpp index f61120e..e1f1a66 100644 --- a/Source/WebCore/workers/WorkerThread.cpp +++ b/Source/WebCore/workers/WorkerThread.cpp @@ -61,7 +61,8 @@ unsigned WorkerThread::workerThreadCount() return m_threadCount; } -struct WorkerThreadStartupData : Noncopyable { +struct WorkerThreadStartupData { + WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode) { diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp index ee9e20f..c05ab29 100644 --- a/Source/WebCore/xml/XMLHttpRequest.cpp +++ b/Source/WebCore/xml/XMLHttpRequest.cpp @@ -38,6 +38,7 @@ #include "InspectorInstrumentation.h" #include "ResourceError.h" #include "ResourceRequest.h" +#include "ScriptCallStack.h" #include "SecurityOrigin.h" #include "Settings.h" #include "SharedBuffer.h" @@ -64,7 +65,9 @@ namespace WebCore { static WTF::RefCountedLeakCounter xmlHttpRequestCounter("XMLHttpRequest"); #endif -struct XMLHttpRequestStaticData : Noncopyable { +struct XMLHttpRequestStaticData { + WTF_MAKE_NONCOPYABLE(XMLHttpRequestStaticData); WTF_MAKE_FAST_ALLOCATED; +public: XMLHttpRequestStaticData(); String m_proxyHeaderPrefix; String m_secHeaderPrefix; @@ -806,7 +809,7 @@ static void reportUnsafeUsage(ScriptExecutionContext* context, const String& mes return; // FIXME: It's not good to report the bad usage without indicating what source line it came from. // We should pass additional parameters so we can tell the console where the mistake occurred. - context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String()); + context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String(), 0); } void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& value, ExceptionCode& ec) diff --git a/Source/WebCore/xml/XMLHttpRequest.h b/Source/WebCore/xml/XMLHttpRequest.h index bc6815d..b15d358 100644 --- a/Source/WebCore/xml/XMLHttpRequest.h +++ b/Source/WebCore/xml/XMLHttpRequest.h @@ -44,6 +44,7 @@ class TextResourceDecoder; class ThreadableLoader; class XMLHttpRequest : public RefCounted<XMLHttpRequest>, public EventTarget, private ThreadableLoaderClient, public ActiveDOMObject { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<XMLHttpRequest> create(ScriptExecutionContext* context) { return adoptRef(new XMLHttpRequest(context)); } ~XMLHttpRequest(); diff --git a/Source/WebCore/xml/XPathExpressionNode.h b/Source/WebCore/xml/XPathExpressionNode.h index c04d45b..4b5baa8 100644 --- a/Source/WebCore/xml/XPathExpressionNode.h +++ b/Source/WebCore/xml/XPathExpressionNode.h @@ -39,7 +39,9 @@ namespace WebCore { namespace XPath { - struct EvaluationContext : FastAllocBase { + struct EvaluationContext { + WTF_MAKE_FAST_ALLOCATED; + public: RefPtr<Node> node; unsigned long size; unsigned long position; @@ -53,7 +55,8 @@ namespace WebCore { virtual ~ParseNode() { } }; - class Expression : public ParseNode, public Noncopyable { + class Expression : public ParseNode { + WTF_MAKE_NONCOPYABLE(Expression); WTF_MAKE_FAST_ALLOCATED; public: static EvaluationContext& evaluationContext(); diff --git a/Source/WebCore/xml/XPathNodeSet.h b/Source/WebCore/xml/XPathNodeSet.h index d5c47be..619d91c 100644 --- a/Source/WebCore/xml/XPathNodeSet.h +++ b/Source/WebCore/xml/XPathNodeSet.h @@ -37,7 +37,8 @@ namespace WebCore { namespace XPath { - class NodeSet : public FastAllocBase { + class NodeSet { + WTF_MAKE_FAST_ALLOCATED; public: NodeSet() : m_isSorted(true), m_subtreesAreDisjoint(false) { } diff --git a/Source/WebCore/xml/XPathParser.h b/Source/WebCore/xml/XPathParser.h index 0ee447a..f49b44b 100644 --- a/Source/WebCore/xml/XPathParser.h +++ b/Source/WebCore/xml/XPathParser.h @@ -58,7 +58,8 @@ namespace WebCore { Token(int t, EqTestOp::Opcode v): type(t), eqop(v) {} }; - class Parser : public Noncopyable { + class Parser { + WTF_MAKE_NONCOPYABLE(Parser); public: Parser(); ~Parser(); diff --git a/Source/WebCore/xml/XPathPredicate.h b/Source/WebCore/xml/XPathPredicate.h index 5f2482a..3600154 100644 --- a/Source/WebCore/xml/XPathPredicate.h +++ b/Source/WebCore/xml/XPathPredicate.h @@ -105,7 +105,8 @@ namespace WebCore { virtual Value::Type resultType() const { return Value::NodeSetValue; } }; - class Predicate : public Noncopyable { + class Predicate { + WTF_MAKE_NONCOPYABLE(Predicate); WTF_MAKE_FAST_ALLOCATED; public: Predicate(Expression*); ~Predicate(); diff --git a/Source/WebCore/xml/XPathStep.h b/Source/WebCore/xml/XPathStep.h index ec022b3..b031baf 100644 --- a/Source/WebCore/xml/XPathStep.h +++ b/Source/WebCore/xml/XPathStep.h @@ -39,7 +39,8 @@ namespace WebCore { class Predicate; - class Step : public ParseNode, public Noncopyable { + class Step : public ParseNode { + WTF_MAKE_NONCOPYABLE(Step); WTF_MAKE_FAST_ALLOCATED; public: enum Axis { AncestorAxis, AncestorOrSelfAxis, AttributeAxis, @@ -49,7 +50,8 @@ namespace WebCore { SelfAxis }; - class NodeTest : public FastAllocBase { + class NodeTest { + WTF_MAKE_FAST_ALLOCATED; public: enum Kind { TextNodeTest, CommentNodeTest, ProcessingInstructionNodeTest, AnyNodeTest, NameTest diff --git a/Source/WebCore/xml/XSLImportRule.h b/Source/WebCore/xml/XSLImportRule.h index 63c271e..3c5939d 100644 --- a/Source/WebCore/xml/XSLImportRule.h +++ b/Source/WebCore/xml/XSLImportRule.h @@ -35,6 +35,7 @@ namespace WebCore { class CachedXSLStyleSheet; class XSLImportRule : public StyleBase, private CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr<XSLImportRule> create(XSLStyleSheet* parentSheet, const String& href) { diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index dc89558..ef70b92 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,14 @@ +2011-01-20 Zoltan Horvath <zoltan@webkit.org> + + Reviewed by Csaba Osztrogonác. + + Refactoring of the custom allocation framework + https://bugs.webkit.org/show_bug.cgi?id=49897 + + Inheriting from FastAllocBase can result in objects getting larger (bug #33896, #46589). + The modification replaces Noncopyable and FastAllocBase classes and these inherits with their + equivalent macro implementation at the necessary places. + 2011-01-17 Dan Bernstein <mitz@apple.com> Rubber-stamped by Mark Rowe. diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index a0e0410..e2d81f7 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,792 @@ +2011-01-21 Charlie Reis <creis@chromium.org> + + Reviewed by Darin Fisher. + + Crash in WebCore::HistoryController::itemsAreClones + https://bugs.webkit.org/show_bug.cgi?id=52819 + + Adds sanity checks to help diagnose the crash. + + * src/WebFrameImpl.cpp: + +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Darin Fisher. + + Add run-time enable support for the web audio API + https://bugs.webkit.org/show_bug.cgi?id=52741 + + * public/WebRuntimeFeatures.h: + * public/WebSettings.h: + * src/WebRuntimeFeatures.cpp: + (WebKit::WebRuntimeFeatures::enableWebAudio): + (WebKit::WebRuntimeFeatures::isWebAudioEnabled): + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setWebAudioEnabled): + * src/WebSettingsImpl.h: + +2011-01-21 Ryosuke Niwa <rniwa@webkit.org> + + Unreviewed; another Chromium build fix attempt for r76378. + + * src/WebScrollbarImpl.cpp: + (WebKit::WebScrollbar::create): + (WebKit::WebScrollbarImpl::WebScrollbarImpl): + (WebKit::WebScrollbarImpl::setValue): + +2011-01-21 Ryosuke Niwa <rniwa@webkit.org> + + Unreviewed Chromium build fix attempt for r76378. + + * src/WebScrollbarImpl.cpp: + (WebKit::WebScrollbar::create): + (WebKit::WebScrollbarImpl::WebScrollbarImpl): + +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Kenneth Russell. + + Add chromium bundled audio spatialization resources to WebAudio.grd + https://bugs.webkit.org/show_bug.cgi?id=52651 + + * WebKit.grd: + +2011-01-21 Xiyuan Xia <xiyuan@chromium.org> + + Reviewed by Tony Chang. + + Use WebThemeEngine for relevant RenderTheme parts for chromium/linux. + https://bugs.webkit.org/show_bug.cgi?id=52826 + + * WebKit.gyp: + * src/ChromiumBridge.cpp: + (WebCore::WebThemePart): + (WebCore::GetWebThemeExtraParams): + +2011-01-21 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Part 2 of "Cleanup Scrollbar/ScrollbarClient relationship" + https://bugs.webkit.org/show_bug.cgi?id=52779 + + Rename ScrollbarClient -> ScrollableArea. + + * src/AutoFillPopupMenuClient.cpp: + (WebKit::AutoFillPopupMenuClient::createScrollbar): + * src/AutoFillPopupMenuClient.h: + * src/WebScrollbarImpl.cpp: + (WebKit::WebScrollbarImpl::WebScrollbarImpl): + (WebKit::WebScrollbarImpl::scroll): + (WebKit::WebScrollbarImpl::onMouseWheel): + (WebKit::WebScrollbarImpl::onKeyDown): + * src/WebScrollbarImpl.h: + * tests/PopupMenuTest.cpp: + (WebKit::TestPopupMenuClient::createScrollbar): + +2011-01-21 Sailesh Agrawal <sail@chromium.org> + + Reviewed by Ryosuke Niwa. + + [chromium] Notify WebFrameClient when spellcheck state changes + https://bugs.webkit.org/show_bug.cgi?id=52680 + + * public/WebFrameClient.h: + (WebKit::WebFrameClient::continuousSpellCheckingEnabledStateChanged): + * src/EditorClientImpl.cpp: + (WebKit::EditorClientImpl::toggleContinuousSpellChecking): + * src/WebFrameImpl.cpp: + +2011-01-21 Tony Chang <tony@chromium.org> + + Unreviewed, updating chromium DEPS so we can pull in linux theme changes. + + * DEPS: + +2011-01-21 Adam Klein <adamk@chromium.org> + + Reviewed by Eric Seidel. + + [chromium] Rename ChromiumBridge to PlatformBridge + https://bugs.webkit.org/show_bug.cgi?id=52471 + + * WebKit.gyp: + * src/AssertMatchingEnums.cpp: + * src/PlatformBridge.cpp: + (WebCore::toChromeClientImpl): + (WebCore::toWebWidgetClient): + (WebCore::getCookieJar): + (WebCore::PlatformBridge::cacheMetadata): + (WebCore::PlatformBridge::clipboardIsFormatAvailable): + (WebCore::PlatformBridge::clipboardReadPlainText): + (WebCore::PlatformBridge::clipboardReadHTML): + (WebCore::PlatformBridge::clipboardWriteSelection): + (WebCore::PlatformBridge::clipboardWritePlainText): + (WebCore::PlatformBridge::clipboardWriteURL): + (WebCore::PlatformBridge::clipboardWriteImage): + (WebCore::PlatformBridge::clipboardWriteData): + (WebCore::PlatformBridge::clipboardReadAvailableTypes): + (WebCore::PlatformBridge::clipboardReadData): + (WebCore::PlatformBridge::clipboardReadFilenames): + (WebCore::PlatformBridge::setCookies): + (WebCore::PlatformBridge::cookies): + (WebCore::PlatformBridge::cookieRequestHeaderFieldValue): + (WebCore::PlatformBridge::rawCookies): + (WebCore::PlatformBridge::deleteCookie): + (WebCore::PlatformBridge::cookiesEnabled): + (WebCore::PlatformBridge::prefetchDNS): + (WebCore::PlatformBridge::fileExists): + (WebCore::PlatformBridge::deleteFile): + (WebCore::PlatformBridge::deleteEmptyDirectory): + (WebCore::PlatformBridge::getFileSize): + (WebCore::PlatformBridge::revealFolderInOS): + (WebCore::PlatformBridge::getFileModificationTime): + (WebCore::PlatformBridge::directoryName): + (WebCore::PlatformBridge::pathByAppendingComponent): + (WebCore::PlatformBridge::makeAllDirectories): + (WebCore::PlatformBridge::getAbsolutePath): + (WebCore::PlatformBridge::isDirectory): + (WebCore::PlatformBridge::filePathToURL): + (WebCore::PlatformBridge::openFile): + (WebCore::PlatformBridge::closeFile): + (WebCore::PlatformBridge::seekFile): + (WebCore::PlatformBridge::truncateFile): + (WebCore::PlatformBridge::readFromFile): + (WebCore::PlatformBridge::writeToFile): + (WebCore::PlatformBridge::ensureFontLoaded): + (WebCore::PlatformBridge::getFontFamilyForCharacters): + (WebCore::PlatformBridge::getRenderStyleForStrike): + (WebCore::PlatformBridge::loadFont): + (WebCore::PlatformBridge::databaseOpenFile): + (WebCore::PlatformBridge::databaseDeleteFile): + (WebCore::PlatformBridge::databaseGetFileAttributes): + (WebCore::PlatformBridge::databaseGetFileSize): + (WebCore::PlatformBridge::idbFactory): + (WebCore::PlatformBridge::idbShutdown): + (WebCore::PlatformBridge::createIDBKeysFromSerializedValuesAndKeyPath): + (WebCore::PlatformBridge::signedPublicKeyAndChallengeString): + (WebCore::PlatformBridge::computedDefaultLanguage): + (WebCore::PlatformBridge::layoutTestMode): + (WebCore::PlatformBridge::isSupportedImageMIMEType): + (WebCore::PlatformBridge::isSupportedJavaScriptMIMEType): + (WebCore::PlatformBridge::isSupportedNonImageMIMEType): + (WebCore::PlatformBridge::mimeTypeForExtension): + (WebCore::PlatformBridge::mimeTypeFromFile): + (WebCore::PlatformBridge::preferredExtensionForMIMEType): + (WebCore::PlatformBridge::plugins): + (WebCore::PlatformBridge::pluginScriptableObject): + (WebCore::PlatformBridge::loadPlatformImageResource): + (WebCore::PlatformBridge::loadPlatformAudioResource): + (WebCore::PlatformBridge::decodeAudioFileData): + (WebCore::PlatformBridge::sandboxEnabled): + (WebCore::PlatformBridge::setSharedTimerFiredFunction): + (WebCore::PlatformBridge::setSharedTimerFireTime): + (WebCore::PlatformBridge::stopSharedTimer): + (WebCore::PlatformBridge::decrementStatsCounter): + (WebCore::PlatformBridge::incrementStatsCounter): + (WebCore::PlatformBridge::histogramCustomCounts): + (WebCore::PlatformBridge::histogramEnumeration): + (WebCore::PlatformBridge::suddenTerminationChanged): + (WebCore::PlatformBridge::currentTime): + (WebCore::PlatformBridge::paintButton): + (WebCore::PlatformBridge::paintMenuList): + (WebCore::PlatformBridge::paintScrollbarArrow): + (WebCore::PlatformBridge::paintScrollbarThumb): + (WebCore::PlatformBridge::paintScrollbarTrack): + (WebCore::PlatformBridge::paintSpinButton): + (WebCore::PlatformBridge::paintTextField): + (WebCore::PlatformBridge::paintTrackbar): + (WebCore::PlatformBridge::paintProgressBar): + (WebCore::WebThemePart): + (WebCore::WebThemeState): + (WebCore::GetWebThemeExtraParams): + (WebCore::PlatformBridge::getThemePartSize): + (WebCore::PlatformBridge::paintThemePart): + (WebCore::PlatformBridge::traceEventBegin): + (WebCore::PlatformBridge::traceEventEnd): + (WebCore::PlatformBridge::visitedLinkHash): + (WebCore::PlatformBridge::isLinkVisited): + (WebCore::PlatformBridge::notifyJSOutOfMemory): + (WebCore::PlatformBridge::memoryUsageMB): + (WebCore::PlatformBridge::actualMemoryUsageMB): + (WebCore::PlatformBridge::screenDepth): + (WebCore::PlatformBridge::screenDepthPerComponent): + (WebCore::PlatformBridge::screenIsMonochrome): + (WebCore::PlatformBridge::screenRect): + (WebCore::PlatformBridge::screenAvailableRect): + (WebCore::PlatformBridge::popupsAllowed): + (WebCore::WorkerContextProxy::create): + * src/ResourceHandle.cpp: + (WebCore::ResourceHandle::cacheMetadata): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::WebFrameImpl): + (WebKit::WebFrameImpl::~WebFrameImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): + +2011-01-20 Adam Klein <adamk@chromium.org> + + Reviewed by Andreas Kling. + + [chromium] Remove deprecated WebKit::nameOfInputElement function + https://bugs.webkit.org/show_bug.cgi?id=52824 + + * src/DOMUtilitiesPrivate.cpp: + * src/DOMUtilitiesPrivate.h: + +2011-01-20 Sam Weinig <sam@webkit.org> + + Reviewed by Dave Hyatt. + + Cleanup Scrollbar/ScrollbarClient relationship + https://bugs.webkit.org/show_bug.cgi?id=52779 + + * src/WebScrollbarImpl.cpp: + (WebKit::WebScrollbarImpl::WebScrollbarImpl): + (WebKit::WebScrollbarImpl::value): + (WebKit::WebScrollbarImpl::setValue): + (WebKit::WebScrollbarImpl::scroll): + (WebKit::WebScrollbarImpl::onMouseDown): + (WebKit::WebScrollbarImpl::onMouseMove): + (WebKit::WebScrollbarImpl::onMouseWheel): + (WebKit::WebScrollbarImpl::onKeyDown): + (WebKit::WebScrollbarImpl::scrollPosition): + (WebKit::WebScrollbarImpl::setScrollOffset): + * src/WebScrollbarImpl.h: + +2011-01-20 James Robinson <jamesr@chromium.org> + + Reviewed by Darin Fisher. + + Implement mozilla's requestAnimationFrame API + https://bugs.webkit.org/show_bug.cgi?id=51218 + + Chromium WebKit API support for window.webkitRequestAnimationFrame() + + * features.gypi: + * public/WebWidget.h: + * public/WebWidgetClient.h: + (WebKit::WebWidgetClient::scheduleAnimation): + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::scheduleAnimation): + * src/ChromeClientImpl.h: + * src/WebPopupMenuImpl.cpp: + (WebKit::WebPopupMenuImpl::animate): + (WebKit::WebPopupMenuImpl::scheduleAnimation): + * src/WebPopupMenuImpl.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::animate): + * src/WebViewImpl.h: + +2010-12-14 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Adam Barth. + + [V8] Get rid of delayed exception reporting in V8ConsoleMessage.cpp + https://bugs.webkit.org/show_bug.cgi?id=51044 + + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::runJavaScriptAlert): + * src/WebScriptController.cpp: + (WebKit::WebScriptController::flushConsoleMessages): + +2010-12-27 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown + https://bugs.webkit.org/show_bug.cgi?id=8519 + + Uncaught exceptions are propagated to window.onerror hander if one is present. + The handler is expected to be a function accepting three arguments: error message, + resource url and line number where the exception occured. + + It was decided to dispatch ErrorEvent to all listeners/handlers no matter if they + were created in the same isolated world where the exception occured or not. + + Tests: fast/events/window-onerror1.html + fast/events/window-onerror10.html + fast/events/window-onerror11.html + fast/events/window-onerror12.html + fast/events/window-onerror2.html + fast/events/window-onerror3.html + fast/events/window-onerror4.html + fast/events/window-onerror5.html + fast/events/window-onerror6.html + fast/events/window-onerror7.html + fast/events/window-onerror8.html + fast/events/window-onerror9.html + http/tests/security/window-onerror-exception-in-iframe.html + userscripts/window-onerror-for-isolated-world-1.html + userscripts/window-onerror-for-isolated-world-2.html + + * src/WebWorkerClientImpl.cpp: + (WebKit::WebWorkerClientImpl::postExceptionToWorkerObject): + (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObject): + (WebKit::WebWorkerClientImpl::postExceptionToWorkerObjectTask): + (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask): + +2011-01-19 Dmitry Titov <dimich@chromium.org> + + [Chromium] Unreviewed, build fix. + + During revert of 76203, sheriffbot did not revert "rename+change" correctly. + + * src/ChromiumBridge.cpp: Renamed from Source/WebKit/chromium/src/PlatformBridge.cpp. + (WebCore::toChromeClientImpl): + (WebCore::toWebWidgetClient): + (WebCore::getCookieJar): + (WebCore::ChromiumBridge::cacheMetadata): + (WebCore::ChromiumBridge::clipboardIsFormatAvailable): + (WebCore::ChromiumBridge::clipboardReadPlainText): + (WebCore::ChromiumBridge::clipboardReadHTML): + (WebCore::ChromiumBridge::clipboardWriteSelection): + (WebCore::ChromiumBridge::clipboardWritePlainText): + (WebCore::ChromiumBridge::clipboardWriteURL): + (WebCore::ChromiumBridge::clipboardWriteImage): + (WebCore::ChromiumBridge::clipboardWriteData): + (WebCore::ChromiumBridge::clipboardReadAvailableTypes): + (WebCore::ChromiumBridge::clipboardReadData): + (WebCore::ChromiumBridge::clipboardReadFilenames): + (WebCore::ChromiumBridge::setCookies): + (WebCore::ChromiumBridge::cookies): + (WebCore::ChromiumBridge::cookieRequestHeaderFieldValue): + (WebCore::ChromiumBridge::rawCookies): + (WebCore::ChromiumBridge::deleteCookie): + (WebCore::ChromiumBridge::cookiesEnabled): + (WebCore::ChromiumBridge::prefetchDNS): + (WebCore::ChromiumBridge::fileExists): + (WebCore::ChromiumBridge::deleteFile): + (WebCore::ChromiumBridge::deleteEmptyDirectory): + (WebCore::ChromiumBridge::getFileSize): + (WebCore::ChromiumBridge::revealFolderInOS): + (WebCore::ChromiumBridge::getFileModificationTime): + (WebCore::ChromiumBridge::directoryName): + (WebCore::ChromiumBridge::pathByAppendingComponent): + (WebCore::ChromiumBridge::makeAllDirectories): + (WebCore::ChromiumBridge::getAbsolutePath): + (WebCore::ChromiumBridge::isDirectory): + (WebCore::ChromiumBridge::filePathToURL): + (WebCore::ChromiumBridge::openFile): + (WebCore::ChromiumBridge::closeFile): + (WebCore::ChromiumBridge::seekFile): + (WebCore::ChromiumBridge::truncateFile): + (WebCore::ChromiumBridge::readFromFile): + (WebCore::ChromiumBridge::writeToFile): + (WebCore::ChromiumBridge::ensureFontLoaded): + (WebCore::ChromiumBridge::getFontFamilyForCharacters): + (WebCore::ChromiumBridge::getRenderStyleForStrike): + (WebCore::ChromiumBridge::loadFont): + (WebCore::ChromiumBridge::databaseOpenFile): + (WebCore::ChromiumBridge::databaseDeleteFile): + (WebCore::ChromiumBridge::databaseGetFileAttributes): + (WebCore::ChromiumBridge::databaseGetFileSize): + (WebCore::ChromiumBridge::idbFactory): + (WebCore::ChromiumBridge::idbShutdown): + (WebCore::ChromiumBridge::createIDBKeysFromSerializedValuesAndKeyPath): + (WebCore::ChromiumBridge::signedPublicKeyAndChallengeString): + (WebCore::ChromiumBridge::computedDefaultLanguage): + (WebCore::ChromiumBridge::layoutTestMode): + (WebCore::ChromiumBridge::isSupportedImageMIMEType): + (WebCore::ChromiumBridge::isSupportedJavaScriptMIMEType): + (WebCore::ChromiumBridge::isSupportedNonImageMIMEType): + (WebCore::ChromiumBridge::mimeTypeForExtension): + (WebCore::ChromiumBridge::mimeTypeFromFile): + (WebCore::ChromiumBridge::preferredExtensionForMIMEType): + (WebCore::ChromiumBridge::plugins): + (WebCore::ChromiumBridge::pluginScriptableObject): + (WebCore::ChromiumBridge::loadPlatformImageResource): + (WebCore::ChromiumBridge::loadPlatformAudioResource): + (WebCore::ChromiumBridge::decodeAudioFileData): + (WebCore::ChromiumBridge::sandboxEnabled): + (WebCore::ChromiumBridge::setSharedTimerFiredFunction): + (WebCore::ChromiumBridge::setSharedTimerFireTime): + (WebCore::ChromiumBridge::stopSharedTimer): + (WebCore::ChromiumBridge::decrementStatsCounter): + (WebCore::ChromiumBridge::incrementStatsCounter): + (WebCore::ChromiumBridge::histogramCustomCounts): + (WebCore::ChromiumBridge::histogramEnumeration): + (WebCore::ChromiumBridge::suddenTerminationChanged): + (WebCore::ChromiumBridge::currentTime): + (WebCore::ChromiumBridge::paintButton): + (WebCore::ChromiumBridge::paintMenuList): + (WebCore::ChromiumBridge::paintScrollbarArrow): + (WebCore::ChromiumBridge::paintScrollbarThumb): + (WebCore::ChromiumBridge::paintScrollbarTrack): + (WebCore::ChromiumBridge::paintSpinButton): + (WebCore::ChromiumBridge::paintTextField): + (WebCore::ChromiumBridge::paintTrackbar): + (WebCore::ChromiumBridge::paintProgressBar): + (WebCore::WebThemePart): + (WebCore::WebThemeState): + (WebCore::GetWebThemeExtraParams): + (WebCore::ChromiumBridge::getThemePartSize): + (WebCore::ChromiumBridge::paintThemePart): + (WebCore::ChromiumBridge::traceEventBegin): + (WebCore::ChromiumBridge::traceEventEnd): + (WebCore::ChromiumBridge::visitedLinkHash): + (WebCore::ChromiumBridge::isLinkVisited): + (WebCore::ChromiumBridge::notifyJSOutOfMemory): + (WebCore::ChromiumBridge::memoryUsageMB): + (WebCore::ChromiumBridge::actualMemoryUsageMB): + (WebCore::ChromiumBridge::screenDepth): + (WebCore::ChromiumBridge::screenDepthPerComponent): + (WebCore::ChromiumBridge::screenIsMonochrome): + (WebCore::ChromiumBridge::screenRect): + (WebCore::ChromiumBridge::screenAvailableRect): + (WebCore::ChromiumBridge::popupsAllowed): + (WebCore::WorkerContextProxy::create): + +2011-01-19 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r76203. + http://trac.webkit.org/changeset/76203 + https://bugs.webkit.org/show_bug.cgi?id=52784 + + Broke Win compile on Chromium bots (Requested by dimich on + #webkit). + + * WebKit.gyp: + * src/AssertMatchingEnums.cpp: + * src/ChromiumBridge.cpp: Renamed from Source/WebKit/chromium/src/PlatformBridge.cpp. + (WebCore::toChromeClientImpl): + (WebCore::toWebWidgetClient): + (WebCore::getCookieJar): + (WebCore::ChromiumBridge::cacheMetadata): + (WebCore::ChromiumBridge::clipboardIsFormatAvailable): + (WebCore::ChromiumBridge::clipboardReadPlainText): + (WebCore::ChromiumBridge::clipboardReadHTML): + (WebCore::ChromiumBridge::clipboardWriteSelection): + (WebCore::ChromiumBridge::clipboardWritePlainText): + (WebCore::ChromiumBridge::clipboardWriteURL): + (WebCore::ChromiumBridge::clipboardWriteImage): + (WebCore::ChromiumBridge::clipboardWriteData): + (WebCore::ChromiumBridge::clipboardReadAvailableTypes): + (WebCore::ChromiumBridge::clipboardReadData): + (WebCore::ChromiumBridge::clipboardReadFilenames): + (WebCore::ChromiumBridge::setCookies): + (WebCore::ChromiumBridge::cookies): + (WebCore::ChromiumBridge::cookieRequestHeaderFieldValue): + (WebCore::ChromiumBridge::rawCookies): + (WebCore::ChromiumBridge::deleteCookie): + (WebCore::ChromiumBridge::cookiesEnabled): + (WebCore::ChromiumBridge::prefetchDNS): + (WebCore::ChromiumBridge::fileExists): + (WebCore::ChromiumBridge::deleteFile): + (WebCore::ChromiumBridge::deleteEmptyDirectory): + (WebCore::ChromiumBridge::getFileSize): + (WebCore::ChromiumBridge::revealFolderInOS): + (WebCore::ChromiumBridge::getFileModificationTime): + (WebCore::ChromiumBridge::directoryName): + (WebCore::ChromiumBridge::pathByAppendingComponent): + (WebCore::ChromiumBridge::makeAllDirectories): + (WebCore::ChromiumBridge::getAbsolutePath): + (WebCore::ChromiumBridge::isDirectory): + (WebCore::ChromiumBridge::filePathToURL): + (WebCore::ChromiumBridge::openFile): + (WebCore::ChromiumBridge::closeFile): + (WebCore::ChromiumBridge::seekFile): + (WebCore::ChromiumBridge::truncateFile): + (WebCore::ChromiumBridge::readFromFile): + (WebCore::ChromiumBridge::writeToFile): + (WebCore::ChromiumBridge::ensureFontLoaded): + (WebCore::ChromiumBridge::getFontFamilyForCharacters): + (WebCore::ChromiumBridge::getRenderStyleForStrike): + (WebCore::ChromiumBridge::loadFont): + (WebCore::ChromiumBridge::databaseOpenFile): + (WebCore::ChromiumBridge::databaseDeleteFile): + (WebCore::ChromiumBridge::databaseGetFileAttributes): + (WebCore::ChromiumBridge::databaseGetFileSize): + (WebCore::ChromiumBridge::idbFactory): + (WebCore::ChromiumBridge::idbShutdown): + (WebCore::ChromiumBridge::createIDBKeysFromSerializedValuesAndKeyPath): + (WebCore::ChromiumBridge::signedPublicKeyAndChallengeString): + (WebCore::ChromiumBridge::computedDefaultLanguage): + (WebCore::ChromiumBridge::layoutTestMode): + (WebCore::ChromiumBridge::isSupportedImageMIMEType): + (WebCore::ChromiumBridge::isSupportedJavaScriptMIMEType): + (WebCore::ChromiumBridge::isSupportedNonImageMIMEType): + (WebCore::ChromiumBridge::mimeTypeForExtension): + (WebCore::ChromiumBridge::mimeTypeFromFile): + (WebCore::ChromiumBridge::preferredExtensionForMIMEType): + (WebCore::ChromiumBridge::plugins): + (WebCore::ChromiumBridge::pluginScriptableObject): + (WebCore::ChromiumBridge::loadPlatformImageResource): + (WebCore::ChromiumBridge::loadPlatformAudioResource): + (WebCore::ChromiumBridge::decodeAudioFileData): + (WebCore::ChromiumBridge::sandboxEnabled): + (WebCore::ChromiumBridge::setSharedTimerFiredFunction): + (WebCore::ChromiumBridge::setSharedTimerFireTime): + (WebCore::ChromiumBridge::stopSharedTimer): + (WebCore::ChromiumBridge::decrementStatsCounter): + (WebCore::ChromiumBridge::incrementStatsCounter): + (WebCore::ChromiumBridge::histogramCustomCounts): + (WebCore::ChromiumBridge::histogramEnumeration): + (WebCore::ChromiumBridge::suddenTerminationChanged): + (WebCore::ChromiumBridge::currentTime): + (WebCore::ChromiumBridge::paintButton): + (WebCore::ChromiumBridge::paintMenuList): + (WebCore::ChromiumBridge::paintScrollbarArrow): + (WebCore::ChromiumBridge::paintScrollbarThumb): + (WebCore::ChromiumBridge::paintScrollbarTrack): + (WebCore::ChromiumBridge::paintSpinButton): + (WebCore::ChromiumBridge::paintTextField): + (WebCore::ChromiumBridge::paintTrackbar): + (WebCore::ChromiumBridge::paintProgressBar): + (WebCore::WebThemePart): + (WebCore::WebThemeState): + (WebCore::GetWebThemeExtraParams): + (WebCore::ChromiumBridge::getThemePartSize): + (WebCore::ChromiumBridge::paintThemePart): + (WebCore::ChromiumBridge::traceEventBegin): + (WebCore::ChromiumBridge::traceEventEnd): + (WebCore::ChromiumBridge::visitedLinkHash): + (WebCore::ChromiumBridge::isLinkVisited): + (WebCore::ChromiumBridge::notifyJSOutOfMemory): + (WebCore::ChromiumBridge::memoryUsageMB): + (WebCore::ChromiumBridge::actualMemoryUsageMB): + (WebCore::ChromiumBridge::screenDepth): + (WebCore::ChromiumBridge::screenDepthPerComponent): + (WebCore::ChromiumBridge::screenIsMonochrome): + (WebCore::ChromiumBridge::screenRect): + (WebCore::ChromiumBridge::screenAvailableRect): + (WebCore::ChromiumBridge::popupsAllowed): + (WebCore::WorkerContextProxy::create): + * src/ResourceHandle.cpp: + (WebCore::ResourceHandle::cacheMetadata): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::WebFrameImpl): + (WebKit::WebFrameImpl::~WebFrameImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): + +2011-01-19 Adam Klein <adamk@chromium.org> + + Reviewed by Darin Fisher. + + [chromium] Rename ChromiumBridge to PlatformBridge + https://bugs.webkit.org/show_bug.cgi?id=52471 + + * WebKit.gyp: + * src/AssertMatchingEnums.cpp: + * src/PlatformBridge.cpp: + (WebCore::toChromeClientImpl): + (WebCore::toWebWidgetClient): + (WebCore::getCookieJar): + (WebCore::PlatformBridge::cacheMetadata): + (WebCore::PlatformBridge::clipboardIsFormatAvailable): + (WebCore::PlatformBridge::clipboardReadPlainText): + (WebCore::PlatformBridge::clipboardReadHTML): + (WebCore::PlatformBridge::clipboardWriteSelection): + (WebCore::PlatformBridge::clipboardWritePlainText): + (WebCore::PlatformBridge::clipboardWriteURL): + (WebCore::PlatformBridge::clipboardWriteImage): + (WebCore::PlatformBridge::clipboardWriteData): + (WebCore::PlatformBridge::clipboardReadAvailableTypes): + (WebCore::PlatformBridge::clipboardReadData): + (WebCore::PlatformBridge::clipboardReadFilenames): + (WebCore::PlatformBridge::setCookies): + (WebCore::PlatformBridge::cookies): + (WebCore::PlatformBridge::cookieRequestHeaderFieldValue): + (WebCore::PlatformBridge::rawCookies): + (WebCore::PlatformBridge::deleteCookie): + (WebCore::PlatformBridge::cookiesEnabled): + (WebCore::PlatformBridge::prefetchDNS): + (WebCore::PlatformBridge::fileExists): + (WebCore::PlatformBridge::deleteFile): + (WebCore::PlatformBridge::deleteEmptyDirectory): + (WebCore::PlatformBridge::getFileSize): + (WebCore::PlatformBridge::revealFolderInOS): + (WebCore::PlatformBridge::getFileModificationTime): + (WebCore::PlatformBridge::directoryName): + (WebCore::PlatformBridge::pathByAppendingComponent): + (WebCore::PlatformBridge::makeAllDirectories): + (WebCore::PlatformBridge::getAbsolutePath): + (WebCore::PlatformBridge::isDirectory): + (WebCore::PlatformBridge::filePathToURL): + (WebCore::PlatformBridge::openFile): + (WebCore::PlatformBridge::closeFile): + (WebCore::PlatformBridge::seekFile): + (WebCore::PlatformBridge::truncateFile): + (WebCore::PlatformBridge::readFromFile): + (WebCore::PlatformBridge::writeToFile): + (WebCore::PlatformBridge::ensureFontLoaded): + (WebCore::PlatformBridge::getFontFamilyForCharacters): + (WebCore::PlatformBridge::getRenderStyleForStrike): + (WebCore::PlatformBridge::loadFont): + (WebCore::PlatformBridge::databaseOpenFile): + (WebCore::PlatformBridge::databaseDeleteFile): + (WebCore::PlatformBridge::databaseGetFileAttributes): + (WebCore::PlatformBridge::databaseGetFileSize): + (WebCore::PlatformBridge::idbFactory): + (WebCore::PlatformBridge::idbShutdown): + (WebCore::PlatformBridge::createIDBKeysFromSerializedValuesAndKeyPath): + (WebCore::PlatformBridge::signedPublicKeyAndChallengeString): + (WebCore::PlatformBridge::computedDefaultLanguage): + (WebCore::PlatformBridge::layoutTestMode): + (WebCore::PlatformBridge::isSupportedImageMIMEType): + (WebCore::PlatformBridge::isSupportedJavaScriptMIMEType): + (WebCore::PlatformBridge::isSupportedNonImageMIMEType): + (WebCore::PlatformBridge::mimeTypeForExtension): + (WebCore::PlatformBridge::mimeTypeFromFile): + (WebCore::PlatformBridge::preferredExtensionForMIMEType): + (WebCore::PlatformBridge::plugins): + (WebCore::PlatformBridge::pluginScriptableObject): + (WebCore::PlatformBridge::loadPlatformImageResource): + (WebCore::PlatformBridge::loadPlatformAudioResource): + (WebCore::PlatformBridge::decodeAudioFileData): + (WebCore::PlatformBridge::sandboxEnabled): + (WebCore::PlatformBridge::setSharedTimerFiredFunction): + (WebCore::PlatformBridge::setSharedTimerFireTime): + (WebCore::PlatformBridge::stopSharedTimer): + (WebCore::PlatformBridge::decrementStatsCounter): + (WebCore::PlatformBridge::incrementStatsCounter): + (WebCore::PlatformBridge::histogramCustomCounts): + (WebCore::PlatformBridge::histogramEnumeration): + (WebCore::PlatformBridge::suddenTerminationChanged): + (WebCore::PlatformBridge::currentTime): + (WebCore::PlatformBridge::paintButton): + (WebCore::PlatformBridge::paintMenuList): + (WebCore::PlatformBridge::paintScrollbarArrow): + (WebCore::PlatformBridge::paintScrollbarThumb): + (WebCore::PlatformBridge::paintScrollbarTrack): + (WebCore::PlatformBridge::paintSpinButton): + (WebCore::PlatformBridge::paintTextField): + (WebCore::PlatformBridge::paintTrackbar): + (WebCore::PlatformBridge::paintProgressBar): + (WebCore::WebThemePart): + (WebCore::WebThemeState): + (WebCore::GetWebThemeExtraParams): + (WebCore::PlatformBridge::getThemePartSize): + (WebCore::PlatformBridge::paintThemePart): + (WebCore::PlatformBridge::traceEventBegin): + (WebCore::PlatformBridge::traceEventEnd): + (WebCore::PlatformBridge::visitedLinkHash): + (WebCore::PlatformBridge::isLinkVisited): + (WebCore::PlatformBridge::notifyJSOutOfMemory): + (WebCore::PlatformBridge::memoryUsageMB): + (WebCore::PlatformBridge::actualMemoryUsageMB): + (WebCore::PlatformBridge::screenDepth): + (WebCore::PlatformBridge::screenDepthPerComponent): + (WebCore::PlatformBridge::screenIsMonochrome): + (WebCore::PlatformBridge::screenRect): + (WebCore::PlatformBridge::screenAvailableRect): + (WebCore::PlatformBridge::popupsAllowed): + (WebCore::WorkerContextProxy::create): + * src/ResourceHandle.cpp: + (WebCore::ResourceHandle::cacheMetadata): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::WebFrameImpl): + (WebKit::WebFrameImpl::~WebFrameImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): + +2011-01-19 James Robinson <jamesr@chromium.org> + + Unreviewed, rolling out r76194. + http://trac.webkit.org/changeset/76194 + https://bugs.webkit.org/show_bug.cgi?id=51218 + + Caused mysterious compile failure on the chromium win + build.webkit.org bots + + * features.gypi: + * public/WebWidget.h: + * public/WebWidgetClient.h: + * src/ChromeClientImpl.cpp: + * src/ChromeClientImpl.h: + * src/WebPopupMenuImpl.cpp: + * src/WebPopupMenuImpl.h: + * src/WebViewImpl.cpp: + * src/WebViewImpl.h: + +2011-01-19 James Robinson <jamesr@chromium.org> + + Reviewed by Darin Fisher. + + Implement mozilla's requestAnimationFrame API + https://bugs.webkit.org/show_bug.cgi?id=51218 + + Chromium WebKit API support for window.webkitRequestAnimationFrame() + + * features.gypi: + * public/WebWidget.h: + * public/WebWidgetClient.h: + (WebKit::WebWidgetClient::scheduleAnimation): + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::scheduleAnimation): + * src/ChromeClientImpl.h: + * src/WebPopupMenuImpl.cpp: + (WebKit::WebPopupMenuImpl::animate): + (WebKit::WebPopupMenuImpl::scheduleAnimation): + * src/WebPopupMenuImpl.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::animate): + * src/WebViewImpl.h: + +2011-01-19 Tony Chang <tony@chromium.org> + + Unreviewed, roll chromium deps to pick up fixes for the linux build. + + * DEPS: + +2011-01-19 Satish Sampath <satish@chromium.org> + + Reviewed by Jeremy Orlow. + + Send origin/url as part of speech input requests to the embedder. + https://bugs.webkit.org/show_bug.cgi?id=52718 + + * public/WebSpeechInputController.h: + (WebKit::WebSpeechInputController::startRecognition): Updated prototype. + * src/SpeechInputClientImpl.cpp: + (WebKit::SpeechInputClientImpl::startRecognition): Pass up additional origin parameter. + * src/SpeechInputClientImpl.h: + * src/WebSpeechInputControllerMockImpl.cpp: Updated code to pass additional parameter. + (WebKit::WebSpeechInputControllerMockImpl::startRecognition): + * src/WebSpeechInputControllerMockImpl.h: Added new variant of startRecognition method. + +2011-01-19 Pavel Feldman <pfeldman@chromium.org> + + Not reviewed: updating Chromium devtools sanity tests for downstream use. + + * src/js/Tests.js: + (.TestSuite.prototype._checkExecutionLine): + +2011-01-18 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: make InjectedScriptAccess API a part of Web Inspector protocol. + https://bugs.webkit.org/show_bug.cgi?id=52652 + + Calls served by the InjectedScript should be first class protocol + citizens, not dispatched via single protocol message. + + * src/js/Tests.js: + +2011-01-18 Victoria Kirst <vrk@chromium.org> + + Reviewed by Kenneth Russell. + + [chromium] Adding support for YV16 video frame formats. + https://bugs.webkit.org/show_bug.cgi?id=52345 + + * src/VideoFrameChromiumImpl.cpp: + (WebKit::VideoFrameChromiumImpl::requiredTextureSize): + +2011-01-18 Adam Klein <adamk@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] Replace ChromiumBridge::widgetSetCursor with ChromeClient::setCursor + https://bugs.webkit.org/show_bug.cgi?id=42236 + + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::setCursor): + * src/ChromeClientImpl.h: + * src/ChromiumBridge.cpp: + 2011-01-17 Nico Weber <thakis@chromium.org> Unreviewed. diff --git a/Source/WebKit/chromium/DEPS b/Source/WebKit/chromium/DEPS index 78e8b45..8d08c3f 100644 --- a/Source/WebKit/chromium/DEPS +++ b/Source/WebKit/chromium/DEPS @@ -32,7 +32,7 @@ vars = { 'chromium_svn': 'http://src.chromium.org/svn/trunk/src', - 'chromium_rev': '71607' + 'chromium_rev': '71969' } deps = { diff --git a/Source/WebKit/chromium/WebKit.grd b/Source/WebKit/chromium/WebKit.grd index 9b02554..38570b9 100644 --- a/Source/WebKit/chromium/WebKit.grd +++ b/Source/WebKit/chromium/WebKit.grd @@ -10,6 +10,246 @@ <release seq="1"> <includes> <include name="IDR_DEVTOOLS_DEBUGGER_SCRIPT_JS" file="..\..\..\Source\WebCore\bindings\v8\DebuggerScript.js" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T000_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T000_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T015_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T015_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T030_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T030_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T045_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T045_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T060_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T060_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T075_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T075_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T090_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T090_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T105_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T105_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T120_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T120_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T135_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T135_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T150_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T150_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T165_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T165_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T180_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T180_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T195_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T195_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T210_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T210_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T225_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T225_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T240_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T240_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T255_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T255_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T270_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T270_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T285_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T285_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T300_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T300_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T315_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T315_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T330_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T330_P345.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P000" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P000.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P015" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P015.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P030" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P030.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P045" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P045.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P060" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P060.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P075" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P075.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P090" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P090.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P315" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P315.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P330" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P330.wav" type="BINDATA"/> + <include name="IDR_AUDIO_SPATIALIZATION_T345_P345" file="..\..\WebCore\platform\audio\resources\IRC_Composite_C_R0195_T345_P345.wav" type="BINDATA"/> </includes> </release> </grit> diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index 85f671d..3a3672c 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -315,7 +315,6 @@ 'src/BoundObject.h', 'src/ChromeClientImpl.cpp', 'src/ChromeClientImpl.h', - 'src/ChromiumBridge.cpp', 'src/ChromiumCurrentTime.cpp', 'src/ChromiumThreading.cpp', 'src/CompositionUnderlineBuilder.h', @@ -384,6 +383,7 @@ 'src/MediaPlayerPrivateChromium.cpp', 'src/NotificationPresenterImpl.h', 'src/NotificationPresenterImpl.cpp', + 'src/PlatformBridge.cpp', 'src/PlatformMessagePortChannel.cpp', 'src/PlatformMessagePortChannel.h', 'src/ResourceHandle.cpp', @@ -952,6 +952,7 @@ 'variables': { 'repack_path': '<(chromium_src_dir)/tools/data_pack/repack.py', 'pak_inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/gfx/gfx_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak', diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi index 372cc5c..7f4cda6 100644 --- a/Source/WebKit/chromium/features.gypi +++ b/Source/WebKit/chromium/features.gypi @@ -69,6 +69,7 @@ 'ENABLE_OPENTYPE_SANITIZER=1', 'ENABLE_ORIENTATION_EVENTS=0', 'ENABLE_PROGRESS_TAG=1', + 'ENABLE_REQUEST_ANIMATION_FRAME=1', 'ENABLE_SHARED_WORKERS=1', 'ENABLE_SVG=1', 'ENABLE_SVG_ANIMATION=1', diff --git a/Source/WebKit/chromium/public/WebFrameClient.h b/Source/WebKit/chromium/public/WebFrameClient.h index 1c6fd04..2e1890a 100644 --- a/Source/WebKit/chromium/public/WebFrameClient.h +++ b/Source/WebKit/chromium/public/WebFrameClient.h @@ -109,6 +109,9 @@ public: // Controls whether images are allowed for this frame. virtual bool allowImages(WebFrame*, bool enabledPerSettings) { return enabledPerSettings; } + // Notifies the client that continuous spell checking has been enabled or + // disabled. + virtual void didToggleContinuousSpellChecking(WebFrame*) { } // Load commands ------------------------------------------------------- diff --git a/Source/WebKit/chromium/public/WebRuntimeFeatures.h b/Source/WebKit/chromium/public/WebRuntimeFeatures.h index 5537ee2..097e95b 100644 --- a/Source/WebKit/chromium/public/WebRuntimeFeatures.h +++ b/Source/WebKit/chromium/public/WebRuntimeFeatures.h @@ -68,6 +68,9 @@ public: WEBKIT_API static void enableIndexedDatabase(bool); WEBKIT_API static bool isIndexedDatabaseEnabled(); + WEBKIT_API static void enableWebAudio(bool); + WEBKIT_API static bool isWebAudioEnabled(); + WEBKIT_API static void enableWebGL(bool); WEBKIT_API static bool isWebGLEnabled(); diff --git a/Source/WebKit/chromium/public/WebSettings.h b/Source/WebKit/chromium/public/WebSettings.h index ccff28b..bfb5122 100644 --- a/Source/WebKit/chromium/public/WebSettings.h +++ b/Source/WebKit/chromium/public/WebSettings.h @@ -89,6 +89,7 @@ public: virtual void setAllowFileAccessFromFileURLs(bool) = 0; virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0; virtual void setOfflineWebApplicationCacheEnabled(bool) = 0; + virtual void setWebAudioEnabled(bool) = 0; virtual void setExperimentalWebGLEnabled(bool) = 0; virtual void setShowDebugBorders(bool) = 0; virtual void setEditingBehavior(EditingBehavior) = 0; diff --git a/Source/WebKit/chromium/public/WebSpeechInputController.h b/Source/WebKit/chromium/public/WebSpeechInputController.h index 6ed546f..eb83ec7 100644 --- a/Source/WebKit/chromium/public/WebSpeechInputController.h +++ b/Source/WebKit/chromium/public/WebSpeechInputController.h @@ -35,8 +35,8 @@ namespace WebKit { -class WebString; struct WebRect; +class WebSecurityOrigin; class WebString; // Provides an embedder API called by WebKit. @@ -45,6 +45,11 @@ public: // Starts speech recognition. Speech will get recorded until the endpointer detects silence, // runs to the limit or stopRecording is called. Progress indications and the recognized // text are returned via the listener interface. + virtual bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin) + { + return startRecognition(requestId, elementRect, language, grammar); + } + // TODO(satish): Remove this once chromium has rolled past the above change. virtual bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar) { WEBKIT_ASSERT_NOT_REACHED(); diff --git a/Source/WebKit/chromium/public/WebWidget.h b/Source/WebKit/chromium/public/WebWidget.h index ccad134..36fbf31 100644 --- a/Source/WebKit/chromium/public/WebWidget.h +++ b/Source/WebKit/chromium/public/WebWidget.h @@ -56,6 +56,10 @@ public: // Called to resize the WebWidget. virtual void resize(const WebSize&) = 0; + // Called to update imperative animation state. This should be called before + // paint, although the client can rate-limit these calls. + virtual void animate() = 0; + // Called to layout the WebWidget. This MUST be called before Paint, // and it may result in calls to WebWidgetClient::didInvalidateRect. virtual void layout() = 0; diff --git a/Source/WebKit/chromium/public/WebWidgetClient.h b/Source/WebKit/chromium/public/WebWidgetClient.h index 373426d..85e4015 100644 --- a/Source/WebKit/chromium/public/WebWidgetClient.h +++ b/Source/WebKit/chromium/public/WebWidgetClient.h @@ -56,6 +56,9 @@ public: // Called when a call to WebWidget::composite is required virtual void scheduleComposite() { } + // Called when a call to WebWidget::animate is required + virtual void scheduleAnimation() { } + // Called when the widget acquires or loses focus, respectively. virtual void didFocus() { } virtual void didBlur() { } diff --git a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp index e1ee4a1..e89fb74 100644 --- a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp +++ b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp @@ -80,7 +80,7 @@ #include <wtf/text/StringImpl.h> #if OS(DARWIN) -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "mac/WebThemeEngine.h" #endif @@ -398,17 +398,17 @@ COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPermissionDenied, Geoloca COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPositionUnavailable, GeolocationError::PositionUnavailable); #if OS(DARWIN) -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateDisabled, ChromiumBridge::StateDisabled); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateInactive, ChromiumBridge::StateInactive); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateActive, ChromiumBridge::StateActive); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StatePressed, ChromiumBridge::StatePressed); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateDisabled, PlatformBridge::StateDisabled); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateInactive, PlatformBridge::StateInactive); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateActive, PlatformBridge::StateActive); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StatePressed, PlatformBridge::StatePressed); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::SizeRegular, ChromiumBridge::SizeRegular); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::SizeSmall, ChromiumBridge::SizeSmall); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::SizeRegular, PlatformBridge::SizeRegular); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::SizeSmall, PlatformBridge::SizeSmall); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarOrientationHorizontal, ChromiumBridge::ScrollbarOrientationHorizontal); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarOrientationVertical, ChromiumBridge::ScrollbarOrientationVertical); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarOrientationHorizontal, PlatformBridge::ScrollbarOrientationHorizontal); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarOrientationVertical, PlatformBridge::ScrollbarOrientationVertical); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarParentScrollView, ChromiumBridge::ScrollbarParentScrollView); -COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarParentRenderLayer, ChromiumBridge::ScrollbarParentRenderLayer); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarParentScrollView, PlatformBridge::ScrollbarParentScrollView); +COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarParentRenderLayer, PlatformBridge::ScrollbarParentRenderLayer); #endif diff --git a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp index 4f57994..2ce31a9 100644 --- a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp +++ b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp @@ -254,11 +254,11 @@ HostWindow* AutoFillPopupMenuClient::hostWindow() const } PassRefPtr<Scrollbar> AutoFillPopupMenuClient::createScrollbar( - ScrollbarClient* client, + ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size) { - return Scrollbar::createNativeScrollbar(client, orientation, size); + return Scrollbar::createNativeScrollbar(scrollableArea, orientation, size); } void AutoFillPopupMenuClient::initialize( diff --git a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.h b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.h index 0129a81..0071121 100644 --- a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.h +++ b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.h @@ -97,7 +97,7 @@ public: virtual WebCore::FontSelector* fontSelector() const; virtual WebCore::HostWindow* hostWindow() const; virtual PassRefPtr<WebCore::Scrollbar> createScrollbar( - WebCore::ScrollbarClient* client, + WebCore::ScrollableArea* client, WebCore::ScrollbarOrientation orientation, WebCore::ScrollbarControlSize size); diff --git a/Source/WebKit/chromium/src/BoundObject.h b/Source/WebKit/chromium/src/BoundObject.h index 769e83f..394ff7c 100644 --- a/Source/WebKit/chromium/src/BoundObject.h +++ b/Source/WebKit/chromium/src/BoundObject.h @@ -39,7 +39,8 @@ 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 { +class BoundObject { + WTF_MAKE_NONCOPYABLE(BoundObject); public: BoundObject(v8::Handle<v8::Context> context, void* v8This, const char* objectName); virtual ~BoundObject(); diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp index 1a984c1..a63a625 100644 --- a/Source/WebKit/chromium/src/ChromeClientImpl.cpp +++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp @@ -436,11 +436,6 @@ void ChromeClientImpl::closeWindowSoon() void ChromeClientImpl::runJavaScriptAlert(Frame* frame, const String& message) { if (m_webView->client()) { -#if USE(V8) - // Before showing the JavaScript dialog, we give the proxy implementation - // a chance to process any pending console messages. - V8Proxy::processConsoleMessages(); -#endif m_webView->client()->runModalAlertDialog( WebFrameImpl::fromFrame(frame), message); } @@ -532,6 +527,13 @@ void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect invalidateContentsAndWindow(updateRect, immediate); } +#if ENABLE(REQUEST_ANIMATION_FRAME) +void ChromeClientImpl::scheduleAnimation() +{ + m_webView->client()->scheduleAnimation(); +} +#endif + void ChromeClientImpl::scroll( const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect& clipRect) @@ -700,6 +702,11 @@ void ChromeClientImpl::popupClosed(WebCore::PopupContainer* popupContainer) m_webView->popupClosed(popupContainer); } +void ChromeClientImpl::setCursor(const WebCore::Cursor& cursor) +{ + setCursor(WebCursorInfo(cursor)); +} + void ChromeClientImpl::setCursor(const WebCursorInfo& cursor) { if (m_webView->client()) diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.h b/Source/WebKit/chromium/src/ChromeClientImpl.h index b024bc0..07f7d1f 100644 --- a/Source/WebKit/chromium/src/ChromeClientImpl.h +++ b/Source/WebKit/chromium/src/ChromeClientImpl.h @@ -105,6 +105,9 @@ public: virtual void invalidateWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); +#if ENABLE(REQUEST_ANIMATION_FRAME) + virtual void scheduleAnimation(); +#endif virtual void scroll( const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect); @@ -132,7 +135,7 @@ public: virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*); virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); virtual void chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*); - virtual void setCursor(const WebCore::Cursor&) { } + virtual void setCursor(const WebCore::Cursor&); virtual void formStateDidChange(const WebCore::Node*); virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; } #if ENABLE(TOUCH_EVENTS) @@ -167,8 +170,7 @@ public: virtual void postAccessibilityNotification(WebCore::AccessibilityObject*, WebCore::AXObjectCache::AXNotification); // ChromeClientImpl: - void setCursor(const WebCursorInfo& cursor); - void setCursorForPlugin(const WebCursorInfo& cursor); + void setCursorForPlugin(const WebCursorInfo&); virtual bool selectItemWritingDirectionIsNatural(); virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const; @@ -180,6 +182,7 @@ public: private: void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*); + void setCursor(const WebCursorInfo&); WebViewImpl* m_webView; // weak pointer bool m_toolbarsVisible; diff --git a/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp index 6f952f7..e688bfa 100644 --- a/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp +++ b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp @@ -39,8 +39,6 @@ #include "HTMLOptionElement.h" #include "Node.h" -#include "WebInputElement.h" - using namespace WebCore; namespace { @@ -79,11 +77,6 @@ HTMLOptionElement* toHTMLOptionElement(Node* node) return toHTMLElement<HTMLOptionElement>(node, HTMLNames::optionTag); } -String nameOfInputElement(HTMLInputElement* element) -{ - return WebInputElement(element).nameForAutofill(); -} - bool elementHasLegalLinkAttribute(const Element* element, const QualifiedName& attrName) { diff --git a/Source/WebKit/chromium/src/DOMUtilitiesPrivate.h b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.h index f5d03a5..99e3d9c 100644 --- a/Source/WebKit/chromium/src/DOMUtilitiesPrivate.h +++ b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.h @@ -31,8 +31,6 @@ #ifndef DOMUtilitiesPrivate_h #define DOMUtilitiesPrivate_h -#include <wtf/Forward.h> - namespace WebCore { class Element; class HTMLInputElement; @@ -53,9 +51,6 @@ WebCore::HTMLLinkElement* toHTMLLinkElement(WebCore::Node*); WebCore::HTMLMetaElement* toHTMLMetaElement(WebCore::Node*); WebCore::HTMLOptionElement* toHTMLOptionElement(WebCore::Node*); -// FIXME: Deprecate. Use WebInputElement::nameForAutofill instead. -WTF::String nameOfInputElement(WebCore::HTMLInputElement*); - // For img, script, iframe, frame element, when attribute name is src, // for link, a, area element, when attribute name is href, // for form element, when attribute name is action, diff --git a/Source/WebKit/chromium/src/DebuggerAgentManager.cpp b/Source/WebKit/chromium/src/DebuggerAgentManager.cpp index 0860cb1..b76bcfe 100644 --- a/Source/WebKit/chromium/src/DebuggerAgentManager.cpp +++ b/Source/WebKit/chromium/src/DebuggerAgentManager.cpp @@ -55,7 +55,8 @@ bool DebuggerAgentManager::s_exposeV8DebuggerProtocol = false; namespace { -class CallerIdWrapper : public v8::Debug::ClientData, public Noncopyable { +class CallerIdWrapper : public v8::Debug::ClientData { + WTF_MAKE_NONCOPYABLE(CallerIdWrapper); public: CallerIdWrapper() : m_callerIsMananager(true), m_callerId(0) { } explicit CallerIdWrapper(int callerId) diff --git a/Source/WebKit/chromium/src/DebuggerAgentManager.h b/Source/WebKit/chromium/src/DebuggerAgentManager.h index 66bd714..a323311 100644 --- a/Source/WebKit/chromium/src/DebuggerAgentManager.h +++ b/Source/WebKit/chromium/src/DebuggerAgentManager.h @@ -63,7 +63,8 @@ class WebViewImpl; // 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 { +class DebuggerAgentManager { + WTF_MAKE_NONCOPYABLE(DebuggerAgentManager); public: static void debugAttach(DebuggerAgentImpl* debuggerAgent); static void debugDetach(DebuggerAgentImpl* debuggerAgent); diff --git a/Source/WebKit/chromium/src/EditorClientImpl.cpp b/Source/WebKit/chromium/src/EditorClientImpl.cpp index 19b5873..68694c2 100644 --- a/Source/WebKit/chromium/src/EditorClientImpl.cpp +++ b/Source/WebKit/chromium/src/EditorClientImpl.cpp @@ -45,6 +45,7 @@ #include "WebAutoFillClient.h" #include "WebEditingAction.h" #include "WebElement.h" +#include "WebFrameClient.h" #include "WebFrameImpl.h" #include "WebKit.h" #include "WebInputElement.h" @@ -161,6 +162,11 @@ void EditorClientImpl::toggleContinuousSpellChecking() m_spellCheckThisFieldStatus = SpellCheckForcedOff; else m_spellCheckThisFieldStatus = SpellCheckForcedOn; + + WebFrameImpl* webframe = WebFrameImpl::fromFrame( + m_webView->focusedWebCoreFrame()); + if (webframe) + webframe->client()->didToggleContinuousSpellChecking(webframe); } bool EditorClientImpl::isGrammarCheckingEnabled() diff --git a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h index fc21f3e..2867917 100644 --- a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h +++ b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h @@ -44,8 +44,8 @@ namespace WebKit { class WebDevToolsFrontendClient; class WebDevToolsFrontendImpl; -class InspectorFrontendClientImpl : public WebCore::InspectorFrontendClient - , public Noncopyable { +class InspectorFrontendClientImpl : public WebCore::InspectorFrontendClient { + WTF_MAKE_NONCOPYABLE(InspectorFrontendClientImpl); public: InspectorFrontendClientImpl(WebCore::Page*, WebDevToolsFrontendClient*, WebDevToolsFrontendImpl*); virtual ~InspectorFrontendClientImpl(); diff --git a/Source/WebKit/chromium/src/ChromiumBridge.cpp b/Source/WebKit/chromium/src/PlatformBridge.cpp index e16025c..04016fc 100644 --- a/Source/WebKit/chromium/src/ChromiumBridge.cpp +++ b/Source/WebKit/chromium/src/PlatformBridge.cpp @@ -29,7 +29,7 @@ */ #include "config.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include <googleurl/src/url_util.h> @@ -39,7 +39,6 @@ #include "WebClipboard.h" #include "WebCookie.h" #include "WebCookieJar.h" -#include "WebCursorInfo.h" #include "WebData.h" #include "WebDragData.h" #include "WebFileUtilities.h" @@ -146,14 +145,14 @@ static WebCookieJar* getCookieJar(const Document* document) // Cache ---------------------------------------------------------------------- -void ChromiumBridge::cacheMetadata(const KURL& url, double responseTime, const Vector<char>& data) +void PlatformBridge::cacheMetadata(const KURL& url, double responseTime, const Vector<char>& data) { webKitClient()->cacheMetadata(url, responseTime, data.data(), data.size()); } // Clipboard ------------------------------------------------------------------ -bool ChromiumBridge::clipboardIsFormatAvailable( +bool PlatformBridge::clipboardIsFormatAvailable( PasteboardPrivate::ClipboardFormat format, PasteboardPrivate::ClipboardBuffer buffer) { @@ -162,14 +161,14 @@ bool ChromiumBridge::clipboardIsFormatAvailable( static_cast<WebClipboard::Buffer>(buffer)); } -String ChromiumBridge::clipboardReadPlainText( +String PlatformBridge::clipboardReadPlainText( PasteboardPrivate::ClipboardBuffer buffer) { return webKitClient()->clipboard()->readPlainText( static_cast<WebClipboard::Buffer>(buffer)); } -void ChromiumBridge::clipboardReadHTML( +void PlatformBridge::clipboardReadHTML( PasteboardPrivate::ClipboardBuffer buffer, String* htmlText, KURL* sourceURL) { @@ -179,7 +178,7 @@ void ChromiumBridge::clipboardReadHTML( *sourceURL = url; } -void ChromiumBridge::clipboardWriteSelection(const String& htmlText, +void PlatformBridge::clipboardWriteSelection(const String& htmlText, const KURL& sourceURL, const String& plainText, bool writeSmartPaste) @@ -188,17 +187,17 @@ void ChromiumBridge::clipboardWriteSelection(const String& htmlText, htmlText, sourceURL, plainText, writeSmartPaste); } -void ChromiumBridge::clipboardWritePlainText(const String& plainText) +void PlatformBridge::clipboardWritePlainText(const String& plainText) { webKitClient()->clipboard()->writePlainText(plainText); } -void ChromiumBridge::clipboardWriteURL(const KURL& url, const String& title) +void PlatformBridge::clipboardWriteURL(const KURL& url, const String& title) { webKitClient()->clipboard()->writeURL(url, title); } -void ChromiumBridge::clipboardWriteImage(NativeImagePtr image, +void PlatformBridge::clipboardWriteImage(NativeImagePtr image, const KURL& sourceURL, const String& title) { @@ -210,14 +209,14 @@ void ChromiumBridge::clipboardWriteImage(NativeImagePtr image, webKitClient()->clipboard()->writeImage(webImage, sourceURL, title); } -void ChromiumBridge::clipboardWriteData(const String& type, +void PlatformBridge::clipboardWriteData(const String& type, const String& data, const String& metadata) { webKitClient()->clipboard()->writeData(type, data, metadata); } -HashSet<String> ChromiumBridge::clipboardReadAvailableTypes( +HashSet<String> PlatformBridge::clipboardReadAvailableTypes( PasteboardPrivate::ClipboardBuffer buffer, bool* containsFilenames) { WebVector<WebString> result = webKitClient()->clipboard()->readAvailableTypes( @@ -228,7 +227,7 @@ HashSet<String> ChromiumBridge::clipboardReadAvailableTypes( return types; } -bool ChromiumBridge::clipboardReadData(PasteboardPrivate::ClipboardBuffer buffer, +bool PlatformBridge::clipboardReadData(PasteboardPrivate::ClipboardBuffer buffer, const String& type, String& data, String& metadata) { WebString resultData; @@ -242,7 +241,7 @@ bool ChromiumBridge::clipboardReadData(PasteboardPrivate::ClipboardBuffer buffer return succeeded; } -Vector<String> ChromiumBridge::clipboardReadFilenames(PasteboardPrivate::ClipboardBuffer buffer) +Vector<String> PlatformBridge::clipboardReadFilenames(PasteboardPrivate::ClipboardBuffer buffer) { WebVector<WebString> result = webKitClient()->clipboard()->readFilenames( static_cast<WebClipboard::Buffer>(buffer)); @@ -254,7 +253,7 @@ Vector<String> ChromiumBridge::clipboardReadFilenames(PasteboardPrivate::Clipboa // Cookies -------------------------------------------------------------------- -void ChromiumBridge::setCookies(const Document* document, const KURL& url, +void PlatformBridge::setCookies(const Document* document, const KURL& url, const String& value) { WebCookieJar* cookieJar = getCookieJar(document); @@ -262,7 +261,7 @@ void ChromiumBridge::setCookies(const Document* document, const KURL& url, cookieJar->setCookie(url, document->firstPartyForCookies(), value); } -String ChromiumBridge::cookies(const Document* document, const KURL& url) +String PlatformBridge::cookies(const Document* document, const KURL& url) { String result; WebCookieJar* cookieJar = getCookieJar(document); @@ -271,7 +270,7 @@ String ChromiumBridge::cookies(const Document* document, const KURL& url) return result; } -String ChromiumBridge::cookieRequestHeaderFieldValue(const Document* document, +String PlatformBridge::cookieRequestHeaderFieldValue(const Document* document, const KURL& url) { String result; @@ -281,7 +280,7 @@ String ChromiumBridge::cookieRequestHeaderFieldValue(const Document* document, return result; } -bool ChromiumBridge::rawCookies(const Document* document, const KURL& url, Vector<Cookie>& rawCookies) +bool PlatformBridge::rawCookies(const Document* document, const KURL& url, Vector<Cookie>& rawCookies) { rawCookies.clear(); WebVector<WebCookie> webCookies; @@ -305,14 +304,14 @@ bool ChromiumBridge::rawCookies(const Document* document, const KURL& url, Vecto return true; } -void ChromiumBridge::deleteCookie(const Document* document, const KURL& url, const String& cookieName) +void PlatformBridge::deleteCookie(const Document* document, const KURL& url, const String& cookieName) { WebCookieJar* cookieJar = getCookieJar(document); if (cookieJar) cookieJar->deleteCookie(url, cookieName); } -bool ChromiumBridge::cookiesEnabled(const Document* document) +bool PlatformBridge::cookiesEnabled(const Document* document) { bool result = false; WebCookieJar* cookieJar = getCookieJar(document); @@ -323,39 +322,39 @@ bool ChromiumBridge::cookiesEnabled(const Document* document) // DNS ------------------------------------------------------------------------ -void ChromiumBridge::prefetchDNS(const String& hostname) +void PlatformBridge::prefetchDNS(const String& hostname) { webKitClient()->prefetchHostName(hostname); } // File ------------------------------------------------------------------------ -bool ChromiumBridge::fileExists(const String& path) +bool PlatformBridge::fileExists(const String& path) { return webKitClient()->fileUtilities()->fileExists(path); } -bool ChromiumBridge::deleteFile(const String& path) +bool PlatformBridge::deleteFile(const String& path) { return webKitClient()->fileUtilities()->deleteFile(path); } -bool ChromiumBridge::deleteEmptyDirectory(const String& path) +bool PlatformBridge::deleteEmptyDirectory(const String& path) { return webKitClient()->fileUtilities()->deleteEmptyDirectory(path); } -bool ChromiumBridge::getFileSize(const String& path, long long& result) +bool PlatformBridge::getFileSize(const String& path, long long& result) { return webKitClient()->fileUtilities()->getFileSize(path, result); } -void ChromiumBridge::revealFolderInOS(const String& path) +void PlatformBridge::revealFolderInOS(const String& path) { webKitClient()->fileUtilities()->revealFolderInOS(path); } -bool ChromiumBridge::getFileModificationTime(const String& path, time_t& result) +bool PlatformBridge::getFileModificationTime(const String& path, time_t& result) { double modificationTime; if (!webKitClient()->fileUtilities()->getFileModificationTime(path, modificationTime)) @@ -364,62 +363,62 @@ bool ChromiumBridge::getFileModificationTime(const String& path, time_t& result) return true; } -String ChromiumBridge::directoryName(const String& path) +String PlatformBridge::directoryName(const String& path) { return webKitClient()->fileUtilities()->directoryName(path); } -String ChromiumBridge::pathByAppendingComponent(const String& path, const String& component) +String PlatformBridge::pathByAppendingComponent(const String& path, const String& component) { return webKitClient()->fileUtilities()->pathByAppendingComponent(path, component); } -bool ChromiumBridge::makeAllDirectories(const String& path) +bool PlatformBridge::makeAllDirectories(const String& path) { return webKitClient()->fileUtilities()->makeAllDirectories(path); } -String ChromiumBridge::getAbsolutePath(const String& path) +String PlatformBridge::getAbsolutePath(const String& path) { return webKitClient()->fileUtilities()->getAbsolutePath(path); } -bool ChromiumBridge::isDirectory(const String& path) +bool PlatformBridge::isDirectory(const String& path) { return webKitClient()->fileUtilities()->isDirectory(path); } -KURL ChromiumBridge::filePathToURL(const String& path) +KURL PlatformBridge::filePathToURL(const String& path) { return webKitClient()->fileUtilities()->filePathToURL(path); } -PlatformFileHandle ChromiumBridge::openFile(const String& path, FileOpenMode mode) +PlatformFileHandle PlatformBridge::openFile(const String& path, FileOpenMode mode) { return webKitClient()->fileUtilities()->openFile(path, mode); } -void ChromiumBridge::closeFile(PlatformFileHandle& handle) +void PlatformBridge::closeFile(PlatformFileHandle& handle) { webKitClient()->fileUtilities()->closeFile(handle); } -long long ChromiumBridge::seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin) +long long PlatformBridge::seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin) { return webKitClient()->fileUtilities()->seekFile(handle, offset, origin); } -bool ChromiumBridge::truncateFile(PlatformFileHandle handle, long long offset) +bool PlatformBridge::truncateFile(PlatformFileHandle handle, long long offset) { return webKitClient()->fileUtilities()->truncateFile(handle, offset); } -int ChromiumBridge::readFromFile(PlatformFileHandle handle, char* data, int length) +int PlatformBridge::readFromFile(PlatformFileHandle handle, char* data, int length) { return webKitClient()->fileUtilities()->readFromFile(handle, data, length); } -int ChromiumBridge::writeToFile(PlatformFileHandle handle, const char* data, int length) +int PlatformBridge::writeToFile(PlatformFileHandle handle, const char* data, int length) { return webKitClient()->fileUtilities()->writeToFile(handle, data, length); } @@ -427,7 +426,7 @@ int ChromiumBridge::writeToFile(PlatformFileHandle handle, const char* data, int // Font ----------------------------------------------------------------------- #if OS(WINDOWS) -bool ChromiumBridge::ensureFontLoaded(HFONT font) +bool PlatformBridge::ensureFontLoaded(HFONT font) { WebSandboxSupport* ss = webKitClient()->sandboxSupport(); @@ -438,7 +437,7 @@ bool ChromiumBridge::ensureFontLoaded(HFONT font) #endif #if OS(LINUX) || OS(FREEBSD) -String ChromiumBridge::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters) +String PlatformBridge::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters) { if (webKitClient()->sandboxSupport()) return webKitClient()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters); @@ -450,7 +449,7 @@ String ChromiumBridge::getFontFamilyForCharacters(const UChar* characters, size_ return WebString(); } -void ChromiumBridge::getRenderStyleForStrike(const char* font, int sizeAndStyle, FontRenderStyle* result) +void PlatformBridge::getRenderStyleForStrike(const char* font, int sizeAndStyle, FontRenderStyle* result) { WebFontRenderStyle style; @@ -464,7 +463,7 @@ void ChromiumBridge::getRenderStyleForStrike(const char* font, int sizeAndStyle, #endif #if OS(DARWIN) -bool ChromiumBridge::loadFont(NSFont* srcFont, ATSFontContainerRef* out) +bool PlatformBridge::loadFont(NSFont* srcFont, ATSFontContainerRef* out) { WebSandboxSupport* ss = webKitClient()->sandboxSupport(); if (ss) @@ -481,42 +480,42 @@ bool ChromiumBridge::loadFont(NSFont* srcFont, ATSFontContainerRef* out) // Databases ------------------------------------------------------------------ -PlatformFileHandle ChromiumBridge::databaseOpenFile(const String& vfsFileName, int desiredFlags) +PlatformFileHandle PlatformBridge::databaseOpenFile(const String& vfsFileName, int desiredFlags) { return webKitClient()->databaseOpenFile(WebString(vfsFileName), desiredFlags); } -int ChromiumBridge::databaseDeleteFile(const String& vfsFileName, bool syncDir) +int PlatformBridge::databaseDeleteFile(const String& vfsFileName, bool syncDir) { return webKitClient()->databaseDeleteFile(WebString(vfsFileName), syncDir); } -long ChromiumBridge::databaseGetFileAttributes(const String& vfsFileName) +long PlatformBridge::databaseGetFileAttributes(const String& vfsFileName) { return webKitClient()->databaseGetFileAttributes(WebString(vfsFileName)); } -long long ChromiumBridge::databaseGetFileSize(const String& vfsFileName) +long long PlatformBridge::databaseGetFileSize(const String& vfsFileName) { return webKitClient()->databaseGetFileSize(WebString(vfsFileName)); } // Indexed Database ----------------------------------------------------------- -PassRefPtr<IDBFactoryBackendInterface> ChromiumBridge::idbFactory() +PassRefPtr<IDBFactoryBackendInterface> PlatformBridge::idbFactory() { // There's no reason why we need to allocate a new proxy each time, but // there's also no strong reason not to. return IDBFactoryBackendProxy::create(); } -void ChromiumBridge::idbShutdown() +void PlatformBridge::idbShutdown() { // In the browser process, this shuts down the utility process. In the renderer process, it does nothing. webKitClient()->idbShutdown(); } -void ChromiumBridge::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys) +void PlatformBridge::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys) { WebVector<WebSerializedScriptValue> webValues = values; WebVector<WebIDBKey> webKeys; @@ -530,7 +529,7 @@ void ChromiumBridge::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<Re // Keygen --------------------------------------------------------------------- -String ChromiumBridge::signedPublicKeyAndChallengeString( +String PlatformBridge::signedPublicKeyAndChallengeString( unsigned keySizeIndex, const String& challenge, const KURL& url) { return webKitClient()->signedPublicKeyAndChallengeString(keySizeIndex, @@ -540,63 +539,63 @@ String ChromiumBridge::signedPublicKeyAndChallengeString( // Language ------------------------------------------------------------------- -String ChromiumBridge::computedDefaultLanguage() +String PlatformBridge::computedDefaultLanguage() { return webKitClient()->defaultLocale(); } // LayoutTestMode ------------------------------------------------------------- -bool ChromiumBridge::layoutTestMode() +bool PlatformBridge::layoutTestMode() { return WebKit::layoutTestMode(); } // MimeType ------------------------------------------------------------------- -bool ChromiumBridge::isSupportedImageMIMEType(const String& mimeType) +bool PlatformBridge::isSupportedImageMIMEType(const String& mimeType) { return webKitClient()->mimeRegistry()->supportsImageMIMEType(mimeType) != WebMimeRegistry::IsNotSupported; } -bool ChromiumBridge::isSupportedJavaScriptMIMEType(const String& mimeType) +bool PlatformBridge::isSupportedJavaScriptMIMEType(const String& mimeType) { return webKitClient()->mimeRegistry()->supportsJavaScriptMIMEType(mimeType) != WebMimeRegistry::IsNotSupported; } -bool ChromiumBridge::isSupportedNonImageMIMEType(const String& mimeType) +bool PlatformBridge::isSupportedNonImageMIMEType(const String& mimeType) { return webKitClient()->mimeRegistry()->supportsNonImageMIMEType(mimeType) != WebMimeRegistry::IsNotSupported; } -String ChromiumBridge::mimeTypeForExtension(const String& extension) +String PlatformBridge::mimeTypeForExtension(const String& extension) { return webKitClient()->mimeRegistry()->mimeTypeForExtension(extension); } -String ChromiumBridge::mimeTypeFromFile(const String& path) +String PlatformBridge::mimeTypeFromFile(const String& path) { return webKitClient()->mimeRegistry()->mimeTypeFromFile(path); } -String ChromiumBridge::preferredExtensionForMIMEType(const String& mimeType) +String PlatformBridge::preferredExtensionForMIMEType(const String& mimeType) { return webKitClient()->mimeRegistry()->preferredExtensionForMIMEType(mimeType); } // Plugin --------------------------------------------------------------------- -bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo>* results) +bool PlatformBridge::plugins(bool refresh, Vector<PluginInfo>* results) { WebPluginListBuilderImpl builder(results); webKitClient()->getPluginList(refresh, &builder); return true; // FIXME: There is no need for this function to return a value. } -NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget) +NPObject* PlatformBridge::pluginScriptableObject(Widget* widget) { if (!widget || !widget->isPluginContainer()) return 0; @@ -606,7 +605,7 @@ NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget) // Resources ------------------------------------------------------------------ -PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) +PassRefPtr<Image> PlatformBridge::loadPlatformImageResource(const char* name) { const WebData& resource = webKitClient()->loadResource(name); if (resource.isEmpty()) @@ -619,7 +618,7 @@ PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) #if ENABLE(WEB_AUDIO) -PassOwnPtr<AudioBus> ChromiumBridge::loadPlatformAudioResource(const char* name, double sampleRate) +PassOwnPtr<AudioBus> PlatformBridge::loadPlatformAudioResource(const char* name, double sampleRate) { const WebData& resource = webKitClient()->loadResource(name); if (resource.isEmpty()) @@ -628,7 +627,7 @@ PassOwnPtr<AudioBus> ChromiumBridge::loadPlatformAudioResource(const char* name, return decodeAudioFileData(resource.data(), resource.size(), sampleRate); } -PassOwnPtr<AudioBus> ChromiumBridge::decodeAudioFileData(const char* data, size_t size, double sampleRate) +PassOwnPtr<AudioBus> PlatformBridge::decodeAudioFileData(const char* data, size_t size, double sampleRate) { WebAudioBus webAudioBus; if (webKitClient()->loadAudioResource(&webAudioBus, data, size, sampleRate)) @@ -640,60 +639,60 @@ PassOwnPtr<AudioBus> ChromiumBridge::decodeAudioFileData(const char* data, size_ // Sandbox -------------------------------------------------------------------- -bool ChromiumBridge::sandboxEnabled() +bool PlatformBridge::sandboxEnabled() { return webKitClient()->sandboxEnabled(); } // SharedTimers --------------------------------------------------------------- -void ChromiumBridge::setSharedTimerFiredFunction(void (*func)()) +void PlatformBridge::setSharedTimerFiredFunction(void (*func)()) { webKitClient()->setSharedTimerFiredFunction(func); } -void ChromiumBridge::setSharedTimerFireTime(double fireTime) +void PlatformBridge::setSharedTimerFireTime(double fireTime) { webKitClient()->setSharedTimerFireTime(fireTime); } -void ChromiumBridge::stopSharedTimer() +void PlatformBridge::stopSharedTimer() { webKitClient()->stopSharedTimer(); } // StatsCounters -------------------------------------------------------------- -void ChromiumBridge::decrementStatsCounter(const char* name) +void PlatformBridge::decrementStatsCounter(const char* name) { webKitClient()->decrementStatsCounter(name); } -void ChromiumBridge::incrementStatsCounter(const char* name) +void PlatformBridge::incrementStatsCounter(const char* name) { webKitClient()->incrementStatsCounter(name); } -void ChromiumBridge::histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount) +void PlatformBridge::histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount) { webKitClient()->histogramCustomCounts(name, sample, min, max, bucketCount); } -void ChromiumBridge::histogramEnumeration(const char* name, int sample, int boundaryValue) +void PlatformBridge::histogramEnumeration(const char* name, int sample, int boundaryValue) { webKitClient()->histogramEnumeration(name, sample, boundaryValue); } // Sudden Termination --------------------------------------------------------- -void ChromiumBridge::suddenTerminationChanged(bool enabled) +void PlatformBridge::suddenTerminationChanged(bool enabled) { webKitClient()->suddenTerminationChanged(enabled); } // SystemTime ----------------------------------------------------------------- -double ChromiumBridge::currentTime() +double PlatformBridge::currentTime() { return webKitClient()->currentTime(); } @@ -702,7 +701,7 @@ double ChromiumBridge::currentTime() #if OS(WINDOWS) -void ChromiumBridge::paintButton( +void PlatformBridge::paintButton( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect) { @@ -710,7 +709,7 @@ void ChromiumBridge::paintButton( gc->platformContext()->canvas(), part, state, classicState, rect); } -void ChromiumBridge::paintMenuList( +void PlatformBridge::paintMenuList( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect) { @@ -718,7 +717,7 @@ void ChromiumBridge::paintMenuList( gc->platformContext()->canvas(), part, state, classicState, rect); } -void ChromiumBridge::paintScrollbarArrow( +void PlatformBridge::paintScrollbarArrow( GraphicsContext* gc, int state, int classicState, const IntRect& rect) { @@ -726,7 +725,7 @@ void ChromiumBridge::paintScrollbarArrow( gc->platformContext()->canvas(), state, classicState, rect); } -void ChromiumBridge::paintScrollbarThumb( +void PlatformBridge::paintScrollbarThumb( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect) { @@ -734,7 +733,7 @@ void ChromiumBridge::paintScrollbarThumb( gc->platformContext()->canvas(), part, state, classicState, rect); } -void ChromiumBridge::paintScrollbarTrack( +void PlatformBridge::paintScrollbarTrack( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect, const IntRect& alignRect) { @@ -743,7 +742,7 @@ void ChromiumBridge::paintScrollbarTrack( alignRect); } -void ChromiumBridge::paintSpinButton( +void PlatformBridge::paintSpinButton( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect) { @@ -751,7 +750,7 @@ void ChromiumBridge::paintSpinButton( gc->platformContext()->canvas(), part, state, classicState, rect); } -void ChromiumBridge::paintTextField( +void PlatformBridge::paintTextField( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect, const Color& color, bool fillContentArea, bool drawEdges) @@ -764,7 +763,7 @@ void ChromiumBridge::paintTextField( backgroundColor, fillContentArea, drawEdges); } -void ChromiumBridge::paintTrackbar( +void PlatformBridge::paintTrackbar( GraphicsContext* gc, int part, int state, int classicState, const IntRect& rect) { @@ -772,7 +771,7 @@ void ChromiumBridge::paintTrackbar( gc->platformContext()->canvas(), part, state, classicState, rect); } -void ChromiumBridge::paintProgressBar( +void PlatformBridge::paintProgressBar( GraphicsContext* gc, const IntRect& barRect, const IntRect& valueRect, bool determinate, double animatedSeconds) { webKitClient()->themeEngine()->paintProgressBar( @@ -781,50 +780,101 @@ void ChromiumBridge::paintProgressBar( #elif OS(LINUX) -static WebThemeEngine::Part WebThemePart(ChromiumBridge::ThemePart part) +static WebThemeEngine::Part WebThemePart(PlatformBridge::ThemePart part) { switch (part) { - case ChromiumBridge::PartScrollbarDownArrow: return WebThemeEngine::PartScrollbarDownArrow; - case ChromiumBridge::PartScrollbarLeftArrow: return WebThemeEngine::PartScrollbarLeftArrow; - case ChromiumBridge::PartScrollbarRightArrow: return WebThemeEngine::PartScrollbarRightArrow; - case ChromiumBridge::PartScrollbarUpArrow: return WebThemeEngine::PartScrollbarUpArrow; - case ChromiumBridge::PartScrollbarHorizontalThumb: return WebThemeEngine::PartScrollbarHorizontalThumb; - case ChromiumBridge::PartScrollbarVerticalThumb: return WebThemeEngine::PartScrollbarVerticalThumb; - case ChromiumBridge::PartScrollbarHorizontalTrack: return WebThemeEngine::PartScrollbarHorizontalTrack; - case ChromiumBridge::PartScrollbarVerticalTrack: return WebThemeEngine::PartScrollbarVerticalTrack; + case PlatformBridge::PartScrollbarDownArrow: return WebThemeEngine::PartScrollbarDownArrow; + case PlatformBridge::PartScrollbarLeftArrow: return WebThemeEngine::PartScrollbarLeftArrow; + case PlatformBridge::PartScrollbarRightArrow: return WebThemeEngine::PartScrollbarRightArrow; + case PlatformBridge::PartScrollbarUpArrow: return WebThemeEngine::PartScrollbarUpArrow; + case PlatformBridge::PartScrollbarHorizontalThumb: return WebThemeEngine::PartScrollbarHorizontalThumb; + case PlatformBridge::PartScrollbarVerticalThumb: return WebThemeEngine::PartScrollbarVerticalThumb; + case PlatformBridge::PartScrollbarHorizontalTrack: return WebThemeEngine::PartScrollbarHorizontalTrack; + case PlatformBridge::PartScrollbarVerticalTrack: return WebThemeEngine::PartScrollbarVerticalTrack; + case PlatformBridge::PartCheckbox: return WebThemeEngine::PartCheckbox; + case PlatformBridge::PartRadio: return WebThemeEngine::PartRadio; + case PlatformBridge::PartButton: return WebThemeEngine::PartButton; + case PlatformBridge::PartTextField: return WebThemeEngine::PartTextField; + case PlatformBridge::PartMenuList: return WebThemeEngine::PartMenuList; + case PlatformBridge::PartSliderTrack: return WebThemeEngine::PartSliderTrack; + case PlatformBridge::PartSliderThumb: return WebThemeEngine::PartSliderThumb; + case PlatformBridge::PartInnerSpinButton: return WebThemeEngine::PartInnerSpinButton; + case PlatformBridge::PartProgressBar: return WebThemeEngine::PartProgressBar; } ASSERT_NOT_REACHED(); return WebThemeEngine::PartScrollbarDownArrow; } -static WebThemeEngine::State WebThemeState(ChromiumBridge::ThemePaintState state) +static WebThemeEngine::State WebThemeState(PlatformBridge::ThemePaintState state) { switch (state) { - case ChromiumBridge::StateDisabled: return WebThemeEngine::StateDisabled; - case ChromiumBridge::StateHover: return WebThemeEngine::StateHover; - case ChromiumBridge::StateNormal: return WebThemeEngine::StateNormal; - case ChromiumBridge::StatePressed: return WebThemeEngine::StatePressed; + case PlatformBridge::StateDisabled: return WebThemeEngine::StateDisabled; + case PlatformBridge::StateHover: return WebThemeEngine::StateHover; + case PlatformBridge::StateNormal: return WebThemeEngine::StateNormal; + case PlatformBridge::StatePressed: return WebThemeEngine::StatePressed; } ASSERT_NOT_REACHED(); return WebThemeEngine::StateDisabled; } -static void GetWebThemeExtraParams(ChromiumBridge::ThemePart part, ChromiumBridge::ThemePaintState state, const ChromiumBridge::ThemePaintExtraParams* extraParams, WebThemeEngine::ExtraParams* webThemeExtraParams) +static void GetWebThemeExtraParams(PlatformBridge::ThemePart part, PlatformBridge::ThemePaintState state, const PlatformBridge::ThemePaintExtraParams* extraParams, WebThemeEngine::ExtraParams* webThemeExtraParams) { - if (part == ChromiumBridge::PartScrollbarHorizontalTrack || part == ChromiumBridge::PartScrollbarVerticalTrack) { + switch (part) { + case PlatformBridge::PartScrollbarHorizontalTrack: + case PlatformBridge::PartScrollbarVerticalTrack: webThemeExtraParams->scrollbarTrack.trackX = extraParams->scrollbarTrack.trackX; webThemeExtraParams->scrollbarTrack.trackY = extraParams->scrollbarTrack.trackY; webThemeExtraParams->scrollbarTrack.trackWidth = extraParams->scrollbarTrack.trackWidth; webThemeExtraParams->scrollbarTrack.trackHeight = extraParams->scrollbarTrack.trackHeight; + break; + case PlatformBridge::PartCheckbox: + webThemeExtraParams->button.checked = extraParams->button.checked; + webThemeExtraParams->button.indeterminate = extraParams->button.indeterminate; + break; + case PlatformBridge::PartRadio: + webThemeExtraParams->button.checked = extraParams->button.checked; + break; + case PlatformBridge::PartButton: + webThemeExtraParams->button.isDefault = extraParams->button.isDefault; + webThemeExtraParams->button.backgroundColor = extraParams->button.backgroundColor; + break; + case PlatformBridge::PartTextField: + webThemeExtraParams->textField.isTextArea = extraParams->textField.isTextArea; + webThemeExtraParams->textField.isListbox = extraParams->textField.isListbox; + webThemeExtraParams->textField.backgroundColor = extraParams->textField.backgroundColor; + break; + case PlatformBridge::PartMenuList: + webThemeExtraParams->menuList.arrowX = extraParams->menuList.arrowX; + webThemeExtraParams->menuList.arrowY = extraParams->menuList.arrowY; + webThemeExtraParams->menuList.backgroundColor = extraParams->menuList.backgroundColor; + break; + case PlatformBridge::PartSliderTrack: + case PlatformBridge::PartSliderThumb: + webThemeExtraParams->slider.vertical = extraParams->slider.vertical; + webThemeExtraParams->slider.inDrag = extraParams->slider.inDrag; + break; + case PlatformBridge::PartInnerSpinButton: + webThemeExtraParams->innerSpin.spinUp = extraParams->innerSpin.spinUp; + webThemeExtraParams->innerSpin.readOnly = extraParams->innerSpin.readOnly; + break; + case PlatformBridge::PartProgressBar: + webThemeExtraParams->progressBar.determinate = extraParams->progressBar.determinate; + webThemeExtraParams->progressBar.valueRectX = extraParams->progressBar.valueRectX; + webThemeExtraParams->progressBar.valueRectY = extraParams->progressBar.valueRectY; + webThemeExtraParams->progressBar.valueRectWidth = extraParams->progressBar.valueRectWidth; + webThemeExtraParams->progressBar.valueRectHeight = extraParams->progressBar.valueRectHeight; + break; + default: + break; // Parts that have no extra params get here. } } -IntSize ChromiumBridge::getThemePartSize(ThemePart part) +IntSize PlatformBridge::getThemePartSize(ThemePart part) { return webKitClient()->themeEngine()->getSize(WebThemePart(part)); } -void ChromiumBridge::paintThemePart( +void PlatformBridge::paintThemePart( GraphicsContext* gc, ThemePart part, ThemePaintState state, const IntRect& rect, const ThemePaintExtraParams* extraParams) { WebThemeEngine::ExtraParams webThemeExtraParams; @@ -835,7 +885,7 @@ void ChromiumBridge::paintThemePart( #elif OS(DARWIN) -void ChromiumBridge::paintScrollbarThumb( +void PlatformBridge::paintScrollbarThumb( GraphicsContext* gc, ThemePaintState state, ThemePaintSize size, const IntRect& rect, const ThemePaintScrollbarInfo& scrollbarInfo) { WebThemeEngine::ScrollbarInfo webThemeScrollbarInfo; @@ -859,19 +909,19 @@ void ChromiumBridge::paintScrollbarThumb( // Trace Event ---------------------------------------------------------------- -void ChromiumBridge::traceEventBegin(const char* name, void* id, const char* extra) +void PlatformBridge::traceEventBegin(const char* name, void* id, const char* extra) { webKitClient()->traceEventBegin(name, id, extra); } -void ChromiumBridge::traceEventEnd(const char* name, void* id, const char* extra) +void PlatformBridge::traceEventEnd(const char* name, void* id, const char* extra) { webKitClient()->traceEventEnd(name, id, extra); } // Visited Links -------------------------------------------------------------- -LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, unsigned length) +LinkHash PlatformBridge::visitedLinkHash(const UChar* url, unsigned length) { url_canon::RawCanonOutput<2048> buffer; url_parse::Parsed parsed; @@ -880,7 +930,7 @@ LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, unsigned length) return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); } -LinkHash ChromiumBridge::visitedLinkHash(const KURL& base, +LinkHash PlatformBridge::visitedLinkHash(const KURL& base, const AtomicString& attributeURL) { // Resolve the relative URL using googleurl and pass the absolute URL up to @@ -914,7 +964,7 @@ LinkHash ChromiumBridge::visitedLinkHash(const KURL& base, return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); } -bool ChromiumBridge::isLinkVisited(LinkHash visitedLinkHash) +bool PlatformBridge::isLinkVisited(LinkHash visitedLinkHash) { return webKitClient()->isLinkVisited(visitedLinkHash); } @@ -923,7 +973,7 @@ bool ChromiumBridge::isLinkVisited(LinkHash visitedLinkHash) // Glue layer. Once the Glue layer moves entirely into the WebKit layer, these // methods will be deleted. -void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) +void PlatformBridge::notifyJSOutOfMemory(Frame* frame) { if (!frame) return; @@ -934,17 +984,17 @@ void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) webFrame->client()->didExhaustMemoryAvailableForScript(webFrame); } -int ChromiumBridge::memoryUsageMB() +int PlatformBridge::memoryUsageMB() { return static_cast<int>(webKitClient()->memoryUsageMB()); } -int ChromiumBridge::actualMemoryUsageMB() +int PlatformBridge::actualMemoryUsageMB() { return static_cast<int>(webKitClient()->actualMemoryUsageMB()); } -int ChromiumBridge::screenDepth(Widget* widget) +int PlatformBridge::screenDepth(Widget* widget) { WebWidgetClient* client = toWebWidgetClient(widget); if (!client) @@ -952,7 +1002,7 @@ int ChromiumBridge::screenDepth(Widget* widget) return client->screenInfo().depth; } -int ChromiumBridge::screenDepthPerComponent(Widget* widget) +int PlatformBridge::screenDepthPerComponent(Widget* widget) { WebWidgetClient* client = toWebWidgetClient(widget); if (!client) @@ -960,7 +1010,7 @@ int ChromiumBridge::screenDepthPerComponent(Widget* widget) return client->screenInfo().depthPerComponent; } -bool ChromiumBridge::screenIsMonochrome(Widget* widget) +bool PlatformBridge::screenIsMonochrome(Widget* widget) { WebWidgetClient* client = toWebWidgetClient(widget); if (!client) @@ -968,7 +1018,7 @@ bool ChromiumBridge::screenIsMonochrome(Widget* widget) return client->screenInfo().isMonochrome; } -IntRect ChromiumBridge::screenRect(Widget* widget) +IntRect PlatformBridge::screenRect(Widget* widget) { WebWidgetClient* client = toWebWidgetClient(widget); if (!client) @@ -976,7 +1026,7 @@ IntRect ChromiumBridge::screenRect(Widget* widget) return client->screenInfo().rect; } -IntRect ChromiumBridge::screenAvailableRect(Widget* widget) +IntRect PlatformBridge::screenAvailableRect(Widget* widget) { WebWidgetClient* client = toWebWidgetClient(widget); if (!client) @@ -984,19 +1034,12 @@ IntRect ChromiumBridge::screenAvailableRect(Widget* widget) return client->screenInfo().availableRect; } -bool ChromiumBridge::popupsAllowed(NPP npp) +bool PlatformBridge::popupsAllowed(NPP npp) { // FIXME: Give the embedder a way to control this. return false; } -void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) -{ - ChromeClientImpl* client = toChromeClientImpl(widget); - if (client) - client->setCursor(WebCursorInfo(cursor)); -} - WorkerContextProxy* WorkerContextProxy::create(Worker* worker) { return WebWorkerClientImpl::createWorkerContextProxy(worker); diff --git a/Source/WebKit/chromium/src/ResourceHandle.cpp b/Source/WebKit/chromium/src/ResourceHandle.cpp index 83e0017..72f60bb 100644 --- a/Source/WebKit/chromium/src/ResourceHandle.cpp +++ b/Source/WebKit/chromium/src/ResourceHandle.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "ResourceHandle.h" -#include "ChromiumBridge.h" +#include "PlatformBridge.h" #include "ResourceHandleClient.h" #include "ResourceRequest.h" #include "SharedBuffer.h" @@ -330,7 +330,7 @@ bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*) // static void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vector<char>& data) { - ChromiumBridge::cacheMetadata(response.url(), response.responseTime(), data); + PlatformBridge::cacheMetadata(response.url(), response.responseTime(), data); } } // namespace WebCore diff --git a/Source/WebKit/chromium/src/SpeechInputClientImpl.cpp b/Source/WebKit/chromium/src/SpeechInputClientImpl.cpp index b5ed384..e481f6e 100644 --- a/Source/WebKit/chromium/src/SpeechInputClientImpl.cpp +++ b/Source/WebKit/chromium/src/SpeechInputClientImpl.cpp @@ -32,7 +32,9 @@ #include "SpeechInputClientImpl.h" #include "PlatformString.h" +#include "SecurityOrigin.h" #include "SpeechInputListener.h" +#include "WebSecurityOrigin.h" #include "WebSpeechInputController.h" #include "WebString.h" #include "WebViewClient.h" @@ -62,10 +64,10 @@ void SpeechInputClientImpl::setListener(WebCore::SpeechInputListener* listener) m_listener = listener; } -bool SpeechInputClientImpl::startRecognition(int requestId, const WebCore::IntRect& elementRect, const AtomicString& language, const String& grammar) +bool SpeechInputClientImpl::startRecognition(int requestId, const WebCore::IntRect& elementRect, const AtomicString& language, const String& grammar, WebCore::SecurityOrigin* origin) { ASSERT(m_listener); - return m_controller->startRecognition(requestId, elementRect, language, grammar); + return m_controller->startRecognition(requestId, elementRect, language, grammar, WebSecurityOrigin(origin)); } void SpeechInputClientImpl::stopRecording(int requestId) diff --git a/Source/WebKit/chromium/src/SpeechInputClientImpl.h b/Source/WebKit/chromium/src/SpeechInputClientImpl.h index 520803a..a81151d 100644 --- a/Source/WebKit/chromium/src/SpeechInputClientImpl.h +++ b/Source/WebKit/chromium/src/SpeechInputClientImpl.h @@ -40,6 +40,7 @@ #include <wtf/PassOwnPtr.h> namespace WebCore { +class SecurityOrigin; class SpeechInputListener; } @@ -57,7 +58,7 @@ public: // SpeechInputClient methods. void setListener(WebCore::SpeechInputListener*); - bool startRecognition(int requestId, const WebCore::IntRect& elementRect, const AtomicString& language, const String& grammar); + bool startRecognition(int requestId, const WebCore::IntRect& elementRect, const AtomicString& language, const String& grammar, WebCore::SecurityOrigin*); void stopRecording(int); void cancelRecognition(int); diff --git a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp index 99e3e1e..86545b7 100644 --- a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp +++ b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp @@ -111,6 +111,7 @@ const IntSize VideoFrameChromiumImpl::requiredTextureSize(unsigned plane) const { switch (format()) { case RGBA: + case YV16: return IntSize(stride(plane), height()); case YV12: if (plane == static_cast<unsigned>(yPlane)) diff --git a/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h index 866a1cb..dc7d2df 100644 --- a/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h +++ b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h @@ -55,8 +55,8 @@ struct WebDevToolsMessageData; using WTF::String; -class WebDevToolsFrontendImpl : public WebKit::WebDevToolsFrontend - , public Noncopyable { +class WebDevToolsFrontendImpl : public WebKit::WebDevToolsFrontend { + WTF_MAKE_NONCOPYABLE(WebDevToolsFrontendImpl); public: WebDevToolsFrontendImpl( WebKit::WebViewImpl* webViewImpl, diff --git a/Source/WebKit/chromium/src/WebFontImpl.cpp b/Source/WebKit/chromium/src/WebFontImpl.cpp index 8c61997..e1fa0e7 100644 --- a/Source/WebKit/chromium/src/WebFontImpl.cpp +++ b/Source/WebKit/chromium/src/WebFontImpl.cpp @@ -35,6 +35,7 @@ #include "FontDescription.h" #include "GraphicsContext.h" #include "PlatformContextSkia.h" +#include "TextRun.h" #include "WebFloatPoint.h" #include "WebFloatRect.h" #include "WebFontDescription.h" diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp index a13eec0..8651fa8 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.cpp +++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp @@ -74,7 +74,6 @@ #include "AssociatedURLLoader.h" #include "BackForwardController.h" #include "Chrome.h" -#include "ChromiumBridge.h" #include "ClipboardUtilitiesChromium.h" #include "Console.h" #include "DOMUtilitiesPrivate.h" @@ -103,6 +102,7 @@ #include "InspectorController.h" #include "Page.h" #include "Performance.h" +#include "PlatformBridge.h" #include "PlatformContextSkia.h" #include "PluginDocument.h" #include "PrintContext.h" @@ -284,7 +284,8 @@ WebPluginContainerImpl* WebFrameImpl::pluginContainerFromFrame(Frame* frame) // Simple class to override some of PrintContext behavior. Some of the methods // made virtual so that they can be overriden by ChromePluginPrintContext. -class ChromePrintContext : public PrintContext, public Noncopyable { +class ChromePrintContext : public PrintContext { + WTF_MAKE_NONCOPYABLE(ChromePrintContext); public: ChromePrintContext(Frame* frame) : PrintContext(frame) @@ -883,6 +884,17 @@ void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item) RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item); ASSERT(historyItem.get()); + // Sanity check for http://webkit.org/b/52819. It appears that some child + // items of this item might be null. Try validating just the first set of + // children in an attempt to catch it early. + const HistoryItemVector& childItems = historyItem->children(); + int size = childItems.size(); + for (int i = 0; i < size; ++i) { + RefPtr<HistoryItem> childItem = childItems[i].get(); + if (!childItem.get()) + CRASH(); + } + // If there is no currentItem, which happens when we are navigating in // session history after a crash, we need to manufacture one otherwise WebKit // hoarks. This is probably the wrong thing to do, but it seems to work. @@ -1198,6 +1210,9 @@ void WebFrameImpl::enableContinuousSpellChecking(bool enable) { if (enable == isContinuousSpellCheckingEnabled()) return; + // Note, the editor will will notify the client that the continuous spell + // checking state has changed by calling + // WebFrameClient::didToggleContinuousSpellChecking(). frame()->editor()->toggleContinuousSpellChecking(); } @@ -1820,13 +1835,13 @@ WebFrameImpl::WebFrameImpl(WebFrameClient* client) , m_animationController(this) , m_identifier(generateFrameIdentifier()) { - ChromiumBridge::incrementStatsCounter(webFrameActiveCount); + PlatformBridge::incrementStatsCounter(webFrameActiveCount); frameCount++; } WebFrameImpl::~WebFrameImpl() { - ChromiumBridge::decrementStatsCounter(webFrameActiveCount); + PlatformBridge::decrementStatsCounter(webFrameActiveCount); frameCount--; cancelPendingScopingEffort(); diff --git a/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp b/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp index 8d8c53e..53eca19 100644 --- a/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp +++ b/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp @@ -38,7 +38,7 @@ namespace WebKit { WebSecurityOrigin WebGeolocationPermissionRequest::securityOrigin() const { - return WebSecurityOrigin::create(m_private->frame()->document()->url()); + return WebSecurityOrigin(m_private->frame()->document()->securityOrigin()); } void WebGeolocationPermissionRequest::setIsAllowed(bool allowed) diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp index 63ebed8..a209e6a 100644 --- a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp +++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp @@ -151,6 +151,10 @@ void WebPopupMenuImpl::resize(const WebSize& newSize) } } +void WebPopupMenuImpl::animate() +{ +} + void WebPopupMenuImpl::layout() { } @@ -299,6 +303,10 @@ void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect invalidateContentsAndWindow(updateRect, immediate); } +void WebPopupMenuImpl::scheduleAnimation() +{ +} + void WebPopupMenuImpl::scroll(const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect& clipRect) diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.h b/Source/WebKit/chromium/src/WebPopupMenuImpl.h index b8ef7ba..7bb9f7e 100644 --- a/Source/WebKit/chromium/src/WebPopupMenuImpl.h +++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.h @@ -56,11 +56,13 @@ struct WebRect; class WebPopupMenuImpl : public WebPopupMenu, public WebCore::FramelessScrollViewClient, public RefCounted<WebPopupMenuImpl> { + WTF_MAKE_FAST_ALLOCATED; public: // WebWidget virtual void close(); virtual WebSize size() { return m_size; } virtual void resize(const WebSize&); + virtual void animate(); virtual void layout(); virtual void paint(WebCanvas* canvas, const WebRect& rect); virtual void themeChanged(); @@ -105,6 +107,7 @@ public: virtual void invalidateWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); + virtual void scheduleAnimation(); virtual void scroll( const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); diff --git a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp index edb0413..0b5d397 100644 --- a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp +++ b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -184,6 +184,22 @@ bool WebRuntimeFeatures::isIndexedDatabaseEnabled() #endif } +void WebRuntimeFeatures::enableWebAudio(bool enable) +{ +#if ENABLE(WEB_AUDIO) + RuntimeEnabledFeatures::setWebkitAudioContextEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isWebAudioEnabled() +{ +#if ENABLE(WEB_AUDIO) + return RuntimeEnabledFeatures::webkitAudioContextEnabled(); +#else + return false; +#endif +} + void WebRuntimeFeatures::enableWebGL(bool enable) { #if ENABLE(3D_CANVAS) diff --git a/Source/WebKit/chromium/src/WebScriptController.cpp b/Source/WebKit/chromium/src/WebScriptController.cpp index 0aa11a6..10bc68f 100644 --- a/Source/WebKit/chromium/src/WebScriptController.cpp +++ b/Source/WebKit/chromium/src/WebScriptController.cpp @@ -54,7 +54,7 @@ void WebScriptController::enableV8SingleThreadMode() void WebScriptController::flushConsoleMessages() { - WebCore::V8Proxy::processConsoleMessages(); + // FIXME: remove this method after all it's usages are gone. } } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebScrollbarImpl.cpp b/Source/WebKit/chromium/src/WebScrollbarImpl.cpp index 8b9e287..05d2d1f 100644 --- a/Source/WebKit/chromium/src/WebScrollbarImpl.cpp +++ b/Source/WebKit/chromium/src/WebScrollbarImpl.cpp @@ -62,9 +62,10 @@ int WebScrollbar::defaultThickness() WebScrollbarImpl::WebScrollbarImpl(WebScrollbarClient* client, Orientation orientation) : m_client(client) + , m_scrollOffset(0) { m_scrollbar = Scrollbar::createNativeScrollbar( - static_cast<ScrollbarClient*>(this), + static_cast<ScrollableArea*>(this), static_cast<ScrollbarOrientation>(orientation), RegularScrollbar); } @@ -89,12 +90,12 @@ void WebScrollbarImpl::setLocation(const WebRect& rect) int WebScrollbarImpl::value() const { - return m_scrollbar->value(); + return m_scrollOffset; } void WebScrollbarImpl::setValue(int position) { - m_scrollbar->setValue(position, Scrollbar::NotFromScrollAnimator); + WebCore::ScrollableArea::scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), position); } void WebScrollbarImpl::setDocumentSize(int size) @@ -112,7 +113,8 @@ void WebScrollbarImpl::scroll(ScrollDirection direction, ScrollGranularity granu dir = horizontal ? ScrollRight : ScrollDown; else dir = horizontal ? ScrollLeft : ScrollUp; - m_scrollbar->scroll(dir, static_cast<WebCore::ScrollGranularity>(granularity), multiplier); + + WebCore::ScrollableArea::scroll(dir, static_cast<WebCore::ScrollGranularity>(granularity), multiplier); } void WebScrollbarImpl::paint(WebCanvas* canvas, const WebRect& rect) @@ -167,11 +169,11 @@ bool WebScrollbarImpl::onMouseDown(const WebInputEvent& event) if (!m_scrollbar->frameRect().contains(mousedown.x, mousedown.y)) return false; - mousedown.x -= m_scrollbar->x(); - mousedown.y -= m_scrollbar->y(); - m_scrollbar->mouseDown(PlatformMouseEventBuilder(m_scrollbar.get(), mousedown)); - return true; - } + mousedown.x -= m_scrollbar->x(); + mousedown.y -= m_scrollbar->y(); + m_scrollbar->mouseDown(PlatformMouseEventBuilder(m_scrollbar.get(), mousedown)); + return true; +} bool WebScrollbarImpl::onMouseUp(const WebInputEvent& event) { @@ -183,16 +185,16 @@ bool WebScrollbarImpl::onMouseUp(const WebInputEvent& event) bool WebScrollbarImpl::onMouseMove(const WebInputEvent& event) { - WebMouseEvent mousemove = *static_cast<const WebMouseEvent*>(&event); - if (m_scrollbar->frameRect().contains(mousemove.x, mousemove.y) - || m_scrollbar->pressedPart() != NoPart) { - mousemove.x -= m_scrollbar->x(); - mousemove.y -= m_scrollbar->y(); - return m_scrollbar->mouseMoved(PlatformMouseEventBuilder(m_scrollbar.get(), mousemove)); - } + WebMouseEvent mousemove = *static_cast<const WebMouseEvent*>(&event); + if (m_scrollbar->frameRect().contains(mousemove.x, mousemove.y) + || m_scrollbar->pressedPart() != NoPart) { + mousemove.x -= m_scrollbar->x(); + mousemove.y -= m_scrollbar->y(); + return m_scrollbar->mouseMoved(PlatformMouseEventBuilder(m_scrollbar.get(), mousemove)); + } - if (m_scrollbar->hoveredPart() != NoPart) - m_scrollbar->mouseExited(); + if (m_scrollbar->hoveredPart() != NoPart) + m_scrollbar->mouseExited(); return false; } @@ -206,59 +208,59 @@ bool WebScrollbarImpl::onMouseLeave(const WebInputEvent& event) bool WebScrollbarImpl::onMouseWheel(const WebInputEvent& event) { - // Same logic as in Scrollview.cpp. If we can move at all, we'll accept the event. - WebMouseWheelEvent mousewheel = *static_cast<const WebMouseWheelEvent*>(&event); - int maxScrollDelta = m_scrollbar->maximum() - m_scrollbar->value(); - float delta = m_scrollbar->orientation() == HorizontalScrollbar ? mousewheel.deltaX : mousewheel.deltaY; - if ((delta < 0 && maxScrollDelta > 0) || (delta > 0 && m_scrollbar->value() > 0)) { - if (mousewheel.scrollByPage) { - ASSERT(m_scrollbar->orientation() == VerticalScrollbar); - bool negative = delta < 0; - delta = max(max(static_cast<float>(m_scrollbar->visibleSize()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollbar->visibleSize() - Scrollbar::maxOverlapBetweenPages())), 1.0f); - if (negative) - delta *= -1; - } - m_scrollbar->scroll((m_scrollbar->orientation() == HorizontalScrollbar) ? WebCore::ScrollLeft : WebCore::ScrollUp, WebCore::ScrollByPixel, delta); - return true; + // Same logic as in Scrollview.cpp. If we can move at all, we'll accept the event. + WebMouseWheelEvent mousewheel = *static_cast<const WebMouseWheelEvent*>(&event); + int maxScrollDelta = m_scrollbar->maximum() - m_scrollbar->value(); + float delta = m_scrollbar->orientation() == HorizontalScrollbar ? mousewheel.deltaX : mousewheel.deltaY; + if ((delta < 0 && maxScrollDelta > 0) || (delta > 0 && m_scrollbar->value() > 0)) { + if (mousewheel.scrollByPage) { + ASSERT(m_scrollbar->orientation() == VerticalScrollbar); + bool negative = delta < 0; + delta = max(max(static_cast<float>(m_scrollbar->visibleSize()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollbar->visibleSize() - Scrollbar::maxOverlapBetweenPages())), 1.0f); + if (negative) + delta *= -1; } + WebCore::ScrollableArea::scroll((m_scrollbar->orientation() == HorizontalScrollbar) ? WebCore::ScrollLeft : WebCore::ScrollUp, WebCore::ScrollByPixel, delta); + return true; + } return false; } bool WebScrollbarImpl::onKeyDown(const WebInputEvent& event) { - WebKeyboardEvent keyboard = *static_cast<const WebKeyboardEvent*>(&event); - int keyCode; - // We have to duplicate this logic from WebViewImpl because there it uses - // Char and RawKeyDown events, which don't exist at this point. - if (keyboard.windowsKeyCode == VKEY_SPACE) - keyCode = ((keyboard.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT); - else { - if (keyboard.modifiers == WebInputEvent::ControlKey) { - // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl - // key combinations which affect scrolling. Safari is buggy in the - // sense that it scrolls the page for all Ctrl+scrolling key - // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc. - switch (keyboard.windowsKeyCode) { - case VKEY_HOME: - case VKEY_END: - break; - default: - return false; - } + WebKeyboardEvent keyboard = *static_cast<const WebKeyboardEvent*>(&event); + int keyCode; + // We have to duplicate this logic from WebViewImpl because there it uses + // Char and RawKeyDown events, which don't exist at this point. + if (keyboard.windowsKeyCode == VKEY_SPACE) + keyCode = ((keyboard.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT); + else { + if (keyboard.modifiers == WebInputEvent::ControlKey) { + // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl + // key combinations which affect scrolling. Safari is buggy in the + // sense that it scrolls the page for all Ctrl+scrolling key + // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc. + switch (keyboard.windowsKeyCode) { + case VKEY_HOME: + case VKEY_END: + break; + default: + return false; } + } - if (keyboard.isSystemKey || (keyboard.modifiers & WebInputEvent::ShiftKey)) - return false; + if (keyboard.isSystemKey || (keyboard.modifiers & WebInputEvent::ShiftKey)) + return false; - keyCode = keyboard.windowsKeyCode; - } - WebCore::ScrollDirection scrollDirection; - WebCore::ScrollGranularity scrollGranularity; - if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranularity)) { - // Will return false if scroll direction wasn't compatible with this scrollbar. - return m_scrollbar->scroll(scrollDirection, scrollGranularity); - } + keyCode = keyboard.windowsKeyCode; + } + WebCore::ScrollDirection scrollDirection; + WebCore::ScrollGranularity scrollGranularity; + if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranularity)) { + // Will return false if scroll direction wasn't compatible with this scrollbar. + return WebCore::ScrollableArea::scroll(scrollDirection, scrollGranularity); + } return false; } @@ -267,13 +269,18 @@ int WebScrollbarImpl::scrollSize(WebCore::ScrollbarOrientation orientation) cons return (orientation == m_scrollbar->orientation()) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0; } -void WebScrollbarImpl::setScrollOffsetFromAnimation(const WebCore::IntPoint& offset) +int WebScrollbarImpl::scrollPosition(WebCore::Scrollbar*) const { - m_scrollbar->setValue((m_scrollbar->orientation() == HorizontalScrollbar) ? offset.x() : offset.y(), Scrollbar::FromScrollAnimator); + return m_scrollOffset; } -void WebScrollbarImpl::valueChanged(WebCore::Scrollbar*) +void WebScrollbarImpl::setScrollOffset(const WebCore::IntPoint& offset) { + if (m_scrollbar->orientation() == HorizontalScrollbar) + m_scrollOffset = offset.x(); + else + m_scrollOffset = offset.y(); + m_client->valueChanged(this); } diff --git a/Source/WebKit/chromium/src/WebScrollbarImpl.h b/Source/WebKit/chromium/src/WebScrollbarImpl.h index 5512867..4dcfd5d 100644 --- a/Source/WebKit/chromium/src/WebScrollbarImpl.h +++ b/Source/WebKit/chromium/src/WebScrollbarImpl.h @@ -31,7 +31,7 @@ #ifndef WebScrollbarImpl_h #define WebScrollbarImpl_h -#include "ScrollbarClient.h" +#include "ScrollableArea.h" #include "WebScrollbar.h" #include <wtf/RefPtr.h> @@ -43,7 +43,7 @@ class Scrollbar; namespace WebKit { class WebScrollbarImpl : public WebScrollbar, - public WebCore::ScrollbarClient { + public WebCore::ScrollableArea { public: WebScrollbarImpl(WebScrollbarClient*, Orientation orientation); ~WebScrollbarImpl(); @@ -57,10 +57,10 @@ public: virtual void paint(WebCanvas*, const WebRect&); virtual bool handleInputEvent(const WebInputEvent&); - // WebCore::ScrollbarClient methods - virtual int scrollSize(WebCore::ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const WebCore::IntPoint&); - virtual void valueChanged(WebCore::Scrollbar*); + // WebCore::ScrollableArea methods + virtual int scrollSize(WebCore::ScrollbarOrientation) const; + virtual int scrollPosition(WebCore::Scrollbar*) const; + virtual void setScrollOffset(const WebCore::IntPoint&); virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&); virtual bool isActive() const; virtual bool scrollbarCornerPresent() const; @@ -76,6 +76,7 @@ private: WebScrollbarClient* m_client; + int m_scrollOffset; RefPtr<WebCore::Scrollbar> m_scrollbar; }; diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.cpp b/Source/WebKit/chromium/src/WebSettingsImpl.cpp index c66a57b..0457f77 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.cpp +++ b/Source/WebKit/chromium/src/WebSettingsImpl.cpp @@ -264,6 +264,11 @@ void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled) m_settings->setOfflineWebApplicationCacheEnabled(enabled); } +void WebSettingsImpl::setWebAudioEnabled(bool enabled) +{ + m_settings->setWebAudioEnabled(enabled); +} + void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled) { m_settings->setWebGLEnabled(enabled); diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.h b/Source/WebKit/chromium/src/WebSettingsImpl.h index febc959..4960bb9 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.h +++ b/Source/WebKit/chromium/src/WebSettingsImpl.h @@ -84,6 +84,7 @@ public: virtual void setAllowFileAccessFromFileURLs(bool); virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); virtual void setOfflineWebApplicationCacheEnabled(bool); + virtual void setWebAudioEnabled(bool); virtual void setExperimentalWebGLEnabled(bool); virtual void setShowDebugBorders(bool); virtual void setEditingBehavior(EditingBehavior); diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp index 48f8b50..3beb785 100644 --- a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp +++ b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp @@ -32,8 +32,10 @@ #include "WebSpeechInputControllerMockImpl.h" #include "PlatformString.h" +#include "SecurityOrigin.h" #include "SpeechInputClientMock.h" #include "WebRect.h" +#include "WebSecurityOrigin.h" namespace WebKit { @@ -80,9 +82,9 @@ void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const m_listener->setRecognitionResult(requestId, result); } -bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar) +bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin) { - return m_webcoreMock->startRecognition(requestId, elementRect, language, grammar); + return m_webcoreMock->startRecognition(requestId, elementRect, language, grammar, origin.get()); } void WebSpeechInputControllerMockImpl::cancelRecognition(int requestId) diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h index bf00ed0..4c8fee7 100644 --- a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h +++ b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h @@ -57,7 +57,7 @@ public: void setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result); // WebSpeechInputController methods. - bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar); + bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin&); void cancelRecognition(int requestId); void stopRecording(int requestId); diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index 41a0804..798e5ff 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -34,23 +34,22 @@ #include "AutoFillPopupMenuClient.h" #include "AXObjectCache.h" #include "BackForwardListChromium.h" +#include "CSSStyleSelector.h" +#include "CSSValueKeywords.h" #include "Chrome.h" -#include "ChromiumBridge.h" #include "ColorSpace.h" #include "CompositionUnderlineVectorBuilder.h" #include "ContextMenu.h" #include "ContextMenuController.h" #include "ContextMenuItem.h" -#include "CSSStyleSelector.h" -#include "CSSValueKeywords.h" #include "Cursor.h" +#include "DOMUtilitiesPrivate.h" #include "DeviceOrientationClientProxy.h" #include "Document.h" #include "DocumentLoader.h" -#include "DOMUtilitiesPrivate.h" #include "DragController.h" -#include "DragScrollTimer.h" #include "DragData.h" +#include "DragScrollTimer.h" #include "Editor.h" #include "EventHandler.h" #include "Extensions3D.h" @@ -65,8 +64,8 @@ #include "GraphicsContext3DInternal.h" #include "HTMLInputElement.h" #include "HTMLMediaElement.h" -#include "HitTestResult.h" #include "HTMLNames.h" +#include "HitTestResult.h" #include "Image.h" #include "ImageBuffer.h" #include "InspectorController.h" @@ -78,6 +77,7 @@ #include "PageGroup.h" #include "PageGroupLoadDeferrer.h" #include "Pasteboard.h" +#include "PlatformBridge.h" #include "PlatformContextSkia.h" #include "PlatformKeyboardEvent.h" #include "PlatformMouseEvent.h" @@ -98,8 +98,8 @@ #include "Vector.h" #include "WebAccessibilityObject.h" #include "WebAutoFillClient.h" -#include "WebDevToolsAgentPrivate.h" #include "WebDevToolsAgentImpl.h" +#include "WebDevToolsAgentPrivate.h" #include "WebDragData.h" #include "WebFrameImpl.h" #include "WebImage.h" @@ -972,6 +972,18 @@ void WebViewImpl::resize(const WebSize& newSize) #endif } +void WebViewImpl::animate() +{ +#if ENABLE(REQUEST_ANIMATION_FRAME) + WebFrameImpl* webframe = mainFrameImpl(); + if (webframe) { + FrameView* view = webframe->frameView(); + if (view) + view->serviceScriptedAnimations(); + } +#endif +} + void WebViewImpl::layout() { WebFrameImpl* webframe = mainFrameImpl(); @@ -2287,7 +2299,7 @@ void WebViewImpl::invalidateRootLayerRect(const IntRect& rect) void WebViewImpl::setIsAcceleratedCompositingActive(bool active) { - ChromiumBridge::histogramEnumeration("GPU.setIsAcceleratedCompositingActive", active * 2 + m_isAcceleratedCompositingActive, 4); + PlatformBridge::histogramEnumeration("GPU.setIsAcceleratedCompositingActive", active * 2 + m_isAcceleratedCompositingActive, 4); if (m_isAcceleratedCompositingActive == active) return; diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index bc79ec1..d164a48 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -91,6 +91,7 @@ public: virtual void close(); virtual WebSize size() { return m_size; } virtual void resize(const WebSize&); + virtual void animate(); virtual void layout(); virtual void paint(WebCanvas*, const WebRect&); virtual void themeChanged(); diff --git a/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp index 18282e3..f90e7e8 100644 --- a/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp @@ -41,6 +41,7 @@ #include "MessageEvent.h" #include "MessagePort.h" #include "MessagePortChannel.h" +#include "ScriptCallStack.h" #include "ScriptExecutionContext.h" #include "Worker.h" #include "WorkerContext.h" @@ -247,7 +248,7 @@ void WebWorkerClientImpl::postExceptionToWorkerObject(const WebString& errorMess sourceURL, lineNumber)); if (unhandled) - m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL); + m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0); } void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int destination, @@ -274,7 +275,7 @@ void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int destination, static_cast<MessageType>(messageType), static_cast<MessageLevel>(messageLevel), String(message), lineNumber, - String(sourceURL)); + String(sourceURL), 0); } void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int sourceId, @@ -381,9 +382,7 @@ void WebWorkerClientImpl::postExceptionToWorkerObjectTask( sourceURL, lineNumber)); if (!handled) - thisPtr->m_scriptExecutionContext->reportException(errorMessage, - lineNumber, - sourceURL); + thisPtr->m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0); } void WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask(ScriptExecutionContext* context, @@ -398,8 +397,7 @@ void WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask(ScriptExecutionCo thisPtr->m_scriptExecutionContext->addMessage(static_cast<MessageSource>(sourceId), static_cast<MessageType>(messageType), static_cast<MessageLevel>(messageLevel), - message, lineNumber, - sourceURL); + message, lineNumber, sourceURL, 0); } void WebWorkerClientImpl::confirmMessageFromWorkerObjectTask(ScriptExecutionContext* context, diff --git a/Source/WebKit/chromium/src/js/Tests.js b/Source/WebKit/chromium/src/js/Tests.js index f2e8dcb..900d79e 100644 --- a/Source/WebKit/chromium/src/js/Tests.js +++ b/Source/WebKit/chromium/src/js/Tests.js @@ -616,7 +616,7 @@ TestSuite.prototype.evaluateInConsole_ = function(code, callback) */ TestSuite.prototype._checkExecutionLine = function(sourceFrame, lineNumber, lineContent) { - this.assertEquals(lineNumber, sourceFrame.executionLine, "Unexpected execution line number."); + this.assertEquals(lineNumber, sourceFrame._executionLine, "Unexpected execution line number."); this.assertEquals(lineContent, sourceFrame._textModel.line(lineNumber - 1), "Unexpected execution line text."); } @@ -686,7 +686,8 @@ TestSuite.prototype._checkSourceFrameWhenLoaded = function(expectations, callbac var test = this; var frame = WebInspector.currentPanel.visibleView.sourceFrame; - if (frame._loaded) + + if (frame._textViewer) checkExecLine(); else { setTimeout(function() { @@ -741,32 +742,6 @@ TestSuite.prototype._waitUntilScriptsAreParsed = function(expectedScripts, callb /** - * Executes the 'code' with InjectedScriptAccess.getProperties overriden - * so that all callbacks passed to InjectedScriptAccess.getProperties are - * extended with the "hook". - * @param {Function} hook The hook function. - * @param {Function} code A code snippet to be executed. - */ -TestSuite.prototype._hookGetPropertiesCallback = function(hook, code) -{ - var accessor = InjectedScriptAccess.prototype; - var orig = accessor.getProperties; - accessor.getProperties = function(objectProxy, ignoreHasOwnProperty, abbreviate, callback) { - orig.call(this, objectProxy, ignoreHasOwnProperty, abbreviate, - function() { - callback.apply(this, arguments); - hook(); - }); - }; - try { - code(); - } finally { - accessor.getProperties = orig; - } -}; - - -/** * Key event with given key identifier. */ TestSuite.createKeyEvent = function(keyIdentifier) diff --git a/Source/WebKit/chromium/tests/PopupMenuTest.cpp b/Source/WebKit/chromium/tests/PopupMenuTest.cpp index dab5ff9..4c9a149 100644 --- a/Source/WebKit/chromium/tests/PopupMenuTest.cpp +++ b/Source/WebKit/chromium/tests/PopupMenuTest.cpp @@ -96,7 +96,7 @@ public: virtual FontSelector* fontSelector() const { return 0; } virtual HostWindow* hostWindow() const { return 0; } - virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize) { return 0; } + virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize) { return 0; } private: unsigned m_selectIndex; diff --git a/Source/WebKit/efl/WebCoreSupport/FullscreenVideoControllerEfl.h b/Source/WebKit/efl/WebCoreSupport/FullscreenVideoControllerEfl.h index 4bbae25..67c4608 100644 --- a/Source/WebKit/efl/WebCoreSupport/FullscreenVideoControllerEfl.h +++ b/Source/WebKit/efl/WebCoreSupport/FullscreenVideoControllerEfl.h @@ -27,7 +27,8 @@ #include "HTMLMediaElement.h" #include <wtf/RefPtr.h> -class FullscreenVideoController : public Noncopyable { +class FullscreenVideoController { + WTF_MAKE_NONCOPYABLE(FullscreenVideoController); public: FullscreenVideoController(); virtual ~FullscreenVideoController(); diff --git a/Source/WebKit/gtk/ChangeLog b/Source/WebKit/gtk/ChangeLog index ef1f2aa..912c948 100644 --- a/Source/WebKit/gtk/ChangeLog +++ b/Source/WebKit/gtk/ChangeLog @@ -1,3 +1,28 @@ +2011-01-21 Carlos Garcia Campos <cgarcia@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Show caps lock indicator in password fields + https://bugs.webkit.org/show_bug.cgi?id=52878 + + Test: manual-tests/password-caps-lock.html + + * webkit/webkitwebview.cpp: + (webkit_web_view_key_release_event): Call + capsLockStateMayHaveChanged() when caps lock key is pressed. + +2011-01-19 Joone Hur <joone.hur@collabora.co.uk> + + Reviewed by Andreas Kling. + + [GTK] No need to invalidate empty areas in ChromeClient::invalidateContentsAndWindow + https://bugs.webkit.org/show_bug.cgi?id=52702 + + Don't call gdk_window_invalidate_rect if an updated rectangle is empty. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::invalidateContentsAndWindow): + 2011-01-17 Philippe Normand <pnormand@igalia.com> Unreviewed, build fix for 2 GTK tests html file paths. diff --git a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp index 8b6a483..04ee8ba 100644 --- a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp +++ b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp @@ -377,7 +377,7 @@ void ChromeClient::invalidateContentsAndWindow(const IntRect& updateRect, bool i GdkRectangle rect = updateRect; GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(m_webView)); - if (window) { + if (window && !updateRect.isEmpty()) { gdk_window_invalidate_rect(window, &rect, FALSE); // We don't currently do immediate updates since they delay other UI elements. //if (immediate) diff --git a/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h b/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h index d4bbea2..3fb8b16 100644 --- a/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h +++ b/Source/WebKit/gtk/WebCoreSupport/FullscreenVideoController.h @@ -27,7 +27,8 @@ #include "HTMLMediaElement.h" #include <wtf/RefPtr.h> -class FullscreenVideoController : public Noncopyable { +class FullscreenVideoController { + WTF_MAKE_NONCOPYABLE(FullscreenVideoController); public: FullscreenVideoController(); virtual ~FullscreenVideoController(); diff --git a/Source/WebKit/gtk/webkit/webkitdownload.cpp b/Source/WebKit/gtk/webkit/webkitdownload.cpp index 60b8e6d..a7890c1 100644 --- a/Source/WebKit/gtk/webkit/webkitdownload.cpp +++ b/Source/WebKit/gtk/webkit/webkitdownload.cpp @@ -57,7 +57,8 @@ using namespace WebCore; * out what is to be downloaded, and do it itself. */ -class DownloadClient : public Noncopyable, public ResourceHandleClient { +class DownloadClient : public ResourceHandleClient { + WTF_MAKE_NONCOPYABLE(DownloadClient); public: DownloadClient(WebKitDownload*); diff --git a/Source/WebKit/gtk/webkit/webkitwebview.cpp b/Source/WebKit/gtk/webkit/webkitwebview.cpp index e5d5b84..c855507 100644 --- a/Source/WebKit/gtk/webkit/webkitwebview.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebview.cpp @@ -790,6 +790,9 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey if (!frame->view()) return FALSE; + if (event->keyval == GDK_Caps_Lock) + frame->eventHandler()->capsLockStateMayHaveChanged(); + PlatformKeyboardEvent keyboardEvent(event); if (frame->eventHandler()->keyEvent(keyboardEvent)) return TRUE; diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog index fcd7edb..121250d 100644 --- a/Source/WebKit/mac/ChangeLog +++ b/Source/WebKit/mac/ChangeLog @@ -1,3 +1,125 @@ +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Darin Fisher. + + Add run-time enable support for the web audio API + https://bugs.webkit.org/show_bug.cgi?id=52741 + + * WebView/WebPreferenceKeysPrivate.h: + * WebView/WebPreferences.mm: + (-[WebPreferences webAudioEnabled]): + (-[WebPreferences setWebAudioEnabled:]): + * WebView/WebPreferencesPrivate.h: + * WebView/WebView.mm: + (-[WebView _preferencesChangedNotification:]): + +2011-01-20 John Sullivan <sullivan@apple.com> + + Reviewed by Mark Rowe. + + Shift-tab doesn't cycle through fields in http authentication panel + https://bugs.webkit.org/show_bug.cgi?id=52850 + + * Panels/English.lproj/WebAuthenticationPanel.nib/designable.nib: + * Panels/English.lproj/WebAuthenticationPanel.nib/keyedobjects.nib: + Re-wired the key loop so that there aren't two views with the same nextKeyView. + +2011-01-20 Beth Dakin <bdakin@apple.com> + + Reviewed by Geoffrey Garen. + + Fix for <rdar://problem/8890255> + + Allow WebKitSystemInterface to draw scrollbars + when appropriate. + * WebCoreSupport/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + +2011-01-19 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Sam Weinig. + + GraphicsLayers in subframes can get sync'd multiple times + https://bugs.webkit.org/show_bug.cgi?id=52489 + + * WebView/WebView.mm: + (-[WebView _syncCompositingChanges]): syncCompositingStateRecursive() + was renamed to syncCompositingStateIncludingSubframes(). + +2011-01-19 Darin Adler <darin@apple.com> + + Reviewed by Sam Weinig. + + Would like script debugging protocol method to differentiate between caught and uncaught exceptions + https://bugs.webkit.org/show_bug.cgi?id=52104 + rdar://problem/8704226 + + * WebView/WebDelegateImplementationCaching.h: + Fix type of second integer in CallScriptDebugDelegate function overload + to be int to match the actual Objective-C method. Added a new overload + that includes a BOOL in the right place. Added a boolean named + exceptionWasRaisedExpectsHasHandlerFlag. + + * WebView/WebDelegateImplementationCaching.mm: + (CallDelegate): Added overloads as above. + (CallScriptDebugDelegate): Ditto. + + * WebView/WebScriptDebugDelegate.h: Added new method with the additional + boolean argument. Marked the old method informally deprecated. + + * WebView/WebScriptDebugger.mm: + (WebScriptDebugger::exception): Added code to call with or without the + boolean depending on exceptionWasRaisedExpectsHasHandlerFlag. + + * WebView/WebView.mm: + (-[WebView _cacheScriptDebugDelegateImplementations]): Set up the + exceptionWasRaisedExpectsHasHandlerFlag. Also fixed old code that was not + guaranteed to set didParseSourceExpectsBaseLineNumber to NO. + +2011-01-19 Tony Gentilcore <tonyg@chromium.org> + + Reviewed by Mihai Parparita. + + Perform some forward declaration + https://bugs.webkit.org/show_bug.cgi?id=52522 + + * Misc/WebKitNSStringExtras.mm: + +2011-01-19 Pavel Podivilov <podivilov@chromium.org> + + Reviewed by Yury Semikhatsky. + + Web Inspector: [JSC] scripts have incorrect starting line (always 1). + https://bugs.webkit.org/show_bug.cgi?id=52721 + + * WebView/WebScriptDebugger.h: + * WebView/WebScriptDebugger.mm: + (toNSString): + (WebScriptDebugger::sourceParsed): + +2011-01-19 Levi Weintraub <leviw@google.com> + + Reviewed by Ryosuke Niwa. + + Updating to use Position::parentAnchoredEquivalent instead of + the old htmlediting rangeCompliantEquivalent. + + remove rangeCompliantEquivalent and replace it with Position methods + https://bugs.webkit.org/show_bug.cgi?id=25057 + + * WebView/WebFrame.mm: + (-[WebFrame _smartDeleteRangeForProposedRange:]): + +2011-01-18 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Darin Adler. + + REGRESSION: A problem with Voiceover and finding links + https://bugs.webkit.org/show_bug.cgi?id=52324 + + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView accessibilityIsIgnored]): + 2011-01-17 David Kilzer <ddkilzer@apple.com> <http://webkit.org/b/52596> Add missing DOMDocument/DOMDocumentFragment headers to Xcode project diff --git a/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm b/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm index 4bf268c..a997e30 100644 --- a/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm +++ b/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm @@ -30,6 +30,7 @@ #import <WebCore/Font.h> #import <WebCore/GraphicsContext.h> +#import <WebCore/TextRun.h> #import <WebCore/WebCoreNSStringExtras.h> #import <WebKit/WebNSFileManagerExtras.h> #import <WebKit/WebNSObjectExtras.h> diff --git a/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/designable.nib b/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/designable.nib index 1e684d5..d102a89 100644 --- a/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/designable.nib +++ b/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/designable.nib @@ -2,13 +2,13 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">10J530</string> - <string key="IBDocument.InterfaceBuilderVersion">804</string> + <string key="IBDocument.SystemVersion">10J567</string> + <string key="IBDocument.InterfaceBuilderVersion">823</string> <string key="IBDocument.AppKitVersion">1038.35</string> - <string key="IBDocument.HIToolboxVersion">461.00</string> + <string key="IBDocument.HIToolboxVersion">462.00</string> <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> - <string key="NS.object.0">804</string> + <string key="NS.object.0">823</string> </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -389,14 +389,6 @@ </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">nextKeyView</string> - <reference key="source" ref="71972597"/> - <reference key="destination" ref="368270689"/> - </object> - <int key="connectionID">36</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> <string key="label">imageView</string> <reference key="source" ref="238662661"/> <reference key="destination" ref="285173040"/> @@ -413,67 +405,91 @@ </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">nextKeyView</string> - <reference key="source" ref="368270689"/> - <reference key="destination" ref="657854151"/> + <string key="label">separateRealmLabel</string> + <reference key="source" ref="238662661"/> + <reference key="destination" ref="1000280557"/> </object> - <int key="connectionID">41</int> + <int key="connectionID">100057</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">nextKeyView</string> - <reference key="source" ref="657854151"/> - <reference key="destination" ref="494193237"/> + <reference key="source" ref="705333610"/> + <reference key="destination" ref="1000280557"/> </object> - <int key="connectionID">42</int> + <int key="connectionID">100058</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">nextKeyView</string> - <reference key="source" ref="494193237"/> - <reference key="destination" ref="305175176"/> + <reference key="source" ref="1000280557"/> + <reference key="destination" ref="199018347"/> </object> - <int key="connectionID">43</int> + <int key="connectionID">100059</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">nextKeyView</string> - <reference key="source" ref="305175176"/> - <reference key="destination" ref="705333610"/> + <reference key="source" ref="199018347"/> + <reference key="destination" ref="477300420"/> </object> - <int key="connectionID">100042</int> + <int key="connectionID">100060</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">nextKeyView</string> - <reference key="source" ref="705333610"/> - <reference key="destination" ref="199018347"/> + <reference key="source" ref="477300420"/> + <reference key="destination" ref="71972597"/> </object> - <int key="connectionID">100045</int> + <int key="connectionID">100061</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">nextKeyView</string> - <reference key="source" ref="199018347"/> - <reference key="destination" ref="71972597"/> + <reference key="source" ref="71972597"/> + <reference key="destination" ref="833115728"/> </object> - <int key="connectionID">100046</int> + <int key="connectionID">100062</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">nextKeyView</string> - <reference key="source" ref="1000280557"/> + <reference key="source" ref="833115728"/> <reference key="destination" ref="368270689"/> </object> - <int key="connectionID">100051</int> + <int key="connectionID">100063</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">separateRealmLabel</string> - <reference key="source" ref="238662661"/> - <reference key="destination" ref="1000280557"/> + <string key="label">nextKeyView</string> + <reference key="source" ref="368270689"/> + <reference key="destination" ref="657854151"/> </object> - <int key="connectionID">100057</int> + <int key="connectionID">100064</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">nextKeyView</string> + <reference key="source" ref="657854151"/> + <reference key="destination" ref="494193237"/> + </object> + <int key="connectionID">100065</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">nextKeyView</string> + <reference key="source" ref="494193237"/> + <reference key="destination" ref="305175176"/> + </object> + <int key="connectionID">100066</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">nextKeyView</string> + <reference key="source" ref="305175176"/> + <reference key="destination" ref="705333610"/> + </object> + <int key="connectionID">100067</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -780,10 +796,10 @@ <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> - <string>{{288, 734}, {424, 254}}</string> + <string>{{288, 843}, {424, 254}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> - <string>{{288, 734}, {424, 254}}</string> + <string>{{288, 843}, {424, 254}}</string> <integer value="1"/> <integer value="0"/> <integer value="0"/> @@ -809,7 +825,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">100057</int> + <int key="maxID">100067</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/keyedobjects.nib b/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/keyedobjects.nib Binary files differindex 5bd4806..42a4b1d 100644 --- a/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/keyedobjects.nib +++ b/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/keyedobjects.nib diff --git a/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h b/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h index f784ade..4f2c566 100644 --- a/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h +++ b/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h @@ -313,7 +313,8 @@ private: bool demarshalValueFromArray(JSC::ExecState*, NSArray *array, NSUInteger& index, JSC::JSValue& result); void demarshalValues(JSC::ExecState*, data_t valuesData, mach_msg_type_number_t valuesLength, JSC::MarkedArgumentBuffer& result); - class LocalObjectMap : Noncopyable { + class LocalObjectMap { + WTF_MAKE_NONCOPYABLE(LocalObjectMap); public: LocalObjectMap(); ~LocalObjectMap(); diff --git a/Source/WebKit/mac/Storage/WebDatabaseTrackerClient.mm b/Source/WebKit/mac/Storage/WebDatabaseTrackerClient.mm index 2913739..65aba43 100644 --- a/Source/WebKit/mac/Storage/WebDatabaseTrackerClient.mm +++ b/Source/WebKit/mac/Storage/WebDatabaseTrackerClient.mm @@ -52,7 +52,8 @@ WebDatabaseTrackerClient::~WebDatabaseTrackerClient() { } -class DidModifyOriginData : public Noncopyable { +class DidModifyOriginData { + WTF_MAKE_NONCOPYABLE(DidModifyOriginData); public: static void dispatchToMainThread(WebDatabaseTrackerClient* client, SecurityOrigin* origin) { diff --git a/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm b/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm index e1c1058..70767ee 100644 --- a/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm +++ b/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm @@ -123,6 +123,8 @@ void InitWebCoreSystemInterface(void) INIT(CreateCTTypesetterWithUniCharProviderAndOptions); INIT(IOSurfaceContextCreate); INIT(IOSurfaceContextCreateImage); + INIT(MakeScrollbarPainter); + INIT(ScrollbarPainterPaint); #endif didInit = true; diff --git a/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h b/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h index 2aadc83..8bc776b 100644 --- a/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h +++ b/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h @@ -80,6 +80,7 @@ struct WebFrameLoadDelegateImplementationCache { struct WebScriptDebugDelegateImplementationCache { BOOL didParseSourceExpectsBaseLineNumber; + BOOL exceptionWasRaisedExpectsHasHandlerFlag; IMP didParseSourceFunc; IMP failedToParseSourceFunc; IMP didEnterCallFrameFunc; @@ -138,7 +139,8 @@ BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id, id, id CallScriptDebugDelegate(IMP, WebView *, SEL, id, id, NSInteger, id); id CallScriptDebugDelegate(IMP, WebView *, SEL, id, NSInteger, id, NSInteger, id); id CallScriptDebugDelegate(IMP, WebView *, SEL, id, NSInteger, id, id, id); -id CallScriptDebugDelegate(IMP, WebView *, SEL, id, NSInteger, NSInteger, id); +id CallScriptDebugDelegate(IMP, WebView *, SEL, id, NSInteger, int, id); +id CallScriptDebugDelegate(IMP, WebView *, SEL, id, BOOL, NSInteger, int, id); id CallHistoryDelegate(IMP, WebView *, SEL); id CallHistoryDelegate(IMP, WebView *, SEL, id, id); diff --git a/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm b/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm index d00d60b..c070b2b 100644 --- a/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm +++ b/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm @@ -345,7 +345,7 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE return nil; } -static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer1, NSInteger integer2, id object2) +static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer1, int integer2, id object2) { if (!delegate) return nil; @@ -359,6 +359,20 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE return nil; } +static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, BOOL boolean, NSInteger integer1, int integer2, id object2) +{ + if (!delegate) + return nil; + if (!self->_private->catchesDelegateExceptions) + return implementation(delegate, selector, self, object1, boolean, integer1, integer2, object2); + @try { + return implementation(delegate, selector, self, object1, boolean, integer1, integer2, object2); + } @catch(id exception) { + ReportDiscardedDelegateException(selector, exception); + } + return nil; +} + static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, NSInteger integer, id object3) { if (!delegate) @@ -574,11 +588,16 @@ id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id o return CallDelegate(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer, object2, object3, object4); } -id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer1, NSInteger integer2, id object2) +id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer1, int integer2, id object2) { return CallDelegate(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer1, integer2, object2); } +id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, BOOL boolean, NSInteger integer1, int integer2, id object2) +{ + return CallDelegate(implementation, self, self->_private->scriptDebugDelegate, selector, object1, boolean, integer1, integer2, object2); +} + id CallHistoryDelegate(IMP implementation, WebView *self, SEL selector) { return CallDelegate(implementation, self, self->_private->historyDelegate, selector); diff --git a/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm b/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm index 79c3067..b8edef8 100644 --- a/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm +++ b/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm @@ -565,11 +565,7 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; - (BOOL)accessibilityIsIgnored { - id docView = [self documentView]; - if ([docView isKindOfClass:[WebFrameView class]] && ![(WebFrameView *)docView allowsScrolling]) - return YES; - - return [super accessibilityIsIgnored]; + return YES; } - (void)setScrollOrigin:(NSPoint)scrollOrigin updatePosition:(BOOL)updatePosition diff --git a/Source/WebKit/mac/WebView/WebFrame.mm b/Source/WebKit/mac/WebView/WebFrame.mm index 3dde06f..154156a 100644 --- a/Source/WebKit/mac/WebView/WebFrame.mm +++ b/Source/WebKit/mac/WebView/WebFrame.mm @@ -802,8 +802,8 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) if (newEnd.isNull()) newEnd = end; - newStart = rangeCompliantEquivalent(newStart); - newEnd = rangeCompliantEquivalent(newEnd); + newStart = newStart.parentAnchoredEquivalent(); + newEnd = newEnd.parentAnchoredEquivalent(); RefPtr<Range> range = _private->coreFrame->document()->createRange(); int exception = 0; diff --git a/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h b/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h index 93f83fc..e6ba629 100644 --- a/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h +++ b/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h @@ -91,6 +91,7 @@ #define WebKitAcceleratedCompositingEnabledPreferenceKey @"WebKitAcceleratedCompositingEnabled" #define WebKitShowDebugBordersPreferenceKey @"WebKitShowDebugBorders" #define WebKitShowRepaintCounterPreferenceKey @"WebKitShowRepaintCounter" +#define WebKitWebAudioEnabledPreferenceKey @"WebKitWebAudioEnabled" #define WebKitWebGLEnabledPreferenceKey @"WebKitWebGLEnabled" #define WebKitAccelerated2dCanvasEnabledPreferenceKey @"WebKitAccelerated2dCanvasEnabled" #define WebKitPluginAllowedRunTimePreferenceKey @"WebKitPluginAllowedRunTime" diff --git a/Source/WebKit/mac/WebView/WebPreferences.mm b/Source/WebKit/mac/WebView/WebPreferences.mm index 7ce3bc4..c97cc2a 100644 --- a/Source/WebKit/mac/WebView/WebPreferences.mm +++ b/Source/WebKit/mac/WebView/WebPreferences.mm @@ -1264,6 +1264,16 @@ static NSString *classIBCreatorID = nil; [self _setBoolValue:enabled forKey:WebKitShowRepaintCounterPreferenceKey]; } +- (BOOL)webAudioEnabled +{ + return [self _boolValueForKey:WebKitWebAudioEnabledPreferenceKey]; +} + +- (void)setWebAudioEnabled:(BOOL)enabled +{ + [self _setBoolValue:enabled forKey:WebKitWebAudioEnabledPreferenceKey]; +} + - (BOOL)webGLEnabled { return [self _boolValueForKey:WebKitWebGLEnabledPreferenceKey]; diff --git a/Source/WebKit/mac/WebView/WebPreferencesPrivate.h b/Source/WebKit/mac/WebView/WebPreferencesPrivate.h index 89b6288..25a1bbd 100644 --- a/Source/WebKit/mac/WebView/WebPreferencesPrivate.h +++ b/Source/WebKit/mac/WebView/WebPreferencesPrivate.h @@ -185,6 +185,9 @@ extern NSString *WebPreferencesRemovedNotification; - (BOOL)showRepaintCounter; - (void)setShowRepaintCounter:(BOOL)show; +- (BOOL)webAudioEnabled; +- (void)setWebAudioEnabled:(BOOL)enabled; + - (BOOL)webGLEnabled; - (void)setWebGLEnabled:(BOOL)enabled; diff --git a/Source/WebKit/mac/WebView/WebScriptDebugDelegate.h b/Source/WebKit/mac/WebView/WebScriptDebugDelegate.h index 823cc35..2444b98 100644 --- a/Source/WebKit/mac/WebView/WebScriptDebugDelegate.h +++ b/Source/WebKit/mac/WebView/WebScriptDebugDelegate.h @@ -99,9 +99,17 @@ enum { // exception is being thrown - (void)webView:(WebView *)webView exceptionWasRaised:(WebScriptCallFrame *)frame + hasHandler:(BOOL)hasHandler sourceId:(WebSourceId)sid line:(int)lineno forWebFrame:(WebFrame *)webFrame; + +// exception is being thrown (deprecated old version; called only if new version is not implemented) +- (void)webView:(WebView *)webView exceptionWasRaised:(WebScriptCallFrame *)frame + sourceId:(WebSourceId)sid + line:(int)lineno + forWebFrame:(WebFrame *)webFrame; + @end diff --git a/Source/WebKit/mac/WebView/WebScriptDebugger.h b/Source/WebKit/mac/WebView/WebScriptDebugger.h index c4147a2..73c9466 100644 --- a/Source/WebKit/mac/WebView/WebScriptDebugger.h +++ b/Source/WebKit/mac/WebView/WebScriptDebugger.h @@ -53,7 +53,7 @@ public: void initGlobalCallFrame(const JSC::DebuggerCallFrame&); - virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMsg); + virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const JSC::UString& errorMsg); virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); virtual void returnEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber); diff --git a/Source/WebKit/mac/WebView/WebScriptDebugger.mm b/Source/WebKit/mac/WebView/WebScriptDebugger.mm index 25ef4b7..9bc3bce 100644 --- a/Source/WebKit/mac/WebView/WebScriptDebugger.mm +++ b/Source/WebKit/mac/WebView/WebScriptDebugger.mm @@ -34,7 +34,7 @@ #import "WebViewInternal.h" #import <JavaScriptCore/DebuggerCallFrame.h> #import <JavaScriptCore/JSGlobalObject.h> -#import <JavaScriptCore/SourceCode.h> +#import <JavaScriptCore/SourceProvider.h> #import <WebCore/DOMWindow.h> #import <WebCore/Frame.h> #import <WebCore/JSDOMWindow.h> @@ -57,11 +57,11 @@ NSString *toNSString(const UString& s) return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.characters()) length:s.length()]; } -static NSString *toNSString(const SourceCode& s) +static NSString *toNSString(SourceProvider* s) { - if (!s.length()) + if (!s->length()) return nil; - return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s.data()) length:s.length()]; + return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(s->data()) length:s->length()]; } // convert UString to NSURL @@ -104,15 +104,16 @@ void WebScriptDebugger::initGlobalCallFrame(const DebuggerCallFrame& debuggerCal } // callbacks - relay to delegate -void WebScriptDebugger::sourceParsed(ExecState* exec, const SourceCode& source, int errorLine, const UString& errorMsg) +void WebScriptDebugger::sourceParsed(ExecState* exec, SourceProvider* sourceProvider, int errorLine, const UString& errorMsg) { if (m_callingDelegate) return; m_callingDelegate = true; - NSString *nsSource = toNSString(source); - NSURL *nsURL = toNSURL(source.provider()->url()); + NSString *nsSource = toNSString(sourceProvider); + NSURL *nsURL = toNSURL(sourceProvider->url()); + int firstLine = sourceProvider->startPosition().m_line.oneBasedInt(); WebFrame *webFrame = toWebFrame(exec->dynamicGlobalObject()); WebView *webView = [webFrame webView]; @@ -121,9 +122,9 @@ void WebScriptDebugger::sourceParsed(ExecState* exec, const SourceCode& source, if (errorLine == -1) { if (implementations->didParseSourceFunc) { if (implementations->didParseSourceExpectsBaseLineNumber) - CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:), nsSource, source.firstLine(), nsURL, source.provider()->asID(), webFrame); + CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:), nsSource, firstLine, nsURL, sourceProvider->asID(), webFrame); else - CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:fromURL:sourceId:forWebFrame:), nsSource, [nsURL absoluteString], source.provider()->asID(), webFrame); + CallScriptDebugDelegate(implementations->didParseSourceFunc, webView, @selector(webView:didParseSource:fromURL:sourceId:forWebFrame:), nsSource, [nsURL absoluteString], sourceProvider->asID(), webFrame); } } else { NSString* nsErrorMessage = toNSString(errorMsg); @@ -131,7 +132,7 @@ void WebScriptDebugger::sourceParsed(ExecState* exec, const SourceCode& source, NSError *error = [[NSError alloc] initWithDomain:WebScriptErrorDomain code:WebScriptGeneralErrorCode userInfo:info]; if (implementations->failedToParseSourceFunc) - CallScriptDebugDelegate(implementations->failedToParseSourceFunc, webView, @selector(webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:), nsSource, source.firstLine(), nsURL, error, webFrame); + CallScriptDebugDelegate(implementations->failedToParseSourceFunc, webView, @selector(webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:), nsSource, firstLine, nsURL, error, webFrame); [error release]; [info release]; @@ -211,9 +212,13 @@ void WebScriptDebugger::exception(const DebuggerCallFrame& debuggerCallFrame, in WebView *webView = [webFrame webView]; [m_topCallFrame.get() _setDebuggerCallFrame:debuggerCallFrame]; - WebScriptDebugDelegateImplementationCache* implementations = WebViewGetScriptDebugDelegateImplementations(webView); - if (implementations->exceptionWasRaisedFunc) - CallScriptDebugDelegate(implementations->exceptionWasRaisedFunc, webView, @selector(webView:exceptionWasRaised:sourceId:line:forWebFrame:), m_topCallFrame.get(), sourceID, lineNumber, webFrame); + WebScriptDebugDelegateImplementationCache* cache = WebViewGetScriptDebugDelegateImplementations(webView); + if (cache->exceptionWasRaisedFunc) { + if (cache->exceptionWasRaisedExpectsHasHandlerFlag) + CallScriptDebugDelegate(cache->exceptionWasRaisedFunc, webView, @selector(webView:exceptionWasRaised:hasHandler:sourceId:line:forWebFrame:), m_topCallFrame.get(), hasHandler, sourceID, lineNumber, webFrame); + else + CallScriptDebugDelegate(cache->exceptionWasRaisedFunc, webView, @selector(webView:exceptionWasRaised:sourceId:line:forWebFrame:), m_topCallFrame.get(), sourceID, lineNumber, webFrame); + } m_callingDelegate = false; } diff --git a/Source/WebKit/mac/WebView/WebView.mm b/Source/WebKit/mac/WebView/WebView.mm index 809b286..82e4f2c 100644 --- a/Source/WebKit/mac/WebView/WebView.mm +++ b/Source/WebKit/mac/WebView/WebView.mm @@ -1496,6 +1496,7 @@ static bool fastDocumentTeardownEnabled() settings->setShowDebugBorders([preferences showDebugBorders]); settings->setShowRepaintCounter([preferences showRepaintCounter]); settings->setPluginAllowedRunTime([preferences pluginAllowedRunTime]); + settings->setWebAudioEnabled([preferences webAudioEnabled]); settings->setWebGLEnabled([preferences webGLEnabled]); settings->setAccelerated2dCanvasEnabled([preferences accelerated2dCanvasEnabled]); settings->setLoadDeferringEnabled(shouldEnableLoadDeferring()); @@ -1604,14 +1605,23 @@ static inline IMP getMethod(id o, SEL s) cache->didParseSourceFunc = getMethod(delegate, @selector(webView:didParseSource:baseLineNumber:fromURL:sourceId:forWebFrame:)); if (cache->didParseSourceFunc) cache->didParseSourceExpectsBaseLineNumber = YES; - else + else { + cache->didParseSourceExpectsBaseLineNumber = NO; cache->didParseSourceFunc = getMethod(delegate, @selector(webView:didParseSource:fromURL:sourceId:forWebFrame:)); + } cache->failedToParseSourceFunc = getMethod(delegate, @selector(webView:failedToParseSource:baseLineNumber:fromURL:withError:forWebFrame:)); cache->didEnterCallFrameFunc = getMethod(delegate, @selector(webView:didEnterCallFrame:sourceId:line:forWebFrame:)); cache->willExecuteStatementFunc = getMethod(delegate, @selector(webView:willExecuteStatement:sourceId:line:forWebFrame:)); cache->willLeaveCallFrameFunc = getMethod(delegate, @selector(webView:willLeaveCallFrame:sourceId:line:forWebFrame:)); - cache->exceptionWasRaisedFunc = getMethod(delegate, @selector(webView:exceptionWasRaised:sourceId:line:forWebFrame:)); + + cache->exceptionWasRaisedFunc = getMethod(delegate, @selector(webView:exceptionWasRaised:hasHandler:sourceId:line:forWebFrame:)); + if (cache->exceptionWasRaisedFunc) + cache->exceptionWasRaisedExpectsHasHandlerFlag = YES; + else { + cache->exceptionWasRaisedExpectsHasHandlerFlag = NO; + cache->exceptionWasRaisedFunc = getMethod(delegate, @selector(webView:exceptionWasRaised:sourceId:line:forWebFrame:)); + } } - (void)_cacheHistoryDelegateImplementations @@ -5947,7 +5957,7 @@ static inline uint64_t roundUpToPowerOf2(uint64_t num) { Frame* frame = [self _mainCoreFrame]; if (frame && frame->view()) - return frame->view()->syncCompositingStateRecursive(); + return frame->view()->syncCompositingStateIncludingSubframes(); return YES; } diff --git a/Source/WebKit/qt/Api/DerivedSources.pro b/Source/WebKit/qt/Api/DerivedSources.pro index 3109ffe..8084242 100644 --- a/Source/WebKit/qt/Api/DerivedSources.pro +++ b/Source/WebKit/qt/Api/DerivedSources.pro @@ -45,7 +45,7 @@ for(HEADER, WEBKIT_API_HEADERS) { # the package sources are relocatable. PATH_TO_HEADER = $$HEADER - CONFIG(standalone_package): PATH_TO_HEADER = ../../../Source/WebKit/qt/Api/$$basename(HEADER) + CONFIG(standalone_package): PATH_TO_HEADER = ../../WebKit/qt/Api/$$basename(HEADER) eval($${HEADER_TARGET}.target = $${DESTDIR}/$${HEADER_NAME}) eval($${HEADER_TARGET}.depends = $$HEADER) diff --git a/Source/WebKit/qt/Api/qwebframe.cpp b/Source/WebKit/qt/Api/qwebframe.cpp index 9c89a4c..0d502b3 100644 --- a/Source/WebKit/qt/Api/qwebframe.cpp +++ b/Source/WebKit/qt/Api/qwebframe.cpp @@ -1071,7 +1071,7 @@ void QWebFrame::setScrollBarValue(Qt::Orientation orientation, int value) value = 0; else if (value > scrollBarMaximum(orientation)) value = scrollBarMaximum(orientation); - sb->setValue(value, Scrollbar::NotFromScrollAnimator); + sb->scrollableArea()->scrollToOffsetWithoutAnimation(orientation == Qt::Horizontal ? HorizontalScrollbar : VerticalScrollbar, value); } } diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog index 06fb368..aec5b45 100644 --- a/Source/WebKit/qt/ChangeLog +++ b/Source/WebKit/qt/ChangeLog @@ -1,3 +1,70 @@ +2011-01-21 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Part 2 of "Cleanup Scrollbar/ScrollbarClient relationship" + https://bugs.webkit.org/show_bug.cgi?id=52779 + + Rename ScrollbarClient -> ScrollableArea. + + * Api/qwebframe.cpp: + (QWebFrame::setScrollBarValue): + +2011-01-20 Sam Weinig <sam@webkit.org> + + Fix build. + + * Api/qwebframe.cpp: + (QWebFrame::setScrollBarValue): + +2011-01-20 Sam Weinig <sam@webkit.org> + + Fix build. + + * Api/qwebframe.cpp: + (QWebFrame::setScrollBarValue): + +2011-01-20 Sam Weinig <sam@webkit.org> + + Reviewed by Dave Hyatt. + + Cleanup Scrollbar/ScrollbarClient relationship + https://bugs.webkit.org/show_bug.cgi?id=52779 + + * Api/qwebframe.cpp: + (QWebFrame::setScrollBarValue): + +2011-01-19 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Sam Weinig. + + GraphicsLayers in subframes can get sync'd multiple times + https://bugs.webkit.org/show_bug.cgi?id=52489 + + * WebCoreSupport/PageClientQt.cpp: + (WebCore::PageClientQWidget::syncLayers): syncCompositingStateRecursive() + was renamed to syncCompositingStateIncludingSubframes(). + +2011-01-19 Csaba Osztrogonác <ossy@webkit.org> + + Reviewed by Laszlo Gombos and Tor Arne Vestbø. + + [Qt] Remove unnecessary "../Source" from paths + after moving source files into Source is finished. + + * Api/DerivedSources.pro: + +2011-01-18 Robert Hogan <robert@webkit.org> + + Reviewed by Simon Hausmann. + + [Qt] http/tests/incremental/slow-utf8-text.pl fails + https://bugs.webkit.org/show_bug.cgi?id=44282 + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::responseMimeType): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + 2011-01-17 Alexey Proskuryakov <ap@apple.com> https://bugs.webkit.org/show_bug.cgi?id=52495 diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index ecd91eb..a7a495a 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -31,6 +31,7 @@ #include "ContextMenuController.h" #include "DeviceOrientation.h" #include "DeviceOrientationClientMockQt.h" +#include "DocumentLoader.h" #include "Editor.h" #include "EditorClientQt.h" #include "Element.h" @@ -885,6 +886,13 @@ QVariantList DumpRenderTreeSupportQt::nodesFromRect(const QWebElement& document, return res; } +QString DumpRenderTreeSupportQt::responseMimeType(QWebFrame* frame) +{ + WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); + WebCore::DocumentLoader* docLoader = coreFrame->loader()->documentLoader(); + return docLoader->responseMIMEType(); +} + // Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* frame) diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index 6917039..dd84e76 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -184,6 +184,7 @@ public: static QString viewportAsText(QWebPage*, const QSize&); static QVariantList nodesFromRect(const QWebElement& document, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping); + static QString responseMimeType(QWebFrame*); }; #endif diff --git a/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp index c3869c5..1821bec 100644 --- a/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp @@ -170,7 +170,7 @@ void PageClientQWidget::markForSync(bool scheduleSync) void PageClientQWidget::syncLayers(Timer<PageClientQWidget>*) { - QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateRecursive(); + QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateIncludingSubframes(); } #endif @@ -321,7 +321,7 @@ void PageClientQGraphicsWidget::createOrDeleteOverlay() void PageClientQGraphicsWidget::syncLayers() { if (shouldSync) { - QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateRecursive(); + QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateIncludingSubframes(); shouldSync = false; } } @@ -342,7 +342,7 @@ void PageClientQGraphicsWidget::setRootGraphicsLayer(QGraphicsObject* layer) if (rootGraphicsLayer) { rootGraphicsLayer.data()->setParentItem(0); view->scene()->removeItem(rootGraphicsLayer.data()); - QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateRecursive(); + QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateIncludingSubframes(); } rootGraphicsLayer = layer; diff --git a/Source/WebKit/win/COMEnumVariant.h b/Source/WebKit/win/COMEnumVariant.h index a93a3c2..6725107 100644 --- a/Source/WebKit/win/COMEnumVariant.h +++ b/Source/WebKit/win/COMEnumVariant.h @@ -29,12 +29,12 @@ #define NOMINMAX #include <unknwn.h> -#include <wtf/Noncopyable.h> #include "COMVariantSetter.h" template<typename ContainerType> -class COMEnumVariant : public IEnumVARIANT, public Noncopyable { +class COMEnumVariant : public IEnumVARIANT { + WTF_MAKE_NONCOPYABLE(COMEnumVariant); public: static COMEnumVariant* adopt(ContainerType&); static COMEnumVariant* createInstance(const ContainerType&); diff --git a/Source/WebKit/win/COMPropertyBag.h b/Source/WebKit/win/COMPropertyBag.h index 610c367..620458e 100644 --- a/Source/WebKit/win/COMPropertyBag.h +++ b/Source/WebKit/win/COMPropertyBag.h @@ -35,7 +35,8 @@ #include "COMVariantSetter.h"
template<typename ValueType, typename KeyType = typename WTF::String, typename HashType = typename WTF::StringHash>
-class COMPropertyBag : public IPropertyBag, public IPropertyBag2, Noncopyable {
+class COMPropertyBag : public IPropertyBag, public IPropertyBag2 {
+ WTF_MAKE_NONCOPYABLE(COMPropertyBag);
public:
typedef HashMap<KeyType, ValueType, HashType> HashMapType;
diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog index f26f0f2..6a3b53c 100644 --- a/Source/WebKit/win/ChangeLog +++ b/Source/WebKit/win/ChangeLog @@ -1,3 +1,152 @@ +2011-01-21 Chris Rogers <crogers@google.com> + + Reviewed by Darin Fisher. + + Add run-time enable support for the web audio API + https://bugs.webkit.org/show_bug.cgi?id=52741 + + * WebPreferenceKeysPrivate.h: + * WebView.cpp: + (WebView::notifyPreferencesChanged): + +2011-01-21 Sam Weinig <sam@webkit.org> + + Fix windows build. + + * WebScrollBar.h: + +2011-01-21 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Part 2 of "Cleanup Scrollbar/ScrollbarClient relationship" + https://bugs.webkit.org/show_bug.cgi?id=52779 + + Rename ScrollbarClient -> ScrollableArea. + + * WebScrollBar.cpp: + (WebScrollBar::scroll): + * WebScrollBar.h: + +2011-01-20 Adam Roben <aroben@apple.com> + + Update for CACFLayerTreeHost changes + + Fixes <http://webkit.org/b/52852> Flushing layer changes and rendering are intertwined in + CACFLayerTreeHost, but shouldn't be + + Reviewed by Simon Fraser. + + * WebView.cpp: + (WebView::paint): Changed to flush layer changes via CACFLayerTreeHost, which will call back + to our own flushing function if needed. + + * WebView.h: Removed shouldRender, which is no longer used or needed. + +2011-01-21 Adam Roben <aroben@apple.com> + + Update for WKCACFLayerRenderer -> CACFLayerTreeHost rename + + Also renamed WebView::m_layerRenderer to WebView::m_layerTreeHost to match. + + Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't + + Reviewed by Simon Fraser. + + * WebPreferences.cpp: + * WebView.cpp: + (WebView::setAcceleratedCompositing): Also made sure to remove our HWND from the layer tree + host before we get rid of the layer tree host itself. + * WebView.h: + +2011-01-21 Adam Roben <aroben@apple.com> + + Replace some "sync compositing state" terminology with "flush pending GraphicsLayer changes" + + This seems to be the direction in which our code is moving. I chose "GraphicsLayer" as + opposed to just "layer" because there are cases where we flush changes to CACFLayers that + don't have a corresponding GraphicsLayer. + + Fixes <http://webkit.org/b/52894> "Sync compositing state" terminology in + WKCACFLayerRenderer and friends is confusing + + Reviewed by Simon Fraser. + + * WebCoreSupport/WebChromeClient.cpp: + (WebChromeClient::scheduleCompositingLayerSync): Updated for WebView changes. + + * WebView.cpp: + (WebView::paint): Updated for rename. + (WebView::flushPendingGraphicsLayerChangesSoon): Renamed from scheduleCompositingLayerSync. + (WebView::notifySyncRequired): Updated for rename. + (WebView::flushPendingGraphicsLayerChanges): Renamed from syncCompositingState. + + * WebView.h: Did the renames. + +2011-01-20 Sam Weinig <sam@webkit.org> + + Reviewed by Dave Hyatt. + + Cleanup Scrollbar/ScrollbarClient relationship + https://bugs.webkit.org/show_bug.cgi?id=52779 + + * WebScrollBar.cpp: + (WebScrollBar::WebScrollBar): + (WebScrollBar::setValue): + (WebScrollBar::value): + (WebScrollBar::scroll): + (WebScrollBar::scrollPosition): + (WebScrollBar::setScrollOffset): + * WebScrollBar.h: + +2011-01-19 Adam Roben <aroben@apple.com> + + Update for WKCACFLayerRenderer changes + + Fixes <http://webkit.org/b/52749> WKCACFLayerRenderer should be + ref-counted + + Reviewed by Simon Fraser. + + * WebView.cpp: + (WebView::~WebView): Added some assertions to make sure we've gotten rid of our + compositing-related members. My biggest concern was making sure that m_layerRenderer was + gone, which would also mean we had nulled out its client pointer. + (WebView::setAcceleratedCompositing): Changed to call WKCACFLayerRenderer::setClient instead + of passing the client into create(), and to clear out the client before nulling out + m_layerRenderer. + + * WebView.h: Changed m_layerRenderer from an OwnPtr to a RefPtr. + +2011-01-19 Adam Roben <aroben@apple.com> + + Teach WebView::scrollBackingStore about compositing mode + + Test: + compositing/scroll-painted-composited-content.html + + Fixes <http://webkit.org/b/52720> REGRESSION (r75987): Assertion failure in + WebView::scrollBackingStore when scrolling page with composited content + + Reviewed by Anders Carlsson. + + * WebView.cpp: + (WebView::scrollBackingStore): Do something sensible (though naive) when in compositing + mode, rather than incorrectly asserting that this function is never called in that case. For + now we just repaint the entire scrolled region; someday hopefully we can avoid having to + repaint the areas that have just been moved. + +2011-01-19 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Sam Weinig. + + GraphicsLayers in subframes can get sync'd multiple times + https://bugs.webkit.org/show_bug.cgi?id=52489 + + * WebView.cpp: + (WebView::syncCompositingState): syncCompositingStateRecursive() + was renamed to syncCompositingStateIncludingSubframes(). + 2011-01-17 Adam Roben <aroben@apple.com> Update for WKCACFLayerRenderer changes diff --git a/Source/WebKit/win/FullscreenVideoController.h b/Source/WebKit/win/FullscreenVideoController.h index 6b56ab5..a65529e 100644 --- a/Source/WebKit/win/FullscreenVideoController.h +++ b/Source/WebKit/win/FullscreenVideoController.h @@ -102,7 +102,8 @@ private: int m_dragStartOffset; }; -class FullscreenVideoController : WebCore::MediaPlayerPrivateFullscreenClient, public Noncopyable { +class FullscreenVideoController : WebCore::MediaPlayerPrivateFullscreenClient { + WTF_MAKE_NONCOPYABLE(FullscreenVideoController); public: FullscreenVideoController(); virtual ~FullscreenVideoController(); diff --git a/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp index 6460b4a..f5cce4e 100644 --- a/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp @@ -826,7 +826,7 @@ void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graph void WebChromeClient::scheduleCompositingLayerSync() { - m_webView->scheduleCompositingLayerSync(); + m_webView->flushPendingGraphicsLayerChangesSoon(); } #endif diff --git a/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp b/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp index f4d9842..184df95 100644 --- a/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp +++ b/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp @@ -43,6 +43,7 @@ #include <WebCore/Page.h> #include <WebCore/Settings.h> #include <WebCore/StringTruncator.h> +#include <WebCore/TextRun.h> #include <WebCore/WebCoreTextRenderer.h> #pragma warning(pop) diff --git a/Source/WebKit/win/WebDatabaseManager.cpp b/Source/WebKit/win/WebDatabaseManager.cpp index bdcb549..e2b81e1 100644 --- a/Source/WebKit/win/WebDatabaseManager.cpp +++ b/Source/WebKit/win/WebDatabaseManager.cpp @@ -52,7 +52,8 @@ static inline bool isEqual(LPCWSTR s1, LPCWSTR s2) return !wcscmp(s1, s2); } -class DatabaseDetailsPropertyBag : public IPropertyBag, public Noncopyable { +class DatabaseDetailsPropertyBag : public IPropertyBag { + WTF_MAKE_NONCOPYABLE(DatabaseDetailsPropertyBag); public: static DatabaseDetailsPropertyBag* createInstance(const DatabaseDetails&); @@ -328,7 +329,8 @@ HRESULT STDMETHODCALLTYPE WebDatabaseManager::deleteDatabase( return S_OK; } -class DidModifyOriginData : public Noncopyable { +class DidModifyOriginData { + WTF_MAKE_NONCOPYABLE(DidModifyOriginData); public: static void dispatchToMainThread(WebDatabaseManager* databaseManager, SecurityOrigin* origin) { diff --git a/Source/WebKit/win/WebInspector.h b/Source/WebKit/win/WebInspector.h index 053a593..e2d2fcd 100644 --- a/Source/WebKit/win/WebInspector.h +++ b/Source/WebKit/win/WebInspector.h @@ -34,7 +34,8 @@ class WebView; -class WebInspector : public IWebInspector, public IWebInspectorPrivate, public Noncopyable { +class WebInspector : public IWebInspector, public IWebInspectorPrivate { + WTF_MAKE_NONCOPYABLE(WebInspector); public: static WebInspector* createInstance(WebView*); diff --git a/Source/WebKit/win/WebLocalizableStrings.cpp b/Source/WebKit/win/WebLocalizableStrings.cpp index da6b221..e9b99ad 100644 --- a/Source/WebKit/win/WebLocalizableStrings.cpp +++ b/Source/WebKit/win/WebLocalizableStrings.cpp @@ -72,7 +72,8 @@ static LocalizedStringMap frameworkLocStrings() return map; } -class LocalizedString : public Noncopyable { +class LocalizedString { + WTF_MAKE_NONCOPYABLE(LocalizedString); public: LocalizedString(CFStringRef string) : m_cfString(string) diff --git a/Source/WebKit/win/WebPreferenceKeysPrivate.h b/Source/WebKit/win/WebPreferenceKeysPrivate.h index 0b781d8..be0ebe5 100644 --- a/Source/WebKit/win/WebPreferenceKeysPrivate.h +++ b/Source/WebKit/win/WebPreferenceKeysPrivate.h @@ -67,6 +67,7 @@ #define WebKitCacheModelPreferenceKey "WebKitCacheModelPreferenceKey" #define WebKitLocalStorageDatabasePathPreferenceKey "WebKitLocalStorageDatabasePath" #define WebKitHyperlinkAuditingEnabledPreferenceKey "WebKitHyperlinkAuditingEnabled" +#define WebKitWebAudioEnabledPreferenceKey "WebKitWebAudioEnabled" // These are private both because callers should be using the cover methods and because the // cover methods themselves are private. diff --git a/Source/WebKit/win/WebPreferences.cpp b/Source/WebKit/win/WebPreferences.cpp index 5a2c19b..a962471 100644 --- a/Source/WebKit/win/WebPreferences.cpp +++ b/Source/WebKit/win/WebPreferences.cpp @@ -29,23 +29,22 @@ #include "WebPreferences.h" #include "COMPtr.h" +#include "WebLocalizableStrings.h" #include "WebNotificationCenter.h" #include "WebPreferenceKeysPrivate.h" -#include <wtf/text/StringHash.h> +#include <CoreFoundation/CoreFoundation.h> +#include <WebCore/CACFLayerTreeHost.h> #include <WebCore/FileSystem.h> #include <WebCore/Font.h> #include <WebCore/PlatformString.h> -#include <WebCore/WKCACFLayerRenderer.h> -#include "WebLocalizableStrings.h" - -#include <CoreFoundation/CoreFoundation.h> #include <limits> #include <shlobj.h> #include <tchar.h> #include <wtf/HashMap.h> #include <wtf/OwnArrayPtr.h> #include <wtf/text/CString.h> +#include <wtf/text/StringHash.h> #if PLATFORM(CG) #include <CoreGraphics/CoreGraphics.h> @@ -1446,7 +1445,7 @@ HRESULT WebPreferences::setAcceleratedCompositingEnabled(BOOL enabled) HRESULT WebPreferences::acceleratedCompositingEnabled(BOOL* enabled) { #if USE(ACCELERATED_COMPOSITING) - *enabled = WKCACFLayerRenderer::acceleratedCompositingAvailable() && boolValueForKey(CFSTR(WebKitAcceleratedCompositingEnabledPreferenceKey)); + *enabled = CACFLayerTreeHost::acceleratedCompositingAvailable() && boolValueForKey(CFSTR(WebKitAcceleratedCompositingEnabledPreferenceKey)); #else *enabled = FALSE; #endif diff --git a/Source/WebKit/win/WebScriptWorld.h b/Source/WebKit/win/WebScriptWorld.h index f088a72..01511de 100644 --- a/Source/WebKit/win/WebScriptWorld.h +++ b/Source/WebKit/win/WebScriptWorld.h @@ -31,7 +31,8 @@ namespace WebCore { class DOMWrapperWorld; } -class WebScriptWorld : public Noncopyable, public IWebScriptWorld { +class WebScriptWorld : public IWebScriptWorld { + WTF_MAKE_NONCOPYABLE(WebScriptWorld); public: static WebScriptWorld* standardWorld(); static COMPtr<WebScriptWorld> createInstance(); diff --git a/Source/WebKit/win/WebScrollBar.cpp b/Source/WebKit/win/WebScrollBar.cpp index 8613c1c..45bc8f3 100644 --- a/Source/WebKit/win/WebScrollBar.cpp +++ b/Source/WebKit/win/WebScrollBar.cpp @@ -42,6 +42,7 @@ using namespace WebCore; WebScrollBar::WebScrollBar() : m_refCount(0) , m_containingWindow(0) + , m_currentPosition(0) { gClassCount++; gClassNameCount.add("WebScrollBar"); @@ -143,7 +144,7 @@ HRESULT STDMETHODCALLTYPE WebScrollBar::setRect( HRESULT STDMETHODCALLTYPE WebScrollBar::setValue( /* [in] */ int value) { - m_scrollBar->setValue(value, Scrollbar::NotFromScrollAnimator); + m_currentPosition = value; return S_OK; } @@ -152,7 +153,7 @@ HRESULT STDMETHODCALLTYPE WebScrollBar::value( { if (!value) return E_POINTER; - *value = m_scrollBar->value(); + *value = m_currentPosition; return S_OK; } @@ -247,27 +248,25 @@ HRESULT STDMETHODCALLTYPE WebScrollBar::scroll( { ScrollDirection webCoreScrollDirection = (ScrollDirection) direction; ScrollGranularity webCoreGranularity = (ScrollGranularity) granularity; - m_scrollBar->scroll(webCoreScrollDirection, webCoreGranularity, multiplier); + ScrollableArea::scroll(webCoreScrollDirection, webCoreGranularity, multiplier); return S_OK; } -// ScrollbarClient ------------------------------------------------------- +// ScrollableArea ------------------------------------------------------- + int WebScrollBar::scrollSize(ScrollbarOrientation orientation) const { return (orientation == m_scrollBar->orientation()) ? (m_scrollBar->totalSize() - m_scrollBar->visibleSize()) : 0; } -void WebScrollBar::setScrollOffsetFromAnimation(const IntPoint& offset) +int WebScrollBar::scrollPosition(Scrollbar*) const { - m_scrollBar->setValue((m_scrollBar->orientation() == HorizontalScrollbar) ? offset.x() : offset.y(), Scrollbar::FromScrollAnimator); + return m_currentPosition; } -void WebScrollBar::valueChanged(Scrollbar* scrollBar) +void WebScrollBar::setScrollOffset(const IntPoint& offset) { - if (m_scrollBar != scrollBar) { - ASSERT(false); // shouldn't happen - return; - } + m_currentPosition = (m_scrollBar->orientation() == HorizontalScrollbar) ? offset.x() : offset.y(); m_delegate->valueChanged(this); } diff --git a/Source/WebKit/win/WebScrollBar.h b/Source/WebKit/win/WebScrollBar.h index 90f2491..ca44e8b 100644 --- a/Source/WebKit/win/WebScrollBar.h +++ b/Source/WebKit/win/WebScrollBar.h @@ -34,17 +34,14 @@ #pragma warning(push, 0) #include <WebCore/COMPtr.h> #include <WebCore/Scrollbar.h> -#include <WebCore/ScrollbarClient.h> +#include <WebCore/ScrollableArea.h> #pragma warning(pop) namespace WebCore { class Scrollbar; } -using namespace WebCore; - -class WebScrollBar : public IWebScrollBarPrivate, ScrollbarClient -{ +class WebScrollBar : public IWebScrollBarPrivate, WebCore::ScrollableArea { public: static WebScrollBar* createInstance(); protected: @@ -115,11 +112,11 @@ public: /* [in] */ float multiplier); protected: - // ScrollbarClient - virtual int scrollSize(ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const IntPoint&); - virtual void valueChanged(Scrollbar*); - virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); + // ScrollableArea + virtual int scrollSize(WebCore::ScrollbarOrientation) const; + virtual int scrollPosition(WebCore::Scrollbar*) const; + virtual void setScrollOffset(const WebCore::IntPoint&); + virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&); // FIXME: We should provide a way to set this value. virtual bool isActive() const { return true; } @@ -128,6 +125,7 @@ protected: ULONG m_refCount; HWND m_containingWindow; + int m_currentPosition; RefPtr<WebCore::Scrollbar> m_scrollBar; COMPtr<IWebScrollBarDelegatePrivate> m_delegate; }; diff --git a/Source/WebKit/win/WebSerializedJSValue.h b/Source/WebKit/win/WebSerializedJSValue.h index a2d6d56..6e3747d 100644 --- a/Source/WebKit/win/WebSerializedJSValue.h +++ b/Source/WebKit/win/WebSerializedJSValue.h @@ -34,7 +34,8 @@ namespace WebCore { class SerializedScriptValue; } -class WebSerializedJSValue : public Noncopyable, public IWebSerializedJSValue, public IWebSerializedJSValuePrivate { +class WebSerializedJSValue : public IWebSerializedJSValue, public IWebSerializedJSValuePrivate { + WTF_MAKE_NONCOPYABLE(WebSerializedJSValue); public: static COMPtr<WebSerializedJSValue> createInstance(); diff --git a/Source/WebKit/win/WebUserContentURLPattern.h b/Source/WebKit/win/WebUserContentURLPattern.h index e8f6b67..42854b4 100644 --- a/Source/WebKit/win/WebUserContentURLPattern.h +++ b/Source/WebKit/win/WebUserContentURLPattern.h @@ -32,7 +32,8 @@ namespace WebCore { class UserContentURLPattern; } -class WebUserContentURLPattern : public Noncopyable, public IWebUserContentURLPattern { +class WebUserContentURLPattern : public IWebUserContentURLPattern { + WTF_MAKE_NONCOPYABLE(WebUserContentURLPattern); public: static COMPtr<WebUserContentURLPattern> createInstance(); diff --git a/Source/WebKit/win/WebView.cpp b/Source/WebKit/win/WebView.cpp index ae91724..da88be4 100644 --- a/Source/WebKit/win/WebView.cpp +++ b/Source/WebKit/win/WebView.cpp @@ -387,6 +387,11 @@ WebView::~WebView() ASSERT(!m_preferences); ASSERT(!m_viewWindow); +#if USE(ACCELERATED_COMPOSITING) + ASSERT(!m_layerTreeHost); + ASSERT(!m_backingLayer); +#endif + WebViewCount--; gClassCount--; gClassNameCount.remove("WebView"); @@ -819,7 +824,12 @@ void WebView::addToDirtyRegion(HRGN newRegion) void WebView::scrollBackingStore(FrameView* frameView, int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect) { #if USE(ACCELERATED_COMPOSITING) - ASSERT(!isAcceleratedCompositing()); + if (isAcceleratedCompositing()) { + // FIXME: We should be doing something smarter here, like moving tiles around and painting + // any newly-exposed tiles. <http://webkit.org/b/52714> + m_backingLayer->setNeedsDisplayInRect(scrollViewRect); + return; + } #endif LOCAL_GDI_COUNTER(0, __FUNCTION__); @@ -873,8 +883,8 @@ void WebView::sizeChanged(const IntSize& newSize) coreFrame->view()->resize(newSize); #if USE(ACCELERATED_COMPOSITING) - if (m_layerRenderer) - m_layerRenderer->resize(); + if (m_layerTreeHost) + m_layerTreeHost->resize(); if (m_backingLayer) { m_backingLayer->setSize(newSize); m_backingLayer->setNeedsDisplay(); @@ -980,11 +990,11 @@ void WebView::paint(HDC dc, LPARAM options) #if USE(ACCELERATED_COMPOSITING) if (isAcceleratedCompositing()) { - syncCompositingState(); - // Syncing might have taken us out of compositing mode. + m_layerTreeHost->flushPendingLayerChangesNow(); + // Flushing might have taken us out of compositing mode. if (isAcceleratedCompositing()) { // FIXME: We need to paint into dc (if provided). <http://webkit.org/b/52578> - m_layerRenderer->paint(); + m_layerTreeHost->paint(); ::ValidateRect(m_viewWindow, 0); return; } @@ -4792,6 +4802,10 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification) return hr; settings->setShowRepaintCounter(enabled); +#if ENABLE(WEB_AUDIO) + settings->setWebAudioEnabled(true); +#endif // ENABLE(WEB_AUDIO) + #if ENABLE(3D_CANVAS) settings->setWebGLEnabled(true); #endif // ENABLE(3D_CANVAS) @@ -6262,26 +6276,26 @@ void WebView::setRootChildLayer(GraphicsLayer* layer) m_backingLayer->addChild(layer); } -void WebView::scheduleCompositingLayerSync() +void WebView::flushPendingGraphicsLayerChangesSoon() { - if (!m_layerRenderer) + if (!m_layerTreeHost) return; - m_layerRenderer->syncCompositingStateSoon(); + m_layerTreeHost->flushPendingGraphicsLayerChangesSoon(); } void WebView::setAcceleratedCompositing(bool accelerated) { - if (m_isAcceleratedCompositing == accelerated || !WKCACFLayerRenderer::acceleratedCompositingAvailable()) + if (m_isAcceleratedCompositing == accelerated || !CACFLayerTreeHost::acceleratedCompositingAvailable()) return; if (accelerated) { - m_layerRenderer = WKCACFLayerRenderer::create(this); - if (m_layerRenderer) { + m_layerTreeHost = CACFLayerTreeHost::create(); + if (m_layerTreeHost) { m_isAcceleratedCompositing = true; - // Create the root layer + m_layerTreeHost->setClient(this); ASSERT(m_viewWindow); - m_layerRenderer->setHostWindow(m_viewWindow); + m_layerTreeHost->setWindow(m_viewWindow); // FIXME: We could perhaps get better performance by never allowing this layer to // become tiled (or choosing a higher-than-normal tiling threshold). @@ -6294,7 +6308,7 @@ void WebView::setAcceleratedCompositing(bool accelerated) m_backingLayer->setSize(IntRect(clientRect).size()); m_backingLayer->setNeedsDisplay(); - m_layerRenderer->setRootChildLayer(PlatformCALayer::platformCALayer(m_backingLayer->platformLayer())); + m_layerTreeHost->setRootChildLayer(PlatformCALayer::platformCALayer(m_backingLayer->platformLayer())); // We aren't going to be using our backing store while we're in accelerated compositing // mode. But don't delete it immediately, in case we switch out of accelerated @@ -6302,7 +6316,10 @@ void WebView::setAcceleratedCompositing(bool accelerated) deleteBackingStoreSoon(); } } else { - m_layerRenderer = 0; + ASSERT(m_layerTreeHost); + m_layerTreeHost->setClient(0); + m_layerTreeHost->setWindow(0); + m_layerTreeHost = 0; m_backingLayer = 0; m_isAcceleratedCompositing = false; } @@ -6468,7 +6485,7 @@ void WebView::notifyAnimationStarted(const GraphicsLayer*, double) void WebView::notifySyncRequired(const GraphicsLayer*) { - scheduleCompositingLayerSync(); + flushPendingGraphicsLayerChangesSoon(); } void WebView::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const IntRect& inClip) @@ -6493,19 +6510,7 @@ bool WebView::showRepaintCounter() const return m_page->settings()->showRepaintCounter(); } -bool WebView::shouldRender() const -{ - Frame* coreFrame = core(m_mainFrame); - if (!coreFrame) - return true; - FrameView* frameView = coreFrame->view(); - if (!frameView) - return true; - - return !frameView->layoutPending(); -} - -void WebView::syncCompositingState() +void WebView::flushPendingGraphicsLayerChanges() { Frame* coreFrame = core(m_mainFrame); if (!coreFrame) @@ -6522,7 +6527,7 @@ void WebView::syncCompositingState() if (m_backingLayer) m_backingLayer->syncCompositingStateForThisLayerOnly(); - view->syncCompositingStateRecursive(); + view->syncCompositingStateIncludingSubframes(); } #endif diff --git a/Source/WebKit/win/WebView.h b/Source/WebKit/win/WebView.h index f775eaf..1a993c6 100644 --- a/Source/WebKit/win/WebView.h +++ b/Source/WebKit/win/WebView.h @@ -40,8 +40,8 @@ #include <wtf/RefPtr.h> #if USE(ACCELERATED_COMPOSITING) +#include <WebCore/CACFLayerTreeHost.h> #include <WebCore/PlatformCALayer.h> -#include <WebCore/WKCACFLayerRenderer.h> #endif class FullscreenVideoController; @@ -71,7 +71,7 @@ class WebView , WebCore::WindowMessageListener #if USE(ACCELERATED_COMPOSITING) , WebCore::GraphicsLayerClient - , WebCore::WKCACFLayerRendererClient + , WebCore::CACFLayerTreeHostClient #endif { public: @@ -905,7 +905,7 @@ public: void downloadURL(const WebCore::KURL&); #if USE(ACCELERATED_COMPOSITING) - void scheduleCompositingLayerSync(); + void flushPendingGraphicsLayerChangesSoon(); void setRootChildLayer(WebCore::GraphicsLayer*); #endif @@ -947,9 +947,8 @@ private: virtual bool showDebugBorders() const; virtual bool showRepaintCounter() const; - // WKCACFLayerRendererClient - virtual bool shouldRender() const; - virtual void syncCompositingState(); + // CACFLayerTreeHostClient + virtual void flushPendingGraphicsLayerChanges(); #endif protected: @@ -1056,7 +1055,7 @@ protected: bool isAcceleratedCompositing() const { return m_isAcceleratedCompositing; } void setAcceleratedCompositing(bool); - OwnPtr<WebCore::WKCACFLayerRenderer> m_layerRenderer; + RefPtr<WebCore::CACFLayerTreeHost> m_layerTreeHost; OwnPtr<WebCore::GraphicsLayer> m_backingLayer; bool m_isAcceleratedCompositing; #endif diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index f382e2e..e83c4ed 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,1045 @@ +2011-01-21 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Adam Roben. + + WebKit2: Need API to stop loading a WKFrame + https://bugs.webkit.org/show_bug.cgi?id=52925 + + * UIProcess/API/C/WKFrame.cpp: + (WKFrameStopLoading): Call through to WebFrameProxy::stopLoading. + * UIProcess/API/C/WKFrame.h: + * UIProcess/WebFrameProxy.cpp: + (WebKit::WebFrameProxy::stopLoading): Send a message to the WebProcess to stop loading the frame + with the passed in ID. + * UIProcess/WebFrameProxy.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::stopLoadingFrame): Call stopForUserCancel on the passed-in frame. + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: Add StopLoadingFrame. + +2011-01-21 Brady Eidson <beidson@apple.com> + + Reviewed by Adam Roben. + + <rdar://problem/8894125> and https://bugs.webkit.org/show_bug.cgi?id=52916 + Expose "suggested filename" for a resource based on its resource response. + + API pieces: + * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: + (WKBundleFrameCopySuggestedFilenameForResourceURL): + * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: + + Implementation: + * WebProcess/WebPage/WebFrame.cpp: + (WebKit::WebFrame::suggestedFilenameForResourceURL): See if the DocumentLoader has + a resource for this URL and, if so, return the response's suggested filename. + * WebProcess/WebPage/WebFrame.h: + +2011-01-21 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + DrawingAreaProxyImpl::paint should return the unpainted region + https://bugs.webkit.org/show_bug.cgi?id=52918 + + * UIProcess/API/mac/WKView.mm: + (-[WKView drawRect:]): + Add unpaintedRegion parameter. + + * UIProcess/BackingStore.h: + (WebKit::BackingStore::size): + Add a size getter. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::paint): + Initialize the unpainted region to the dirty region, then subtract the painted region. + +2011-01-21 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein and Maciej Stachowiak. + + Fix for <rdar://problem/8896057> + + Give the Web Process access to the PubSub agent. + + * WebProcess/com.apple.WebProcess.sb: + +2011-01-21 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Part 2 of "Cleanup Scrollbar/ScrollbarClient relationship" + https://bugs.webkit.org/show_bug.cgi?id=52779 + + Rename ScrollbarClient -> ScrollableArea. + + * UIProcess/win/WebPopupMenuProxyWin.cpp: + (WebKit::WebPopupMenuProxyWin::onMouseWheel): + (WebKit::WebPopupMenuProxyWin::scrollToRevealSelection): + * UIProcess/win/WebPopupMenuProxyWin.h: + +2011-01-21 Adam Roben <aroben@apple.com> + + Update for WKCACFLayerRenderer -> CACFLayerView rename + + Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't + + Reviewed by Simon Fraser. + + * WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp: Just removed all the unnecessary + #includes. + +2011-01-20 Darin Adler <darin@apple.com> + + Reviewed by Dan Bernstein. + + WebKit2: Implement showModalDialog + https://bugs.webkit.org/show_bug.cgi?id=52855 + + * Shared/WebPageCreationParameters.h: Added canRunModal. + + * UIProcess/API/C/WKPage.h: Added a runModal function pointer to + WKPageUIClient. Also removed a lot of redundant typedefs and added + a new one, WKPageCallback, for callbacks without arguments or return + values. + + * UIProcess/API/qt/qwkpage.cpp: + (QWKPage::QWKPage): Added a runModal function pointer of 0. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::creationParameters): Set canRunModal + based on return value of WebUIClient::canRunModal. + + * UIProcess/WebPageProxy.h: Added runModal. + Calls WebUIClient::runModal. + + * UIProcess/WebPageProxy.messages.in: Added RunModal message. + Also removed the periods from the phrases in the comments + as Maciej requested a while back. + + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::canRunModal): Added. Returns true or false + based on whether a runModal function was supplied in the + WKPageUIClient structure. + (WebKit::WebUIClient::runModal): Added. Calls the runModal + function from the WKPageUIClient structure. + * UIProcess/WebUIClient.h: Declared the above functions. + + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::canRunModal): Call through to WebPage. + (WebKit::WebChromeClient::runModal): Ditto. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::WebPage): Initialize m_canRunModal based on the + creation parameters. Initialize m_isRunningModal to false. + (WebKit::WebPage::close): Stop the nested run loop if we are running modal. + (WebKit::WebPage::runModal): Send a message to ask the UI process to run + modal and then start a nested run loop. It gets stopped when the page is closed. + * WebProcess/WebPage/WebPage.h: Defined the canRunModal function + and declared the runModal function. + +2011-01-20 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=52849 + Make window.print work with WebKit2 + + * UIProcess/API/qt/qwkpage.cpp: + (QWKPage::QWKPage): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::printFrame): + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::printFrame): + * UIProcess/WebUIClient.h: + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::print): + Just pass through deelagte call to a WebKit2 client. + + * UIProcess/API/C/WKPage.h: Also added "Callback" suffix to other printing related function + types. + +2011-01-20 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Keep track of the latest update timestamp in the backing store + https://bugs.webkit.org/show_bug.cgi?id=52848 + + * Shared/UpdateInfo.h: + (WebKit::UpdateInfo::UpdateInfo): + Initialize timestamp to 0. + + * UIProcess/BackingStore.cpp: + (WebKit::BackingStore::BackingStore): + Initialize m_latestUpdateTimestamp to 0. + + (WebKit::BackingStore::incorporateUpdate): + If the update is too old, discard it. Otherwise, create a bitmap + and pass it to platformIncorporateUpdate. Finally update the timestamp. + + * UIProcess/BackingStore.h: + Add m_latestUpdateTimestamp. + + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::platformIncorporateUpdate): + Update now that we are already given the shareable bitmap. + +2011-01-20 Beth Dakin <bdakin@apple.com> + + Reviewed by Geoffrey Garen. + + Fix for <rdar://problem/8890255> + + Allow WebKitSystemInterface to draw scrollbars + when appropriate. + * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + +2011-01-20 Sam Weinig <sam@webkit.org> + + Reviewed by Dave Hyatt. + + Cleanup Scrollbar/ScrollbarClient relationship + https://bugs.webkit.org/show_bug.cgi?id=52779 + + * UIProcess/win/WebPopupMenuProxyWin.cpp: + (WebKit::WebPopupMenuProxyWin::scrollPosition): + (WebKit::WebPopupMenuProxyWin::setScrollOffset): + (WebKit::WebPopupMenuProxyWin::scrollTo): + (WebKit::WebPopupMenuProxyWin::onMouseWheel): + (WebKit::WebPopupMenuProxyWin::scrollToRevealSelection): + * UIProcess/win/WebPopupMenuProxyWin.h: + (WebKit::WebPopupMenuProxyWin::verticalScrollbar): + +2011-01-20 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Add a timestamp to UpdateInfo + https://bugs.webkit.org/show_bug.cgi?id=52844 + + * Shared/UpdateInfo.cpp: + (WebKit::UpdateInfo::encode): + (WebKit::UpdateInfo::decode): + * Shared/UpdateInfo.h: + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::setSize): + (WebKit::DrawingAreaImpl::display): + +2011-01-20 Anders Carlsson <andersca@apple.com> + + Reviewed by Beth Dakin. + + Add Connection::waitForAndDispatchImmediately + https://bugs.webkit.org/show_bug.cgi?id=52841 + + * Platform/CoreIPC/Connection.h: + (CoreIPC::Connection::waitForAndDispatchImmediately): + +2011-01-20 Kevin Decker <kdecker@apple.com> + + Reviewed by Anders Carlsson. + + <rdar://problem/8880689> need a way to obtain the rendered rectangle for box elements + https://bugs.webkit.org/show_bug.cgi?id=52823 + + * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp: + (WKBundleNodeHandleGetRenderRect): Added new method that will return a rendered rectangle for box elements + * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h: Ditto. + * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp: Ditto. + (WebKit::InjectedBundleNodeHandle::renderRect): Ditto. + * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h: Ditto. + +2011-01-20 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com> + + Reviewed by Andreas Kling. + + Remove null ptr deref that happens when reattaching to + a new web process. + + Implement didRelaunchProcess that sets the drawing area size + after the drawing area is re-instantiated. + + [Qt][WK2] Null ptr deref in UI process after web process has crashed + https://bugs.webkit.org/show_bug.cgi?id=52796 + + * UIProcess/API/qt/qgraphicswkview.cpp: + (QGraphicsWKView::QGraphicsWKView): + * UIProcess/API/qt/qwkpage.cpp: + (QWKPagePrivate::QWKPagePrivate): + (QWKPagePrivate::init): + (QWKPagePrivate::createDrawingAreaProxy): + (QWKPagePrivate::didRelaunchProcess): Reset drawing area size after crash. + * UIProcess/API/qt/qwkpage_p.h: + +2011-01-20 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Adam Roben. + + WebKitTestRunner needs to support layoutTestController.evaluateScriptInIsolatedWorld + https://bugs.webkit.org/show_bug.cgi?id=42327 + + Added a new API call, WKBundleFrameForJavaScriptContext, that gets the WKBundleFrameRef + that corresponds to a JSContextRef (or null if none). + + * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: + (WKBundleFrameForJavaScriptContext): Simple wrapper, defers to a WebFrame + static method. + * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: + * WebProcess/WebPage/WebFrame.cpp: + (WebKit::WebFrame::frameForContext): Follow the maze of twisty pointers. + * WebProcess/WebPage/WebFrame.h: + +2011-01-20 Alejandro G. Castro <alex@igalia.com> + + Fix compilation error in GTK WebKit2. + + * Platform/CoreIPC/gtk/ConnectionGtk.cpp: + (CoreIPC::readBytesFromSocket): + (CoreIPC::writeBytesToSocket): + +2011-01-20 Zoltan Horvath <zoltan@webkit.org> + + Reviewed by Csaba Osztrogonác. + + Refactoring of the custom allocation framework + https://bugs.webkit.org/show_bug.cgi?id=49897 + + Inheriting from FastAllocBase can result in objects getting larger (bug #33896, #46589). + The modification replaces Noncopyable and FastAllocBase classes and these inherits with their + equivalent macro implementation at the necessary places. + +2011-01-19 Simon Fraser <simon.fraser@apple.com> + + Fix the WebKit2 build. + + * WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm: + (WebKit::LayerBackedDrawingArea::syncCompositingLayers): + +2011-01-19 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Darin Adler. + + WebKit2: Need API to get the parent frame of a frame + https://bugs.webkit.org/show_bug.cgi?id=52774 + + Add the API to get the parent frame of a frame. + + * UIProcess/API/C/WKFrame.cpp: + (WKFrameGetParentFrame): + * UIProcess/API/C/WKFrame.h: + +2011-01-19 Enrica Casucci <enrica@apple.com> + + Reviewed by Darin Adler. + + WebKit2: add support for drag and drop + https://bugs.webkit.org/show_bug.cgi?id=52343 + <rdar://problem/7660558> + + This patch contains the remaining work to support drag and drop on Mac. + I've added a PasteboardTypes class to encapsulate all the pasteboard formats + supported for drag and drop. + In this implementation we don't support the promised types, since I could not + find an efficient way to do this across processes. + The bulk of the patch consists in creating a shareable bitmap for the drag image, + pass its handle to the UI process and create a new NSImage from it to be given to + AppKit for dragging. + I've added the missing implementation of the methods in the drag client to hook + up the placement of the data in the pasteboard. + + * Shared/mac/PasteboardTypes.h: Added. + * Shared/mac/PasteboardTypes.mm: Added. + (WebKit::PasteboardTypes::forEditing): + (WebKit::PasteboardTypes::forURL): + (WebKit::PasteboardTypes::forImages): + (WebKit::PasteboardTypes::forImagesWithArchive): + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::setDragImage): Added. + * UIProcess/API/mac/WKView.mm: + (-[WKView _registerDraggedTypes]): Refactored to use the new PasteboardTypes class. + (-[WKView initWithFrame:contextRef:pageGroupRef:]): + (-[WKView _setMouseDownEvent:]): + (-[WKView _mouseHandler:]): + (-[WKView mouseDown:]): + (-[WKView mouseUp:]): + (-[WKView mouseDragged:]): + (-[WKView draggedImage:endedAt:operation:]): + (-[WKView draggingEntered:]): + (-[WKView _setDragImage:at:linkDrag:]): + * UIProcess/API/mac/WKViewInternal.h: + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::setDragImage): + (WebKit::WebPageProxy::dragEnded): + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * WebKit2.xcodeproj/project.pbxproj: + * WebProcess/WebCoreSupport/WebDragClient.cpp: + * WebProcess/WebCoreSupport/WebDragClient.h: + * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: Added. + (WebKit::fontFromNSFont): + (WebKit::WebDragClient::startDrag): Added implementation. + (WebKit::WebDragClient::createDragImageForLink): Ditto. + (WebKit::writeURL): Helper function. + (WebKit::writeImage): Helper function. + (WebKit::WebDragClient::declareAndWriteDragImage): Added implementation. + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::dragEnded): + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Put the deprecated Connection member functions next to eachother + https://bugs.webkit.org/show_bug.cgi?id=52767 + + * Platform/CoreIPC/Connection.h: + (CoreIPC::Connection::sendSync): + (CoreIPC::Connection::send): + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + When resizing, the web process should repaint the page + https://bugs.webkit.org/show_bug.cgi?id=52764 + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::didSetSize): + Incorporate the update. + + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + Return early if the update bounds rect is empty. This can happen if painting is + disabled and we get a DidSetSize message. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::setSize): + If painting is disabled, just send back an empty UpdateInfo struct. Otherwise, + paint and fill in the UpdateInfo struct. + + (WebKit::DrawingAreaImpl::display): + Assert that painting is not disabled. + +2011-01-19 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=52739 + Make it possible for a WebKit2 client to print headers and footers + + * UIProcess/API/C/WKPage.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::headerHeight): + (WebKit::WebPageProxy::footerHeight): + (WebKit::WebPageProxy::drawHeader): + (WebKit::WebPageProxy::drawFooter): + * UIProcess/WebPageProxy.h: + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::headerHeight): + (WebKit::WebUIClient::footerHeight): + (WebKit::WebUIClient::drawHeader): + (WebKit::WebUIClient::drawFooter): + * UIProcess/WebUIClient.h: + Pass UIClient calls through. + + * UIProcess/API/mac/WKView.mm: + (currentPrintOperationScale): A helper to extract scale factor from the current NSPrintOperation. + (-[WKView _adjustPrintingMarginsForHeaderAndFooter]): Copied from WebKit1. Change current + print info to account for header and footer height as provided by the client. + (-[WKView knowsPageRange:]): Call -[self _adjustPrintingMarginsForHeaderAndFooter]. + (-[WKView drawPageBorderWithSize:]): When AppKit asks to print page border, call the client + to do that. Code adapted form WebKit1. + + * UIProcess/API/qt/qwkpage: + (QWKPage::QWKPage): Added zeroes for new WKPageUIClient members to avoid breaking the build. + +2011-01-19 Jessie Berlin <jberlin@apple.com> + + Reviewed by Darin Adler. + + Crash in WebDatabaseManagerProxy::getDatabaseOrigins when called after the WebProcess has + died at least once + https://bugs.webkit.org/show_bug.cgi?id=52730 + + WebDatabaseManagerProxy::invalidate was setting m_webContext to 0, and invalidate gets + called in WebContext::processDidClose. However, m_webContext is only set in the + constructor, which is only called from the constructor of WebContext, so attempting to send + a message to any new WebProcess after the first one died was causing a null deref. + + This patch moves setting m_webcontext into clearContext and clearContext is only called in + the WebContext destructor. + + This patch also adds checks for a valid WebProcessProxy before attempting to send messages to + the WebProcessProxy so that if the WebProcess has died and has not been revived, it does not + attempt to dereference a null WebProcessProxy. + + * UIProcess/WebContext.cpp: + (WebKit::WebContext::~WebContext): + Call WebDatabaseManagerProxy::clearContext. + * UIProcess/WebContext.h: + (WebKit::WebContext::hasValidProcess): + Make this method public so that it can be called from WebDatabaseManagerProxy. + + * UIProcess/WebDatabaseManagerProxy.cpp: + (WebKit::WebDatabaseManagerProxy::getDatabasesByOrigin): + If there isn't a valid process, invalidate the callback and return early. + (WebKit::WebDatabaseManagerProxy::getDatabaseOrigins): + Ditto. + (WebKit::WebDatabaseManagerProxy::deleteDatabaseWithNameForOrigin): + If tehre isn't a valid process return early. + (WebKit::WebDatabaseManagerProxy::deleteDatabasesForOrigin): + Ditto. + (WebKit::WebDatabaseManagerProxy::deleteAllDatabases): + Ditto. + (WebKit::WebDatabaseManagerProxy::setQuotaForOrigin): + Ditto. + (WebKit::WebDatabaseManagerProxy::invalidate): + Move setting m_webContext to 0 from here ... + * UIProcess/WebDatabaseManagerProxy.h: + (WebKit::WebDatabaseManagerProxy::clearContext): + ... to here. + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Suspend/resume painting as the WKView visibility changes + https://bugs.webkit.org/show_bug.cgi?id=52738 + + * UIProcess/DrawingAreaProxy.h: + (WebKit::DrawingAreaProxy::visibilityDidChange): + Add new member function. It should really be pure virtual once setPageIsVisible + is removed. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::visibilityDidChange): + Send SuspendPainting/ResumePainting messages based on whether the view is visible or not. + + (WebKit::DrawingAreaProxyImpl::setPageIsVisible): + Make this a stub; it should really be removed. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::viewStateDidChange): + Call visibilityDidChange. + + * UIProcess/WebPageProxy.h: + (WebKit::WebPageProxy::isViewVisible): + Add new getter. + + * WebProcess/WebPage/DrawingArea.messages.in: + Add SuspendPainting and ResumePainting messages. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::DrawingAreaImpl): + Initialize m_isPaintingSuspended. + + (WebKit::DrawingAreaImpl::suspendPainting): + Set m_isPaintingSuspended to true and stop the display timer. + + (WebKit::DrawingAreaImpl::resumePainting): + Set m_isPaintingSuspended to false. + + (WebKit::DrawingAreaImpl::scheduleDisplay): + (WebKit::DrawingAreaImpl::display): + Bail if m_isPaintingSuspended is true. + +2011-01-19 Andreas Kling <kling@webkit.org> + + Reviewed by Simon Hausmann. + + [Qt][WK2] Implement formatLocalizedString() for Qt. + + * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: + (WebKit::formatLocalizedString): + +2011-01-19 Chris Marrin <cmarrin@apple.com> + + Reviewed by Simon Fraser. + + WK2 - Multiple crashes in PlatformCALayer::replaceSublayer + https://bugs.webkit.org/show_bug.cgi?id=52695 + + Added a hostingLayer as the parent of the existing drawingLayer. + The hostingLayer is now the root which is passed to the + remote context. It never changes except to track the size + of the window. The backingLayer is now a child of the + hostingLayer, which allow it to switch between tiled and + non-tiled. + + I also now give back accurate settings for debug borders and + repaint counters. + + * WebProcess/WebPage/LayerBackedDrawingArea.cpp: + (WebKit::LayerBackedDrawingArea::LayerBackedDrawingArea): + (WebKit::LayerBackedDrawingArea::setSize): + (WebKit::LayerBackedDrawingArea::showDebugBorders): + (WebKit::LayerBackedDrawingArea::showRepaintCounter): + * WebProcess/WebPage/LayerBackedDrawingArea.h: + * WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm: + (WebKit::LayerBackedDrawingArea::platformInit): + (WebKit::LayerBackedDrawingArea::attachCompositingContext): + (WebKit::LayerBackedDrawingArea::syncCompositingLayers): + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Send a new SetSize message if the size differs from the current size + https://bugs.webkit.org/show_bug.cgi?id=52728 + + * UIProcess/DrawingAreaProxy.h: + (WebKit::DrawingAreaProxy::didSetSize): + Add UpdateInfo parameter. + + * UIProcess/DrawingAreaProxy.messages.in: + Add UpdateInfo parameter to the DidSetSize message. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::didSetSize): + If the view size differs from the current size send another SetSize message. + + * UIProcess/DrawingAreaProxyImpl.h: + Add UpdateInfo parameter to didSetSize. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::setSize): + The DidSetSize message now takes an UpdateInfo parameter. + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Throttle sending of SetSize messages + https://bugs.webkit.org/show_bug.cgi?id=52727 + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::DrawingAreaProxyImpl): + Initialize m_isWaitingForDidSetSize to false. + + (WebKit::DrawingAreaProxyImpl::didSetSize): + Null out the backing store. + + (WebKit::DrawingAreaProxyImpl::sendSetSize): + If m_isWaitingForDidSetSize is true, do nothing. Otherwise, set m_isWaitingForDidSetSize + to true and send a SetSize message. + + * UIProcess/DrawingAreaProxyImpl.h: + Add m_isWaitingForDidSetSize. + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Pass WebPageCreationParameters to DrawingArea::create + https://bugs.webkit.org/show_bug.cgi?id=52726 + + * WebProcess/WebPage/DrawingArea.cpp: + (WebKit::DrawingArea::create): + * WebProcess/WebPage/DrawingArea.h: + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::create): + (WebKit::DrawingAreaImpl::DrawingAreaImpl): + * WebProcess/WebPage/DrawingAreaImpl.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::WebPage): + (WebKit::WebPage::changeAcceleratedCompositingMode): + +2011-01-19 Csaba Osztrogonác <ossy@webkit.org> + + Reviewed by Laszlo Gombos and Tor Arne Vestbø. + + [Qt] Remove unnecessary "../Source" from paths + after moving source files into Source is finished. + + * DerivedSources.pro: + * WebKit2.pro: + +2011-01-18 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Sam Weinig. + + WebKitTestRunner should track loading more like DumpRenderTree + https://bugs.webkit.org/show_bug.cgi?id=52692 + + Relax the message check in didSaveFrameToPageCache a bit more, since + layout tests were still hitting the old one. + + * UIProcess/WebPageProxy.cpp: + (WebKit::isDisconnectedFrame): + (WebKit::WebPageProxy::didSaveFrameToPageCache): + +2011-01-18 Brady Eidson <beidson@apple.com> + + Reviewed by Darin Adler. + + <rdar://problem/8860833> and https://bugs.webkit.org/show_bug.cgi?id=52599 + UIProcess crash in WebPageProxy::reattachToWebProcess when web process crashes with a new tab/window. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::reattachToWebProcessWithItem): Null check item *both* places it is used. + +2011-01-18 Brady Eidson <beidson@apple.com> + + Reviewed by Maciej Stachowiak. + + <rdar://problem/8752200> and https://bugs.webkit.org/show_bug.cgi?id=52664 + Need WebKit2 API to asynchronously get the resource data for a URL + + Rename WKFrameGetMainResourceDataFunction to WKFrameGetResourceDataFunction, and add + new API to get a resource by URL: + * UIProcess/API/C/WKFrame.cpp: + (WKFrameGetMainResourceData): + (WKFrameGetResourceData): + (callGetResourceDataBlockAndDispose): + (WKFrameGetMainResourceData_b): + (WKFrameGetResourceData_b): + * UIProcess/API/C/WKFrame.h: + + Implement the new API in the UIProcess side: + * UIProcess/WebFrameProxy.cpp: + (WebKit::WebFrameProxy::getResourceData): + * UIProcess/WebFrameProxy.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::getResourceDataFromFrame): + * UIProcess/WebPageProxy.h: + + Have the WebProcess get the data and call back to the UIProcess: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::getResourceDataFromFrame): + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Make PageClientImpl::scrollView do hardware blitting + https://bugs.webkit.org/show_bug.cgi?id=52689 + + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::scrollView): + Clip the scroll rect and scroll the view. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + Scroll before painting. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Artifacts when scrolling with new drawing area + https://bugs.webkit.org/show_bug.cgi?id=52682 + + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::scroll): + When scrolling, we want the intersection of the scroll rect and clip rect. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Use a CGLayer for the backing store when possible + https://bugs.webkit.org/show_bug.cgi?id=52679 + + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::paint): + If there is a layer, paint it into the given context. + + (WebKit::BackingStore::backingStoreContext): + If we can get the containing window graphics context, use it to create a + CGLayer that we'll use for the backing store. + + (WebKit::BackingStore::scroll): + Paint the layer into itself. + + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::containingWindowGraphicsContext): + Call the page client. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Pass the web page proxy to BackingStore::create + https://bugs.webkit.org/show_bug.cgi?id=52673 + + * UIProcess/BackingStore.cpp: + (WebKit::BackingStore::create): + Add WebPageProxy parameter. + + (WebKit::BackingStore::BackingStore): + Add WebPageProxy parameter. + + * UIProcess/BackingStore.h: + Add WebPageProxy member variable. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + Pass the web page proxy when creating the backing store. + + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::backingStoreContext): + Set the default blend mode. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Factor code to create the backing store bitmap context out into a new function + https://bugs.webkit.org/show_bug.cgi?id=52670 + + * UIProcess/BackingStore.h: + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::backingStoreContext): + Create the backing store context. + + (WebKit::BackingStore::incorporateUpdate): + Call backingStoreContext. + + (WebKit::BackingStore::scroll): + Assert that the context is not null. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Add PageClientImpl::containingWindowGraphicsContext + https://bugs.webkit.org/show_bug.cgi?id=52666 + + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::containingWindowGraphicsContext): + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.h: + +2011-01-18 Damian Kaleta <dkaleta@apple.com> + + Reviewed by Sam Weinig. + + WK2 methods WKPageScaleWebView and WKPageGetViewScaleFactor need to have consistent names + https://bugs.webkit.org/show_bug.cgi?id=52647 + + * UIProcess/API/C/WKPage.cpp: + (WKPageSetScaleFactor): + (WKPageGetScaleFactor): + * UIProcess/API/C/WKPage.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Ask the web page proxy to scroll the view when needed + https://bugs.webkit.org/show_bug.cgi?id=52665 + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::scrollView): + * UIProcess/WebPageProxy.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Fix build. + + * UIProcess/win/WebView.cpp: + (WebKit::WebView::scrollView): + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Add PageClient::scrollView + https://bugs.webkit.org/show_bug.cgi?id=52663 + + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::scrollView): + * UIProcess/API/qt/qwkpage.cpp: + (QWKPagePrivate::scrollView): + * UIProcess/API/qt/qwkpage_p.h: + * UIProcess/PageClient.h: + * UIProcess/win/WebView.cpp: + (WebKit::PageClientImpl::scrollView): + * UIProcess/win/WebView.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Rename scrollDelta to scrollOffset everywhere. + + * Shared/UpdateInfo.cpp: + (WebKit::UpdateInfo::encode): + (WebKit::UpdateInfo::decode): + * Shared/UpdateInfo.h: + * UIProcess/BackingStore.h: + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::incorporateUpdate): + (WebKit::BackingStore::scroll): + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::scroll): + (WebKit::WebChromeClient::delegatedScrollRequested): + * WebProcess/WebCoreSupport/WebChromeClient.h: + * WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp: + (WebKit::ChunkedUpdateDrawingArea::scroll): + * WebProcess/WebPage/ChunkedUpdateDrawingArea.h: + * WebProcess/WebPage/DrawingArea.h: + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::scroll): + (WebKit::DrawingAreaImpl::display): + * WebProcess/WebPage/DrawingAreaImpl.h: + * WebProcess/WebPage/LayerBackedDrawingArea.cpp: + (WebKit::LayerBackedDrawingArea::scroll): + * WebProcess/WebPage/LayerBackedDrawingArea.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Get and paint each individual rect in -[WKView drawRect:] + https://bugs.webkit.org/show_bug.cgi?id=52660 + + * UIProcess/API/mac/WKView.mm: + (-[WKView drawRect:]): + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Assertion when loading two URLs in quick succession + https://bugs.webkit.org/show_bug.cgi?id=52649 + <rdar://problem/8764645> + + If beginLoad is called twice without didStartProvisionalLoad being called in between, + m_pendingProvisionalSandboxExtension would be non-null and an assert would fire. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::SandboxExtensionTracker::beginLoad): + Instead of asserting that m_pendingProvisionalSandboxExtension is null, invalidate it + if it is not null, since that's valid. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Implement NPN_PopUpContextMenu + https://bugs.webkit.org/show_bug.cgi?id=52646 + <rdar://problem/8735616> + + * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp: + (WebKit::NPN_PopUpContextMenu): + Call NetscapePlugin::popUpContextMenu. + + * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: + (WebKit::NetscapePlugin::NetscapePlugin): + Initialize m_currentMouseEvent. + + * WebProcess/Plugins/Netscape/NetscapePlugin.h: + Add m_currentMouseEvent. + + * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: + (WebKit::NetscapePlugin::popUpContextMenu): + Convert the coordinates from the current mouse event to screen coordinates and call + WKPopupContextMenu. + + (WebKit::NetscapePlugin::platformHandleMouseEvent): + Update m_currentMouseEvent. + +2011-01-18 Jessie Berlin <jberlin@apple.com> + + Reviewed by Darin Adler. + + WebKit2: Do not assert that the provisional and committed URLs cannot be empty/null + https://bugs.webkit.org/show_bug.cgi?id=52641 + + * UIProcess/WebFrameProxy.cpp: + (WebKit::WebFrameProxy::didStartProvisionalLoad): + (WebKit::WebFrameProxy::didCommitLoad): + (WebKit::WebFrameProxy::didFinishLoad): + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + ASSERT in plug-in code when going to youtube + https://bugs.webkit.org/show_bug.cgi?id=52638 + + * PluginProcess/PluginControllerProxy.cpp: + (WebKit::PluginControllerProxy::paintEntirePlugin): + Don't try to paint the plug-in if the plug-in frame is empty. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Plug-in hosting WebProcess instances appear in Activity Monitor as WebProcess + https://bugs.webkit.org/show_bug.cgi?id=52635 + <rdar://problem/8731337> + + * PluginProcess/PluginProcess.cpp: + (WebKit::PluginProcess::initialize): + Call platformInitialize. + + * PluginProcess/PluginProcess.h: + Add platformInitialize. + + * PluginProcess/mac/PluginProcessMac.mm: + (WebKit::PluginProcess::platformInitialize): + Set the compositing render server port and the visible application name. + + * Shared/Plugins/PluginProcessCreationParameters.cpp: + (WebKit::PluginProcessCreationParameters::encode): + (WebKit::PluginProcessCreationParameters::decode): + Encode/decode the parent process name. + + * Shared/Plugins/PluginProcessCreationParameters.h: + Add parentProcessName. + + * Shared/WebProcessCreationParameters.cpp: + (WebKit::WebProcessCreationParameters::encode): + (WebKit::WebProcessCreationParameters::decode): + Encode/decode the parent process name. + + * Shared/WebProcessCreationParameters.h: + Add parentProcessName. + + * UIProcess/Launcher/mac/ProcessLauncherMac.mm: + (WebKit::ProcessLauncher::launchProcess): + Don't pass the parent process name here. + + * UIProcess/Plugins/mac/PluginProcessProxyMac.mm: + (WebKit::PluginProcessProxy::platformInitializePluginProcess): + Set the visible name. + + * UIProcess/mac/WebContextMac.mm: + (WebKit::WebContext::platformInitializeWebProcess): + Pass along the parent process name. + + * WebProcess/mac/WebProcessMac.mm: + (WebKit::WebProcess::platformInitializeWebProcess): + Set the visible name. + + * WebProcess/mac/WebProcessMainMac.mm: + (WebKit::WebProcessMain): + Don't set the visible name here. It's done in platformInitializeWebProcess. + +2011-01-18 Balazs Kelemen <kbalazs@webkit.org> + + Reviewed by Csaba Osztrogonác. + + [Qt][WK2] Not implemented warnings should not break layout tests + https://bugs.webkit.org/show_bug.cgi?id=52616 + + * WebKit2Prefix.h: Define DISABLE_NOT_IMPLEMENTED_WARNINGS on Qt. + 2011-01-17 Jon Honeycutt <jhoneycutt@apple.com> Windows build fix. Unreviewed. diff --git a/Source/WebKit2/DerivedSources.pro b/Source/WebKit2/DerivedSources.pro index 4f6c7d9..4164203 100644 --- a/Source/WebKit2/DerivedSources.pro +++ b/Source/WebKit2/DerivedSources.pro @@ -5,10 +5,10 @@ CONFIG -= debug_and_release CONFIG(standalone_package) { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = $$PWD/generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../WebCore/generated } else { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../WebCore/generated } WEBCORE_GENERATED_HEADERS_FOR_WEBKIT2 += \ diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.h b/Source/WebKit2/Platform/CoreIPC/Connection.h index b7e5b0f..1b009cf 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.h +++ b/Source/WebKit2/Platform/CoreIPC/Connection.h @@ -115,23 +115,22 @@ public: void invalidate(); void markCurrentlyDispatchedMessageAsInvalid(); - // FIXME: This variant of send is deprecated, all clients should move to the overload that takes a message. - template<typename E, typename T> bool send(E messageID, uint64_t destinationID, const T& arguments); - - template<typename T> bool send(const T& message, uint64_t destinationID); - static const unsigned long long NoTimeout = 10000000000ULL; - // FIXME: This variant of sendSync is deprecated, all clients should move to the overload that takes a message. - template<typename E, typename T, typename U> bool sendSync(E messageID, uint64_t destinationID, const T& arguments, const U& reply, double timeout = NoTimeout); + template<typename T> bool send(const T& message, uint64_t destinationID); template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = NoTimeout); - - template<typename E> PassOwnPtr<ArgumentDecoder> waitFor(E messageID, uint64_t destinationID, double timeout); + template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, double timeout); PassOwnPtr<ArgumentEncoder> createSyncMessageArgumentEncoder(uint64_t destinationID, uint64_t& syncRequestID); bool sendMessage(MessageID, PassOwnPtr<ArgumentEncoder>); bool sendSyncReply(PassOwnPtr<ArgumentEncoder>); + // FIXME: These variants of senc, sendSync and waitFor are all deprecated. + // All clients should move to the overloads that take a message type. + template<typename E, typename T> bool send(E messageID, uint64_t destinationID, const T& arguments); + template<typename E, typename T, typename U> bool sendSync(E messageID, uint64_t destinationID, const T& arguments, const U& reply, double timeout = NoTimeout); + template<typename E> PassOwnPtr<ArgumentDecoder> waitFor(E messageID, uint64_t destinationID, double timeout); + private: template<typename T> class Message { public: @@ -300,15 +299,6 @@ private: #endif }; -template<typename E, typename T> -bool Connection::send(E messageID, uint64_t destinationID, const T& arguments) -{ - OwnPtr<ArgumentEncoder> argumentEncoder = ArgumentEncoder::create(destinationID); - argumentEncoder->encode(arguments); - - return sendMessage(MessageID(messageID), argumentEncoder.release()); -} - template<typename T> bool Connection::send(const T& message, uint64_t destinationID) { OwnPtr<ArgumentEncoder> argumentEncoder = ArgumentEncoder::create(destinationID); @@ -317,6 +307,36 @@ template<typename T> bool Connection::send(const T& message, uint64_t destinatio return sendMessage(MessageID(T::messageID), argumentEncoder.release()); } +template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout) +{ + uint64_t syncRequestID = 0; + OwnPtr<ArgumentEncoder> argumentEncoder = createSyncMessageArgumentEncoder(destinationID, syncRequestID); + + // Encode the rest of the input arguments. + argumentEncoder->encode(message); + + // Now send the message and wait for a reply. + OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID, MessageID::SyncMessage), syncRequestID, argumentEncoder.release(), timeout); + if (!replyDecoder) + return false; + + // Decode the reply. + return replyDecoder->decode(const_cast<typename T::Reply&>(reply)); +} + +template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, double timeout) +{ + OwnPtr<ArgumentDecoder> decoder = waitForMessage(MessageID(T::messageID), destinationID, timeout); + if (!decoder) + return false; + + ASSERT(decoder->destinationID() == destinationID); + m_client->didReceiveMessage(this, MessageID(T::messageID), decoder.get()); + return true; +} + +// These three member functions are all deprecated. + template<typename E, typename T, typename U> inline bool Connection::sendSync(E messageID, uint64_t destinationID, const T& arguments, const U& reply, double timeout) { @@ -335,21 +355,13 @@ inline bool Connection::sendSync(E messageID, uint64_t destinationID, const T& a return replyDecoder->decode(const_cast<U&>(reply)); } -template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout) +template<typename E, typename T> +bool Connection::send(E messageID, uint64_t destinationID, const T& arguments) { - uint64_t syncRequestID = 0; - OwnPtr<ArgumentEncoder> argumentEncoder = createSyncMessageArgumentEncoder(destinationID, syncRequestID); - - // Encode the rest of the input arguments. - argumentEncoder->encode(message); - - // Now send the message and wait for a reply. - OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID, MessageID::SyncMessage), syncRequestID, argumentEncoder.release(), timeout); - if (!replyDecoder) - return false; + OwnPtr<ArgumentEncoder> argumentEncoder = ArgumentEncoder::create(destinationID); + argumentEncoder->encode(arguments); - // Decode the reply. - return replyDecoder->decode(const_cast<typename T::Reply&>(reply)); + return sendMessage(MessageID(messageID), argumentEncoder.release()); } template<typename E> inline PassOwnPtr<ArgumentDecoder> Connection::waitFor(E messageID, uint64_t destinationID, double timeout) diff --git a/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp b/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp index 65b1254..d561110 100644 --- a/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp +++ b/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp @@ -41,7 +41,7 @@ static const size_t initialMessageBufferSize = 4096; static int readBytesFromSocket(int fileDescriptor, uint8_t* ptr, size_t length) { ASSERT(fileDescriptor > 0); - ASSERT(buffer); + ASSERT(ptr); ASSERT(length > 0); ssize_t numberOfBytesRead = 0; @@ -69,7 +69,7 @@ static int readBytesFromSocket(int fileDescriptor, uint8_t* ptr, size_t length) static bool writeBytesToSocket(int fileDescriptor, uint8_t* ptr, size_t length) { ASSERT(fileDescriptor > 0); - ASSERT(buffer); + ASSERT(ptr); ASSERT(length > 0); ssize_t numberOfBytesWritten = 0; diff --git a/Source/WebKit2/Platform/Module.h b/Source/WebKit2/Platform/Module.h index 0825bf6..ec7523c 100644 --- a/Source/WebKit2/Platform/Module.h +++ b/Source/WebKit2/Platform/Module.h @@ -39,7 +39,8 @@ namespace WebKit { -class Module : public Noncopyable { +class Module { + WTF_MAKE_NONCOPYABLE(Module); public: Module(const String& path); ~Module(); diff --git a/Source/WebKit2/Platform/SharedMemory.h b/Source/WebKit2/Platform/SharedMemory.h index 05dc0dd..9854132 100644 --- a/Source/WebKit2/Platform/SharedMemory.h +++ b/Source/WebKit2/Platform/SharedMemory.h @@ -52,7 +52,8 @@ public: ReadWrite }; - class Handle : Noncopyable { + class Handle { + WTF_MAKE_NONCOPYABLE(Handle); public: Handle(); ~Handle(); diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp index 5eb8dd4..42e9e6d 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp @@ -390,6 +390,9 @@ void PluginControllerProxy::handleKeyboardEvent(const WebKeyboardEvent& keyboard void PluginControllerProxy::paintEntirePlugin() { + if (m_frameRect.isEmpty()) + return; + m_dirtyRect = m_frameRect; paint(); } diff --git a/Source/WebKit2/PluginProcess/PluginProcess.cpp b/Source/WebKit2/PluginProcess/PluginProcess.cpp index 6c19c21..6124f9a 100644 --- a/Source/WebKit2/PluginProcess/PluginProcess.cpp +++ b/Source/WebKit2/PluginProcess/PluginProcess.cpp @@ -115,9 +115,7 @@ void PluginProcess::initialize(const PluginProcessCreationParameters& parameters m_pluginPath = parameters.pluginPath; -#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) - m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); -#endif + platformInitialize(parameters); } void PluginProcess::createWebProcessConnection() diff --git a/Source/WebKit2/PluginProcess/PluginProcess.h b/Source/WebKit2/PluginProcess/PluginProcess.h index e60d52d..6c221e7 100644 --- a/Source/WebKit2/PluginProcess/PluginProcess.h +++ b/Source/WebKit2/PluginProcess/PluginProcess.h @@ -40,6 +40,7 @@ class WebProcessConnection; struct PluginProcessCreationParameters; class PluginProcess : ChildProcess { + WTF_MAKE_NONCOPYABLE(PluginProcess); public: static PluginProcess& shared(); @@ -72,6 +73,8 @@ private: void shutdownTimerFired(); + void platformInitialize(const PluginProcessCreationParameters&); + // The connection to the UI process. RefPtr<CoreIPC::Connection> m_connection; diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm index ccf444c..3919c8b 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm @@ -24,11 +24,16 @@ */ #if ENABLE(PLUGIN_PROCESS) + +// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized +#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str] #include "PluginProcess.h" #include "NetscapePlugin.h" #include "PluginProcessShim.h" +#include "PluginProcessCreationParameters.h" +#include <WebKitSystemInterface.h> #include <dlfcn.h> namespace WebKit { @@ -84,6 +89,19 @@ void PluginProcess::initializeShim() initFunc(callbacks); } +void PluginProcess::platformInitialize(const PluginProcessCreationParameters& parameters) +{ + m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); + + NSString *applicationName = [NSString stringWithFormat:UI_STRING("%@ (%@ Internet plug-in)", + "visible name of the plug-in host process. The first argument is the plug-in name " + "and the second argument is the application name."), + [[(NSString *)parameters.pluginPath lastPathComponent] stringByDeletingPathExtension], + (NSString *)parameters.parentProcessName]; + + WKSetVisibleApplicationName((CFStringRef)applicationName); +} + } // namespace WebKit #endif // ENABLE(PLUGIN_PROCESS) diff --git a/Source/WebKit2/Shared/ChildProcess.h b/Source/WebKit2/Shared/ChildProcess.h index 78fe1f4..8c5e8e3 100644 --- a/Source/WebKit2/Shared/ChildProcess.h +++ b/Source/WebKit2/Shared/ChildProcess.h @@ -27,13 +27,11 @@ #define ChildProcess_h #include "Connection.h" -#include <wtf/Noncopyable.h> namespace WebKit { class ChildProcess : protected CoreIPC::Connection::Client { WTF_MAKE_NONCOPYABLE(ChildProcess); - protected: ChildProcess(); ~ChildProcess(); diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp index 90bbf07..c95a825 100644 --- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp @@ -40,6 +40,7 @@ void PluginProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) encoder->encode(pluginPath); #if PLATFORM(MAC) + encoder->encode(parentProcessName); encoder->encode(acceleratedCompositingPort); #endif } @@ -50,6 +51,8 @@ bool PluginProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, return false; #if PLATFORM(MAC) + if (!decoder->decode(result.parentProcessName)) + return false; if (!decoder->decode(result.acceleratedCompositingPort)) return false; #endif diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h index 1aeef01..62cf4bb 100644 --- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h +++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h @@ -50,6 +50,7 @@ struct PluginProcessCreationParameters { String pluginPath; #if PLATFORM(MAC) + String parentProcessName; CoreIPC::MachPort acceleratedCompositingPort; #endif }; diff --git a/Source/WebKit2/Shared/UpdateInfo.cpp b/Source/WebKit2/Shared/UpdateInfo.cpp index 1b504ed..182f75b 100644 --- a/Source/WebKit2/Shared/UpdateInfo.cpp +++ b/Source/WebKit2/Shared/UpdateInfo.cpp @@ -31,9 +31,10 @@ namespace WebKit { void UpdateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const { + encoder->encode(timestamp); encoder->encode(viewSize); encoder->encode(scrollRect); - encoder->encode(scrollDelta); + encoder->encode(scrollOffset); encoder->encode(updateRectBounds); encoder->encode(updateRects); encoder->encode(bitmapHandle); @@ -41,11 +42,13 @@ void UpdateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const bool UpdateInfo::decode(CoreIPC::ArgumentDecoder* decoder, UpdateInfo& result) { + if (!decoder->decode(result.timestamp)) + return false; if (!decoder->decode(result.viewSize)) return false; if (!decoder->decode(result.scrollRect)) return false; - if (!decoder->decode(result.scrollDelta)) + if (!decoder->decode(result.scrollOffset)) return false; if (!decoder->decode(result.updateRectBounds)) return false; diff --git a/Source/WebKit2/Shared/UpdateInfo.h b/Source/WebKit2/Shared/UpdateInfo.h index 850911c..2ceb164 100644 --- a/Source/WebKit2/Shared/UpdateInfo.h +++ b/Source/WebKit2/Shared/UpdateInfo.h @@ -41,17 +41,20 @@ class UpdateInfo { WTF_MAKE_NONCOPYABLE(UpdateInfo); public: - UpdateInfo() { } + UpdateInfo() : timestamp(0) { } void encode(CoreIPC::ArgumentEncoder*) const; static bool decode(CoreIPC::ArgumentDecoder*, UpdateInfo&); + // The timestamp of this update. + double timestamp; + // The size of the web view. WebCore::IntSize viewSize; // The rect and delta to be scrolled. WebCore::IntRect scrollRect; - WebCore::IntSize scrollDelta; + WebCore::IntSize scrollOffset; // The bounds of the update rects. WebCore::IntRect updateRectBounds; diff --git a/Source/WebKit2/Shared/WebMemorySampler.h b/Source/WebKit2/Shared/WebMemorySampler.h index 93254d9..c50d3bf 100644 --- a/Source/WebKit2/Shared/WebMemorySampler.h +++ b/Source/WebKit2/Shared/WebMemorySampler.h @@ -69,8 +69,8 @@ struct WebMemoryStatistics Vector<size_t> values; }; -class WebMemorySampler : public Noncopyable { - +class WebMemorySampler { + WTF_MAKE_NONCOPYABLE(WebMemorySampler); public: static WebMemorySampler* shared(); void start(const double interval=0); diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.h b/Source/WebKit2/Shared/WebPageCreationParameters.h index e698ce7..8c76f68 100644 --- a/Source/WebKit2/Shared/WebPageCreationParameters.h +++ b/Source/WebKit2/Shared/WebPageCreationParameters.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -66,9 +66,12 @@ struct WebPageCreationParameters { SessionState sessionState; uint64_t highestUsedBackForwardItemID; + bool canRunModal; + #if PLATFORM(MAC) bool isSmartInsertDeleteEnabled; #endif + #if PLATFORM(WIN) HWND nativeWindow; #endif diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp index ceae6c1..77e3a82 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp @@ -56,6 +56,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con encoder->encode(languageCode); encoder->encode(textCheckerState); #if PLATFORM(MAC) + encoder->encode(parentProcessName); encoder->encode(presenterApplicationPid); encoder->encode(nsURLCachePath); encoder->encode(nsURLCacheMemoryCapacity); @@ -95,6 +96,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web return false; #if PLATFORM(MAC) + if (!decoder->decode(parameters.parentProcessName)) + return false; if (!decoder->decode(parameters.presenterApplicationPid)) return false; if (!decoder->decode(parameters.nsURLCachePath)) diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.h b/Source/WebKit2/Shared/WebProcessCreationParameters.h index fe582b3..50d8a90 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.h +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.h @@ -73,6 +73,8 @@ struct WebProcessCreationParameters { TextCheckerState textCheckerState; #if PLATFORM(MAC) + String parentProcessName; + pid_t presenterApplicationPid; CString nsURLCachePath; diff --git a/Source/WebKit2/Shared/mac/PasteboardTypes.h b/Source/WebKit2/Shared/mac/PasteboardTypes.h new file mode 100644 index 0000000..712c4c0 --- /dev/null +++ b/Source/WebKit2/Shared/mac/PasteboardTypes.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011 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. + * + * 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. + */ + +#ifndef PasteboardTypes_h +#define PasteboardTypes_h + +namespace WebKit { + +class PasteboardTypes { +public: + static NSString * const WebArchivePboardType; + static NSString * const WebURLsWithTitlesPboardType; + static NSString * const WebURLPboardType; + static NSString * const WebURLNamePboardType; + + static NSArray *forEditing(); + static NSArray *forURL(); + static NSArray *forImages(); + static NSArray *forImagesWithArchive(); +}; + +} // namespace WebKit + +#endif // PasteboardTypes_h diff --git a/Source/WebKit2/Shared/mac/PasteboardTypes.mm b/Source/WebKit2/Shared/mac/PasteboardTypes.mm new file mode 100644 index 0000000..380e24c --- /dev/null +++ b/Source/WebKit2/Shared/mac/PasteboardTypes.mm @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011 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. + * + * 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. + */ + +#import "PasteboardTypes.h" +#import <wtf/RetainPtr.h> + +namespace WebKit { + +NSString * const PasteboardTypes::WebArchivePboardType = @"Apple Web Archive pasteboard type"; +NSString * const PasteboardTypes::WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; +NSString * const PasteboardTypes::WebURLPboardType = @"public.url"; +NSString * const PasteboardTypes::WebURLNamePboardType = @"public.url-name"; + +static inline NSArray *retain(NSArray *array) +{ + CFRetain(array); + return array; +} + +NSArray* PasteboardTypes::forEditing() +{ + static NSArray *types = retain([NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType, +#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) + NSPICTPboardType, +#endif + NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil]); + return types; +} + +NSArray* PasteboardTypes::forURL() +{ + static NSArray *types = retain([NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil]); + return types; +} + +NSArray* PasteboardTypes::forImages() +{ + static NSArray *types = retain([NSArray arrayWithObjects:NSTIFFPboardType, WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, nil]); + return types; +} + +NSArray* PasteboardTypes::forImagesWithArchive() +{ + static NSArray *types = retain([NSArray arrayWithObjects:NSTIFFPboardType, WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSRTFDPboardType, WebArchivePboardType, nil]); + return types; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.cpp b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp index 7c9ae11..cce572a 100644 --- a/Source/WebKit2/UIProcess/API/C/WKFrame.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp @@ -75,6 +75,11 @@ WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frameRef) return toCopiedURLAPI(toImpl(frameRef)->unreachableURL()); } +void WKFrameStopLoading(WKFrameRef frameRef) +{ + toImpl(frameRef)->stopLoading(); +} + WKStringRef WKFrameCopyMIMEType(WKFrameRef frameRef) { return toCopiedAPI(toImpl(frameRef)->mimeType()); @@ -95,6 +100,11 @@ WKArrayRef WKFrameCopyChildFrames(WKFrameRef frameRef) return toAPI(toImpl(frameRef)->childFrames().releaseRef()); } +WKFrameRef WKFrameGetParentFrame(WKFrameRef frameRef) +{ + return toAPI(toImpl(frameRef)->parentFrame()); +} + WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frameRef) { return toAPI(toImpl(frameRef)->certificateInfo()); @@ -125,22 +135,32 @@ bool WKFrameIsFrameSet(WKFrameRef frameRef) return toImpl(frameRef)->isFrameSet(); } -void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetMainResourceDataFunction callback, void* context) +void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetResourceDataFunction callback, void* context) { toImpl(frameRef)->getMainResourceData(DataCallback::create(context, callback)); } +void WKFrameGetResourceData(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataFunction callback, void* context) +{ + toImpl(frameRef)->getResourceData(toImpl(resourceURL), DataCallback::create(context, callback)); +} + #ifdef __BLOCKS__ -static void callGetMainResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context) +static void callGetResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context) { - WKFrameGetMainResourceDataBlock block = (WKFrameGetMainResourceDataBlock)context; + WKFrameGetResourceDataBlock block = (WKFrameGetResourceDataBlock)context; block(data, error); Block_release(block); } -void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetMainResourceDataBlock block) +void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetResourceDataBlock block) +{ + WKFrameGetMainResourceData(frameRef, callGetResourceDataBlockAndDispose, Block_copy(block)); +} + +void WKFrameGetResourceData_b(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataBlock block) { - WKFrameGetMainResourceData(frameRef, callGetMainResourceDataBlockAndDispose, Block_copy(block)); + WKFrameGetResourceData(frameRef, resourceURL, callGetResourceDataBlockAndDispose, Block_copy(block)); } #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.h b/Source/WebKit2/UIProcess/API/C/WKFrame.h index f812aeb..334a27b 100644 --- a/Source/WebKit2/UIProcess/API/C/WKFrame.h +++ b/Source/WebKit2/UIProcess/API/C/WKFrame.h @@ -51,6 +51,8 @@ WK_EXPORT WKURLRef WKFrameCopyProvisionalURL(WKFrameRef frame); WK_EXPORT WKURLRef WKFrameCopyURL(WKFrameRef frame); WK_EXPORT WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frame); +WK_EXPORT void WKFrameStopLoading(WKFrameRef frame); + WK_EXPORT WKStringRef WKFrameCopyMIMEType(WKFrameRef frame); WK_EXPORT WKStringRef WKFrameCopyTitle(WKFrameRef frame); @@ -58,6 +60,8 @@ WK_EXPORT WKPageRef WKFrameGetPage(WKFrameRef frame); WK_EXPORT WKArrayRef WKFrameCopyChildFrames(WKFrameRef frame); +WK_EXPORT WKFrameRef WKFrameGetParentFrame(WKFrameRef frame); + WK_EXPORT WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frame); WK_EXPORT bool WKFrameCanProvideSource(WKFrameRef frame); @@ -68,11 +72,13 @@ WK_EXPORT bool WKFrameIsDisplayingMarkupDocument(WKFrameRef frame); WK_EXPORT bool WKFrameIsFrameSet(WKFrameRef frame); -typedef void (*WKFrameGetMainResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext); -WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetMainResourceDataFunction function, void* functionContext); +typedef void (*WKFrameGetResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext); +WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetResourceDataFunction function, void* functionContext); +WK_EXPORT void WKFrameGetResourceData(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataFunction function, void* functionContext); #ifdef __BLOCKS__ -typedef void (^WKFrameGetMainResourceDataBlock)(WKDataRef data, WKErrorRef error); -WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetMainResourceDataBlock block); +typedef void (^WKFrameGetResourceDataBlock)(WKDataRef data, WKErrorRef error); +WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetResourceDataBlock block); +WK_EXPORT void WKFrameGetResourceData_b(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataBlock block); #endif typedef void (*WKFrameGetWebArchiveFunction)(WKDataRef archiveData, WKErrorRef error, void* functionContext); diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp index edcbf87..82daa4b 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp @@ -260,11 +260,16 @@ void WKPageSetPageAndTextZoomFactors(WKPageRef pageRef, double pageZoomFactor, d toImpl(pageRef)->setPageAndTextZoomFactors(pageZoomFactor, textZoomFactor); } -void WKPageScaleWebView(WKPageRef pageRef, double scale, WKPoint origin) +void WKPageSetScaleFactor(WKPageRef pageRef, double scale, WKPoint origin) { toImpl(pageRef)->scaleWebView(scale, toIntPoint(origin)); } +double WKPageGetScaleFactor(WKPageRef pageRef) +{ + return toImpl(pageRef)->viewScaleFactor(); +} + void WKPageSetUseFixedLayout(WKPageRef pageRef, bool fixed) { toImpl(pageRef)->setUseFixedLayout(fixed); @@ -285,11 +290,6 @@ WKSize WKPageFixedLayoutSize(WKPageRef pageRef) return toAPI(toImpl(pageRef)->fixedLayoutSize()); } -double WKPageGetViewScaleFactor(WKPageRef pageRef) -{ - return toImpl(pageRef)->viewScaleFactor(); -} - void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount) { toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount); diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h index 05730e5..e4bf162 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.h +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -41,6 +41,8 @@ extern "C" { #endif +typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo); + // FrameLoad Client typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); @@ -59,19 +61,6 @@ typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFr typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo); typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo); -// Progress Client -typedef void (*WKPageDidStartProgressCallback)(WKPageRef page, const void *clientInfo); -typedef void (*WKPageDidChangeProgressCallback)(WKPageRef page, const void *clientInfo); -typedef void (*WKPageDidFinishProgressCallback)(WKPageRef page, const void *clientInfo); - -// WebProcess Client -// FIXME: These three functions should not be part of this client. -typedef void (*WKPageProcessDidBecomeUnresponsiveCallback)(WKPageRef page, const void *clientInfo); -typedef void (*WKPageProcessDidBecomeResponsiveCallback)(WKPageRef page, const void *clientInfo); -typedef void (*WKPageProcessDidCrashCallback)(WKPageRef page, const void *clientInfo); - -typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, const void *clientInfo); - struct WKPageLoaderClient { int version; const void * clientInfo; @@ -93,16 +82,16 @@ struct WKPageLoaderClient { WKPageDidReceiveAuthenticationChallengeInFrameCallback didReceiveAuthenticationChallengeInFrame; // FIXME: Move to progress client. - WKPageDidStartProgressCallback didStartProgress; - WKPageDidChangeProgressCallback didChangeProgress; - WKPageDidFinishProgressCallback didFinishProgress; + WKPageCallback didStartProgress; + WKPageCallback didChangeProgress; + WKPageCallback didFinishProgress; // FIXME: These three functions should not be part of this client. - WKPageProcessDidBecomeUnresponsiveCallback processDidBecomeUnresponsive; - WKPageProcessDidBecomeResponsiveCallback processDidBecomeResponsive; - WKPageProcessDidCrashCallback processDidCrash; + WKPageCallback processDidBecomeUnresponsive; + WKPageCallback processDidBecomeResponsive; + WKPageCallback processDidCrash; - WKPageDidChangeBackForwardListCallback didChangeBackForwardList; + WKPageCallback didChangeBackForwardList; }; typedef struct WKPageLoaderClient WKPageLoaderClient; @@ -152,8 +141,6 @@ typedef struct WKPageResourceLoadClient WKPageResourceLoadClient; // UI Client typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo); -typedef void (*WKPageShowPageCallback)(WKPageRef page, const void *clientInfo); -typedef void (*WKPageCloseCallback)(WKPageRef page, const void *clientInfo); typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo); typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo); typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo); @@ -172,18 +159,21 @@ typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, con typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo); typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo); typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo); -typedef void (*WKPageDidDrawCallback)(WKPageRef page, const void *clientInfo); -typedef void (*WKPageDidScrollCallback)(WKPageRef page, const void *clientInfo); typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentUsage, unsigned long long expectedUsage, const void *clientInfo); typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo); typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo); +typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo); +typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo); +typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo); +typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo); +typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo); struct WKPageUIClient { int version; const void * clientInfo; WKPageCreateNewPageCallback createNewPage; - WKPageShowPageCallback showPage; - WKPageCloseCallback close; + WKPageCallback showPage; + WKPageCallback close; WKPageRunJavaScriptAlertCallback runJavaScriptAlert; WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm; WKPageRunJavaScriptPromptCallback runJavaScriptPrompt; @@ -202,11 +192,17 @@ struct WKPageUIClient { WKPageGetWindowFrameCallback getWindowFrame; WKPageSetWindowFrameCallback setWindowFrame; WKPageRunBeforeUnloadConfirmPanelCallback runBeforeUnloadConfirmPanel; - WKPageDidDrawCallback didDraw; - WKPageDidScrollCallback pageDidScroll; + WKPageCallback didDraw; + WKPageCallback pageDidScroll; WKPageExceededDatabaseQuotaCallback exceededDatabaseQuota; WKPageRunOpenPanelCallback runOpenPanel; WKPageDecidePolicyForGeolocationPermissionRequestCallback decidePolicyForGeolocationPermissionRequest; + WKPageHeaderHeightCallback headerHeight; + WKPageFooterHeightCallback footerHeight; + WKPageDrawHeaderCallback drawHeader; + WKPageDrawFooterCallback drawFooter; + WKPagePrintFrameCallback printFrame; + WKPageCallback runModal; }; typedef struct WKPageUIClient WKPageUIClient; @@ -304,8 +300,8 @@ WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page); WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor); WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor); -WK_EXPORT void WKPageScaleWebView(WKPageRef page, double scale, WKPoint origin); -WK_EXPORT double WKPageGetViewScaleFactor(WKPageRef page); +WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin); +WK_EXPORT double WKPageGetScaleFactor(WKPageRef page); WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed); WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size); diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h index 8322465..625b8f6 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h @@ -51,6 +51,7 @@ private: virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); virtual void setViewNeedsDisplay(const WebCore::IntRect&); virtual void displayView(); + virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual WebCore::IntSize viewSize(); virtual bool isViewWindowActive(); @@ -69,6 +70,7 @@ private: virtual void clearAllEditCommands(); virtual void setEditCommandState(const String& commandName, bool isEnabled, int state); virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines); + virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag); virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); @@ -88,6 +90,8 @@ private: virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&); virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled); + virtual CGContextRef containingWindowGraphicsContext(); + virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&); diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm index c37b641..60be5bc 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm @@ -37,6 +37,7 @@ #import <WebCore/Cursor.h> #import <WebCore/FloatRect.h> #import <WebCore/FoundationExtras.h> +#import <WebCore/GraphicsContext.h> #import <WebCore/KeyboardEvent.h> #import <wtf/PassOwnPtr.h> #import <wtf/text/CString.h> @@ -133,6 +134,14 @@ void PageClientImpl::displayView() [m_wkView displayIfNeeded]; } +void PageClientImpl::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset) +{ + NSRect clippedScrollRect = NSIntersectionRect(scrollRect, NSOffsetRect(scrollRect, -scrollOffset.width(), -scrollOffset.height())); + + [m_wkView translateRectsNeedingDisplayInRect:clippedScrollRect by:scrollOffset]; + [m_wkView scrollRect:clippedScrollRect by:scrollOffset]; +} + IntSize PageClientImpl::viewSize() { return IntSize([m_wkView bounds].size); @@ -270,6 +279,14 @@ void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vect [m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines]; } +void PageClientImpl::setDragImage(const IntPoint& clientPosition, const IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) +{ + OwnPtr<GraphicsContext> graphicsContext = dragImage->createGraphicsContext(); + RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:CGBitmapContextCreateImage(graphicsContext->platformContext()) size:imageSize]); + [dragNSImage.get() setFlipped:YES]; + [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag]; +} + FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect) { return [m_wkView _convertToDeviceSpace:rect]; @@ -327,6 +344,11 @@ void PageClientImpl::setComplexTextInputEnabled(uint64_t pluginComplexTextInputI [m_wkView _setComplexTextInputEnabled:complexTextInputEnabled pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier]; } +CGContextRef PageClientImpl::containingWindowGraphicsContext() +{ + return static_cast<CGContextRef>([[[m_wkView window] graphicsContext] graphicsPort]); +} + void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation) { [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation]; diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index da9b7c9..400239d 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -35,7 +35,9 @@ #import "NativeWebKeyboardEvent.h" #import "PDFViewController.h" #import "PageClientImpl.h" +#import "PasteboardTypes.h" #import "PrintInfo.h" +#import "Region.h" #import "RunLoop.h" #import "TextChecker.h" #import "TextCheckerState.h" @@ -95,6 +97,9 @@ typedef HashMap<String, ValidationVector> ValidationMap; } +NSString* const WebKitOriginalTopPrintingMarginKey = @"WebKitOriginalTopMargin"; +NSString* const WebKitOriginalBottomPrintingMarginKey = @"WebKitOriginalBottomMargin"; + @interface WKViewData : NSObject { @public OwnPtr<PageClientImpl> _pageClient; @@ -135,6 +140,9 @@ typedef HashMap<String, ValidationVector> ValidationMap; bool _inBecomeFirstResponder; bool _inResignFirstResponder; + NSEvent *_mouseDownEvent; + BOOL _ignoringMouseDraggedEvents; + BOOL _dragHasStarted; } @end @@ -195,21 +203,10 @@ static bool useNewDrawingArea() return [self initWithFrame:frame contextRef:contextRef pageGroupRef:nil]; } -static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type"; -static NSString * const WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; -static NSString * const WebURLPboardType = @"public.url"; -static NSString * const WebURLNamePboardType = @"public.url-name"; - - (void)_registerDraggedTypes { - NSArray *editableTypes = [NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType, -#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) - NSPICTPboardType, -#endif - NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil]; - NSArray *URLTypes = [NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil]; - NSMutableSet *types = [[NSMutableSet alloc] initWithArray:editableTypes]; - [types addObjectsFromArray:URLTypes]; + NSMutableSet *types = [[NSMutableSet alloc] initWithArray:PasteboardTypes::forEditing()]; + [types addObjectsFromArray:PasteboardTypes::forURL()]; [self registerForDraggedTypes:[types allObjects]]; [types release]; } @@ -235,6 +232,8 @@ static NSString * const WebURLNamePboardType = @"public.url-name"; _data->_pageClient = PageClientImpl::create(self); _data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef)); _data->_page->initializeWebPage(); + _data->_mouseDownEvent = nil; + _data->_ignoringMouseDraggedEvents = NO; [self _registerDraggedTypes]; @@ -729,6 +728,17 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) return YES; } +- (void)_setMouseDownEvent:(NSEvent *)event +{ + ASSERT(!event || [event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown); + + if (event == _data->_mouseDownEvent) + return; + + [_data->_mouseDownEvent release]; + _data->_mouseDownEvent = [event retain]; +} + #define EVENT_HANDLER(Selector, Type) \ - (void)Selector:(NSEvent *)theEvent \ { \ @@ -751,21 +761,35 @@ EVENT_HANDLER(scrollWheel, Wheel) #undef EVENT_HANDLER -#define MOUSE_EVENT_HANDLER(Selector) \ - - (void)Selector:(NSEvent *)theEvent \ - { \ - NSInputManager *currentInputManager = [NSInputManager currentInputManager]; \ - if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:theEvent]) \ - return; \ - WebMouseEvent webEvent = WebEventFactory::createWebMouseEvent(theEvent, self); \ - _data->_page->handleMouseEvent(webEvent); \ - } +- (void)_mouseHandler:(NSEvent *)event +{ + NSInputManager *currentInputManager = [NSInputManager currentInputManager]; + if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:event]) + return; + WebMouseEvent webEvent = WebEventFactory::createWebMouseEvent(event, self); + _data->_page->handleMouseEvent(webEvent); +} -MOUSE_EVENT_HANDLER(mouseDown) -MOUSE_EVENT_HANDLER(mouseDragged) -MOUSE_EVENT_HANDLER(mouseUp) +- (void)mouseDown:(NSEvent *)event +{ + [self _setMouseDownEvent:event]; + _data->_ignoringMouseDraggedEvents = NO; + _data->_dragHasStarted = NO; + [self _mouseHandler:event]; +} -#undef MOUSE_EVENT_HANDLER +- (void)mouseUp:(NSEvent *)event +{ + [self _setMouseDownEvent:nil]; + [self _mouseHandler:event]; +} + +- (void)mouseDragged:(NSEvent *)event +{ + if (_data->_ignoringMouseDraggedEvents) + return; + [self _mouseHandler:event]; +} - (void)doCommandBySelector:(SEL)selector { @@ -1039,6 +1063,17 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde return resultRect; } +- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation +{ + NSPoint windowImageLoc = [[self window] convertScreenToBase:aPoint]; + NSPoint windowMouseLoc = windowImageLoc; + + // Prevent queued mouseDragged events from coming after the drag and fake mouseUp event. + _data->_ignoringMouseDraggedEvents = YES; + + _data->_page->dragEnded(IntPoint(windowMouseLoc), globalPoint(windowMouseLoc, [self window]), operation); +} + - (DragApplicationFlags)applicationFlags:(id <NSDraggingInfo>)draggingInfo { uint32_t flags = 0; @@ -1058,7 +1093,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]); IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); - + + _data->_page->resetDragOperation(); _data->_page->performDragControllerAction(DragControllerActionEntered, &dragData, [[draggingInfo draggingPasteboard] name]); return NSDragOperationCopy; } @@ -1234,7 +1270,15 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde if (useNewDrawingArea()) { if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) { CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]); - drawingArea->paint(context, enclosingIntRect(rect)); + + const NSRect *rectsBeingDrawn; + NSInteger numRectsBeingDrawn; + [self getRectsBeingDrawn:&rectsBeingDrawn count:&numRectsBeingDrawn]; + for (NSInteger i = 0; i < numRectsBeingDrawn; ++i) { + Region unpaintedRegion; + IntRect rect = enclosingIntRect(rectsBeingDrawn[i]); + drawingArea->paint(context, rect, unpaintedRegion); + } } else if (_data->_page->drawsBackground()) { [_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set]; NSRectFill(rect); @@ -1332,6 +1376,44 @@ static WebFrameProxy* frameBeingPrinted() return [[[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:PrintedFrameKey] webFrame]; } +static float currentPrintOperationScale() +{ + ASSERT([NSPrintOperation currentOperation]); + ASSERT([[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:NSPrintScalingFactor]); + return [[[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:NSPrintScalingFactor] floatValue]; +} + +- (void)_adjustPrintingMarginsForHeaderAndFooter +{ + NSPrintOperation *printOperation = [NSPrintOperation currentOperation]; + NSPrintInfo *info = [printOperation printInfo]; + NSMutableDictionary *infoDictionary = [info dictionary]; + + // We need to modify the top and bottom margins in the NSPrintInfo to account for the space needed by the + // header and footer. Because this method can be called more than once on the same NSPrintInfo (see 5038087), + // we stash away the unmodified top and bottom margins the first time this method is called, and we read from + // those stashed-away values on subsequent calls. + float originalTopMargin; + float originalBottomMargin; + NSNumber *originalTopMarginNumber = [infoDictionary objectForKey:WebKitOriginalTopPrintingMarginKey]; + if (!originalTopMarginNumber) { + ASSERT(![infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey]); + originalTopMargin = [info topMargin]; + originalBottomMargin = [info bottomMargin]; + [infoDictionary setObject:[NSNumber numberWithFloat:originalTopMargin] forKey:WebKitOriginalTopPrintingMarginKey]; + [infoDictionary setObject:[NSNumber numberWithFloat:originalBottomMargin] forKey:WebKitOriginalBottomPrintingMarginKey]; + } else { + ASSERT([originalTopMarginNumber isKindOfClass:[NSNumber class]]); + ASSERT([[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] isKindOfClass:[NSNumber class]]); + originalTopMargin = [originalTopMarginNumber floatValue]; + originalBottomMargin = [[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] floatValue]; + } + + float scale = currentPrintOperationScale(); + [info setTopMargin:originalTopMargin + _data->_page->headerHeight(frameBeingPrinted()) * scale]; + [info setBottomMargin:originalBottomMargin + _data->_page->footerHeight(frameBeingPrinted()) * scale]; +} + - (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef { LOG(View, "Creating an NSPrintOperation for frame '%s'", toImpl(frameRef)->url().utf8().data()); @@ -1364,6 +1446,8 @@ static WebFrameProxy* frameBeingPrinted() if (frame->isMainFrame() && _data->_pdfViewController) return [super knowsPageRange:range]; + [self _adjustPrintingMarginsForHeaderAndFooter]; + _data->_page->computePagesForPrinting(frame, PrintInfo([[NSPrintOperation currentOperation] printInfo]), _data->_printingPageRects, _data->_totalScaleFactorForPrinting); *range = NSMakeRange(1, _data->_printingPageRects.size()); @@ -1418,6 +1502,34 @@ static WebFrameProxy* frameBeingPrinted() CGContextRestoreGState(context); } +- (void)drawPageBorderWithSize:(NSSize)borderSize +{ + ASSERT(NSEqualSizes(borderSize, [[[NSPrintOperation currentOperation] printInfo] paperSize])); + + // The header and footer rect height scales with the page, but the width is always + // all the way across the printed page (inset by printing margins). + NSPrintOperation *printOperation = [NSPrintOperation currentOperation]; + NSPrintInfo *printInfo = [printOperation printInfo]; + float scale = currentPrintOperationScale(); + NSSize paperSize = [printInfo paperSize]; + float headerFooterLeft = [printInfo leftMargin] / scale; + float headerFooterWidth = (paperSize.width - ([printInfo leftMargin] + [printInfo rightMargin])) / scale; + WebFrameProxy* frame = frameBeingPrinted(); + NSRect footerRect = NSMakeRect(headerFooterLeft, [printInfo bottomMargin] / scale - _data->_page->footerHeight(frame), headerFooterWidth, _data->_page->footerHeight(frame)); + NSRect headerRect = NSMakeRect(headerFooterLeft, (paperSize.height - [printInfo topMargin]) / scale, headerFooterWidth, _data->_page->headerHeight(frame)); + + NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; + [currentContext saveGraphicsState]; + NSRectClip(headerRect); + _data->_page->drawHeader(frame, headerRect); + [currentContext restoreGraphicsState]; + + [currentContext saveGraphicsState]; + NSRectClip(footerRect); + _data->_page->drawFooter(frame, footerRect); + [currentContext restoreGraphicsState]; +} + // FIXME 3491344: This is an AppKit-internal method that we need to override in order // to get our shrink-to-fit to work with a custom pagination scheme. We can do this better // if AppKit makes it SPI/API. @@ -1792,4 +1904,22 @@ static WebFrameProxy* frameBeingPrinted() _data->_pdfViewController->setZoomFactor(zoomFactor); } +- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag +{ + // We need to prevent re-entering this call to avoid crashing in AppKit. + // Given the asynchronous nature of WebKit2 this can now happen. + if (_data->_dragHasStarted) + return; + + _data->_dragHasStarted = YES; + [super dragImage:image + at:clientPoint + offset:NSZeroSize + event:(linkDrag) ? [NSApp currentEvent] :_data->_mouseDownEvent + pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] + source:self + slideBack:YES]; + _data->_dragHasStarted = NO; +} + @end diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h index 1c70b38..cba241d 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h @@ -62,5 +62,6 @@ namespace WebKit { - (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference; - (double)_customRepresentationZoomFactor; - (void)_setCustomRepresentationZoomFactor:(double)zoomFactor; +- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag; @end diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp index f01c5b2..ec23760 100644 --- a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp @@ -66,24 +66,14 @@ QGraphicsWKView::QGraphicsWKView(QWKContext* context, BackingStoreType backingSt setFocusPolicy(Qt::StrongFocus); setAcceptHoverEvents(true); - PassOwnPtr<DrawingAreaProxy> drawingAreaProxy; - d->page = new QWKPage(context); - - switch (backingStoreType) { #if ENABLE(TILED_BACKING_STORE) - case Tiled: - drawingAreaProxy = TiledDrawingAreaProxy::create(this, toImpl(page()->pageRef())); + if (backingStoreType == Tiled) connect(this, SIGNAL(scaleChanged()), this, SLOT(onScaleChanged())); - break; #endif - case Simple: - default: - drawingAreaProxy = ChunkedUpdateDrawingAreaProxy::create(this, toImpl(page()->pageRef())); - break; - } - d->page->d->init(this, drawingAreaProxy); + d->page = new QWKPage(context); + d->page->d->init(this, backingStoreType); connect(d->page, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); connect(d->page, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool))); diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp index 638d9e3..72c1322 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp @@ -88,6 +88,7 @@ QWKPagePrivate::QWKPagePrivate(QWKPage* qq, QWKContext* c) , context(c) , preferences(0) , createNewPageFn(0) + , backingStoreType(QGraphicsWKView::Simple) { memset(actions, 0, sizeof(actions)); page = context->d->context->createWebPage(this, 0); @@ -100,10 +101,10 @@ QWKPagePrivate::~QWKPagePrivate() delete history; } -void QWKPagePrivate::init(QGraphicsItem* view, PassOwnPtr<DrawingAreaProxy> proxy) +void QWKPagePrivate::init(QGraphicsItem* view, QGraphicsWKView::BackingStoreType backingStoreType) { this->view = view; - page->setDrawingArea(proxy); + this->backingStoreType = backingStoreType; page->initializeWebPage(); } @@ -131,7 +132,7 @@ PassOwnPtr<DrawingAreaProxy> QWKPagePrivate::createDrawingAreaProxy() QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view); #if ENABLE(TILED_BACKING_STORE) - if (page->drawingArea()->info().type == DrawingAreaInfo::Tiled) + if (backingStoreType == QGraphicsWKView::Tiled) return TiledDrawingAreaProxy::create(wkView, page.get()); #endif return ChunkedUpdateDrawingAreaProxy::create(wkView, page.get()); @@ -147,6 +148,11 @@ void QWKPagePrivate::displayView() // FIXME: Implement. } +void QWKPagePrivate::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) +{ + // FIXME: Implement. +} + WebCore::IntSize QWKPagePrivate::viewSize() { // FIXME: Implement. @@ -380,6 +386,13 @@ void QWKPagePrivate::touchEvent(QTouchEvent* event) #endif } +void QWKPagePrivate::didRelaunchProcess() +{ + QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view); + if (wkView) + q->setViewportSize(wkView->size().toSize()); +} + QWKPage::QWKPage(QWKContext* context) : d(new QWKPagePrivate(this, context)) { @@ -440,7 +453,13 @@ QWKPage::QWKPage(QWKContext* context) 0, /* pageDidScroll */ 0, /* exceededDatabaseQuota */ 0, /* runOpenPanel */ - 0 /* decidePolicyForGeolocationPermissionRequest */ + 0, /* decidePolicyForGeolocationPermissionRequest */ + 0, /* headerHeight */ + 0, /* footerHeight */ + 0, /* drawHeader */ + 0, /* drawFooter */ + 0, /* printFrame */ + 0 /* runModal */ }; WKPageSetPageUIClient(pageRef(), &uiClient); } diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h index 85135c2..420ff62 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h @@ -24,6 +24,7 @@ #include "DrawingAreaProxy.h" #include "PageClient.h" #include "qwkpage.h" +#include "qgraphicswkview.h" #include "WebPageProxy.h" #include <wtf/PassOwnPtr.h> #include <wtf/RefPtr.h> @@ -41,12 +42,13 @@ public: static QWKPagePrivate* get(QWKPage* page) { return page->d; } - void init(QGraphicsItem*, WTF::PassOwnPtr<WebKit::DrawingAreaProxy>); + void init(QGraphicsItem*, QGraphicsWKView::BackingStoreType); // PageClient virtual PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy(); virtual void setViewNeedsDisplay(const WebCore::IntRect&); virtual void displayView(); + virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual WebCore::IntSize viewSize(); virtual bool isViewWindowActive(); @@ -60,7 +62,7 @@ public: #endif // USE(ACCELERATED_COMPOSITING) virtual void pageDidRequestScroll(const WebCore::IntSize&); virtual void processDidCrash() { } - virtual void didRelaunchProcess() { } + virtual void didRelaunchProcess(); virtual void didChangeContentsSize(const WebCore::IntSize&); virtual void didFindZoomableArea(const WebCore::IntRect&); virtual void setCursor(const WebCore::Cursor&); @@ -119,6 +121,7 @@ public: QPoint tripleClick; QBasicTimer tripleClickTimer; + QGraphicsWKView::BackingStoreType backingStoreType; }; class QtViewportAttributesPrivate : public QSharedData { diff --git a/Source/WebKit2/UIProcess/BackingStore.cpp b/Source/WebKit2/UIProcess/BackingStore.cpp index 06d66af..b468b6b 100644 --- a/Source/WebKit2/UIProcess/BackingStore.cpp +++ b/Source/WebKit2/UIProcess/BackingStore.cpp @@ -25,6 +25,9 @@ #include "BackingStore.h" +#include "ShareableBitmap.h" +#include "UpdateInfo.h" + using namespace WebCore; #if !PLATFORM(MAC) @@ -33,13 +36,15 @@ using namespace WebCore; namespace WebKit { -PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size) +PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, WebPageProxy* webPageProxy) { - return adoptPtr(new BackingStore(size)); + return adoptPtr(new BackingStore(size, webPageProxy)); } -BackingStore::BackingStore(const IntSize& size) +BackingStore::BackingStore(const IntSize& size, WebPageProxy* webPageProxy) : m_size(size) + , m_webPageProxy(webPageProxy) + , m_latestUpdateTimestamp(0) { ASSERT(!m_size.isEmpty()); } @@ -48,4 +53,22 @@ BackingStore::~BackingStore() { } +void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) +{ + if (updateInfo.timestamp < m_latestUpdateTimestamp) { + // The update is too old, discard it. + return; + } + + ASSERT(m_size == updateInfo.viewSize); + + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle); + if (!bitmap) + return; + + incorporateUpdate(bitmap.get(), updateInfo); + + m_latestUpdateTimestamp = updateInfo.timestamp; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/BackingStore.h b/Source/WebKit2/UIProcess/BackingStore.h index e196a55..a3ea065 100644 --- a/Source/WebKit2/UIProcess/BackingStore.h +++ b/Source/WebKit2/UIProcess/BackingStore.h @@ -40,6 +40,7 @@ namespace WebCore { namespace WebKit { +class ShareableBitmap; class UpdateInfo; class WebPageProxy; @@ -47,9 +48,11 @@ class BackingStore { WTF_MAKE_NONCOPYABLE(BackingStore); public: - static PassOwnPtr<BackingStore> create(const WebCore::IntSize&); + static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, WebPageProxy*); ~BackingStore(); + const WebCore::IntSize& size() const { return m_size; } + #if PLATFORM(MAC) typedef CGContextRef PlatformGraphicsContext; #endif @@ -58,13 +61,19 @@ public: void incorporateUpdate(const UpdateInfo&); private: - explicit BackingStore(const WebCore::IntSize&); + BackingStore(const WebCore::IntSize&, WebPageProxy*); - void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + void incorporateUpdate(ShareableBitmap*, const UpdateInfo&); + void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); WebCore::IntSize m_size; + WebPageProxy* m_webPageProxy; + double m_latestUpdateTimestamp; #if PLATFORM(MAC) + CGContextRef backingStoreContext(); + + RetainPtr<CGLayerRef> m_cgLayer; RetainPtr<CGContextRef> m_bitmapContext; #endif }; diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h index a58a0d9..3eb24da 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.h @@ -65,6 +65,10 @@ public: virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext) = 0; virtual void sizeDidChange() = 0; + + // FIXME: visibilityDidChange() should be pure virtual. + virtual void visibilityDidChange() { } + virtual void setPageIsVisible(bool isVisible) = 0; #if USE(ACCELERATED_COMPOSITING) @@ -89,7 +93,7 @@ private: // CoreIPC message handlers. // FIXME: These should be pure virtual. virtual void update(const UpdateInfo&) { } - virtual void didSetSize() { } + virtual void didSetSize(const UpdateInfo&) { } }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in index 7e340d4..ec065c7 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in @@ -22,5 +22,5 @@ messages -> DrawingAreaProxy { Update(WebKit::UpdateInfo updateInfo) - DidSetSize() + DidSetSize(WebKit::UpdateInfo updateInfo) } diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp index 02b0dd2..3207094 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp +++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp @@ -26,6 +26,7 @@ #include "DrawingAreaProxyImpl.h" #include "DrawingAreaMessages.h" +#include "Region.h" #include "UpdateInfo.h" #include "WebPageProxy.h" #include "WebProcessProxy.h" @@ -45,6 +46,7 @@ PassOwnPtr<DrawingAreaProxyImpl> DrawingAreaProxyImpl::create(WebPageProxy* webP DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy* webPageProxy) : DrawingAreaProxy(DrawingAreaInfo::Impl, webPageProxy) + , m_isWaitingForDidSetSize(false) { } @@ -52,12 +54,15 @@ DrawingAreaProxyImpl::~DrawingAreaProxyImpl() { } -void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect) +void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect, Region& unpaintedRegion) { + unpaintedRegion = rect; + if (!m_backingStore) return; m_backingStore->paint(context, rect); + unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size())); } void DrawingAreaProxyImpl::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) @@ -81,9 +86,20 @@ void DrawingAreaProxyImpl::sizeDidChange() sendSetSize(); } -void DrawingAreaProxyImpl::setPageIsVisible(bool pageIsVisible) +void DrawingAreaProxyImpl::visibilityDidChange() +{ + if (!m_webPageProxy->isViewVisible()) { + // Suspend painting. + m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID()); + return; + } + + // Resume painting. + m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID()); +} + +void DrawingAreaProxyImpl::setPageIsVisible(bool) { - // FIXME: Implement. } void DrawingAreaProxyImpl::attachCompositingContext(uint32_t contextID) @@ -104,26 +120,39 @@ void DrawingAreaProxyImpl::update(const UpdateInfo& updateInfo) m_webPageProxy->process()->send(Messages::DrawingArea::DidUpdate(), m_webPageProxy->pageID()); } -void DrawingAreaProxyImpl::didSetSize() +void DrawingAreaProxyImpl::didSetSize(const UpdateInfo& updateInfo) { + ASSERT(m_isWaitingForDidSetSize); + m_isWaitingForDidSetSize = false; + + if (m_size != updateInfo.viewSize) + sendSetSize(); + + m_backingStore = nullptr; + + incorporateUpdate(updateInfo); } void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo) { - // FIXME: Check for the update bounds being empty here. + if (updateInfo.updateRectBounds.isEmpty()) + return; if (!m_backingStore) - m_backingStore = BackingStore::create(updateInfo.viewSize); + m_backingStore = BackingStore::create(updateInfo.viewSize, m_webPageProxy); m_backingStore->incorporateUpdate(updateInfo); + bool shouldScroll = !updateInfo.scrollRect.isEmpty(); + + if (shouldScroll) + m_webPageProxy->scrollView(updateInfo.scrollRect, updateInfo.scrollOffset); + for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) m_webPageProxy->setViewNeedsDisplay(updateInfo.updateRects[i]); - if (!updateInfo.scrollRect.isEmpty()) { - m_webPageProxy->setViewNeedsDisplay(updateInfo.scrollRect); + if (shouldScroll) m_webPageProxy->displayView(); - } } void DrawingAreaProxyImpl::sendSetSize() @@ -131,6 +160,10 @@ void DrawingAreaProxyImpl::sendSetSize() if (!m_webPageProxy->isValid()) return; + if (m_isWaitingForDidSetSize) + return; + + m_isWaitingForDidSetSize = true; m_webPageProxy->process()->send(Messages::DrawingArea::SetSize(m_size), m_webPageProxy->pageID()); } diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h index 0de7ada..bf7b878 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h @@ -31,12 +31,14 @@ namespace WebKit { +class Region; + class DrawingAreaProxyImpl : public DrawingAreaProxy { public: static PassOwnPtr<DrawingAreaProxyImpl> create(WebPageProxy*); virtual ~DrawingAreaProxyImpl(); - void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&); + void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, Region& unpaintedRegion); private: explicit DrawingAreaProxyImpl(WebPageProxy*); @@ -46,17 +48,22 @@ private: virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext); virtual void sizeDidChange(); + virtual void visibilityDidChange(); virtual void setPageIsVisible(bool); virtual void attachCompositingContext(uint32_t contextID); virtual void detachCompositingContext(); // CoreIPC message handlers virtual void update(const UpdateInfo&); - virtual void didSetSize(); + virtual void didSetSize(const UpdateInfo&); void incorporateUpdate(const UpdateInfo&); void sendSetSize(); + // Whether we've sent a SetSize message and are now waiting for a DidSetSize message. + // Used to throttle SetSize messages so we don't send them faster than the Web process can handle. + bool m_isWaitingForDidSetSize; + OwnPtr<BackingStore> m_backingStore; }; diff --git a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm index c285bae..a725d6b 100644 --- a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm +++ b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm @@ -49,32 +49,6 @@ extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, u namespace WebKit { -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) -static const char* processName() -{ - return [[[NSProcessInfo processInfo] processName] fileSystemRepresentation]; -} -#else -// -[NSProcessInfo processName] isn't thread-safe on Leopard and Snow Leopard so we have our own implementation. -static const char* createProcessName() -{ - uint32_t bufferSize = MAXPATHLEN; - char executablePath[bufferSize]; - - if (_NSGetExecutablePath(executablePath, &bufferSize)) - return ""; - - const char *processName = strrchr(executablePath, '/') + 1; - return strdup(processName); -} - -static const char* processName() -{ - static const char* processName = createProcessName(); - return processName; -} -#endif - static void setUpTerminationNotificationHandler(pid_t pid) { #if HAVE(DISPATCH_H) @@ -226,7 +200,7 @@ void ProcessLauncher::launchProcess() CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), this).utf8(); const char* path = [webProcessAppExecutablePath fileSystemRepresentation]; - const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), "-parentprocessname", processName(), 0 }; + const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), 0 }; // Register ourselves. kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0); diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h index 5767b3c..e483aef 100644 --- a/Source/WebKit2/UIProcess/PageClient.h +++ b/Source/WebKit2/UIProcess/PageClient.h @@ -26,6 +26,7 @@ #ifndef PageClient_h #define PageClient_h +#include "ShareableBitmap.h" #include "WebPageProxy.h" #include "WebPopupMenuProxy.h" #include <wtf/Forward.h> @@ -58,6 +59,9 @@ public: // Tell the view to immediately display its invalid rect. virtual void displayView() = 0; + // Tell the view to scroll scrollRect by scrollOffset. + virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0; + // Return the size of the view the page is associated with. virtual WebCore::IntSize viewSize() = 0; @@ -95,7 +99,8 @@ public: virtual void setEditCommandState(const String& commandName, bool isEnabled, int state) = 0; #if PLATFORM(MAC) virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&) = 0; - virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&, uint32_t, uint32_t, Vector<WebCore::CompositionUnderline>&) = 0; + virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) = 0; + virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0; #endif #if PLATFORM(WIN) virtual void compositionSelectionChanged(bool) = 0; @@ -121,6 +126,8 @@ public: #if PLATFORM(MAC) virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) = 0; + + virtual CGContextRef containingWindowGraphicsContext() = 0; #endif // Custom representations. diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h index c265f2e..a150d67 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h @@ -41,7 +41,8 @@ namespace WebKit { class PluginProcessProxy; class WebProcessProxy; -class PluginProcessManager : Noncopyable { +class PluginProcessManager { + WTF_MAKE_NONCOPYABLE(PluginProcessManager); public: static PluginProcessManager& shared(); diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm index 81c8620..eaf8aef 100644 --- a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm +++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm @@ -35,6 +35,7 @@ namespace WebKit { void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters) { #if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION) + parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; mach_port_t renderServerPort = WKInitializeRenderServer(); if (renderServerPort != MACH_PORT_NULL) parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND); diff --git a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp index 485f892..1e0c251 100644 --- a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp +++ b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp @@ -253,7 +253,8 @@ Vector<String> PluginInfoStore::pluginsDirectories() return directories; } -class PathWalker : public Noncopyable { +class PathWalker { + WTF_MAKE_NONCOPYABLE(PathWalker); public: PathWalker(const String& directory) { diff --git a/Source/WebKit2/UIProcess/VisitedLinkProvider.h b/Source/WebKit2/UIProcess/VisitedLinkProvider.h index 015515c..a428d5b 100644 --- a/Source/WebKit2/UIProcess/VisitedLinkProvider.h +++ b/Source/WebKit2/UIProcess/VisitedLinkProvider.h @@ -31,13 +31,13 @@ #include <WebCore/LinkHash.h> #include <wtf/Forward.h> #include <wtf/HashSet.h> -#include <wtf/Noncopyable.h> namespace WebKit { class WebContext; -class VisitedLinkProvider : Noncopyable { +class VisitedLinkProvider { + WTF_MAKE_NONCOPYABLE(VisitedLinkProvider); public: explicit VisitedLinkProvider(WebContext*); diff --git a/Source/WebKit2/UIProcess/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp index 2c75cf2..1bb6bc4 100644 --- a/Source/WebKit2/UIProcess/WebContext.cpp +++ b/Source/WebKit2/UIProcess/WebContext.cpp @@ -114,6 +114,9 @@ WebContext::~WebContext() m_geolocationManagerProxy->invalidate(); m_geolocationManagerProxy->clearContext(); + m_databaseManagerProxy->invalidate(); + m_databaseManagerProxy->clearContext(); + #ifndef NDEBUG webContextCounter.decrement(); #endif diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h index 9996198..e973160 100644 --- a/Source/WebKit2/UIProcess/WebContext.h +++ b/Source/WebKit2/UIProcess/WebContext.h @@ -67,6 +67,7 @@ public: ProcessModel processModel() const { return m_processModel; } WebProcessProxy* process() const { return m_process.get(); } + bool hasValidProcess() const { return m_process && m_process->isValid(); } void processDidFinishLaunching(WebProcessProxy*); void processDidClose(WebProcessProxy*); @@ -142,7 +143,6 @@ private: virtual Type type() const { return APIType; } void ensureWebProcess(); - bool hasValidProcess() const { return m_process && m_process->isValid(); } void platformInitializeWebProcess(WebProcessCreationParameters&); // History client diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp index 6f382b7..1bc0303 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp @@ -100,8 +100,6 @@ WebDatabaseManagerProxy::~WebDatabaseManagerProxy() void WebDatabaseManagerProxy::invalidate() { invalidateCallbackMap(m_arrayCallbacks); - - m_webContext = 0; } void WebDatabaseManagerProxy::initializeClient(const WKDatabaseManagerClient* client) @@ -112,6 +110,10 @@ void WebDatabaseManagerProxy::initializeClient(const WKDatabaseManagerClient* cl void WebDatabaseManagerProxy::getDatabasesByOrigin(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; + if (!m_webContext->hasValidProcess()) { + callback->invalidate(); + return; + } uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabasesByOrigin(callbackID), 0); @@ -164,6 +166,10 @@ void WebDatabaseManagerProxy::didGetDatabasesByOrigin(const Vector<OriginAndData void WebDatabaseManagerProxy::getDatabaseOrigins(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; + if (!m_webContext->hasValidProcess()) { + callback->invalidate(); + return; + } uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabaseOrigins(callbackID), 0); @@ -188,21 +194,29 @@ void WebDatabaseManagerProxy::didGetDatabaseOrigins(const Vector<String>& origin void WebDatabaseManagerProxy::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, WebSecurityOrigin* origin) { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabaseWithNameForOrigin(databaseIdentifier, origin->databaseIdentifier()), 0); } void WebDatabaseManagerProxy::deleteDatabasesForOrigin(WebSecurityOrigin* origin) { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabasesForOrigin(origin->databaseIdentifier()), 0); } void WebDatabaseManagerProxy::deleteAllDatabases() { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::DeleteAllDatabases(), 0); } void WebDatabaseManagerProxy::setQuotaForOrigin(WebSecurityOrigin* origin, uint64_t quota) { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::SetQuotaForOrigin(origin->databaseIdentifier(), quota), 0); } diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h index 9878232..3658845 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h @@ -55,6 +55,7 @@ public: virtual ~WebDatabaseManagerProxy(); void invalidate(); + void clearContext() { m_webContext = 0; } void initializeClient(const WKDatabaseManagerClient*); diff --git a/Source/WebKit2/UIProcess/WebFrameProxy.cpp b/Source/WebKit2/UIProcess/WebFrameProxy.cpp index d3a36f9..779cf61 100644 --- a/Source/WebKit2/UIProcess/WebFrameProxy.cpp +++ b/Source/WebKit2/UIProcess/WebFrameProxy.cpp @@ -29,6 +29,7 @@ #include "WebContext.h" #include "WebFormSubmissionListenerProxy.h" #include "WebFramePolicyListenerProxy.h" +#include "WebPageMessages.h" #include "WebPageProxy.h" #include <WebCore/DOMImplementation.h> #include <WebCore/Image.h> @@ -81,6 +82,17 @@ bool WebFrameProxy::isMainFrame() const return this == m_page->mainFrame(); } +void WebFrameProxy::stopLoading() const +{ + if (!m_page) + return; + + if (!m_page->isValid()) + return; + + m_page->process()->send(Messages::WebPage::StopLoadingFrame(m_frameID), m_page->pageID()); +} + bool WebFrameProxy::canProvideSource() const { return isDisplayingMarkupDocument(); @@ -117,7 +129,6 @@ bool WebFrameProxy::isDisplayingMarkupDocument() const void WebFrameProxy::didStartProvisionalLoad(const String& url) { - ASSERT(!url.isEmpty()); ASSERT(m_loadState == LoadStateFinished); ASSERT(m_provisionalURL.isEmpty()); m_loadState = LoadStateProvisional; @@ -143,7 +154,6 @@ void WebFrameProxy::didFailProvisionalLoad() void WebFrameProxy::didCommitLoad(const String& contentType, const PlatformCertificateInfo& certificateInfo) { ASSERT(m_loadState == LoadStateProvisional); - ASSERT(!m_provisionalURL.isEmpty()); m_loadState = LoadStateCommitted; m_url = m_provisionalURL; m_provisionalURL = String(); @@ -157,7 +167,6 @@ void WebFrameProxy::didFinishLoad() { ASSERT(m_loadState == LoadStateCommitted); ASSERT(m_provisionalURL.isEmpty()); - ASSERT(!m_url.isEmpty()); m_loadState = LoadStateFinished; } @@ -305,4 +314,14 @@ void WebFrameProxy::getMainResourceData(PassRefPtr<DataCallback> callback) m_page->getMainResourceDataOfFrame(this, callback); } +void WebFrameProxy::getResourceData(WebURL* resourceURL, PassRefPtr<DataCallback> callback) +{ + if (!m_page) { + callback->invalidate(); + return; + } + + m_page->getResourceDataFromFrame(this, resourceURL, callback); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebFrameProxy.h b/Source/WebKit2/UIProcess/WebFrameProxy.h index 84c1eb8..6cc2130 100644 --- a/Source/WebKit2/UIProcess/WebFrameProxy.h +++ b/Source/WebKit2/UIProcess/WebFrameProxy.h @@ -86,6 +86,8 @@ public: bool isFrameSet() const { return m_isFrameSet; } LoadState loadState() const { return m_loadState; } + + void stopLoading() const; const String& url() const { return m_url; } const String& provisionalURL() const { return m_provisionalURL; } @@ -107,6 +109,7 @@ public: void getWebArchive(PassRefPtr<DataCallback>); void getMainResourceData(PassRefPtr<DataCallback>); + void getResourceData(WebURL*, PassRefPtr<DataCallback>); void didStartProvisionalLoad(const String& url); void didReceiveServerRedirectForProvisionalLoad(const String& url); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index f433fbd..0be2f11 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -227,7 +227,9 @@ void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item) m_backForwardList->goToItem(item); reattachToWebProcess(); - process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID); + + if (item) + process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID); } void WebPageProxy::initializeWebPage() @@ -475,6 +477,11 @@ void WebPageProxy::displayView() m_pageClient->displayView(); } +void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset) +{ + m_pageClient->scrollView(scrollRect, scrollOffset); +} + void WebPageProxy::viewStateDidChange(ViewStateFlags flags) { if (!isValid()) @@ -490,6 +497,7 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags) bool isVisible = m_pageClient->isViewVisible(); if (isVisible != m_isVisible) { m_isVisible = isVisible; + m_drawingArea->visibilityDidChange(); m_drawingArea->setPageIsVisible(isVisible); } } @@ -609,6 +617,24 @@ void WebPageProxy::didPerformDragControllerAction(uint64_t resultOperation) m_currentDragOperation = static_cast<DragOperation>(resultOperation); } +#if PLATFORM(MAC) +void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag) +{ + RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(imageSize, dragImageHandle); + if (!dragImage) + return; + + m_pageClient->setDragImage(clientPosition, imageSize, dragImage.release(), isLinkDrag); +} +#endif + +void WebPageProxy::dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation) +{ + if (!isValid()) + return; + process()->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID); +} + void WebPageProxy::handleMouseEvent(const WebMouseEvent& event) { if (!isValid()) @@ -960,6 +986,14 @@ void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<D process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID); } +void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resourceURL, PassRefPtr<DataCallback> prpCallback) +{ + RefPtr<DataCallback> callback = prpCallback; + uint64_t callbackID = callback->callbackID(); + m_dataCallbacks.set(callbackID, callback.get()); + process()->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID); +} + void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback) { RefPtr<DataCallback> callback = prpCallback; @@ -1067,6 +1101,11 @@ void WebPageProxy::didCreateSubframe(uint64_t frameID, uint64_t parentFrameID) parentFrame->appendChild(subFrame.get()); } +static bool isDisconnectedFrame(WebFrameProxy* frame) +{ + return !frame->page() || !frame->page()->mainFrame() || !frame->isDescendantOf(frame->page()->mainFrame()); +} + void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID) { MESSAGE_CHECK(m_mainFrame); @@ -1074,7 +1113,7 @@ void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID) WebFrameProxy* subframe = process()->webFrame(frameID); MESSAGE_CHECK(subframe); - if (!subframe->parentFrame()) + if (isDisconnectedFrame(subframe)) return; MESSAGE_CHECK(subframe->isDescendantOf(m_mainFrame.get())); @@ -1633,6 +1672,14 @@ void WebPageProxy::runOpenPanel(uint64_t frameID, const WebOpenPanelParameters:: didCancelForOpenPanel(); } +void WebPageProxy::printFrame(uint64_t frameID) +{ + WebFrameProxy* frame = process()->webFrame(frameID); + MESSAGE_CHECK(frame); + + m_uiClient.printFrame(this, frame); +} + #if PLATFORM(QT) void WebPageProxy::didChangeContentsSize(const WebCore::IntSize& size) { @@ -2231,7 +2278,6 @@ WebPageCreationParameters WebPageProxy::creationParameters() const parameters.isFocused = m_pageClient->isViewFocused(); parameters.isVisible = m_pageClient->isViewVisible(); parameters.isInWindow = m_pageClient->isViewInWindow(); - parameters.drawingAreaInfo = m_drawingArea->info(); parameters.store = m_pageGroup->preferences()->store(); parameters.pageGroupData = m_pageGroup->data(); @@ -2242,6 +2288,7 @@ WebPageCreationParameters WebPageProxy::creationParameters() const parameters.userAgent = userAgent(); parameters.sessionState = SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex()); parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID(); + parameters.canRunModal = m_uiClient.canRunModal(); #if PLATFORM(MAC) parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled; @@ -2315,6 +2362,26 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, request->deny(); } +float WebPageProxy::headerHeight(WebFrameProxy* frame) +{ + return m_uiClient.headerHeight(this, frame); +} + +float WebPageProxy::footerHeight(WebFrameProxy* frame) +{ + return m_uiClient.footerHeight(this, frame); +} + +void WebPageProxy::drawHeader(WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + m_uiClient.drawHeader(this, frame, rect); +} + +void WebPageProxy::drawFooter(WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + m_uiClient.drawFooter(this, frame, rect); +} + void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference) { m_pageClient->didFinishLoadingDataForCustomRepresentation(dataReference); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index 4a9e478..dc43e19 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -173,6 +173,7 @@ public: void setViewNeedsDisplay(const WebCore::IntRect&); void displayView(); + void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); enum { ViewWindowIsActive = 1 << 0, @@ -184,6 +185,7 @@ public: void viewStateDidChange(ViewStateFlags flags); WebCore::IntSize viewSize() const; + bool isViewVisible() const { return m_isVisible; } void executeEditCommand(const String& commandName); void validateMenuItem(const String& commandName); @@ -197,6 +199,7 @@ public: uint64_t characterIndexForPoint(const WebCore::IntPoint); WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t); void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput); + CGContextRef containingWindowGraphicsContext(); #endif #if PLATFORM(WIN) void didChangeCompositionSelection(bool); @@ -264,12 +267,18 @@ public: void getContentsAsString(PassRefPtr<StringCallback>); void getMainResourceDataOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>); + void getResourceDataFromFrame(WebFrameProxy*, WebURL*, PassRefPtr<DataCallback>); void getRenderTreeExternalRepresentation(PassRefPtr<StringCallback>); void getSelectionOrContentsAsString(PassRefPtr<StringCallback>); void getSourceForFrame(WebFrameProxy*, PassRefPtr<StringCallback>); void getWebArchiveOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>); void runJavaScriptInMainFrame(const String&, PassRefPtr<StringCallback>); + float headerHeight(WebFrameProxy*); + float footerHeight(WebFrameProxy*); + void drawHeader(WebFrameProxy*, const WebCore::FloatRect&); + void drawFooter(WebFrameProxy*, const WebCore::FloatRect&); + void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy*, uint64_t listenerID); void backForwardRemovedItem(uint64_t itemID); @@ -277,7 +286,10 @@ public: // Drag and drop support. void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String&); void didPerformDragControllerAction(uint64_t resultOperation); - + void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation); +#if PLATFORM(MAC) + void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag); +#endif void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); @@ -426,8 +438,10 @@ private: void didChangeViewportData(const WebCore::ViewportArguments&); void pageDidScroll(); void runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data&); + void printFrame(uint64_t frameID); void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage, uint64_t& newQuota); void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier); + void runModal() { m_uiClient.runModal(this); } void reattachToWebProcess(); void reattachToWebProcessWithItem(WebBackForwardListItem*); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index 2d576be..6456851 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Apple Inc. All rights reserved. +# Copyright (C) 2010, 2011 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -21,7 +21,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. messages -> WebPageProxy { - # UI messages. + # UI messages CreateNewPage(WebCore::WindowFeatures windowFeatures, uint32_t modifiers, int32_t mouseButton) -> (uint64_t newPageID, WebKit::WebPageCreationParameters newPageParameters) ShowPage() ClosePage() @@ -53,6 +53,8 @@ messages -> WebPageProxy { RunBeforeUnloadConfirmPanel(WTF::String message, uint64_t frameID) -> (bool shouldClose) PageDidScroll() RunOpenPanel(uint64_t frameID, WebKit::WebOpenPanelParameters::Data parameters) + PrintFrame(uint64_t frameID) -> () + RunModal() #if ENABLE(TILED_BACKING_STORE) PageDidRequestScroll(WebCore::IntSize delta) @@ -62,23 +64,23 @@ messages -> WebPageProxy { DidFindZoomableArea(WebCore::IntRect area) #endif - # Policy messages. + # Policy messages DecidePolicyForMIMEType(uint64_t frameID, WTF::String MIMEType, WTF::String url, uint64_t listenerID) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID) DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID) - # Progress messages. + # Progress messages DidChangeProgress(double value) DidFinishProgress() DidStartProgress() - # Frame lifetime messages. + # Frame lifetime messages DidCreateMainFrame(uint64_t frameID) DidCreateSubframe(uint64_t frameID, uint64_t parentFrameID) DidSaveFrameToPageCache(uint64_t frameID); DidRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID); - # Frame load messages. + # Frame load messages DidCommitLoadForFrame(uint64_t frameID, WTF::String mimeType, bool hasCustomRepresentation, WebKit::PlatformCertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData) DidFailLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) DidFailProvisionalLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) @@ -96,7 +98,7 @@ messages -> WebPageProxy { FrameDidBecomeFrameSet(uint64_t frameID, bool value) - # Resource load messages. + # Resource load messages DidInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceRequest request) DidSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse) DidReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceResponse response) @@ -107,21 +109,21 @@ messages -> WebPageProxy { # Custom representations DidFinishLoadingDataForCustomRepresentation(CoreIPC::DataReference data) - # Forms messages. + # Forms messages WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) - # Callback messages. + # Callback messages DataCallback(CoreIPC::DataReference resultData, uint64_t callbackID) StringCallback(WTF::String resultString, uint64_t callbackID) DidReceiveAccessibilityPageToken(CoreIPC::DataReference data) #if PLATFORM(MAC) - # Keyboard support messages. + # Keyboard support messages InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline> underlines) #endif - # BackForward messages. + # BackForward messages BackForwardAddItem(uint64_t itemID) BackForwardGoToItem(uint64_t itemID) BackForwardItemAtIndex(int32_t itemIndex) -> (uint64_t itemID) @@ -129,64 +131,67 @@ messages -> WebPageProxy { BackForwardForwardListCount() -> (int32_t count) BackForwardClear() - # Undo/Redo messages. + # Undo/Redo messages RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction) ClearAllEditCommands() - # Selection messages. + # Selection messages SelectionStateChanged(WebKit::SelectionState selectionState) #if PLATFORM(WIN) DidChangeCompositionSelection(bool hasChanged) #endif - # Find messages. + # Find messages DidCountStringMatches(WTF::String string, uint32_t matchCount) SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut) DidFindString(WTF::String string, uint32_t matchCount) DidFailToFindString(WTF::String string) - # PopupMenu messages. + # PopupMenu messages ShowPopupMenu(WebCore::IntRect rect, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data) HidePopupMenu() - # ContextMenu messages. + # ContextMenu messages ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::ContextMenuState state, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData) #if USE(ACCELERATED_COMPOSITING) - # Accelerated compositing messages. + # Accelerated compositing messages DidChangeAcceleratedCompositing(bool compositing) -> (WebKit::DrawingAreaInfo newDrawingArea) #endif - # Authentication messages. + # Authentication messages CanAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, WebCore::ProtectionSpace protectionSpace) -> (bool canAuthenticate) DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID) - # Database messages. + # Database messages ExceededDatabaseQuota(uint64_t frameID, WTF::String originIdentifier, WTF::String databaseName, WTF::String databaseDisplayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage) -> (uint64_t newQuota) - # Geolocation messages. + # Geolocation messages RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier) - # Plug-in complex text input support messages. #if PLATFORM(MAC) + # Plug-in complex text input support messages SetComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) #endif - # Speech messages. #if PLATFORM(MAC) + # Speech messages GetIsSpeaking() -> (bool isSpeaking) Speak(WTF::String string) StopSpeaking() #endif - # Spelling and grammar. + # Spelling and grammar messages CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results) UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord) GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses) LearnWord(WTF::String word); IgnoreWord(WTF::String word); - # Drag and drop. + # Drag and drop messages DidPerformDragControllerAction(uint64_t resultOperation) +#if PLATFORM(MAC) + SetDragImage(WebCore::IntPoint clientPosition, WebCore::IntSize imageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag) +#endif } diff --git a/Source/WebKit2/UIProcess/WebUIClient.cpp b/Source/WebKit2/UIProcess/WebUIClient.cpp index e95af34..9f2c7ab 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.cpp +++ b/Source/WebKit2/UIProcess/WebUIClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -273,4 +273,57 @@ bool WebUIClient::decidePolicyForGeolocationPermissionRequest(WebPageProxy* page return true; } +float WebUIClient::headerHeight(WebPageProxy* page, WebFrameProxy* frame) +{ + if (!m_client.headerHeight) + return 0; + + return m_client.headerHeight(toAPI(page), toAPI(frame), m_client.clientInfo); +} + +float WebUIClient::footerHeight(WebPageProxy* page, WebFrameProxy* frame) +{ + if (!m_client.footerHeight) + return 0; + + return m_client.footerHeight(toAPI(page), toAPI(frame), m_client.clientInfo); +} + +void WebUIClient::drawHeader(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + if (!m_client.drawHeader) + return; + + m_client.drawHeader(toAPI(page), toAPI(frame), toAPI(rect), m_client.clientInfo); +} + +void WebUIClient::drawFooter(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + if (!m_client.drawFooter) + return; + + m_client.drawFooter(toAPI(page), toAPI(frame), toAPI(rect), m_client.clientInfo); +} + +void WebUIClient::printFrame(WebPageProxy* page, WebFrameProxy* frame) +{ + if (!m_client.printFrame) + return; + + m_client.printFrame(toAPI(page), toAPI(frame), m_client.clientInfo); +} + +bool WebUIClient::canRunModal() const +{ + return m_client.runModal; +} + +void WebUIClient::runModal(WebPageProxy* page) +{ + if (!m_client.runModal) + return; + + m_client.runModal(toAPI(page), m_client.clientInfo); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebUIClient.h b/Source/WebKit2/UIProcess/WebUIClient.h index a25b37f..b873a8d 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.h +++ b/Source/WebKit2/UIProcess/WebUIClient.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -86,6 +86,16 @@ public: bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebOpenPanelParameters::Data&, WebOpenPanelResultListenerProxy*); bool decidePolicyForGeolocationPermissionRequest(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, GeolocationPermissionRequestProxy*); + + // Printing. + float headerHeight(WebPageProxy*, WebFrameProxy*); + float footerHeight(WebPageProxy*, WebFrameProxy*); + void drawHeader(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&); + void drawFooter(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&); + void printFrame(WebPageProxy*, WebFrameProxy*); + + bool canRunModal() const; + void runModal(WebPageProxy*); }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm index 979f755..eacfefa 100644 --- a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm +++ b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm @@ -28,6 +28,7 @@ #include "CGUtilities.h" #include "ShareableBitmap.h" #include "UpdateInfo.h" +#include "WebPageProxy.h" #include <WebCore/GraphicsContext.h> using namespace WebCore; @@ -36,34 +37,70 @@ namespace WebKit { void BackingStore::paint(PlatformGraphicsContext context, const IntRect& rect) { - ASSERT(m_bitmapContext); + if (m_cgLayer) { + CGContextSaveGState(context); + CGContextClipToRect(context, rect); + + CGContextScaleCTM(context, 1, -1); + CGContextDrawLayerAtPoint(context, CGPointMake(0, -m_size.height()), m_cgLayer.get()); + + CGContextRestoreGState(context); + return; + } + ASSERT(m_bitmapContext); paintBitmapContext(context, m_bitmapContext.get(), rect.location(), rect); } -void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) +CGContextRef BackingStore::backingStoreContext() { - ASSERT(m_size == updateInfo.viewSize); + if (m_cgLayer) + return CGLayerGetContext(m_cgLayer.get()); - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle); - if (!bitmap) - return; + // Try to create a layer. + if (CGContextRef containingWindowContext = m_webPageProxy->containingWindowGraphicsContext()) { + m_cgLayer.adoptCF(CGLayerCreateWithContext(containingWindowContext, NSSizeToCGSize(m_size), 0)); + CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get()); + + CGContextSetBlendMode(layerContext, kCGBlendModeCopy); + + // We want the origin to be in the top left corner so flip the backing store context. + CGContextTranslateCTM(layerContext, 0, m_size.height()); + CGContextScaleCTM(layerContext, 1, -1); + + if (m_bitmapContext) { + // Paint the contents of the bitmap into the layer context. + paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height())); + m_bitmapContext = nullptr; + } + + return layerContext; + } if (!m_bitmapContext) { RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); m_bitmapContext.adoptCF(CGBitmapContextCreate(0, m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); - + + CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy); + // We want the origin to be in the top left corner so flip the backing store context. CGContextTranslateCTM(m_bitmapContext.get(), 0, m_size.height()); CGContextScaleCTM(m_bitmapContext.get(), 1, -1); } - scroll(updateInfo.scrollRect, updateInfo.scrollDelta); + return m_bitmapContext.get(); +} + +void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo) +{ + CGContextRef context = backingStoreContext(); + + scroll(updateInfo.scrollRect, updateInfo.scrollOffset); IntPoint updateRectLocation = updateInfo.updateRectBounds.location(); - GraphicsContext graphicsContext(m_bitmapContext.get()); + GraphicsContext graphicsContext(context); // Paint all update rects. for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) { @@ -75,18 +112,30 @@ void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) } } -void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { - if (scrollDelta.isZero()) + if (scrollOffset.isZero()) return; - CGContextSaveGState(m_bitmapContext.get()); + if (m_cgLayer) { + CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get()); - CGContextClipToRect(m_bitmapContext.get(), scrollRect); + // Scroll the layer by painting it into itself with the given offset. + CGContextSaveGState(layerContext); + CGContextClipToRect(layerContext, scrollRect); + CGContextScaleCTM(layerContext, 1, -1); + CGContextDrawLayerAtPoint(layerContext, CGPointMake(scrollOffset.width(), -m_size.height() - scrollOffset.height()), m_cgLayer.get()); + CGContextRestoreGState(layerContext); - CGPoint destination = CGPointMake(scrollRect.x() + scrollDelta.width(), scrollRect.y() + scrollDelta.height()); - paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect); + return; + } + + ASSERT(m_bitmapContext); + CGContextSaveGState(m_bitmapContext.get()); + CGContextClipToRect(m_bitmapContext.get(), scrollRect); + CGPoint destination = CGPointMake(scrollRect.x() + scrollOffset.width(), scrollRect.y() + scrollOffset.height()); + paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect); CGContextRestoreGState(m_bitmapContext.get()); } diff --git a/Source/WebKit2/UIProcess/mac/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm index ce4c3e6..4d1679f 100644 --- a/Source/WebKit2/UIProcess/mac/WebContextMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm @@ -74,7 +74,8 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para cachePath = reinterpret_cast<CFStringRef>(NSHomeDirectory()); NSURLCache *urlCache = [NSURLCache sharedURLCache]; - + + parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; parameters.nsURLCachePath = fileSystemRepresentation([(NSString *)cachePath.get() stringByStandardizingPath]); parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity]; parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity]; diff --git a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm index 36905fb..cd3e6f1 100644 --- a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm @@ -25,6 +25,7 @@ #include "WebPageProxy.h" +#include "PageClient.h" #include <WebCore/Language.h> #include <wtf/text/StringConcatenate.h> @@ -110,4 +111,9 @@ void WebPageProxy::stopSpeaking() [NSApp stopSpeaking:nil]; } +CGContextRef WebPageProxy::containingWindowGraphicsContext() +{ + return m_pageClient->containingWindowGraphicsContext(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp index 64b9fb5..40e3556 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp @@ -432,28 +432,28 @@ void WebPopupMenuProxyWin::invalidateItem(int index) ::InvalidateRect(m_popup, &r, TRUE); } -// ScrollbarClient - int WebPopupMenuProxyWin::scrollSize(ScrollbarOrientation orientation) const { return ((orientation == VerticalScrollbar) && m_scrollbar) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0; } -void WebPopupMenuProxyWin::setScrollOffsetFromAnimation(const IntPoint& offset) +int WebPopupMenuProxyWin::scrollPosition(Scrollbar*) const { - if (m_scrollbar) - m_scrollbar->setValue(offset.y(), Scrollbar::FromScrollAnimator); + return m_scrollOffset; } -void WebPopupMenuProxyWin::valueChanged(Scrollbar* scrollBar) +void WebPopupMenuProxyWin::setScrollOffset(const IntPoint& offset) +{ + scrollTo(offset.y()); +} + +void WebPopupMenuProxyWin::scrollTo(int offset) { ASSERT(m_scrollbar); if (!m_popup) return; - int offset = scrollBar->value(); - if (m_scrollOffset == offset) return; @@ -720,7 +720,8 @@ LRESULT WebPopupMenuProxyWin::onMouseWheel(HWND hWnd, UINT message, WPARAM wPara else --i; } - scrollbar()->scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i)); + + ScrollableArea::scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i)); return 0; } @@ -922,12 +923,12 @@ bool WebPopupMenuProxyWin::scrollToRevealSelection() int index = focusedIndex(); if (index < m_scrollOffset) { - m_scrollbar->setValue(index, Scrollbar::NotFromScrollAnimator); + ScrollableArea::scrollToYOffsetWithoutAnimation(index); return true; } if (index >= m_scrollOffset + visibleItems()) { - m_scrollbar->setValue(index - visibleItems() + 1, Scrollbar::NotFromScrollAnimator); + ScrollableArea::scrollToYOffsetWithoutAnimation(index - visibleItems() + 1); return true; } diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h index 7a53c2c..d1dc466 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h @@ -30,7 +30,7 @@ #include "WebPopupItem.h" #include "WebPopupMenuProxy.h" #include <WebCore/Scrollbar.h> -#include <WebCore/ScrollbarClient.h> +#include <WebCore/ScrollableArea.h> typedef struct HWND__* HWND; typedef struct HDC__* HDC; @@ -40,7 +40,7 @@ namespace WebKit { class WebView; -class WebPopupMenuProxyWin : public WebPopupMenuProxy, private WebCore::ScrollbarClient { +class WebPopupMenuProxyWin : public WebPopupMenuProxy, private WebCore::ScrollableArea { public: static PassRefPtr<WebPopupMenuProxyWin> create(WebView* webView, WebPopupMenuProxy::Client* client) { @@ -58,13 +58,17 @@ private: WebCore::Scrollbar* scrollbar() const { return m_scrollbar.get(); } - // ScrollBarClient - virtual int scrollSize(WebCore::ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const WebCore::IntPoint&); - virtual void valueChanged(WebCore::Scrollbar*); + // ScrollableArea + virtual int scrollSize(WebCore::ScrollbarOrientation) const; + virtual int scrollPosition(WebCore::Scrollbar*) const; + virtual void setScrollOffset(const WebCore::IntPoint&); virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&); virtual bool isActive() const { return true; } virtual bool scrollbarCornerPresent() const { return false; } + virtual WebCore::Scrollbar* verticalScrollbar() const { return m_scrollbar.get(); } + + // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. + void scrollTo(int offset); static bool registerWindowClass(); static LRESULT CALLBACK WebPopupMenuProxyWndProc(HWND, UINT, WPARAM, LPARAM); diff --git a/Source/WebKit2/UIProcess/win/WebView.cpp b/Source/WebKit2/UIProcess/win/WebView.cpp index 4b3992c..4516f54 100644 --- a/Source/WebKit2/UIProcess/win/WebView.cpp +++ b/Source/WebKit2/UIProcess/win/WebView.cpp @@ -591,6 +591,12 @@ void WebView::displayView() ::UpdateWindow(m_window); } +void WebView::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset) +{ + // FIXME: Actually scroll the view contents. + setViewNeedsDisplay(scrollRect); +} + WebCore::IntSize WebView::viewSize() { RECT clientRect; diff --git a/Source/WebKit2/UIProcess/win/WebView.h b/Source/WebKit2/UIProcess/win/WebView.h index c80334e..dfb5ed1 100644 --- a/Source/WebKit2/UIProcess/win/WebView.h +++ b/Source/WebKit2/UIProcess/win/WebView.h @@ -107,6 +107,7 @@ private: virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); virtual void setViewNeedsDisplay(const WebCore::IntRect&); virtual void displayView(); + virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual WebCore::IntSize viewSize(); virtual bool isViewWindowActive(); diff --git a/Source/WebKit2/WebKit2.pro b/Source/WebKit2/WebKit2.pro index f4e007b..c478636 100644 --- a/Source/WebKit2/WebKit2.pro +++ b/Source/WebKit2/WebKit2.pro @@ -7,15 +7,15 @@ isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../.. CONFIG(standalone_package) { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = $$PWD/generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../WebCore/generated } else { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../WebCore/generated } include($$PWD/../../WebKit.pri) include($$PWD/../../common.pri) -include($$PWD/../../Source/WebCore/features.pri) +include($$PWD/../WebCore/features.pri) include(WebKit2.pri) TEMPLATE = lib @@ -34,89 +34,88 @@ DESTDIR = $$WEBKIT2_DESTDIR mac: CONFIG += build_all WEBKIT2_INCLUDEPATH = \ - $$PWD/../.. \ # FIXME: Remove this include once we move all the source to Source. - $$PWD/../../Source \ + $$PWD/.. \ WEBKIT2_INCLUDEPATH = \ - $$PWD/../../Source/JavaScriptCore \ - $$PWD/../../Source/JavaScriptCore/assembler \ - $$PWD/../../Source/JavaScriptCore/bytecode \ - $$PWD/../../Source/JavaScriptCore/bytecompiler \ - $$PWD/../../Source/JavaScriptCore/debugger \ - $$PWD/../../Source/JavaScriptCore/interpreter \ - $$PWD/../../Source/JavaScriptCore/jit \ - $$PWD/../../Source/JavaScriptCore/parser \ - $$PWD/../../Source/JavaScriptCore/pcre \ - $$PWD/../../Source/JavaScriptCore/profiler \ - $$PWD/../../Source/JavaScriptCore/runtime \ - $$PWD/../../Source/JavaScriptCore/wtf \ - $$PWD/../../Source/JavaScriptCore/wtf/symbian \ - $$PWD/../../Source/JavaScriptCore/wtf/unicode \ - $$PWD/../../Source/JavaScriptCore/yarr \ - $$PWD/../../Source/JavaScriptCore/API \ - $$PWD/../../Source/JavaScriptCore/ForwardingHeaders \ + $$PWD/../JavaScriptCore \ + $$PWD/../JavaScriptCore/assembler \ + $$PWD/../JavaScriptCore/bytecode \ + $$PWD/../JavaScriptCore/bytecompiler \ + $$PWD/../JavaScriptCore/debugger \ + $$PWD/../JavaScriptCore/interpreter \ + $$PWD/../JavaScriptCore/jit \ + $$PWD/../JavaScriptCore/parser \ + $$PWD/../JavaScriptCore/pcre \ + $$PWD/../JavaScriptCore/profiler \ + $$PWD/../JavaScriptCore/runtime \ + $$PWD/../JavaScriptCore/wtf \ + $$PWD/../JavaScriptCore/wtf/symbian \ + $$PWD/../JavaScriptCore/wtf/unicode \ + $$PWD/../JavaScriptCore/yarr \ + $$PWD/../JavaScriptCore/API \ + $$PWD/../JavaScriptCore/ForwardingHeaders \ $$WEBKIT2_INCLUDEPATH WEBKIT2_INCLUDEPATH = \ - $$PWD/../../Source/WebCore \ - $$PWD/../../Source/WebCore/accessibility \ - $$PWD/../../Source/WebCore/bindings \ - $$PWD/../../Source/WebCore/bindings/generic \ - $$PWD/../../Source/WebCore/bindings/js \ - $$PWD/../../Source/WebCore/bridge \ - $$PWD/../../Source/WebCore/bridge/c \ - $$PWD/../../Source/WebCore/bridge/jsc \ - $$PWD/../../Source/WebCore/css \ - $$PWD/../../Source/WebCore/dom \ - $$PWD/../../Source/WebCore/dom/default \ - $$PWD/../../Source/WebCore/editing \ - $$PWD/../../Source/WebCore/history \ - $$PWD/../../Source/WebCore/html \ - $$PWD/../../Source/WebCore/html/canvas \ - $$PWD/../../Source/WebCore/inspector \ - $$PWD/../../Source/WebCore/loader \ - $$PWD/../../Source/WebCore/loader/appcache \ - $$PWD/../../Source/WebCore/loader/archive \ - $$PWD/../../Source/WebCore/loader/cache \ - $$PWD/../../Source/WebCore/loader/icon \ - $$PWD/../../Source/WebCore/mathml \ - $$PWD/../../Source/WebCore/notifications \ - $$PWD/../../Source/WebCore/page \ - $$PWD/../../Source/WebCore/page/animation \ - $$PWD/../../Source/WebCore/platform \ - $$PWD/../../Source/WebCore/platform/animation \ - $$PWD/../../Source/WebCore/platform/graphics \ - $$PWD/../../Source/WebCore/platform/graphics/filters \ - $$PWD/../../Source/WebCore/platform/graphics/transforms \ - $$PWD/../../Source/WebCore/platform/image-decoders \ - $$PWD/../../Source/WebCore/platform/mock \ - $$PWD/../../Source/WebCore/platform/network \ - $$PWD/../../Source/WebCore/platform/sql \ - $$PWD/../../Source/WebCore/platform/text \ - $$PWD/../../Source/WebCore/platform/text/transcoder \ - $$PWD/../../Source/WebCore/plugins \ - $$PWD/../../Source/WebCore/rendering \ - $$PWD/../../Source/WebCore/rendering/style \ - $$PWD/../../Source/WebCore/storage \ - $$PWD/../../Source/WebCore/svg \ - $$PWD/../../Source/WebCore/svg/animation \ - $$PWD/../../Source/WebCore/svg/graphics \ - $$PWD/../../Source/WebCore/svg/graphics/filters \ - $$PWD/../../Source/WebCore/svg/properties \ - $$PWD/../../Source/WebCore/websockets \ - $$PWD/../../Source/WebCore/wml \ - $$PWD/../../Source/WebCore/workers \ - $$PWD/../../Source/WebCore/xml \ + $$PWD/../WebCore \ + $$PWD/../WebCore/accessibility \ + $$PWD/../WebCore/bindings \ + $$PWD/../WebCore/bindings/generic \ + $$PWD/../WebCore/bindings/js \ + $$PWD/../WebCore/bridge \ + $$PWD/../WebCore/bridge/c \ + $$PWD/../WebCore/bridge/jsc \ + $$PWD/../WebCore/css \ + $$PWD/../WebCore/dom \ + $$PWD/../WebCore/dom/default \ + $$PWD/../WebCore/editing \ + $$PWD/../WebCore/history \ + $$PWD/../WebCore/html \ + $$PWD/../WebCore/html/canvas \ + $$PWD/../WebCore/inspector \ + $$PWD/../WebCore/loader \ + $$PWD/../WebCore/loader/appcache \ + $$PWD/../WebCore/loader/archive \ + $$PWD/../WebCore/loader/cache \ + $$PWD/../WebCore/loader/icon \ + $$PWD/../WebCore/mathml \ + $$PWD/../WebCore/notifications \ + $$PWD/../WebCore/page \ + $$PWD/../WebCore/page/animation \ + $$PWD/../WebCore/platform \ + $$PWD/../WebCore/platform/animation \ + $$PWD/../WebCore/platform/graphics \ + $$PWD/../WebCore/platform/graphics/filters \ + $$PWD/../WebCore/platform/graphics/transforms \ + $$PWD/../WebCore/platform/image-decoders \ + $$PWD/../WebCore/platform/mock \ + $$PWD/../WebCore/platform/network \ + $$PWD/../WebCore/platform/sql \ + $$PWD/../WebCore/platform/text \ + $$PWD/../WebCore/platform/text/transcoder \ + $$PWD/../WebCore/plugins \ + $$PWD/../WebCore/rendering \ + $$PWD/../WebCore/rendering/style \ + $$PWD/../WebCore/storage \ + $$PWD/../WebCore/svg \ + $$PWD/../WebCore/svg/animation \ + $$PWD/../WebCore/svg/graphics \ + $$PWD/../WebCore/svg/graphics/filters \ + $$PWD/../WebCore/svg/properties \ + $$PWD/../WebCore/websockets \ + $$PWD/../WebCore/wml \ + $$PWD/../WebCore/workers \ + $$PWD/../WebCore/xml \ $$WEBKIT2_INCLUDEPATH WEBKIT2_INCLUDEPATH = \ - $$PWD/../../Source/WebCore/bridge/qt \ - $$PWD/../../Source/WebCore/page/qt \ - $$PWD/../../Source/WebCore/platform/graphics/qt \ - $$PWD/../../Source/WebCore/platform/network/qt \ - $$PWD/../../Source/WebCore/platform/qt \ - $$PWD/../../WebKit/qt/Api \ - $$PWD/../../WebKit/qt/WebCoreSupport \ + $$PWD/../WebCore/bridge/qt \ + $$PWD/../WebCore/page/qt \ + $$PWD/../WebCore/platform/graphics/qt \ + $$PWD/../WebCore/platform/network/qt \ + $$PWD/../WebCore/platform/qt \ + $$PWD/../WebKit/qt/Api \ + $$PWD/../WebKit/qt/WebCoreSupport \ $$WEBKIT2_INCLUDEPATH WEBKIT2_INCLUDEPATH = \ @@ -171,7 +170,7 @@ symbian { INCLUDEPATH = $$WEBKIT2_INCLUDEPATH $$INCLUDEPATH } -PREFIX_HEADER = $$PWD/../../Source/WebKit2/WebKit2Prefix.h +PREFIX_HEADER = $$PWD/../WebKit2/WebKit2Prefix.h *-g++*:QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER" WEBKIT2_GENERATED_HEADERS = \ diff --git a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj index 20143f5..b83c16c 100644 --- a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj +++ b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj @@ -661,6 +661,9 @@ C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */ = {isa = PBXBuildFile; fileRef = C0E3AA441209E2BA00A49D01 /* Module.h */; }; C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */ = {isa = PBXBuildFile; fileRef = C517388012DF8F4F00EE3F47 /* DragControllerAction.h */; }; C5237F6012441CA300780472 /* WebEditorClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C5237F5F12441CA300780472 /* WebEditorClientMac.mm */; }; + C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C554FFA212E4E8EA002F22C0 /* WebDragClientMac.mm */; }; + C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = C574A57F12E66681002DFE98 /* PasteboardTypes.h */; }; + C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = C574A58012E66681002DFE98 /* PasteboardTypes.mm */; }; D3B9484611FF4B6500032B39 /* WebPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */; }; D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484311FF4B6500032B39 /* WebPopupMenu.h */; }; D3B9484811FF4B6500032B39 /* WebSearchPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */; }; @@ -1421,6 +1424,9 @@ C0E3AA481209E45000A49D01 /* ModuleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModuleMac.mm; sourceTree = "<group>"; }; C517388012DF8F4F00EE3F47 /* DragControllerAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragControllerAction.h; sourceTree = "<group>"; }; C5237F5F12441CA300780472 /* WebEditorClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebEditorClientMac.mm; sourceTree = "<group>"; }; + C554FFA212E4E8EA002F22C0 /* WebDragClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDragClientMac.mm; sourceTree = "<group>"; }; + C574A57F12E66681002DFE98 /* PasteboardTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardTypes.h; sourceTree = "<group>"; }; + C574A58012E66681002DFE98 /* PasteboardTypes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteboardTypes.mm; sourceTree = "<group>"; }; D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPopupMenu.cpp; sourceTree = "<group>"; }; D3B9484311FF4B6500032B39 /* WebPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenu.h; sourceTree = "<group>"; }; D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSearchPopupMenu.cpp; sourceTree = "<group>"; }; @@ -2267,6 +2273,7 @@ BC111ADE112F5B9A00337BAB /* mac */ = { isa = PBXGroup; children = ( + C554FFA212E4E8EA002F22C0 /* WebDragClientMac.mm */, 51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */, F6A25FD812ADC6BD00DC40CC /* WebDatabaseManagerMac.mm */, C5237F5F12441CA300780472 /* WebEditorClientMac.mm */, @@ -2322,6 +2329,8 @@ BC111B5A112F628200337BAB /* mac */ = { isa = PBXGroup; children = ( + C574A57F12E66681002DFE98 /* PasteboardTypes.h */, + C574A58012E66681002DFE98 /* PasteboardTypes.mm */, 1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */, C02BFF1D1251502E009CCBEA /* NativeWebKeyboardEventMac.mm */, BCF505E61243047B005955AE /* PlatformCertificateInfo.mm */, @@ -3059,6 +3068,7 @@ 1A64256812DE42EC00CAAE2C /* BackingStore.h in Headers */, C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */, 1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */, + C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3520,6 +3530,8 @@ 1A64256912DE42EC00CAAE2C /* BackingStore.cpp in Sources */, 1A64292D12DE5F9800CAAE2C /* BackingStoreMac.mm in Sources */, 1AA2E51E12E4C05E00BC4966 /* CGUtilities.cpp in Sources */, + C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */, + C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/WebKit2/WebKit2Prefix.h b/Source/WebKit2/WebKit2Prefix.h index 19bee7f..7ed70cb 100644 --- a/Source/WebKit2/WebKit2Prefix.h +++ b/Source/WebKit2/WebKit2Prefix.h @@ -58,6 +58,10 @@ static const type& name() \ #define JS_EXPORTDATA #define JS_EXPORTCLASS +// Disable notImplemented() warnings not to break layout tests. +// FIXME: WebKit2 logging system should behave identical to WebKit1. +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 + #elif defined(__APPLE__) #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) diff --git a/Source/WebKit2/WebProcess/Downloads/Download.h b/Source/WebKit2/WebProcess/Downloads/Download.h index 2319ec7..bacdd01 100644 --- a/Source/WebKit2/WebProcess/Downloads/Download.h +++ b/Source/WebKit2/WebProcess/Downloads/Download.h @@ -63,7 +63,6 @@ class WebPage; class Download : public CoreIPC::MessageSender<Download> { WTF_MAKE_NONCOPYABLE(Download); - public: static PassOwnPtr<Download> create(uint64_t downloadID, const WebCore::ResourceRequest&); ~Download(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index 9410642..f02044c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -85,6 +85,11 @@ JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frameRef) return toImpl(frameRef)->jsContext(); } +WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef context) +{ + return toAPI(WebFrame::frameForContext(context)); +} + JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frameRef, WKBundleScriptWorldRef worldRef) { return toImpl(frameRef)->jsContextForWorld(toImpl(worldRef)); @@ -197,3 +202,8 @@ WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frameRef) return toAPI(view->scrollOffset()); } + +WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) +{ + return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()))); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h index a6a20b2..59c2d75 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h @@ -46,6 +46,8 @@ WK_EXPORT WKURLRef WKBundleFrameCopyProvisionalURL(WKBundleFrameRef frame); WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame); WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frame, WKBundleScriptWorldRef world); +WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef context); + WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world); WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef frame, WKBundleRangeHandleRef rangeHandle, WKBundleScriptWorldRef world); @@ -57,6 +59,8 @@ WK_EXPORT WKRect WKBundleFrameGetContentBounds(WKBundleFrameRef frame); WK_EXPORT WKRect WKBundleFrameGetVisibleContentBounds(WKBundleFrameRef frame); WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frame); +WK_EXPORT WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index 86d913b..bf853d1 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -49,6 +49,11 @@ WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef nodeHandleRef) return toAPI(toImpl(nodeHandleRef)->elementBounds()); } +WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandleRef, bool* isReplaced) +{ + return toAPI(toImpl(nodeHandleRef)->renderRect(isReplaced)); +} + void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandleRef, WKStringRef valueRef) { toImpl(htmlInputElementHandleRef)->setHTMLInputElementValueForUser(toWTFString(valueRef)); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h index 854677b..8953ff8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h @@ -40,6 +40,8 @@ WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCreate(JSContextRef context, J /* Additional DOM Operations */ WK_EXPORT WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef nodeHandle); +WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandle, bool* isReplaced); + /* HTMLInputElement Specific Operations */ WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp index e9370c6..6ee3b31 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp @@ -104,6 +104,11 @@ IntRect InjectedBundleNodeHandle::elementBounds() const return static_cast<Element*>(m_node.get())->boundsInWindowSpace(); } + +IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) const +{ + return m_node.get()->renderRect(isReplaced); +} void InjectedBundleNodeHandle::setHTMLInputElementValueForUser(const String& value) { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h index eff4600..a02f7f2 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h @@ -56,6 +56,7 @@ public: // Additional DOM Operations // Note: These should only be operations that are not exposed to JavaScript. WebCore::IntRect elementBounds() const; + WebCore::IntRect renderRect(bool*) const; void setHTMLInputElementValueForUser(const String&); bool isHTMLInputElementAutofilled() const; void setHTMLInputElementAutofilled(bool); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h index 6737bd4..3518221 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h @@ -40,7 +40,8 @@ namespace WebKit { class NPRuntimeObjectMap; // NPJSObject is an NPObject that wraps a JSObject. -class NPJSObject : public NPObject, Noncopyable { +class NPJSObject : public NPObject { + WTF_MAKE_NONCOPYABLE(NPJSObject); public: static NPJSObject* create(NPRuntimeObjectMap* objectMap, JSC::JSObject* jsObject); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index 566d48d..ba21db1 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -766,10 +766,11 @@ static void NPN_UnscheduleTimer(NPP instance, uint32_t timerID) } #if PLATFORM(MAC) -static NPError NPN_PopUpContextMenu(NPP instance, NPMenu* menu) +static NPError NPN_PopUpContextMenu(NPP npp, NPMenu* menu) { - notImplemented(); - return NPERR_GENERIC_ERROR; + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + + return plugin->popUpContextMenu(menu); } static NPBool NPN_ConvertPoint(NPP npp, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double* destX, double* destY, NPCoordinateSpace destSpace) diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index 0beade2..5674ba5 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -67,6 +67,7 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule) #if PLATFORM(MAC) , m_drawingModel(static_cast<NPDrawingModel>(-1)) , m_eventModel(static_cast<NPEventModel>(-1)) + , m_currentMouseEvent(0) , m_pluginHasFocus(false) , m_windowHasFocus(false) #ifndef NP_NO_CARBON diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index fb5d37e..95ff714 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -54,6 +54,7 @@ public: NPError setDrawingModel(NPDrawingModel); NPError setEventModel(NPEventModel); NPBool convertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double& destX, double& destY, NPCoordinateSpace destSpace); + NPError popUpContextMenu(NPMenu*); #ifndef NP_NO_CARBON WindowRef windowRef() const; @@ -205,6 +206,8 @@ private: NPEventModel m_eventModel; RetainPtr<PlatformLayer> m_pluginLayer; + NPCocoaEvent* m_currentMouseEvent; + bool m_pluginHasFocus; bool m_windowHasFocus; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm index 1240ed7..d57e8d1 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm @@ -157,6 +157,20 @@ NPBool NetscapePlugin::convertPoint(double sourceX, double sourceY, NPCoordinate return true; } + +NPError NetscapePlugin::popUpContextMenu(NPMenu* npMenu) +{ + if (!m_currentMouseEvent) + return NPERR_GENERIC_ERROR; + + double screenX, screenY; + if (!convertPoint(m_currentMouseEvent->data.mouse.pluginX, m_currentMouseEvent->data.mouse.pluginY, NPCoordinateSpacePlugin, screenX, screenY, NPCoordinateSpaceScreen)) + ASSERT_NOT_REACHED(); + + WKPopupContextMenu(reinterpret_cast<NSMenu *>(npMenu), NSMakePoint(screenX, screenY)); + return NPERR_NO_ERROR; +} + #ifndef NP_NO_CARBON typedef HashMap<WindowRef, NetscapePlugin*> WindowMap; @@ -474,7 +488,19 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent) switch (m_eventModel) { case NPEventModelCocoa: { NPCocoaEvent event = initializeMouseEvent(mouseEvent, m_frameRect.location()); - return NPP_HandleEvent(&event); + + NPCocoaEvent* previousMouseEvent = m_currentMouseEvent; + m_currentMouseEvent = &event; + + // Protect against NPP_HandleEvent causing the plug-in to be destroyed, since we + // access m_currentMouseEvent afterwards. + RefPtr<NetscapePlugin> protect(this); + + bool returnValue = NPP_HandleEvent(&event); + + m_currentMouseEvent = previousMouseEvent; + + return returnValue; } #ifndef NP_NO_CARBON diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h index d7ba853..8b60f17 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h @@ -38,7 +38,8 @@ namespace WebKit { class PluginProcessConnection; -class PluginProcessConnectionManager : Noncopyable { +class PluginProcessConnectionManager { + WTF_MAKE_NONCOPYABLE(PluginProcessConnectionManager); public: static PluginProcessConnectionManager& shared(); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index ffca3fa..6da6c6e 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Redistribution and use in source and binary forms, with or without @@ -173,13 +173,12 @@ void WebChromeClient::show() bool WebChromeClient::canRunModal() { - notImplemented(); - return false; + return m_page->canRunModal(); } void WebChromeClient::runModal() { - notImplemented(); + m_page->runModal(); } void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible) @@ -364,16 +363,16 @@ void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool) m_page->drawingArea()->setNeedsDisplay(rect); } -void WebChromeClient::scroll(const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect&) +void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollRect, const IntRect& clipRect) { m_page->pageDidScroll(); - m_page->drawingArea()->scroll(scrollRect, scrollDelta); + m_page->drawingArea()->scroll(intersection(scrollRect, clipRect), scrollOffset); } #if ENABLE(TILED_BACKING_STORE) -void WebChromeClient::delegatedScrollRequested(const IntSize& scrollDelta) +void WebChromeClient::delegatedScrollRequested(const IntSize& scrollOffset) { - m_page->pageDidRequestScroll(scrollDelta); + m_page->pageDidRequestScroll(scrollOffset); } #endif @@ -466,9 +465,10 @@ void WebChromeClient::setToolTip(const String& toolTip, TextDirection) m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip)); } -void WebChromeClient::print(Frame*) +void WebChromeClient::print(Frame* frame) { - notImplemented(); + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply()); } #if ENABLE(DATABASE) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h index 44c3658..d749833 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h @@ -107,9 +107,9 @@ private: virtual void invalidateWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); - virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); + virtual void scroll(const WebCore::IntSize& scrollOffset, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); #if ENABLE(TILED_BACKING_STORE) - virtual void delegatedScrollRequested(const WebCore::IntSize& scrollDelta); + virtual void delegatedScrollRequested(const WebCore::IntSize& scrollOffset); #endif virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp index d11017f..e3d401d 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp @@ -50,6 +50,7 @@ DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& win return DragSourceActionAny; } +#if !PLATFORM(MAC) void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) { } @@ -59,6 +60,7 @@ DragImageRef WebDragClient::createDragImageForLink(KURL&, const String&, Frame*) notImplemented(); return 0; } +#endif void WebDragClient::dragControllerDestroyed() { diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h index ce123c8..6f7cf85 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h @@ -48,6 +48,9 @@ private: virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false); virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL&, const String& label, WebCore::Frame*); +#if PLATFORM(MAC) + virtual void declareAndWriteDragImage(NSPasteboard*, DOMElement*, NSURL*, NSString*, WebCore::Frame*); +#endif virtual void dragControllerDestroyed(); WebPage* m_page; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp index 4567f35..49b31ef 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp @@ -63,6 +63,13 @@ static String formatLocalizedString(String format, ...) RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments)); va_end(arguments); return result.get(); +#elif PLATFORM(QT) + va_list arguments; + va_start(arguments, format); + QString result; + result.vsprintf(format.latin1().data(), arguments); + va_end(arguments); + return result; #else notImplemented(); return format; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm new file mode 100644 index 0000000..9952e3f --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2011 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. + * + * 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. + */ + +#import "PasteboardTypes.h" +#import "ShareableBitmap.h" +#import "WebCoreArgumentCoders.h" +#import "WebDragClient.h" +#import "WebPage.h" +#import "WebPageProxyMessages.h" +#import <WebCore/CachedImage.h> +#import <WebCore/DOMPrivate.h> +#import <WebCore/DOMElementInternal.h> +#import <WebCore/FrameView.h> +#import <WebCore/GraphicsContext.h> +#import <WebCore/LegacyWebArchive.h> +#import <WebCore/RenderImage.h> +#import <WebCore/StringTruncator.h> +#import <wtf/StdLibExtras.h> +#import <WebKit/WebKitNSStringExtras.h> +#import <WebKit/WebNSURLExtras.h> + +using namespace WebCore; + +namespace WebKit { + +const float DragLabelBorderX = 4; +//Keep border_y in synch with DragController::LinkDragBorderInset +const float DragLabelBorderY = 2; +const float DragLabelRadius = 5; +const float LabelBorderYOffset = 2; + +const float MinDragLabelWidthBeforeClip = 120; +const float MaxDragLabelWidth = 320; + +const float DragLinkLabelFontsize = 11; +const float DragLinkUrlFontSize = 10; + +using namespace WebCore; + +static Font& fontFromNSFont(NSFont *font) +{ + static NSFont *currentFont; + DEFINE_STATIC_LOCAL(Font, currentRenderer, ()); + + if ([font isEqual:currentFont]) + return currentRenderer; + if (currentFont) + CFRelease(currentFont); + currentFont = font; + CFRetain(currentFont); + currentRenderer = Font(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]); + return currentRenderer; +} + +void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag) +{ + if (!frame) + return; + ASSERT(clipboard); + + NSImage *dragNSImage = dragImage.get(); + RefPtr<ShareableBitmap> dragShareableImage = ShareableBitmap::createShareable(IntSize([dragNSImage size])); + OwnPtr<GraphicsContext> graphicsContext = dragShareableImage->createGraphicsContext(); + + [NSGraphicsContext saveGraphicsState]; + NSGraphicsContext* bitmapContext = [NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]; + [NSGraphicsContext setCurrentContext: bitmapContext]; + + [dragNSImage drawInRect:NSMakeRect(0, 0, [dragNSImage size].width , [dragNSImage size].height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; + [NSGraphicsContext restoreGraphicsState]; + + SharedMemory::Handle handle; + if (!dragShareableImage->createHandle(handle)) + return; + IntPoint clientPoint(at); + m_page->send(Messages::WebPageProxy::SetDragImage(clientPoint, IntSize([dragNSImage size]), handle, linkDrag)); +} + +DragImageRef WebDragClient::createDragImageForLink(KURL& url, const String& title, Frame* frame) +{ + if (!frame) + return nil; + NSString *label = 0; + if (!title.isEmpty()) + label = title; + NSURL *cocoaURL = url; + NSString *urlString = [cocoaURL _web_userVisibleString]; + + BOOL drawURLString = YES; + BOOL clipURLString = NO; + BOOL clipLabelString = NO; + + if (!label) { + drawURLString = NO; + label = urlString; + } + + NSFont *labelFont = [[NSFontManager sharedFontManager] convertFont:[NSFont systemFontOfSize:DragLinkLabelFontsize] + toHaveTrait:NSBoldFontMask]; + NSFont *urlFont = [NSFont systemFontOfSize:DragLinkUrlFontSize]; + NSSize labelSize; + labelSize.width = [label _web_widthWithFont: labelFont]; + labelSize.height = [labelFont ascender] - [labelFont descender]; + if (labelSize.width > MaxDragLabelWidth){ + labelSize.width = MaxDragLabelWidth; + clipLabelString = YES; + } + + NSSize imageSize; + imageSize.width = labelSize.width + DragLabelBorderX * 2; + imageSize.height = labelSize.height + DragLabelBorderY * 2; + if (drawURLString) { + NSSize urlStringSize; + urlStringSize.width = [urlString _web_widthWithFont: urlFont]; + urlStringSize.height = [urlFont ascender] - [urlFont descender]; + imageSize.height += urlStringSize.height; + if (urlStringSize.width > MaxDragLabelWidth) { + imageSize.width = max(MaxDragLabelWidth + DragLabelBorderY * 2, MinDragLabelWidthBeforeClip); + clipURLString = YES; + } else + imageSize.width = max(labelSize.width + DragLabelBorderX * 2, urlStringSize.width + DragLabelBorderX * 2); + } + NSImage *dragImage = [[[NSImage alloc] initWithSize: imageSize] autorelease]; + [dragImage lockFocus]; + + [[NSColor colorWithDeviceRed: 0.7f green: 0.7f blue: 0.7f alpha: 0.8f] set]; + + // Drag a rectangle with rounded corners + NSBezierPath *path = [NSBezierPath bezierPath]; + [path appendBezierPathWithOvalInRect: NSMakeRect(0, 0, DragLabelRadius * 2, DragLabelRadius * 2)]; + [path appendBezierPathWithOvalInRect: NSMakeRect(0, imageSize.height - DragLabelRadius * 2, DragLabelRadius * 2, DragLabelRadius * 2)]; + [path appendBezierPathWithOvalInRect: NSMakeRect(imageSize.width - DragLabelRadius * 2, imageSize.height - DragLabelRadius * 2, DragLabelRadius * 2, DragLabelRadius * 2)]; + [path appendBezierPathWithOvalInRect: NSMakeRect(imageSize.width - DragLabelRadius * 2, 0, DragLabelRadius * 2, DragLabelRadius * 2)]; + + [path appendBezierPathWithRect: NSMakeRect(DragLabelRadius, 0, imageSize.width - DragLabelRadius * 2, imageSize.height)]; + [path appendBezierPathWithRect: NSMakeRect(0, DragLabelRadius, DragLabelRadius + 10, imageSize.height - 2 * DragLabelRadius)]; + [path appendBezierPathWithRect: NSMakeRect(imageSize.width - DragLabelRadius - 20, DragLabelRadius, DragLabelRadius + 20, imageSize.height - 2 * DragLabelRadius)]; + [path fill]; + + NSColor *topColor = [NSColor colorWithDeviceWhite:0.0f alpha:0.75f]; + NSColor *bottomColor = [NSColor colorWithDeviceWhite:1.0f alpha:0.5f]; + if (drawURLString) { + if (clipURLString) + //urlString = [WebStringTruncator centerTruncateString: urlString toWidth:imageSize.width - (DragLabelBorderX * 2) withFont:urlFont]; + urlString = StringTruncator::centerTruncate(urlString, imageSize.width - (DragLabelBorderX * 2), fontFromNSFont(urlFont)); + [urlString _web_drawDoubledAtPoint:NSMakePoint(DragLabelBorderX, DragLabelBorderY - [urlFont descender]) + withTopColor:topColor bottomColor:bottomColor font:urlFont]; + } + + if (clipLabelString) + //label = [WebStringTruncator rightTruncateString: label toWidth:imageSize.width - (DragLabelBorderX * 2) withFont:labelFont]; + label = StringTruncator::rightTruncate(label, imageSize.width - (DragLabelBorderX * 2), fontFromNSFont(labelFont)); + [label _web_drawDoubledAtPoint:NSMakePoint (DragLabelBorderX, imageSize.height - LabelBorderYOffset - [labelFont pointSize]) + withTopColor:topColor bottomColor:bottomColor font:labelFont]; + + [dragImage unlockFocus]; + + return dragImage; +} + +static void writeURL(NSPasteboard* pasteboard, NSURL* URL, NSString* title, NSArray* types) +{ + ASSERT(URL); + + if (![title length]) { + title = [[URL path] lastPathComponent]; + if (![title length]) + title = [URL _web_userVisibleString]; + } + + if ([types containsObject:NSURLPboardType]) + [URL writeToPasteboard:pasteboard]; + if ([types containsObject:PasteboardTypes::WebURLPboardType]) + [pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType]; + if ([types containsObject:PasteboardTypes::WebURLNamePboardType]) + [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType]; + if ([types containsObject:NSStringPboardType]) + [pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType]; + if ([types containsObject:PasteboardTypes::WebURLsWithTitlesPboardType]) { + NSArray* URLs = [NSArray arrayWithObject:URL]; + unsigned count = [URLs count]; + + if (!count || [pasteboard availableTypeFromArray:[NSArray arrayWithObject:PasteboardTypes::WebURLsWithTitlesPboardType]] == nil) + return; + + NSArray* titles = [NSArray arrayWithObject:title]; + + if (count != [titles count]) + titles = nil; + + NSMutableArray* URLStrings = [NSMutableArray arrayWithCapacity:count]; + NSMutableArray* titlesOrEmptyStrings = [NSMutableArray arrayWithCapacity:count]; + for (unsigned index = 0; index < count; ++index) { + [URLStrings addObject:[[URLs objectAtIndex:index] _web_originalDataAsString]]; + [titlesOrEmptyStrings addObject:(titles == nil) ? @"" : [[titles objectAtIndex:index] _webkit_stringByTrimmingWhitespace]]; + } + + [pasteboard setPropertyList:[NSArray arrayWithObjects:URLStrings, titlesOrEmptyStrings, nil] + forType:PasteboardTypes::WebURLsWithTitlesPboardType]; + } +} + +static void writeImage(NSPasteboard* pasteboard, NSImage *image, DOMElement* element, NSURL* URL, NSString* title, LegacyWebArchive* archive, NSArray* types) +{ + ASSERT(image || element); + ASSERT(URL); + + writeURL(pasteboard, URL, title, types); + + if ([types containsObject:NSTIFFPboardType]) { + // FIXME: we should add handling of promised types. + if (image) + [pasteboard setData:[image TIFFRepresentation] forType:NSTIFFPboardType]; + else if (element) + [pasteboard setData:[element _imageTIFFRepresentation] forType:NSTIFFPboardType]; + } + + if (archive && [types containsObject:PasteboardTypes::WebArchivePboardType]) + [pasteboard setData:[[(NSData *)archive->rawDataRepresentation().get() retain] autorelease] forType:PasteboardTypes::WebArchivePboardType]; +} + +void WebDragClient::declareAndWriteDragImage(NSPasteboard* pasteboard, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame*) +{ + ASSERT(element); + ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]); + + NSString *extension = @""; + if (RenderObject* renderer = core(element)->renderer()) { + if (renderer->isImage()) { + if (CachedImage* image = toRenderImage(renderer)->cachedImage()) { + extension = image->image()->filenameExtension(); + if (![extension length]) + return; + } + } + } + + RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(core(element)); + NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]; + [types addObjectsFromArray:(archive) ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; + [pasteboard declareTypes:types owner:nil]; + writeImage(pasteboard, nil, element, URL, title, archive.get(), types); + [types release]; + + NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil]; + [pasteboard setPropertyList:extensions forType:NSFilesPromisePboardType]; + [extensions release]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm index 90b9a64..f81b627 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -93,6 +93,8 @@ void InitWebCoreSystemInterface(void) #if !defined(BUILDING_ON_SNOW_LEOPARD) INIT(CreateCTTypesetterWithUniCharProviderAndOptions); + INIT(MakeScrollbarPainter); + INIT(ScrollbarPainterPaint); #else INIT(GetHyphenationLocationBeforeIndex); #endif diff --git a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp index 513621c..d629ced 100644 --- a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp +++ b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp @@ -49,7 +49,7 @@ ChunkedUpdateDrawingArea::~ChunkedUpdateDrawingArea() { } -void ChunkedUpdateDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void ChunkedUpdateDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { // FIXME: Do something much smarter. setNeedsDisplay(scrollRect); diff --git a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h index ac4b424..08aa3e7 100644 --- a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h @@ -40,7 +40,7 @@ public: virtual ~ChunkedUpdateDrawingArea(); virtual void setNeedsDisplay(const WebCore::IntRect&); - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual void display(); #if USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp index 3b76aaf..ea5b443 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp @@ -40,31 +40,33 @@ #include "TiledDrawingArea.h" #endif +#include "WebPageCreationParameters.h" + namespace WebKit { -PassRefPtr<DrawingArea> DrawingArea::create(DrawingAreaInfo::Type type, DrawingAreaInfo::Identifier identifier, WebPage* webPage) +PassRefPtr<DrawingArea> DrawingArea::create(WebPage* webPage, const WebPageCreationParameters& parameters) { - switch (type) { + switch (parameters.drawingAreaInfo.type) { case DrawingAreaInfo::None: ASSERT_NOT_REACHED(); break; case DrawingAreaInfo::Impl: #ifdef __APPLE__ - return DrawingAreaImpl::create(identifier, webPage); + return DrawingAreaImpl::create(webPage, parameters); #else return 0; #endif case DrawingAreaInfo::ChunkedUpdate: - return adoptRef(new ChunkedUpdateDrawingArea(identifier, webPage)); + return adoptRef(new ChunkedUpdateDrawingArea(parameters.drawingAreaInfo.identifier, webPage)); #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) case DrawingAreaInfo::LayerBacked: - return adoptRef(new LayerBackedDrawingArea(identifier, webPage)); + return adoptRef(new LayerBackedDrawingArea(parameters.drawingAreaInfo.identifier, webPage)); #endif #if ENABLE(TILED_BACKING_STORE) case DrawingAreaInfo::Tiled: - return adoptRef(new TiledDrawingArea(identifier, webPage)); + return adoptRef(new TiledDrawingArea(parameters.drawingAreaInfo.identifier, webPage)); #endif } diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h index 75f0b00..713994d 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h @@ -40,11 +40,12 @@ namespace WebCore { namespace WebKit { class WebPage; +class WebPageCreationParameters; class DrawingArea : public RefCounted<DrawingArea> { public: // FIXME: It might make sense to move this create function into a factory style class. - static PassRefPtr<DrawingArea> create(DrawingAreaInfo::Type, DrawingAreaInfo::Identifier, WebPage*); + static PassRefPtr<DrawingArea> create(WebPage*, const WebPageCreationParameters&); virtual ~DrawingArea(); #ifdef __APPLE__ @@ -52,7 +53,7 @@ public: #endif virtual void setNeedsDisplay(const WebCore::IntRect&) = 0; - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) = 0; + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0; virtual void pageBackgroundTransparencyChanged() { } @@ -81,6 +82,8 @@ private: // FIXME: These should be pure virtual. virtual void setSize(const WebCore::IntSize&) { } virtual void didUpdate() { } + virtual void suspendPainting() { } + virtual void resumePainting() { } }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in b/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in index 6c628fb..682ef5a 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in @@ -22,5 +22,7 @@ messages -> DrawingArea { SetSize(WebCore::IntSize size) - DidUpdate() + DidUpdate() + SuspendPainting() + ResumePainting() } diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp index ab4655a..2063bd6 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -29,6 +29,7 @@ #include "ShareableBitmap.h" #include "UpdateInfo.h" #include "WebPage.h" +#include "WebPageCreationParameters.h" #include "WebProcess.h" #include <WebCore/GraphicsContext.h> @@ -40,18 +41,19 @@ using namespace WebCore; namespace WebKit { -PassRefPtr<DrawingAreaImpl> DrawingAreaImpl::create(DrawingAreaInfo::Identifier identifier, WebPage* webPage) +PassRefPtr<DrawingAreaImpl> DrawingAreaImpl::create(WebPage* webPage, const WebPageCreationParameters& parameters) { - return adoptRef(new DrawingAreaImpl(identifier, webPage)); + return adoptRef(new DrawingAreaImpl(webPage, parameters)); } DrawingAreaImpl::~DrawingAreaImpl() { } -DrawingAreaImpl::DrawingAreaImpl(DrawingAreaInfo::Identifier identifier, WebPage* webPage) - : DrawingArea(DrawingAreaInfo::Impl, identifier, webPage) +DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParameters& parameters) + : DrawingArea(DrawingAreaInfo::Impl, parameters.drawingAreaInfo.identifier, webPage) , m_isWaitingForDidUpdate(false) + , m_isPaintingSuspended(!parameters.isVisible) , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display) { } @@ -65,7 +67,7 @@ void DrawingAreaImpl::setNeedsDisplay(const IntRect& rect) scheduleDisplay(); } -void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { if (!m_scrollRect.isEmpty() && scrollRect != m_scrollRect) { unsigned scrollArea = scrollRect.width() * scrollRect.height(); @@ -81,7 +83,7 @@ void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDel // Just repaint the entire current scroll rect, we'll scroll the new rect instead. setNeedsDisplay(m_scrollRect); m_scrollRect = IntRect(); - m_scrollDelta = IntSize(); + m_scrollOffset = IntSize(); } // Get the part of the dirty region that is in the scroll rect. @@ -92,19 +94,19 @@ void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDel m_dirtyRegion.subtract(scrollRect); // Move the dirty parts. - Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect); + Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollOffset), scrollRect); // And add them back. m_dirtyRegion.unite(movedDirtyRegionInScrollRect); } // Compute the scroll repaint region. - Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta)); + Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollOffset)); m_dirtyRegion.unite(scrollRepaintRegion); m_scrollRect = scrollRect; - m_scrollDelta += scrollDelta; + m_scrollOffset += scrollOffset; } void DrawingAreaImpl::attachCompositingContext() @@ -139,9 +141,15 @@ void DrawingAreaImpl::setSize(const IntSize& size) m_webPage->setSize(size); m_webPage->layoutIfNeeded(); - // FIXME: Repaint. + UpdateInfo updateInfo; + + if (m_isPaintingSuspended) { + updateInfo.timestamp = currentTime(); + updateInfo.viewSize = m_webPage->size(); + } else + display(updateInfo); - m_webPage->send(Messages::DrawingAreaProxy::DidSetSize()); + m_webPage->send(Messages::DrawingAreaProxy::DidSetSize(updateInfo)); } void DrawingAreaImpl::didUpdate() @@ -152,11 +160,31 @@ void DrawingAreaImpl::didUpdate() display(); } +void DrawingAreaImpl::suspendPainting() +{ + ASSERT(!m_isPaintingSuspended); + + m_isPaintingSuspended = true; + m_displayTimer.stop(); +} + +void DrawingAreaImpl::resumePainting() +{ + ASSERT(m_isPaintingSuspended); + + m_isPaintingSuspended = false; + + // FIXME: Repaint if needed. +} + void DrawingAreaImpl::scheduleDisplay() { if (m_isWaitingForDidUpdate) return; + if (m_isPaintingSuspended) + return; + if (m_dirtyRegion.isEmpty()) return; @@ -168,6 +196,11 @@ void DrawingAreaImpl::scheduleDisplay() void DrawingAreaImpl::display() { + ASSERT(!m_isWaitingForDidUpdate); + + if (m_isPaintingSuspended) + return; + if (m_dirtyRegion.isEmpty()) return; @@ -201,6 +234,8 @@ static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect>& void DrawingAreaImpl::display(UpdateInfo& updateInfo) { + ASSERT(!m_isPaintingSuspended); + // FIXME: It would be better if we could avoid painting altogether when there is a custom representation. if (m_webPage->mainFrameHasCustomRepresentation()) return; @@ -214,11 +249,11 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) } updateInfo.scrollRect = m_scrollRect; - updateInfo.scrollDelta = m_scrollDelta; + updateInfo.scrollOffset = m_scrollOffset; m_dirtyRegion = Region(); m_scrollRect = IntRect(); - m_scrollDelta = IntSize(); + m_scrollOffset = IntSize(); RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size()); if (!bitmap->createHandle(updateInfo.bitmapHandle)) @@ -228,6 +263,7 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) m_webPage->layoutIfNeeded(); + updateInfo.timestamp = currentTime(); updateInfo.viewSize = m_webPage->size(); updateInfo.updateRectBounds = bounds; diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h index 1f1b2e2..e008adc 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h @@ -36,15 +36,15 @@ struct UpdateInfo; class DrawingAreaImpl : public DrawingArea { public: - static PassRefPtr<DrawingAreaImpl> create(DrawingAreaInfo::Identifier, WebPage*); + static PassRefPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&); virtual ~DrawingAreaImpl(); private: - DrawingAreaImpl(DrawingAreaInfo::Identifier, WebPage*); + DrawingAreaImpl(WebPage*, const WebPageCreationParameters&); // DrawingArea virtual void setNeedsDisplay(const WebCore::IntRect&); - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual void attachCompositingContext(); virtual void detachCompositingContext(); virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); @@ -55,6 +55,8 @@ private: // CoreIPC message handlers. virtual void setSize(const WebCore::IntSize&); virtual void didUpdate(); + virtual void suspendPainting(); + virtual void resumePainting(); void scheduleDisplay(); void display(); @@ -62,12 +64,16 @@ private: Region m_dirtyRegion; WebCore::IntRect m_scrollRect; - WebCore::IntSize m_scrollDelta; + WebCore::IntSize m_scrollOffset; // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the // web process won't paint more frequent than the UI process can handle. bool m_isWaitingForDidUpdate; - + + // Whether painting is suspended. We'll still keep track of the dirty region but we + // won't paint until painting has resumed again. + bool m_isPaintingSuspended; + RunLoop::Timer<DrawingAreaImpl> m_displayTimer; }; diff --git a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp index 8a81cca..b104b29 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp +++ b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp @@ -34,6 +34,8 @@ #include "WebPage.h" #include "WebProcess.h" #include <WebCore/GraphicsLayer.h> +#include <WebCore/Page.h> +#include <WebCore/Settings.h> using namespace WebCore; @@ -45,6 +47,12 @@ LayerBackedDrawingArea::LayerBackedDrawingArea(DrawingAreaInfo::Identifier ident , m_attached(false) , m_shouldPaint(true) { + m_hostingLayer = GraphicsLayer::create(this); + m_hostingLayer->setDrawsContent(false); +#ifndef NDEBUG + m_hostingLayer->setName("DrawingArea hosting layer"); +#endif + m_hostingLayer->setSize(webPage->size()); m_backingLayer = GraphicsLayer::create(this); m_backingLayer->setDrawsContent(true); m_backingLayer->setContentsOpaque(webPage->drawsBackground() && !webPage->drawsTransparentBackground()); @@ -53,6 +61,7 @@ LayerBackedDrawingArea::LayerBackedDrawingArea(DrawingAreaInfo::Identifier ident m_backingLayer->setName("DrawingArea backing layer"); #endif m_backingLayer->setSize(webPage->size()); + m_hostingLayer->addChild(m_backingLayer.get()); platformInit(); } @@ -61,7 +70,7 @@ LayerBackedDrawingArea::~LayerBackedDrawingArea() platformClear(); } -void LayerBackedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void LayerBackedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { // FIXME: Do something much smarter. setNeedsDisplay(scrollRect); @@ -99,6 +108,7 @@ void LayerBackedDrawingArea::setSize(const IntSize& viewSize) ASSERT(m_shouldPaint); ASSERT_ARG(viewSize, !viewSize.isEmpty()); + m_hostingLayer->setSize(viewSize); m_backingLayer->setSize(viewSize); scheduleCompositingLayerSync(); @@ -183,14 +193,12 @@ void LayerBackedDrawingArea::paintContents(const GraphicsLayer*, GraphicsContext bool LayerBackedDrawingArea::showDebugBorders() const { - // FIXME: get from settings; - return false; + return m_webPage->corePage()->settings()->showDebugBorders(); } bool LayerBackedDrawingArea::showRepaintCounter() const { - // FIXME: get from settings; - return false; + return m_webPage->corePage()->settings()->showRepaintCounter(); } #if !PLATFORM(MAC) && !PLATFORM(WIN) diff --git a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h index 1b49de2..ed05cc7 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h @@ -56,7 +56,7 @@ public: virtual ~LayerBackedDrawingArea(); virtual void setNeedsDisplay(const WebCore::IntRect&); - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual void display(); virtual void pageBackgroundTransparencyChanged(); @@ -106,6 +106,7 @@ private: RunLoop::Timer<LayerBackedDrawingArea> m_syncTimer; + OwnPtr<WebCore::GraphicsLayer> m_hostingLayer; OwnPtr<WebCore::GraphicsLayer> m_backingLayer; #if PLATFORM(MAC) #if HAVE(HOSTED_CORE_ANIMATION) diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp index c5f117e..42eacc1 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp @@ -34,9 +34,11 @@ #include "WebPageProxyMessages.h" #include "WebProcess.h" #include <JavaScriptCore/APICast.h> +#include <JavaScriptCore/JSContextRef.h> #include <JavaScriptCore/JSLock.h> #include <JavaScriptCore/JSValueRef.h> #include <WebCore/AnimationController.h> +#include <WebCore/ArchiveResource.h> #include <WebCore/CSSComputedStyleDeclaration.h> #include <WebCore/Chrome.h> #include <WebCore/DocumentLoader.h> @@ -455,6 +457,17 @@ JSGlobalContextRef WebFrame::jsContextForWorld(InjectedBundleScriptWorld* world) return toGlobalRef(m_coreFrame->script()->globalObject(world->coreWorld())->globalExec()); } +WebFrame* WebFrame::frameForContext(JSContextRef context) +{ + JSObjectRef globalObjectRef = JSContextGetGlobalObject(context); + JSC::JSObject* globalObjectObj = toJS(globalObjectRef); + if (strcmp(globalObjectObj->classInfo()->className, "JSDOMWindowShell") != 0) + return 0; + + Frame* coreFrame = static_cast<JSDOMWindowShell*>(globalObjectObj)->window()->impl()->frame(); + return static_cast<WebFrameLoaderClient*>(coreFrame->loader()->client())->webFrame(); +} + JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, InjectedBundleScriptWorld* world) { JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld()); @@ -514,4 +527,20 @@ String WebFrame::provisionalURL() const return m_coreFrame->loader()->provisionalDocumentLoader()->url().string(); } +String WebFrame::suggestedFilenameForResourceWithURL(const KURL& url) const +{ + if (!m_coreFrame) + return String(); + + DocumentLoader* loader = m_coreFrame->loader()->documentLoader(); + if (!loader) + return String(); + + RefPtr<ArchiveResource> resource = loader->subresource(url); + if (!resource) + return String(); + + return resource->response().suggestedFilename(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.h b/Source/WebKit2/WebProcess/WebPage/WebFrame.h index 3ded6f6..f254e7a 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.h +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.h @@ -90,6 +90,8 @@ public: JSGlobalContextRef jsContext(); JSGlobalContextRef jsContextForWorld(InjectedBundleScriptWorld*); + static WebFrame* frameForContext(JSContextRef); + JSValueRef jsWrapperForWorld(InjectedBundleNodeHandle*, InjectedBundleScriptWorld*); JSValueRef jsWrapperForWorld(InjectedBundleRangeHandle*, InjectedBundleScriptWorld*); @@ -107,6 +109,7 @@ public: bool allowsFollowingLink(const WebCore::KURL&) const; String provisionalURL() const; + String suggestedFilenameForResourceWithURL(const WebCore::KURL&) const; // Simple listener class used by plug-ins to know when frames finish or fail loading. class LoadListener { diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 2259387..af236e9 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -37,6 +37,7 @@ #include "PluginProxy.h" #include "PluginView.h" #include "PrintInfo.h" +#include "RunLoop.h" #include "SessionState.h" #include "ShareableBitmap.h" #include "WebBackForwardList.h" @@ -149,6 +150,8 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_findController(this) , m_geolocationPermissionRequestManager(this) , m_pageID(pageID) + , m_canRunModal(parameters.canRunModal) + , m_isRunningModal(false) { ASSERT(m_pageID); @@ -182,7 +185,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) platformInitialize(); Settings::setMinDOMTimerInterval(0.004); - m_drawingArea = DrawingArea::create(parameters.drawingAreaInfo.type, parameters.drawingAreaInfo.identifier, this); + m_drawingArea = DrawingArea::create(this, parameters); m_mainFrame = WebFrame::createMainFrame(this); setDrawsBackground(parameters.drawsBackground); @@ -322,7 +325,9 @@ void WebPage::changeAcceleratedCompositingMode(WebCore::GraphicsLayer* layer) if (newDrawingAreaInfo.type != drawingArea()->info().type) { m_drawingArea = 0; if (newDrawingAreaInfo.type != DrawingAreaInfo::None) { - m_drawingArea = DrawingArea::create(newDrawingAreaInfo.type, newDrawingAreaInfo.identifier, this); + WebPageCreationParameters parameters; + parameters.drawingAreaInfo = newDrawingAreaInfo; + m_drawingArea = DrawingArea::create(this, parameters); m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize)); } } @@ -375,6 +380,11 @@ void WebPage::close() m_drawingArea.clear(); WebProcess::shared().removeWebPage(m_pageID); + + if (m_isRunningModal) { + m_isRunningModal = false; + WebProcess::shared().runLoop()->stop(); + } } void WebPage::tryClose() @@ -429,6 +439,15 @@ void WebPage::loadPlainTextString(const String& string) loadData(sharedBuffer, "text/plain", "utf-16", blankURL(), KURL()); } +void WebPage::stopLoadingFrame(uint64_t frameID) +{ + WebFrame* frame = WebProcess::shared().webFrame(frameID); + if (!frame) + return; + + frame->coreFrame()->loader()->stopForUserCancel(); +} + void WebPage::stopLoading() { m_mainFrame->coreFrame()->loader()->stopForUserCancel(); @@ -1134,6 +1153,23 @@ void WebPage::getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID) send(Messages::WebPageProxy::DataCallback(dataReference, callbackID)); } +void WebPage::getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID) +{ + CoreIPC::DataReference dataReference; + + RefPtr<SharedBuffer> buffer; + if (WebFrame* frame = WebProcess::shared().webFrame(frameID)) { + if (DocumentLoader* loader = frame->coreFrame()->loader()->documentLoader()) { + if (RefPtr<ArchiveResource> subresource = loader->subresource(KURL(KURL(), resourceURL))) { + if (buffer = subresource->data()) + dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size()); + } + } + } + + send(Messages::WebPageProxy::DataCallback(dataReference, callbackID)); +} + void WebPage::getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID) { CoreIPC::DataReference dataReference; @@ -1290,6 +1326,20 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli } } +void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation) +{ + IntPoint adjustedClientPosition(clientPosition.x() + m_page->dragController()->dragOffset().x(), clientPosition.y() + m_page->dragController()->dragOffset().y()); + IntPoint adjustedGlobalPosition(globalPosition.x() + m_page->dragController()->dragOffset().x(), globalPosition.y() + m_page->dragController()->dragOffset().y()); + + m_page->dragController()->dragEnded(); + FrameView* view = m_page->mainFrame()->view(); + if (!view) + return; + // FIXME: These are fake modifier keys here, but they should be real ones instead. + PlatformMouseEvent event(adjustedClientPosition, adjustedGlobalPosition, LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime()); + m_page->mainFrame()->eventHandler()->dragSourceEndedAt(event, (DragOperation)operation); +} + WebEditCommand* WebPage::webEditCommand(uint64_t commandID) { return m_editCommandMap.get(commandID).get(); @@ -1590,7 +1640,13 @@ void WebPage::SandboxExtensionTracker::beginLoad(WebFrame* frame, const SandboxE { ASSERT(frame->isMainFrame()); - ASSERT(!m_pendingProvisionalSandboxExtension); + // If we get two beginLoad calls in succession, without a provisional load starting, then + // m_pendingProvisionalSandboxExtension will be non-null. Invalidate and null out the extension if that is the case. + if (m_pendingProvisionalSandboxExtension) { + m_pendingProvisionalSandboxExtension->invalidate(); + m_pendingProvisionalSandboxExtension = nullptr; + } + m_pendingProvisionalSandboxExtension = SandboxExtension::create(handle); } @@ -1633,7 +1689,7 @@ void WebPage::SandboxExtensionTracker::didFailProvisionalLoad(WebFrame* frame) return; m_provisionalSandboxExtension->invalidate(); - m_provisionalSandboxExtension = 0; + m_provisionalSandboxExtension = nullptr; } bool WebPage::hasLocalDataForURL(const KURL& url) @@ -1754,4 +1810,17 @@ void WebPage::drawRectToPDF(uint64_t frameID, const WebCore::IntRect& rect, Vect } #endif +void WebPage::runModal() +{ + if (m_isClosed) + return; + if (m_isRunningModal) + return; + + m_isRunningModal = true; + send(Messages::WebPageProxy::RunModal()); + RunLoop::run(); + ASSERT(!m_isRunningModal); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 7649ab6..d29400f 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -200,6 +200,7 @@ public: bool drawsTransparentBackground() const { return m_drawsTransparentBackground; } void stopLoading(); + void stopLoadingFrame(uint64_t frameID); void setDefersLoading(bool deferLoading); #if USE(ACCELERATED_COMPOSITING) @@ -300,6 +301,7 @@ public: void replaceSelectionWithText(WebCore::Frame*, const String&); void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags); + void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation); void beginPrinting(uint64_t frameID, const PrintInfo&); void endPrinting(); @@ -310,6 +312,9 @@ public: bool mainFrameHasCustomRepresentation() const; + bool canRunModal() const { return m_canRunModal; } + void runModal(); + private: WebPage(uint64_t pageID, const WebPageCreationParameters&); @@ -364,6 +369,7 @@ private: void getContentsAsString(uint64_t callbackID); void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID); + void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID); void getRenderTreeExternalRepresentation(uint64_t callbackID); void getSelectionOrContentsAsString(uint64_t callbackID); void getSourceForFrame(uint64_t frameID, uint64_t callbackID); @@ -492,6 +498,9 @@ private: SandboxExtensionTracker m_sandboxExtensionTracker; uint64_t m_pageID; + + bool m_canRunModal; + bool m_isRunningModal; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index bd6bf1a..e001864 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -46,6 +46,8 @@ messages -> WebPage { LoadURLRequest(WebCore::ResourceRequest request, WebKit::SandboxExtension::Handle sandboxExtensionHandle) Reload(bool reloadFromOrigin) StopLoading() + + StopLoadingFrame(uint64_t frameID) RestoreSessionAndNavigateToCurrentItem(WebKit::SessionState state) @@ -56,6 +58,7 @@ messages -> WebPage { # Callbacks. GetContentsAsString(uint64_t callbackID) GetMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID) + GetResourceDataFromFrame(uint64_t frameID, WTF::String resourceURL, uint64_t callbackID) GetRenderTreeExternalRepresentation(uint64_t callbackID) GetSelectionOrContentsAsString(uint64_t callbackID) GetSourceForFrame(uint64_t frameID, uint64_t callbackID) @@ -98,6 +101,7 @@ messages -> WebPage { # Drag and drop. PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags) + DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation) # Popup menu. DidChangeSelectedIndexForActivePopupMenu(int32_t newIndex); diff --git a/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm index f8b7e71..24fa124 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm @@ -44,7 +44,7 @@ void LayerBackedDrawingArea::platformInit() { setUpUpdateLayoutRunLoopObserver(); - [m_backingLayer->platformLayer() setGeometryFlipped:YES]; + [m_hostingLayer->platformLayer() setGeometryFlipped:YES]; #if HAVE(HOSTED_CORE_ANIMATION) attachCompositingContext(); #endif @@ -80,7 +80,7 @@ void LayerBackedDrawingArea::attachCompositingContext() #if HAVE(HOSTED_CORE_ANIMATION) mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort(); m_remoteLayerRef = WKCARemoteLayerClientMakeWithServerPort(serverPort); - WKCARemoteLayerClientSetLayer(m_remoteLayerRef.get(), m_backingLayer->platformLayer()); + WKCARemoteLayerClientSetLayer(m_remoteLayerRef.get(), m_hostingLayer->platformLayer()); uint32_t contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerRef.get()); WebProcess::shared().connection()->sendSync(DrawingAreaProxyLegacyMessage::AttachCompositingContext, m_webPage->pageID(), CoreIPC::In(contextID), CoreIPC::Out()); @@ -115,9 +115,10 @@ void LayerBackedDrawingArea::scheduleCompositingLayerSync() void LayerBackedDrawingArea::syncCompositingLayers() { + m_hostingLayer->syncCompositingStateForThisLayerOnly(); m_backingLayer->syncCompositingStateForThisLayerOnly(); - bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateRecursive(); + bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); if (!didSync) { } diff --git a/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp b/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp index c07e1f5..cae79c2 100644 --- a/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp +++ b/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp @@ -27,16 +27,6 @@ #include "LayerBackedDrawingArea.h" -#include "DrawingAreaProxyMessageKinds.h" -#include "WebPage.h" -#include "WebProcess.h" -#include <WebCore/Frame.h> -#include <WebCore/FrameView.h> -#include <WebCore/GraphicsLayer.h> -#include <WebCore/Page.h> -#include <WebCore/WKCACFLayerRenderer.h> -#include <WebCore/WebCoreInstanceHandle.h> - using namespace WebCore; namespace WebKit { diff --git a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb index 2123c95..df57bde 100644 --- a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb +++ b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb @@ -124,6 +124,10 @@ (allow process-fork) (allow process-exec (literal "/System/Library/Frameworks/QTKit.framework/Versions/A/Resources/QTKitServer") (with no-sandbox)) +;; FIXME: Once <rdar://problem/8900275> has been fixed, these rules can be removed. +(allow mach-lookup (global-name "com.apple.pubsub.ipc")) +(allow network-outbound (regex #"^/private/tmp/launch-[^/]+/Render")) + ;; FIXME: Investigate these. (allow appleevent-send (appleevent-destination "com.apple.WebProcess")) (allow mach-lookup (global-name-regex #"^EPPC-")) diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index c899fcb..d394c98 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -151,6 +151,12 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters { initializeSandbox(parameters); + if (!parameters.parentProcessName.isNull()) { + // FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized + NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parameters.parentProcessName]; + WKSetVisibleApplicationName((CFStringRef)applicationName); + } + if (!parameters.nsURLCachePath.isNull()) { NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity; NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity; diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm index 5cefb59..a44dc23 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm @@ -80,14 +80,6 @@ int WebProcessMain(const CommandLine& commandLine) WTF::initializeMainThread(); RunLoop::initializeMainRunLoop(); - // Set the visible application name. - String parentProcessName = commandLine["parentprocessname"]; - if (!parentProcessName.isNull()) { - // FIXME: Localization! - NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parentProcessName]; - WKSetVisibleApplicationName((CFStringRef)applicationName); - } - // Create the connection. WebProcess::shared().initialize(serverPort, RunLoop::main()); |