diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-27 09:28:46 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-27 09:28:46 +0200 |
commit | 6668b07fcd51f86be243b9e08e667224e30c0cf8 (patch) | |
tree | 64f466e09b68a77ae1156c0d35cd5b95e18a34ca /Source/WebCore | |
parent | e7923d9de38974f0c6fb7646c898a6ea618261e8 (diff) | |
download | qtwebkit-6668b07fcd51f86be243b9e08e667224e30c0cf8.tar.gz |
Imported WebKit commit 26cd9bd8ab0471ffe987c9b60368f63dc0f1f31b (http://svn.webkit.org/repository/webkit/trunk@121325)
New snapshot with more Windows build fixes
Diffstat (limited to 'Source/WebCore')
180 files changed, 4614 insertions, 2237 deletions
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index fcdeaba93..6d3da7f8c 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -503,6 +503,7 @@ SET(WebCore_SOURCES css/CSSStyleRule.cpp css/CSSStyleSheet.cpp css/CSSTimingFunctionValue.cpp + css/CSSToStyleMap.cpp css/CSSUnicodeRangeValue.cpp css/CSSValue.cpp css/CSSValueList.cpp diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index b4a2c4cfc..6856ca10c 100644..100755 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,11 +1,2108 @@ -2012-06-19 Joel Dillon <joel.dillon@codethink.co.uk> Jocelyn Turcotte <jocelyn.turcotte@nokia.com> +2012-06-26 Yoshifumi Inoue <yosin@chromium.org> - [Qt][Win] Fix broken QtWebKit5.lib linking - https://bugs.webkit.org/show_bug.cgi?id=88321 + [Platform] Change implementation of LocaleICU class to support more UDateFormat. + https://bugs.webkit.org/show_bug.cgi?id=89967 - Reviewed by NOBODY (OOPS!). + Reviewed by Kent Tamura. + + This patch changes internal functions of LocaleICU class to process + multiple ICU date time format handles in addition to short date time + format handle. + + This patch is a part of implementing input type time. I'll add time + format related ICU date time format handles. + + No new tests. This patch doesn't change behavior. + + * platform/text/LocaleICU.cpp: + (WebCore::LocaleICU::initializeShortDateFormat): Changed to use openDateFormat(). + (WebCore::LocaleICU::openDateFormat): Added for common usage of udt_open(). + (WebCore::getDateFormatPattern): Added for common usage of udt_toPattern(). + (WebCore::localizeFormat): Changed to take String parameter. + (WebCore::LocaleICU::initializeLocalizedDateFormatText): Changed to use getDateFormatPattern. + (WebCore::LocaleICU::createLabelVector): Changed to take UDateFormat parameter. + (WebCore::LocaleICU::initializeCalendar): Changed for helper functions. + * platform/text/LocaleICU.h: + (LocaleICU): + +2012-06-26 Luke Macpherson <macpherson@chromium.org> + + Return correct value for css variables enabled runtime flag. + https://bugs.webkit.org/show_bug.cgi?id=90040 + + Reviewed by Dimitri Glazkov. + + Was always returning true for the runtime flag when the compile time flag was on. That was good for testing, + but not so much for production. + + * page/Settings.h: + (WebCore::Settings::cssVariablesEnabled): + +2012-06-26 Xueqing Huang <huangxueqing@baidu.com> + + DragData::asFilenames should not push same file names to result in Windows. + https://bugs.webkit.org/show_bug.cgi?id=79861 + + Reviewed by Alexey Proskuryakov. + + Test: platform/win/fast/forms/file/drag-and-drop-files.html + + * platform/win/DragDataWin.cpp: + (WebCore::DragData::asFilenames): + +2012-06-26 Geoffrey Garen <ggaren@apple.com> + + Reduced (but did not eliminate) use of "berzerker GC" + https://bugs.webkit.org/show_bug.cgi?id=89237 + + Reviewed by Gavin Barraclough. + + (PART 2) + + Don't ASSERT that RootObject's destructor runs and invalidates all + RuntimeObjects before their destructors run. + + We don't guarantee this behavior because some RuntimeObjects may already + be garbage by the time RootObject's destructor runs, in which case + RootObject's weak pointers will be NULL, and RootObject will not call + invalidate() on them. + + It's been theoretically possible for this ASSERT to fire for a while now. + This patch makes it fire all the time. + + Luckily, we only needed the behavior guarded by this ASSERT for WebKit1 + in Safari on Windows (cf. https://bugs.webkit.org/show_bug.cgi?id=61317), + to handle the way WebKit1 would unload plugin DLLs. If this ever becomes + an issue again, we can fix it by (a) not unloading plugin DLLs, + (b) migrating WebKit1 to the WebKit2 JS-plugin binding model, (c) making + the Instance pointer in a RuntimeObject an indirect pointer through + RootObject, or (c) giving RuntimeObject some sort of special way to + access a zombie weak pointer. + + * bridge/runtime_object.cpp: + (JSC::Bindings::RuntimeObject::destroy): ASSERT removed. Anders said so. + +2012-06-26 Douglas Stockwell <dstockwell@chromium.org> + + REGRESSION(r107836): box shadow not drawn for opaque images with an opaque background + https://bugs.webkit.org/show_bug.cgi?id=89958 + + Reviewed by Simon Fraser. + + Don't attempt to draw the box shadow as part of the background if the background is + obscured. + + Test: fast/box-shadow/image-box-shadow.html + + * rendering/RenderImage.cpp: + (WebCore::RenderImage::boxShadowShouldBeAppliedToBackground): + (WebCore): + * rendering/RenderImage.h: + (RenderImage): + +2012-06-26 Nico Weber <thakis@chromium.org> + + Fix new Wunused-private-field violations that crept in + https://bugs.webkit.org/show_bug.cgi?id=90032 + + Reviewed by Adam Barth. + + * page/Performance.h: + (Performance): + +2012-06-26 Gyuyoung Kim <gyuyoung.kim@samsung.com> + + Change return type in bandwidth attribute of network information API + https://bugs.webkit.org/show_bug.cgi?id=89959 + + Reviewed by Adam Barth. + + According to network information API spec, bandwidth attribute should return double type. + But, existing implementation has used *long* and *unsigned int* types. + + No new tests. Covered by existing tests. + + * Modules/networkinfo/NetworkInfo.cpp: + (WebCore::NetworkInfo::NetworkInfo): + * Modules/networkinfo/NetworkInfo.h: + (WebCore::NetworkInfo::create): + (WebCore::NetworkInfo::bandwidth): + (NetworkInfo): + * Modules/networkinfo/NetworkInfoClient.h: + (NetworkInfoClient): + * Modules/networkinfo/NetworkInfoConnection.cpp: + (WebCore::NetworkInfoConnection::bandwidth): + * Modules/networkinfo/NetworkInfoConnection.h: + (NetworkInfoConnection): + * testing/Internals.cpp: + (WebCore::Internals::setNetworkInformation): + * testing/Internals.h: + (Internals): + * testing/Internals.idl: + +2012-06-26 Luke Macpherson <macpherson@chromium.org> + + Be careful not to read past the end of input in CSSParser::lex() when looking for variable definitions. + https://bugs.webkit.org/show_bug.cgi?id=89949 + + Reviewed by Abhishek Arya. + + Added repro case as fast/css/short-inline-style.html. + + * css/CSSParser.cpp: + (WebCore::CSSParser::lex): + +2012-06-26 James Robinson <jamesr@chromium.org> + + [chromium] Remove WebView::graphicsContext3D getter + https://bugs.webkit.org/show_bug.cgi?id=89916 + + Reviewed by Adrienne Walker. + + Deletes code supporting compositor context getter. + + * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: + * platform/graphics/chromium/cc/CCLayerTreeHost.h: + (CCLayerTreeHost): + * platform/graphics/chromium/cc/CCProxy.h: + (CCProxy): + * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: + * platform/graphics/chromium/cc/CCSingleThreadProxy.h: + (CCSingleThreadProxy): + * platform/graphics/chromium/cc/CCThreadProxy.cpp: + * platform/graphics/chromium/cc/CCThreadProxy.h: + (CCThreadProxy): + +2012-06-26 Kulanthaivel Palanichamy <kulanthaivel@codeaurora.org> + + Unexpected element sizes when mixing inline-table with box-sizing + https://bugs.webkit.org/show_bug.cgi?id=89819 + + Reviewed by Julien Chaffraix. + + This change handles box-sizing: border-box property for CSS tables properly. + + Test: fast/box-sizing/css-table-with-box-sizing.html + + * rendering/RenderTable.cpp: + (WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth): + (WebCore::RenderTable::layout): + +2012-06-26 Simon Fraser <simon.fraser@apple.com> + + Optimize mappings of simple transforms in RenderGeometryMap + https://bugs.webkit.org/show_bug.cgi?id=90034 + + Reviewed by Dean Jackson. + + For transforms that are identity or simple translations, don't + fall off the fast path in RenderGeometryMap; we can just + treat them as offsets. + + Improves performance on pages with lots of translateZ(0) elements. + + Remove RenderGeometryMapStep::mapPoint() and mapQuad(), which + were unused. + + No new tests; optimization only, and tested by assertions. + + * rendering/RenderGeometryMap.cpp: + (WebCore::RenderGeometryMap::push): + +2012-06-26 Kevin Ellis <kevers@chromium.org> + + Touch adjustment does not target shadow DOM elements + https://bugs.webkit.org/show_bug.cgi?id=89556 + + The position of internal shadow-DOM nodes were not being considered + when determining the snap position when TOUCH_ADJUSTMENT is enabled + for fine tuning the position of synthetic mouse events. This + restriction results in not being able to select the calendar picker + when input type=date, or to clear the search field for input + type=search. + + Reviewed by Antonio Gomes. + + Test: touchadjustment/nested-shadow-node.html + + * page/EventHandler.cpp: + (WebCore::EventHandler::bestClickableNodeForTouchPoint): + +2012-06-26 Ryosuke Niwa <rniwa@webkit.org> + + Stop calling node() and deprecatedEditingOffset() in comparePositions + https://bugs.webkit.org/show_bug.cgi?id=54535 + + Reviewed by Enrica Casucci. + + Replaced deprecatedNode() and deprecatedEditingOffset() by containerNode() and computeOffsetInContainerNode() + in comparePositions(). + + In addition, fixed a bunch of bugs in DeleteSelectionCommand::handleSpecialCaseBRDelete revealed by this change: + - Use node after position instead of deprecated node in determinig whether start and end positions at a br. + - Don't set m_startsAtEmptyLine true when BR is wrapped in a block element. The only reason this code had worked + was positions like (div, offset, 0) and (br, before) in <div><br> were treated differently, which we no longer do. + + * editing/DeleteSelectionCommand.cpp: + (WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete): + * editing/htmlediting.cpp: + (WebCore::comparePositions): + +2012-06-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL] Use eina_file_ls() in EFL implementation of FileSystem listDirectory() + https://bugs.webkit.org/show_bug.cgi?id=89976 + + Reviewed by Antonio Gomes. + + Rewrite EFL implementation of Filesystem listDirectory() in order to + use eina_file_ls() instead of POSIX C functions. This results in + shorter code. + + No new tests, behavior has not changed. + + * platform/efl/FileSystemEfl.cpp: + (WebCore::listDirectory): + +2012-06-26 Alice Cheng <alice_cheng@apple.com> + + Crash at WebCore::TextIterator::handleTextBox + https://bugs.webkit.org/show_bug.cgi?id=89526 + <rdar://problem/10305315> + + Reviewed by Darin Adler. + + The range used for marking becomes invalid after SpellingCorrectionCommand, due to changes in the DOM made by ReplaceSelectionCommand. + This invalid range caused marking to be incorrect, and Mail.app to crash when iterating through the invalid range. To fix this, + recalculate the range for marking after SpellingCorrectionCommand. + + Test: platform/mac/editing/spelling/autocorrection-blockquote-crash.html + + * editing/AlternativeTextController.cpp: + (WebCore::AlternativeTextController::applyAlternativeTextToRange): + * editing/Editor.cpp: (WebCore::Editor::markAndReplaceFor): + * testing/Internals.cpp: + (WebCore): + (WebCore::Internals::hasAutocorrectedMarker): + * testing/Internals.h: (Internals): + * testing/Internals.idl: + +2012-06-26 Tom Sepez <tsepez@chromium.org> + + [chromium] HTML5 audio/video tags - loading http content from https page doesn't trigger warning. + https://bugs.webkit.org/show_bug.cgi?id=89906 + + Reviewed by Nate Chapin. + + This patch treats mixed CachedRawResources as affecting the display of insecure content. + + Tests: http/tests/security/mixedContent/insecure-audio-video-in-main-frame.html + http/tests/security/mixedContent/insecure-xhr-in-main-frame.html + + * loader/cache/CachedResourceLoader.cpp: + (WebCore::CachedResourceLoader::checkInsecureContent): + +2012-06-26 Joe Thomas <joethomas@motorola.com> + + background-size:0 shows as 1px instead of invisible + https://bugs.webkit.org/show_bug.cgi?id=86942 + + Reviewed by Eric Seidel. + + As per the specification http://www.w3.org/TR/css3-background/#background-size, if the background image's width or height resolves to zero, + this causes the image not to be displayed. The effect should be the same as if it had been a transparent image. + This is also mentioned in http://www.w3.org/TR/2002/WD-css3-background-20020802/#background-size. + + Test: fast/backgrounds/zero-background-size.html + + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelObject::calculateFillTileSize): + +2012-06-26 Adam Klein <adamk@chromium.org> + + [v8] Clean up generated Dictionary-handling code + https://bugs.webkit.org/show_bug.cgi?id=89994 + + Reviewed by Adam Barth. + + No change in behavior, so no new tests. + + * bindings/scripts/CodeGeneratorV8.pm: + (GenerateParametersCheck): + * bindings/scripts/test/V8/V8TestObj.cpp: + (WebCore::TestObjV8Internal::optionsObjectCallback): + +2012-06-26 Raymond Toy <rtoy@google.com> + + Include stdio.h when DEBUG_AUDIONODE_REFERENCES is set + https://bugs.webkit.org/show_bug.cgi?id=89997 + + Reviewed by Eric Seidel. + + No new tests needed for a compile issue + + * Modules/webaudio/AudioNode.cpp: Include stdio.h + +2012-06-26 No'am Rosenthal <noam.rosenthal@nokia.com> + + [Qt] Use premultiplied alpha when extracting image data in WebGL + https://bugs.webkit.org/show_bug.cgi?id=89937 + + Reviewed by Jocelyn Turcotte. + + Perform conversion in QImage only if the image format is not ARGB32 or + ARGB32_Premultiplied. Otherwise, allow packPixels to perform the conversion if the formats + don't match, as packPixels already performs pixel-specific operations. + + Covered by tests in LayoutTests/fast/canvas/webgl, e.g. webgl-composite-modes.html. + + * platform/graphics/qt/GraphicsContext3DQt.cpp: + (WebCore::GraphicsContext3D::getImageData): + +2012-06-26 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Move method precondition checks to front end objects + https://bugs.webkit.org/show_bug.cgi?id=89377 + + Reviewed by Tony Chang. + + Now that metadata exists on the front end, most of the pre-condition validation checks + done on IDB method calls from script can be moved to the front end which simplifies the + code significantly in the case of complex methods like IDBObjectStore::put(). + + Adds an internal "active" flag for transactions, although the behavior is not accurate + to the spec (it should only be true during event callbacks - http://webkit.org/b/89379). + The back-end methods can then be simplifed to just adding async tasks to the transaction, + and the front end methods can take care of all exception cases except for asynchronous + transaction abort which still requires plumbing back to the front end. + + No functional changes - no new tests. + + * Modules/indexeddb/IDBCursor.cpp: + (WebCore::IDBCursor::update): Migrate from IDBObjectStoreBackendImpl::put. + (WebCore::IDBCursor::advance): Add more explicit transaction-is-active check. + (WebCore::IDBCursor::continueFunction): Ditto. + (WebCore::IDBCursor::deleteFunction): Ditto. + (WebCore::IDBCursor::effectiveObjectStore): Convenience function (source may be store or index). + (WebCore): + * Modules/indexeddb/IDBCursor.h: + (WebCore::IDBCursor::isKeyCursor): Distinguish from IDBCursorWithValue. + (IDBCursor): + * Modules/indexeddb/IDBCursorBackendImpl.cpp: + (WebCore::IDBCursorBackendImpl::update): Remove migrated check. + * Modules/indexeddb/IDBCursorWithValue.h: + (IDBCursorWithValue): + * Modules/indexeddb/IDBDatabase.cpp: Migrate checks. + (WebCore::IDBDatabase::createObjectStore): + (WebCore::IDBDatabase::deleteObjectStore): + * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Replace checks with assertions. + (WebCore::IDBDatabaseBackendImpl::createObjectStore): + (WebCore::IDBDatabaseBackendImpl::deleteObjectStore): + * Modules/indexeddb/IDBIndex.cpp: Add transaction-is-active checks. + (WebCore::IDBIndex::openCursor): + (WebCore::IDBIndex::count): + (WebCore::IDBIndex::openKeyCursor): + (WebCore::IDBIndex::get): + (WebCore::IDBIndex::getKey): + * Modules/indexeddb/IDBObjectStore.cpp: Migrate cehcks. + (WebCore::IDBObjectStore::get): + (WebCore::IDBObjectStore::add): Delegates to put(PutMode) + (WebCore::IDBObjectStore::put): Delegates to put(PutMode) + (WebCore): Adds put(PutMode) which has the unified checks migrated from + IDBObjectStoreBackendImpl::put. + (WebCore::IDBObjectStore::deleteFunction): + (WebCore::IDBObjectStore::clear): + (WebCore::IDBObjectStore::createIndex): + (WebCore::IDBObjectStore::deleteIndex): + (WebCore::IDBObjectStore::openCursor): + (WebCore::IDBObjectStore::count): + * Modules/indexeddb/IDBObjectStore.h: Adds put(PutMode). + (IDBObjectStore): + * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: + (WebCore::IDBObjectStoreBackendImpl::getInternal): Fix trace symbol. + (WebCore::IDBObjectStoreBackendImpl::put): Remove migrated checks. + (WebCore::IDBObjectStoreBackendImpl::createIndex): Remove migrated checks. + (WebCore::IDBObjectStoreBackendImpl::deleteIndex): Remove migrated checks. + * Modules/indexeddb/IDBTransaction.cpp: Add active flag tracking. + (WebCore::IDBTransaction::IDBTransaction): + (WebCore::IDBTransaction::abort): + (WebCore::IDBTransaction::onAbort): + (WebCore::IDBTransaction::onComplete): + * Modules/indexeddb/IDBTransaction.h: + (WebCore::IDBTransaction::isActive): + (WebCore::IDBTransaction::isReadOnly): Group IDL/non-IDL methods. + (IDBTransaction): + +2012-06-26 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r121285. + http://trac.webkit.org/changeset/121285 + https://bugs.webkit.org/show_bug.cgi?id=90014 + + "We misinterpreted 'size of the initial containing block'" + (Requested by tomz on #webkit). + + * css/CSSCalculationValue.cpp: + (WebCore::CSSCalcValue::computeLengthPx): + (WebCore::CSSCalcPrimitiveValue::toCalcValue): + (WebCore::CSSCalcPrimitiveValue::computeLengthPx): + (WebCore::CSSCalcBinaryOperation::toCalcValue): + (WebCore::CSSCalcBinaryOperation::computeLengthPx): + * css/CSSCalculationValue.h: + (CSSCalcExpressionNode): + (WebCore::CSSCalcValue::toCalcValue): + (CSSCalcValue): + * css/CSSGradientValue.cpp: + (WebCore::CSSGradientValue::addStops): + (WebCore::positionFromValue): + (WebCore::CSSGradientValue::computeEndPoint): + (WebCore::CSSLinearGradientValue::createGradient): + (WebCore::CSSRadialGradientValue::resolveRadius): + (WebCore::CSSRadialGradientValue::createGradient): + * css/CSSGradientValue.h: + (CSSGradientValue): + (CSSRadialGradientValue): + * css/CSSPrimitiveValue.cpp: + (WebCore::CSSPrimitiveValue::computeLength): + (WebCore::CSSPrimitiveValue::computeLengthDouble): + * css/CSSPrimitiveValue.h: + (CSSPrimitiveValue): + * css/CSSPrimitiveValueMappings.h: + (WebCore::CSSPrimitiveValue::convertToLength): + * css/CSSToStyleMap.cpp: + (WebCore::CSSToStyleMap::mapFillSize): + (WebCore::CSSToStyleMap::mapFillXPosition): + (WebCore::CSSToStyleMap::mapFillYPosition): + (WebCore::CSSToStyleMap::mapNinePieceImageQuad): + * css/CSSToStyleMap.h: + (CSSToStyleMap): + * css/MediaQueryEvaluator.cpp: + (WebCore::computeLength): + (WebCore::device_heightMediaFeatureEval): + (WebCore::device_widthMediaFeatureEval): + (WebCore::heightMediaFeatureEval): + (WebCore::widthMediaFeatureEval): + * css/SVGCSSStyleSelector.cpp: + (WebCore::StyleResolver::applySVGProperty): + * css/StyleBuilder.cpp: + (WebCore::ApplyPropertyAuto::applyValue): + (WebCore::ApplyPropertyClip::convertToLength): + (WebCore::ApplyPropertyLength::applyValue): + (WebCore::ApplyPropertyBorderRadius::applyValue): + (WebCore::ApplyPropertyComputeLength::applyValue): + (WebCore::ApplyPropertyFontSize::applyValue): + (WebCore::ApplyPropertyLineHeight::applyValue): + (WebCore::ApplyPropertyPageSize::mmLength): + (WebCore::ApplyPropertyPageSize::inchLength): + (WebCore::ApplyPropertyPageSize::applyValue): + (WebCore::ApplyPropertyVerticalAlign::applyValue): + * css/StyleResolver.cpp: + (WebCore::StyleResolver::collectMatchingRulesForList): + * css/StyleResolver.h: + (StyleResolver): + * css/WebKitCSSMatrix.cpp: + (WebCore::WebKitCSSMatrix::setMatrixValue): + +2012-06-26 Dave Tu <dtu@chromium.org> + + [chromium] Expose rendering statistics to WebWidget. + https://bugs.webkit.org/show_bug.cgi?id=88268 + + Reviewed by James Robinson. + + The WebKit side of a basic framework for exposing rendering statistics + to Chromium's --enable-benchmarking extension. + + * platform/graphics/chromium/cc/CCLayerTreeHost.h: + (WebCore::CCLayerTreeHost::implFrameNumber): + * platform/graphics/chromium/cc/CCProxy.h: + (CCProxy): + * platform/graphics/chromium/cc/CCSingleThreadProxy.h: + * platform/graphics/chromium/cc/CCThreadProxy.cpp: + (WebCore::CCThreadProxy::implFrameNumber): + (WebCore): + (WebCore::CCThreadProxy::implFrameNumberOnImplThread): + * platform/graphics/chromium/cc/CCThreadProxy.h: + (CCThreadProxy): + +2012-06-26 Dave Tharp <dtharp@codeaurora.org> + + ietestcenter/css3/valuesandunits/units-000.htm asserts + https://bugs.webkit.org/show_bug.cgi?id=86176 + + Reviewed by Beth Dakin. + + Modified computeLengthDouble() to handle vh, vw, and vmin units. Per the spec + (http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths) viewport -percentage + lengths are "relative to the size of the initial containing block", which I read to be + the size of the parent element. Since parentStyle was not available in computeLengthDouble, + most of the changes for this patch involved "pushing down" the parentStyle pointer through + the network of computeLength methods and dependencies. + + Tests: css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vh-border.html + css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmin-border.html + css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vw-border.html + + * css/CSSCalculationValue.cpp: + (WebCore::CSSCalcValue::computeLengthPx): + (WebCore::CSSCalcPrimitiveValue::toCalcValue): + (WebCore::CSSCalcPrimitiveValue::computeLengthPx): + (WebCore::CSSCalcBinaryOperation::toCalcValue): + (WebCore::CSSCalcBinaryOperation::computeLengthPx): + * css/CSSCalculationValue.h: + (CSSCalcExpressionNode): + (WebCore::CSSCalcValue::toCalcValue): + (CSSCalcValue): + * css/CSSGradientValue.cpp: + (WebCore::CSSGradientValue::addStops): + (WebCore::positionFromValue): + (WebCore::CSSGradientValue::computeEndPoint): + (WebCore::CSSLinearGradientValue::createGradient): + (WebCore::CSSRadialGradientValue::resolveRadius): + (WebCore::CSSRadialGradientValue::createGradient): + * css/CSSGradientValue.h: + (CSSGradientValue): + (CSSRadialGradientValue): + * css/CSSPrimitiveValue.cpp: + (WebCore::CSSPrimitiveValue::computeLength): + (WebCore::CSSPrimitiveValue::computeLengthDouble): + * css/CSSPrimitiveValue.h: + (CSSPrimitiveValue): + * css/CSSPrimitiveValueMappings.h: + (WebCore::CSSPrimitiveValue::convertToLength): + * css/CSSToStyleMap.cpp: + (WebCore::CSSToStyleMap::parentStyle): + (WebCore): + (WebCore::CSSToStyleMap::mapFillSize): + (WebCore::CSSToStyleMap::mapFillXPosition): + (WebCore::CSSToStyleMap::mapFillYPosition): + (WebCore::CSSToStyleMap::mapNinePieceImageQuad): + * css/CSSToStyleMap.h: + (CSSToStyleMap): + * css/MediaQueryEvaluator.cpp: + (WebCore::computeLength): + (WebCore::device_heightMediaFeatureEval): + (WebCore::device_widthMediaFeatureEval): + (WebCore::heightMediaFeatureEval): + (WebCore::widthMediaFeatureEval): + * css/SVGCSSStyleSelector.cpp: + (WebCore::StyleResolver::applySVGProperty): + * css/StyleBuilder.cpp: + (WebCore::ApplyPropertyAuto::applyValue): + (WebCore::ApplyPropertyClip::convertToLength): + (WebCore::ApplyPropertyLength::applyValue): + (WebCore::ApplyPropertyBorderRadius::applyValue): + (WebCore::ApplyPropertyComputeLength::applyValue): + (WebCore::ApplyPropertyFontSize::applyValue): + (WebCore::ApplyPropertyLineHeight::applyValue): + (WebCore::ApplyPropertyPageSize::mmLength): + (WebCore::ApplyPropertyPageSize::inchLength): + (WebCore::ApplyPropertyPageSize::applyValue): + (WebCore::ApplyPropertyVerticalAlign::applyValue): + * css/StyleResolver.cpp: + (WebCore::StyleResolver::collectMatchingRulesForList): + * css/StyleResolver.h: + (WebCore::StyleResolver::parentNode): + (StyleResolver): + * css/WebKitCSSMatrix.cpp: + (WebCore::WebKitCSSMatrix::setMatrixValue): + +2012-06-25 James Robinson <jamesr@chromium.org> + + [chromium] Add WebLayer API for scrolling + https://bugs.webkit.org/show_bug.cgi?id=89913 + + Reviewed by Adrienne Walker. + + Use new WebScrollableLayer type in ScrollingCoordinatorChromium. This file peeks "under the hood" a fair amount + since we don't have WebLayer API for scrollbar layers yet. + + * page/scrolling/chromium/ScrollingCoordinatorChromium.cpp: + (WebCore::ScrollingCoordinatorPrivate::setScrollLayer): + (WebCore::ScrollingCoordinatorPrivate::setHorizontalScrollbarLayer): + (WebCore::ScrollingCoordinatorPrivate::setVerticalScrollbarLayer): + (WebCore::ScrollingCoordinatorPrivate::hasScrollLayer): + (WebCore::ScrollingCoordinatorPrivate::scrollLayer): + (ScrollingCoordinatorPrivate): + (WebCore::createScrollbarLayer): + (WebCore::ScrollingCoordinator::setScrollLayer): + (WebCore::ScrollingCoordinator::setNonFastScrollableRegion): + (WebCore::ScrollingCoordinator::setWheelEventHandlerCount): + (WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread): + +2012-06-26 James Robinson <jamesr@chromium.org> + + Unreviewed, rolling out r120501. + http://trac.webkit.org/changeset/120501 + https://bugs.webkit.org/show_bug.cgi?id=89126 + + [skia] Fix is too heavy-handed + + * platform/graphics/skia/ImageBufferSkia.cpp: + (WebCore::drawNeedsCopy): + * platform/graphics/skia/PlatformContextSkia.cpp: + (WebCore::PlatformContextSkia::PlatformContextSkia): + * platform/graphics/skia/PlatformContextSkia.h: + (PlatformContextSkia): + (WebCore::PlatformContextSkia::isDeferred): + (WebCore::PlatformContextSkia::setDeferred): + +2012-06-26 Julien Chaffraix <jchaffraix@webkit.org> + + Crash in FixedTableLayout::layout + https://bugs.webkit.org/show_bug.cgi?id=88676 + + Unreviewed typo fix, pointed out by Darin Adler. + + * rendering/AutoTableLayout.cpp: + (WebCore::AutoTableLayout::layout): + * rendering/FixedTableLayout.cpp: + (WebCore::FixedTableLayout::layout): + +2012-06-26 Adam Klein <adamk@chromium.org> + + MutationObserver.observe should treat a null or undefined options argument as empty + https://bugs.webkit.org/show_bug.cgi?id=89992 + + Reviewed by Ojan Vafai. + + The WebIDL spec was recently updated to treat null or undefined + Dictionary arguments the same as the empty dictionary. This patch + updates MutationObserver.observe to follow that spec. + + Note that we still throw a SYNTAX_ERR in this case, since it's an + error not to pass one of "attributes", "childList", or "characterData" + as a key in the dictionary. + + * dom/WebKitMutationObserver.cpp: + (WebCore::WebKitMutationObserver::observe): + +2012-06-26 Ian Vollick <vollick@chromium.org> + + [chromium] The single thread proxy should not automatically tick new animations. + https://bugs.webkit.org/show_bug.cgi?id=89996 + + Reviewed by James Robinson. + + No new tests. No change to existing functionality. + + * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: + (WebCore::CCSingleThreadProxy::CCSingleThreadProxy): + (WebCore::CCSingleThreadProxy::initializeLayerRenderer): + (WebCore::CCSingleThreadProxy::didAddAnimation): + * platform/graphics/chromium/cc/CCSingleThreadProxy.h: + (WebCore): + +2012-06-26 Julien Chaffraix <jchaffraix@webkit.org> + + Crash in FixedTableLayout::layout + https://bugs.webkit.org/show_bug.cgi?id=88676 + + Reviewed by Abhishek Arya. + + Tests: fast/table/auto-table-layout-colgroup-removal-crash.html + fast/table/fixed-table-layout/colgroup-removal-crash.html + fast/table/fixed-table-layout/prepend-in-fixed-table.html + + The issue comes from RenderTable not properly dirtying its preferred logical + widths. As the table layout codes (both fixed and auto), recomputes their internal + structures at computePreferredLogicalWidth, the internal structure doesn't match + the table sizing and we crash. + + This fix adds a work-around in FixedTableLayout::layout (which matches AutoTableLayout). + The long-term fix would be to properly fix the logic but this is a lot safer, especially + since our logic is really not bullet-proof at the moment. + + * rendering/FixedTableLayout.cpp: + (WebCore::FixedTableLayout::layout): + Added an internal structure recomputation, if we have drifted from our table's structure. + Also we need to update nEffCols if we call calcWidthArray. + + * rendering/AutoTableLayout.cpp: + (WebCore::AutoTableLayout::layout): + Added a comment matching FixedTableLayout. The nEffCols is unneeded but kept for consistency + with FixedTableLayout. + +2012-06-26 Ian Vollick <vollick@chromium.org> + + [chromium] Layer chromium should need a redraw after getting its first non-empty bounds. + https://bugs.webkit.org/show_bug.cgi?id=89784 + + Reviewed by James Robinson. + + Previously, we'd only set needs redraw if the old bounds were zero, + and the new bounds were non-zero, but we should actually have + checked that the old bounds were non-empty. + + Unit test: LayerChromiumTestWithoutFixture.setBoundsTriggersSetNeedsRedrawAfterGettingNonEmptyBounds + + * platform/graphics/chromium/LayerChromium.cpp: + (WebCore::LayerChromium::setBounds): + +2012-06-26 Jia Pu <jpu@apple.com> + + On Mac, autocorrection sometimes fails to take place in Safari. + https://bugs.webkit.org/show_bug.cgi?id=89982 + + Reviewed by Darin Adler. + + Existing test was turned off due to intermittent failure, which is caused by autocorrection result depending on user data + that may be altered by previous test runs. Hopefully we can turn the test back on once we have a way to make autocorrection + behave consistently. + + Basically we should check the value of shouldCheckForCorrection, not shouldShowCorrectionPanel, to determine if we should + early return in markAndReplaceFor(). + + * editing/Editor.cpp: + (WebCore::Editor::markAndReplaceFor): + +2012-06-26 Joe Thomas <joethomas@motorola.com> + + Do early-return when author and user styles are disabled. + https://bugs.webkit.org/show_bug.cgi?id=89947 + + Reviewed by Andreas Kling. + + * dom/Document.cpp: + (WebCore::Document::collectActiveStylesheets): + +2012-06-26 James Robinson <jamesr@chromium.org> + + [chromium] Remove dead compositor-related API from GraphicsContext3DPrivate / Extensions3DChromium + https://bugs.webkit.org/show_bug.cgi?id=89933 + + Reviewed by Kenneth Russell. + + GraphicsContext3DPrivate and Extensions3DChromium had a fair amount of plumbing and boilerplate to support the + compositor's use of GraphicsContext3D. A number of extensions, etc, only make sense for a compositor context. + Since the compositor doesn't use GC3D any more, these are no longer needed. + + * platform/chromium/support/Extensions3DChromium.cpp: + * platform/chromium/support/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3D::~GraphicsContext3D): + (WebCore::GraphicsContext3D::create): + * platform/chromium/support/GraphicsContext3DPrivate.cpp: + (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): + (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): + (WebCore::GrMemoryAllocationChangedCallbackAdapter::GrMemoryAllocationChangedCallbackAdapter): + (WebCore::GraphicsContext3DPrivate::grContext): + * platform/chromium/support/GraphicsContext3DPrivate.h: + (WebCore): + (GraphicsContext3DPrivate): + * platform/graphics/chromium/Extensions3DChromium.h: + +2012-06-26 Yasuhiro Matsuda <mazda@chromium.org> + + [chromium] Add the workaround of IOSurface-related corruption during readback on Mac OS X. + https://bugs.webkit.org/show_bug.cgi?id=89797 + + Reviewed by James Robinson. + + No new tests. This patch doesn't change behavior. + + * platform/graphics/chromium/LayerRendererChromium.cpp: + (WebCore::LayerRendererChromium::getFramebufferPixels): + +2012-06-26 Alexei Filippov <alexeif@chromium.org> + + Web Inspector: Native memory snapshots crash in debug mode. + https://bugs.webkit.org/show_bug.cgi?id=89977 + + Reviewed by Yury Semikhatsky. + + * bindings/v8/V8DOMWrapper.cpp: + (WebCore::V8DOMWrapper::maybeDOMWrapper): + +2012-06-26 Huang Dongsung <luxtella@company100.net> + + [Texmap] Bug fix typo about computing bytesPerLine in BitmapTextureGL. + https://bugs.webkit.org/show_bug.cgi?id=89924 + + "bytesPerLine == targetRect.width() / 4" is invalid. + This patch amended it into "bytesPerLine == targetRect.width() * 4". + Moreover, changed magic number 4 to bytesPerPixel. + + Reviewed by Noam Rosenthal. + + No new tests. Covered by existing tests. + + * platform/graphics/texmap/TextureMapperGL.cpp: + (WebCore::BitmapTextureGL::updateContents): + +2012-06-26 Roland Takacs <takacs.roland@stud.u-szeged.hu> + + Shader compiler unprepared to make ESSL output when GLES is used + https://bugs.webkit.org/show_bug.cgi?id=87718 + + Reviewed by Noam Rosenthal. + + Defined a new member that says what type of output code must be generated + (SH_GLSL_OUTPUT, SH_ESSL_OUTPUT). It is set within the constructor. + + * platform/graphics/ANGLEWebKitBridge.cpp: + (WebCore::ANGLEWebKitBridge::ANGLEWebKitBridge): + (WebCore::ANGLEWebKitBridge::validateShaderSource): + * platform/graphics/ANGLEWebKitBridge.h: + (ANGLEWebKitBridge): + * platform/graphics/qt/GraphicsContext3DQt.cpp: + (WebCore::GraphicsContext3D::GraphicsContext3D): + +2012-06-26 Philip Rogers <pdr@google.com> + + Fix bug where animations failed to start + https://bugs.webkit.org/show_bug.cgi?id=89943 + + Reviewed by Nikolas Zimmermann. + + The unpause code previously checked that the animations had not started + before un-setting the pause state. This meant that if an animation was + paused and unpaused before the animations started, it would remain in the + paused state. This patch simply reorders the unpause logic to fix this bug. + + Test: svg/custom/animate-initial-pause-unpause.html + + * svg/animation/SMILTimeContainer.cpp: + (WebCore::SMILTimeContainer::resume): + +2012-06-26 Yury Semikhatsky <yurys@chromium.org> + + Web Inspector: popover is not shown for detached DOM nodes, not referenced directly from JS + https://bugs.webkit.org/show_bug.cgi?id=89955 + + Reviewed by Vsevolod Vlasov. + + Show object popover for all heap snapshot nodes event for those whose + canBeQueried flag is false. We didn't show popover for such objects before + as it could lead to the backend crash. In the meantime the backend shouldn't + fail on such DOM wrappers and report an error if it cannot resolve + inspected object. + + * inspector/front-end/HeapSnapshotGridNodes.js: + (WebInspector.HeapSnapshotGenericObjectNode): + (WebInspector.HeapSnapshotGenericObjectNode.prototype.get data): + * inspector/front-end/HeapSnapshotView.js: + (WebInspector.HeapSnapshotView.prototype._getHoverAnchor): + +2012-06-26 Christophe Dumez <christophe.dumez@intel.com> + + [EFL] Simplify SharedBuffer::createWithContentsOfFile() implementation + https://bugs.webkit.org/show_bug.cgi?id=89655 + + Reviewed by Csaba Osztrogonác. + + Simplify the implementation of SharedBuffer::createWithContentsOfFile() + in EFL port. + + No new test, no behavior change. + + * platform/efl/SharedBufferEfl.cpp: + (WebCore::SharedBuffer::createWithContentsOfFile): + +2012-06-26 Thiago Marcos P. Santos <thiago.santos@intel.com> + + [EFL] REGRESSION (r121163): fast/frames/iframe-access-screen-of-deleted.html crashes + https://bugs.webkit.org/show_bug.cgi?id=89964 + + Reviewed by Andreas Kling. + + Added missing null pointer check. + + * platform/efl/PlatformScreenEfl.cpp: + (WebCore::screenDepth): + (WebCore::screenDepthPerComponent): + +2012-06-26 Taiju Tsuiki <tzik@chromium.org> + + Web Inspector: Add requestMetadata command and metadataReceived event to FileSystem + https://bugs.webkit.org/show_bug.cgi?id=87856 + + Reviewed by Yury Semikhatsky. + + Test: http/tests/inspector/filesystem/get-metadata.html + + * inspector/Inspector.json: + * inspector/InspectorFileSystemAgent.cpp: + (WebCore): + (WebCore::InspectorFileSystemAgent::requestFileSystemRoot): + (WebCore::InspectorFileSystemAgent::requestDirectoryContent): + (WebCore::InspectorFileSystemAgent::requestMetadata): + * inspector/InspectorFileSystemAgent.h: + (InspectorFileSystemAgent): + * inspector/front-end/FileSystemModel.js: + (WebInspector.FileSystemModel.prototype._directoryContentReceived): + (WebInspector.FileSystemModel.prototype.requestMetadata): + (WebInspector.FileSystemModel.Entry.prototype.get isDirectory): + (WebInspector.FileSystemModel.Entry.prototype.requestMetadata): + (WebInspector.FileSystemRequestManager): + (WebInspector.FileSystemRequestManager.prototype._directoryContentReceived): + (WebInspector.FileSystemRequestManager.prototype.requestMetadata.requestAccepted): + (WebInspector.FileSystemRequestManager.prototype.requestMetadata): + (WebInspector.FileSystemRequestManager.prototype._metadataReceived): + (WebInspector.FileSystemDispatcher.prototype.directoryContentReceived): + (WebInspector.FileSystemDispatcher.prototype.metadataReceived): + +2012-06-25 Jocelyn Turcotte <turcotte.j@gmail.com> + + [Qt] GraphicsSurface: Fix tile update artifacts on Mac + https://bugs.webkit.org/show_bug.cgi?id=89887 + + Reviewed by Noam Rosenthal. + + * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp: + (WebCore::GraphicsSurface::platformCopyToGLTexture): + +2012-06-25 Jocelyn Turcotte <turcotte.j@gmail.com> + + GraphicsSurface: Fix IOSurfaceLock failures on Intel video cards. + https://bugs.webkit.org/show_bug.cgi?id=89883 + + Reviewed by Noam Rosenthal. + + Follow the documentation which says: "If locking the buffer requires a readback, + the lock will fail with an error return of kIOReturnCannotLock." + Also make sure that we use the same set of flags when locking and unlocking + for simplicity and to follow this requirement on the kIOSurfaceLockReadOnly flag. + + * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp: + (WebCore::GraphicsSurface::platformLock): + (WebCore::GraphicsSurface::platformUnlock): + +2012-06-26 Philip Rogers <pdr@google.com> + + Fix setCurrentTime for paused animations + https://bugs.webkit.org/show_bug.cgi?id=81350 + + Reviewed by Nikolas Zimmermann. + + SMILTimeContainer::setElapsed was not resetting the pause time, breaking + setCurrentTime if the animation was paused. + + Test: svg/custom/animate-pause-resume.html + + * svg/animation/SMILTimeContainer.cpp: + (WebCore::SMILTimeContainer::setElapsed): + +2012-06-26 Csaba Osztrogonác <ossy@webkit.org> + + [Qt] Unreviewed typo fix after r121144. + + * Target.pri: + +2012-06-26 Yury Semikhatsky <yurys@chromium.org> + + Web Inspector: columns in heap snapshot summary view are not resizable + https://bugs.webkit.org/show_bug.cgi?id=89952 + + Reviewed by Vsevolod Vlasov. + + * inspector/front-end/HeapSnapshotDataGrids.js: + (WebInspector.HeapSnapshotViewportDataGrid.prototype.onResize): overriden method + should call overriden one to make sure column resizers are added to the DataGrid. + +2012-06-26 Kent Tamura <tkent@chromium.org> + + Refactoring: Simplify FormController interface + https://bugs.webkit.org/show_bug.cgi?id=89951 + + Reviewed by Kentaro Hara. + + - Remove FormController::hasStateForNewFormElements() + takeStateForFormElement() can check the emptiness, and return an empty + FormControlState. + + - Change the argument of takeStateForFormElement() + Passing just one HTMLFormControlElementWithState object instead of two + AtomicStringImpl. This is a preparation to use + HTMLFormControlElementWithState::form() in FormController. + + No new tests. Just a refactoring. + + * html/FormController.cpp: + (WebCore::FormController::takeStateForFormElement): + * html/FormController.h: + (FormController): + * html/HTMLFormControlElementWithState.cpp: + (WebCore::HTMLFormControlElementWithState::finishParsingChildren): + +2012-06-26 Dominic Cooney <dominicc@chromium.org> + + WheelEvent should inherit from MouseEvent + https://bugs.webkit.org/show_bug.cgi?id=76104 + + Reviewed by Kentaro Hara. + + The spec for WheelEvent is + <http://www.w3.org/TR/DOM-Level-3-Events/#webidl-events-WheelEvent> + + Tests: fast/events/event-creation.html + http://samples.msdn.microsoft.com/ietestcenter/dominheritance/showdominheritancetest.htm?Prototype_WheelEvent + + * bindings/objc/PublicDOMInterfaces.h: Remove redundant MouseEvent API from WheelEvent + * bindings/scripts/CodeGeneratorObjC.pm: MouseEvents are Events + * dom/MouseEvent.h: Expose no-arg constructor to WheelEvent + * dom/WheelEvent.cpp: + (WebCore::WheelEvent::WheelEvent): Call MouseEvent superconstructor + (WebCore::WheelEvent::isMouseEvent): Existing callers use this just for + moves and clicks, ie the type is exactly MouseEvent. + * dom/WheelEvent.h: Extend MouseEvent + * dom/WheelEvent.idl: " + +2012-06-25 Ryosuke Niwa <rniwa@webkit.org> + + Get rid of firstItem and nextItem from HTMLCollection + https://bugs.webkit.org/show_bug.cgi?id=89923 + + Reviewed by Andreas Kling. + + Removed HTMLCollection::firstItem and HTMLCollection::nextItem. + Also added hasAnyItem() and hasExactlyOneItem() to HTMLCollection so that named getter on Document + doesn't need to compute the full length before returning a HTMLCollection. + + * accessibility/AccessibilityRenderObject.cpp: + (WebCore::AccessibilityRenderObject::getDocumentLinks): + * bindings/js/JSDOMWindowCustom.cpp: + (WebCore::namedItemGetter): + * bindings/js/JSHTMLDocumentCustom.cpp: + (WebCore::JSHTMLDocument::nameGetter): + * bindings/v8/custom/V8DOMWindowCustom.cpp: + (WebCore::V8DOMWindow::namedPropertyGetter): + * bindings/v8/custom/V8HTMLDocumentCustom.cpp: + (WebCore::V8HTMLDocument::GetNamedProperty): + * dom/Document.cpp: + (WebCore::Document::openSearchDescriptionURL): + * html/HTMLCollection.cpp: + (WebCore::shouldIncludeChildren): + (WebCore::HTMLCollection::HTMLCollection): + (WebCore): + (WebCore::HTMLCollection::item): + * html/HTMLCollection.h: + (HTMLCollection): + (WebCore::HTMLCollection::hasAnyItem): + (WebCore::HTMLCollection::hasExactlyOneItem): + * html/HTMLMapElement.cpp: + (WebCore::HTMLMapElement::imageElement): + +2012-06-25 Pratik Solanki <psolanki@apple.com> + + JavaScript resources have low priority when SVG is enabled + https://bugs.webkit.org/show_bug.cgi?id=89932 + <rdar://problem/11741325> + + Reviewed by Adele Peterson. + + r108785 inadvertently lowered the priority of JavaScript resources. Fix the code so we set + the correct priority for scripts. Also, move the code so that all ifdefs are together at the + bottom to make it a bit easier to read.. + + * loader/cache/CachedResource.cpp: + (WebCore::defaultPriorityForResourceType): + +2012-06-25 Luke Macpherson <macpherson@chromium.org> + + Add runtime flag to enable/disable CSS variables (in addition to existing compile-time flag). + https://bugs.webkit.org/show_bug.cgi?id=89542 + + Reviewed by Dimitri Glazkov. + + Added fast/css/variables/build-supports-variables.html to test runtime flag in test environment. + Updated all other css variables tests to enable the runtime flag from JS. + + * css/CSSParser.cpp: + (WebCore::CSSParserContext::CSSParserContext): + (WebCore::operator==): + (WebCore::CSSParser::cssVariablesEnabled): + (WebCore): + (WebCore::CSSParser::detectDashToken): + (WebCore::CSSParser::lex): + * css/CSSParser.h: + (CSSParser): + * css/CSSParserMode.h: + (CSSParserContext): + * page/Settings.h: + (Settings): + (WebCore::Settings::setCSSVariablesEnabled): + (WebCore::Settings::cssVariablesEnabled): + +2012-06-25 Simon Hausmann <simon.hausmann@nokia.com> + + Unreviewed build fix after r121223. + + Fix the --minimal Qt build, TextureMapperGL now requires WebGL to be enabled. + + * Target.pri: + * WebCore.pri: + +2012-06-25 Dana Jansens <danakj@chromium.org> + + [chromium] CCOverdrawMetrics should use the deviceViewportSize to count actual pixels + https://bugs.webkit.org/show_bug.cgi?id=89922 + + Reviewed by Adrienne Walker. + + * platform/graphics/chromium/cc/CCOverdrawMetrics.cpp: + (WebCore::CCOverdrawMetrics::recordMetricsInternal): + +2012-06-25 Huang Dongsung <luxtella@company100.net> + + [Texmap] Remove platform specific code in BitmapImageGL::updateContents by using + GraphicsContext3D::extractImageData. + https://bugs.webkit.org/show_bug.cgi?id=89867 + + Reviewed by Noam Rosenthal. + + No new tests. Covered by existing tests. + + * platform/graphics/texmap/TextureMapperGL.cpp: + (WebCore): + (WebCore::BitmapTextureGL::didReset): + (WebCore::BitmapTextureGL::updateContents): + +2012-06-25 James Robinson <jamesr@chromium.org> + + [chromium] Remove uncalled ManagedTexture::framebufferTexture2D + https://bugs.webkit.org/show_bug.cgi?id=89930 + + Reviewed by Adrienne Walker. + + Removing dead code. + + * platform/graphics/chromium/ManagedTexture.cpp: + * platform/graphics/chromium/ManagedTexture.h: + (ManagedTexture): + +2012-06-25 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r121206. + http://trac.webkit.org/changeset/121206 + https://bugs.webkit.org/show_bug.cgi?id=89935 + + [chromium] webkit_unit_tests + WebViewTest.MHTMLWithMissingResourceFinishesLoading crash + (Requested by ukai on #webkit). + + * loader/DocumentLoader.cpp: + (WebCore::DocumentLoader::scheduleArchiveLoad): + +2012-06-25 Anantanarayanan G Iyengar <ananta@chromium.org> + + [chromium] Ensure that the compositor code which is aware of flipped status of video-textures + per platform executes on Windows. + https://bugs.webkit.org/show_bug.cgi?id=89914 + + Reviewed by James Robinson. + + No new tests. (HW video decode is still only being tested manually for orientation) + + * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp: + (WebCore::CCVideoLayerImpl::appendQuads): + +2012-06-25 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r121176. + http://trac.webkit.org/changeset/121176 + https://bugs.webkit.org/show_bug.cgi?id=89934 + + [chromium] browser_tests assert failed: + FATAL:native_theme_win.cc(1541)] Check failed: false. Invalid + part: 16 (Requested by ukai on #webkit). + + * platform/chromium/PlatformSupport.h: + (PlatformSupport): + * platform/chromium/ScrollbarThemeChromiumWin.cpp: + (WebCore::ScrollbarThemeChromiumWin::buttonSize): + +2012-06-25 Shinya Kawanaka <shinyak@chromium.org> + + [Shadow] Deleting list distributed to Shadow DOM does not work correctly. + https://bugs.webkit.org/show_bug.cgi?id=89170 + + Reviewed by Ryosuke Niwa. + + When deleting several elements distributed to Shadow DOM, some renderers might be gone in + processing deletion. To fix them, we should call isContentEditable() instead of rendererIsEditable(). + + Test: editing/shadow/delete-list-in-shadow.html + + * editing/DeleteFromTextNodeCommand.cpp: + (WebCore::DeleteFromTextNodeCommand::doApply): + +2012-06-25 Min Qin <qinmin@chromium.org> + + [Chromium] Fix the css stylesheet for android media controls after recent changes + https://bugs.webkit.org/show_bug.cgi?id=89910 + + Reviewed by Adam Barth. + + After the recent changes on upstream chrome video controls, we need to change the css style sheet for chrome on android. + No tests needed, just css changes. + + * css/mediaControlsChromiumAndroid.css: + (audio): + (audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel): + (::-webkit-media-controls): + (audio::-webkit-media-controls-enclosure, video::-webkit-media-controls-enclosure): + (video::-webkit-media-controls-enclosure): + (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-time-remaining-display, video::-webkit-media-controls-time-remaining-display): + (audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline): + (video::-webkit-media-controls-fullscreen-button): + (input[type="range"]::-webkit-media-slider-container): + (input[type="range"]::-webkit-media-slider-thumb): + (audio::-webkit-media-controls-fullscreen-button): + +2012-06-25 Huang Dongsung <luxtella@company100.net> + + [Qt] Avoid a deep copy of QImage in GraphicsContext3D::getImageData. + https://bugs.webkit.org/show_bug.cgi?id=89865 + + Reviewed by Noam Rosenthal. + + No new tests. Covered by existing tests. + + * platform/graphics/qt/GraphicsContext3DQt.cpp: + (WebCore::GraphicsContext3D::getImageData): + +2012-06-25 Nick Carter <nick@chromium.org> + + Reduce memory footprint of BitmapImage Vectors. + https://bugs.webkit.org/show_bug.cgi?id=86563 + + Reviewed by Simon Fraser. + + No new tests, affects template params only. + + * platform/graphics/BitmapImage.h: + (BitmapImage): use an inline capacity of 1 for the image frame Vector + * platform/image-decoders/ImageDecoder.h: + (ImageDecoder): use an inline capacity of 1 for the image frame Vector + +2012-06-25 Kent Tamura <tkent@chromium.org> + + Unreviewed, rolling out r121145. + http://trac.webkit.org/changeset/121145 + https://bugs.webkit.org/show_bug.cgi?id=89847 + + Had an objection for the change. + + * html/FormController.cpp: + (WebCore): + (WebCore::FormControlState::serializeTo): + (WebCore::FormControlState::deserialize): + (WebCore::formStateSignature): + (WebCore::FormController::formElementsState): + (WebCore::FormController::setStateForNewFormElements): + * html/FormController.h: + (FormControlState): + * html/shadow/CalendarPickerElement.cpp: + (WebCore::addJavaScriptString): + +2012-06-25 Jay Civelli <jcivelli@chromium.org> + + Fix progress load reporting for MHTML documents. + + MHTML documents containing references to resources they don't include + never finish loading. + https://bugs.webkit.org/show_bug.cgi?id=71859 + + Reviewed by Nate Chapin. + + * loader/DocumentLoader.cpp: + (WebCore::DocumentLoader::scheduleArchiveLoad): + +2012-06-25 James Robinson <jamesr@chromium.org> + + [chromium] Use WebGraphicsContext3D in compositor implementation + https://bugs.webkit.org/show_bug.cgi?id=89700 + + Reviewed by Adrienne Walker. + + This converts the compositor implementation from using WebCore::GraphicsContext3D to using the Platform-provided + WebGraphicsContext3D. This removes several unnecessary layers of indirection/wrapping and cuts down the + compositor's implementation dependencies. GraphicsContext3D.h is still widely used to provide GL enum values. + Most of the changes are purely mechanical - changing type names and the like. + + Ownership is changed a bit. Instead of multiple components holding references to the compositor's context, the + context is now owned by the CCGraphicsContext, which is now owned directly by CCLayerTreeHostImpl. + CCLayerTreeHostImpl also has ownership of its CCRenderer (LayerRendererChromium in 3D mode) and passes a + non-owning pointer down to the CCRenderer. + + Extension checking is a bit different. The compositor does not (and never has) used extensions provided by + WebGL's request/ensure mechanism. It simply checks for the existence of extensions it needs in the GL_EXTENSIONS + string. + + FrameBufferSkPictureCanvasLayerTextureUpdater had to be patched as well, since it was grabbing a GrContext off + of the compositor's GraphicsContext3D. This caused many problems. It was inefficient, since it required a full + state flush when switching between ganesh and compositor calls. The gpu memory management was completely broken + since the compositor clobbered ganesh's onMemoryAllocationChanged callback. This moves FBSkPCLTU over to using + the appropriate SharedGraphicsContext3D, like filters. + + * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp: + (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect): + (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect): + * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h: + (FrameBufferSkPictureCanvasLayerTextureUpdater): + * platform/graphics/chromium/GeometryBinding.cpp: + (WebCore::GeometryBinding::GeometryBinding): + * platform/graphics/chromium/GeometryBinding.h: + (WebKit): + (GeometryBinding): + (WebCore::GeometryBinding::context): + * platform/graphics/chromium/LayerRendererChromium.cpp: + (WebCore::LayerRendererChromium::create): + (WebCore::LayerRendererChromium::LayerRendererChromium): + (WebCore::LayerRendererChromium::initialize): + (WebCore::LayerRendererChromium::~LayerRendererChromium): + (WebCore::LayerRendererChromium::context): + (WebCore::LayerRendererChromium::debugGLCall): + (WebCore::LayerRendererChromium::setVisible): + (WebCore::LayerRendererChromium::drawStreamVideoQuad): + (WebCore::LayerRendererChromium::drawHeadsUpDisplay): + (WebCore::LayerRendererChromium::swapBuffers): + (WebCore::LayerRendererChromium::onMemoryAllocationChanged): + (WebCore): + (WebCore::LayerRendererChromium::onMemoryAllocationChangedOnImplThread): + (WebCore::LayerRendererChromium::discardFramebuffer): + (WebCore::LayerRendererChromium::ensureFramebuffer): + (WebCore::LayerRendererChromium::onContextLost): + (WebCore::LayerRendererChromium::getFramebufferPixels): + (WebCore::LayerRendererChromium::getFramebufferTexture): + (WebCore::LayerRendererChromium::bindFramebufferToTexture): + (WebCore::LayerRendererChromium::initializeSharedObjects): + (WebCore::LayerRendererChromium::tileCheckerboardProgram): + (WebCore::LayerRendererChromium::solidColorProgram): + (WebCore::LayerRendererChromium::headsUpDisplayProgram): + (WebCore::LayerRendererChromium::renderPassProgram): + (WebCore::LayerRendererChromium::renderPassProgramAA): + (WebCore::LayerRendererChromium::renderPassMaskProgram): + (WebCore::LayerRendererChromium::renderPassMaskProgramAA): + (WebCore::LayerRendererChromium::tileProgram): + (WebCore::LayerRendererChromium::tileProgramOpaque): + (WebCore::LayerRendererChromium::tileProgramAA): + (WebCore::LayerRendererChromium::tileProgramSwizzle): + (WebCore::LayerRendererChromium::tileProgramSwizzleOpaque): + (WebCore::LayerRendererChromium::tileProgramSwizzleAA): + (WebCore::LayerRendererChromium::textureProgram): + (WebCore::LayerRendererChromium::textureProgramFlip): + (WebCore::LayerRendererChromium::textureIOSurfaceProgram): + (WebCore::LayerRendererChromium::videoYUVProgram): + (WebCore::LayerRendererChromium::videoStreamTextureProgram): + (WebCore::LayerRendererChromium::cleanupSharedObjects): + (WebCore::LayerRendererChromium::isContextLost): + * platform/graphics/chromium/LayerRendererChromium.h: + (WebKit): + (WebCore): + (LayerRendererChromium): + (WebCore::LayerRendererChromium::isFramebufferDiscarded): + * platform/graphics/chromium/LayerTextureSubImage.cpp: + (WebCore::LayerTextureSubImage::uploadWithTexSubImage): + (WebCore::LayerTextureSubImage::uploadWithMapTexSubImage): + * platform/graphics/chromium/ManagedTexture.cpp: + (WebCore::ManagedTexture::bindTexture): + (WebCore::ManagedTexture::framebufferTexture2D): + * platform/graphics/chromium/PlatformColor.h: + (WebCore::PlatformColor::bestTextureFormat): + * platform/graphics/chromium/ProgramBinding.cpp: + (WebCore::contextLost): + (WebCore::ProgramBindingBase::init): + (WebCore::ProgramBindingBase::cleanup): + (WebCore::ProgramBindingBase::loadShader): + (WebCore::ProgramBindingBase::createShaderProgram): + * platform/graphics/chromium/ProgramBinding.h: + (WebKit): + (ProgramBindingBase): + (WebCore::ProgramBinding::ProgramBinding): + (WebCore::ProgramBinding::initialize): + * platform/graphics/chromium/ShaderChromium.cpp: + (WebCore::VertexShaderPosTex::init): + (WebCore::VertexShaderPosTexYUVStretch::init): + (WebCore::VertexShaderPos::init): + (WebCore::VertexShaderPosTexTransform::init): + (WebCore::VertexShaderQuad::init): + (WebCore::VertexShaderTile::init): + (WebCore::VertexShaderVideoTransform::init): + (WebCore::FragmentTexAlphaBinding::init): + (WebCore::FragmentTexOpaqueBinding::init): + (WebCore::FragmentShaderOESImageExternal::init): + (WebCore::FragmentShaderRGBATexAlphaAA::init): + (WebCore::FragmentTexClampAlphaAABinding::init): + (WebCore::FragmentShaderRGBATexAlphaMask::init): + (WebCore::FragmentShaderRGBATexAlphaMaskAA::init): + (WebCore::FragmentShaderYUVVideo::init): + (WebCore::FragmentShaderColor::init): + (WebCore::FragmentShaderCheckerboard::init): + * platform/graphics/chromium/ShaderChromium.h: + (WebKit): + (VertexShaderPosTex): + (VertexShaderPosTexYUVStretch): + (VertexShaderPos): + (WebCore::VertexShaderPosTexIdentity::init): + (VertexShaderPosTexTransform): + (VertexShaderQuad): + (VertexShaderTile): + (VertexShaderVideoTransform): + (FragmentTexAlphaBinding): + (FragmentTexOpaqueBinding): + (FragmentShaderOESImageExternal): + (FragmentShaderRGBATexAlphaAA): + (FragmentTexClampAlphaAABinding): + (FragmentShaderRGBATexAlphaMask): + (FragmentShaderRGBATexAlphaMaskAA): + (FragmentShaderYUVVideo): + (FragmentShaderColor): + (FragmentShaderCheckerboard): + * platform/graphics/chromium/TextureCopier.cpp: + (WebCore::AcceleratedTextureCopier::AcceleratedTextureCopier): + (WebCore::AcceleratedTextureCopier::~AcceleratedTextureCopier): + (WebCore::AcceleratedTextureCopier::copyTexture): + * platform/graphics/chromium/TextureCopier.h: + (WebKit): + (WebCore): + (WebCore::AcceleratedTextureCopier::create): + (AcceleratedTextureCopier): + * platform/graphics/chromium/TextureManager.h: + * platform/graphics/chromium/ThrottledTextureUploader.cpp: + (WebCore::ThrottledTextureUploader::Query::Query): + (WebCore::ThrottledTextureUploader::Query::~Query): + (WebCore::ThrottledTextureUploader::Query::begin): + (WebCore::ThrottledTextureUploader::Query::end): + (WebCore::ThrottledTextureUploader::Query::isPending): + (WebCore::ThrottledTextureUploader::Query::wait): + (WebCore::ThrottledTextureUploader::ThrottledTextureUploader): + * platform/graphics/chromium/ThrottledTextureUploader.h: + (WebKit): + (WebCore::ThrottledTextureUploader::create): + (WebCore::ThrottledTextureUploader::Query::create): + (Query): + (ThrottledTextureUploader): + * platform/graphics/chromium/TrackingTextureAllocator.cpp: + (WebCore::TrackingTextureAllocator::TrackingTextureAllocator): + (WebCore::TrackingTextureAllocator::createTexture): + (WebCore::TrackingTextureAllocator::deleteTexture): + (WebCore::TrackingTextureAllocator::deleteAllTextures): + * platform/graphics/chromium/TrackingTextureAllocator.h: + (WebKit): + (WebCore::TrackingTextureAllocator::create): + (TrackingTextureAllocator): + * platform/graphics/chromium/cc/CCGraphicsContext.h: + (CCGraphicsContext): + (WebCore::CCGraphicsContext::create2D): + (WebCore::CCGraphicsContext::create3D): + (WebCore::CCGraphicsContext::context3D): + (WebCore::CCGraphicsContext::CCGraphicsContext): + * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: + (WebCore::CCHeadsUpDisplay::draw): + * platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp: + (WebCore::CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl): + (WebCore::CCIOSurfaceLayerImpl::willDraw): + * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: + (WebCore::CCLayerTreeHost::createContext): + * platform/graphics/chromium/cc/CCLayerTreeHost.h: + (CCLayerTreeHostClient): + (WebCore::LayerRendererCapabilities::LayerRendererCapabilities): + (LayerRendererCapabilities): + (WebCore::CCLayerTreeHost::needsSharedContext): + (CCLayerTreeHost): + * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: + (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer): + * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: + (CCLayerTreeHostImpl): + * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: + (WebCore::CCSingleThreadProxy::initializeContext): + (WebCore::CCSingleThreadProxy::recreateContext): + * platform/graphics/chromium/cc/CCSingleThreadProxy.h: + * platform/graphics/chromium/cc/CCTextureUpdater.cpp: + (WebCore::CCTextureUpdater::update): + * platform/graphics/chromium/cc/CCThreadProxy.cpp: + (WebCore::CCThreadProxy::initializeContext): + (WebCore::CCThreadProxy::recreateContext): + (WebCore::CCThreadProxy::beginFrame): + (WebCore::CCThreadProxy::initializeContextOnImplThread): + (WebCore::CCThreadProxy::recreateContextOnImplThread): + * platform/graphics/chromium/cc/CCThreadProxy.h: + (CCThreadProxy): + * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp: + (WebCore::CCVideoLayerImpl::FramePlane::allocateData): + (WebCore::CCVideoLayerImpl::FramePlane::freeData): + (WebCore::CCVideoLayerImpl::copyPlaneData): + +2012-06-25 Adrienne Walker <enne@google.com> + + [chromium] Make CCThreadProxy not draw a frame mid-commit + https://bugs.webkit.org/show_bug.cgi?id=89905 + + Reviewed by James Robinson. + + If commitComplete is not called before the next frame goes up, then + then the max scroll position on the root scroll layer is not updated. + This causes the compositor-side scrollbar to have an incorrect + visibleSize, causing the thumbRect to become stretched, relative to + when it was originally painted. + + CCScheduler::setVisible has the side effect of kicking off a frame, so + move it last. + + * platform/graphics/chromium/cc/CCThreadProxy.cpp: + (WebCore::CCThreadProxy::scheduledActionCommit): + +2012-06-25 Pablo Flouret <pablof@motorola.com> - * platform/PlatformExportMacros.h: + EventSource: Events should not be dispatched after close() + https://bugs.webkit.org/show_bug.cgi?id=85346 + + Reviewed by Adam Barth. + + Spec changed to make sure that no events are dispatched after close() is + called, even if more data was received before the call to close(). + + See, + https://www.w3.org/Bugs/Public/show_bug.cgi?id=14331#c5 + http://html5.org/tools/web-apps-tracker?from=6771&to=6772 + + Firefox behaves like this already. + + Test: http/tests/eventsource/eventsource-events-after-close.html + + * page/EventSource.cpp: + (WebCore::EventSource::parseEventStream): + +2012-06-25 Mike West <mkwst@chromium.com> + + Fixing compilation failure in StyleResolver.cpp/CSSParser.cpp + https://bugs.webkit.org/show_bug.cgi?id=89892 + + Reviewed by Alexis Menard. + + Adding CSSPropertyVariable to switch statements in CSSParser and + StyleResolver to fix compilation errors under ninja/clang. I've + added both as new cases to the switches, with FIXME comments for + implementation. + + * css/CSSParser.cpp: + (WebCore::CSSParser::parseValue): + * css/StyleResolver.cpp: + (WebCore::StyleResolver::collectMatchingRulesForList): + +2012-06-25 Jay Civelli <jcivelli@chromium.org> + + Fix for a memory leak with MHTMLArchives. + + MHTML files present a flat list of frames and resources but the WebKit Archive + has a tree strcture. So the MHTMLArchive class make sures that every frame + knows about any other frames and resources. + Because these objects are ref counted, that would introduce circular references + preventing the entire Archive from being deleted. + This fixes this by: + - making sure the top-frame (which appears as the first entry in the MHTML) is + not referenced by the other frames. + - when the main frame is deleted it traverse the entire subarchive (sub-frames) + graph and makes sure they clear all their references to other subarchives. + + https://bugs.webkit.org/show_bug.cgi?id=88470 + + Reviewed by Adam Barth. + + * loader/archive/Archive.cpp: + (WebCore::Archive::clearAllSubframeArchives): + (WebCore): + (WebCore::Archive::clearAllSubframeArchivesImpl): + * loader/archive/Archive.h: + (Archive): + * loader/archive/mhtml/MHTMLArchive.cpp: + (WebCore::MHTMLArchive::~MHTMLArchive): + (WebCore): + (WebCore::MHTMLArchive::create): + * loader/archive/mhtml/MHTMLArchive.h: + (MHTMLArchive): + +2012-06-25 Alpha Lam <hclam@chromium.org> + + Unreviewed, rolling out r121178. + http://trac.webkit.org/changeset/121178 + https://bugs.webkit.org/show_bug.cgi?id=89784 + + New unit test added is failing on WebKit Linux (dbg) + + * platform/graphics/chromium/LayerChromium.cpp: + (WebCore::LayerChromium::setBounds): + +2012-06-25 Alpha Lam <hclam@chromium.org> + + Unreviewed, rolling out r121137. + http://trac.webkit.org/changeset/121137 + + Chromium build fix, (un)touch files to build on Chromium Win + Release + + * css/CSSParserMode.h: + * css/CSSValue.h: + (WebCore): + * css/CSSVariableValue.h: + * page/Settings.h: + * rendering/style/RenderStyle.h: + * rendering/style/StyleRareInheritedData.h: + * rendering/style/StyleVariableData.h: + +2012-06-25 Alpha Lam <hclam@chromium.org> + + Unreviewed, rolling out r121129. + http://trac.webkit.org/changeset/121129 + https://bugs.webkit.org/show_bug.cgi?id=89542 + + Chromium ASan failure: crbug.com/134402 + + * css/CSSParser.cpp: + (WebCore::CSSParserContext::CSSParserContext): + (WebCore::operator==): + (WebCore): + (WebCore::CSSParser::detectDashToken): + (WebCore::CSSParser::lex): + * css/CSSParser.h: + (CSSParser): + * css/CSSParserMode.h: + (CSSParserContext): + * css/StyleResolver.cpp: + (WebCore::StyleResolver::collectMatchingRulesForList): + * page/Settings.h: + (Settings): + * testing/InternalSettings.cpp: + * testing/InternalSettings.h: + (InternalSettings): + * testing/InternalSettings.idl: + +2012-06-25 Adam Barth <abarth@webkit.org> + + Use InterpolationLow on chromium-android + https://bugs.webkit.org/show_bug.cgi?id=89849 + + Reviewed by Daniel Bates. + + Min Qin writes: + + Using InterpolationHigh is very very expensive when resampling + images. For example, it took 1400ms to decode an image on + http://www.crossfitsunnyvale.com/blog/, but it took 2800 ms to do the + resampling Switch to InterpolationLow will result in linear + resampling. It is much faster as the time it tooks is almost + non-noticable [sic] on the trace. + + * platform/graphics/skia/PlatformContextSkia.cpp: + (WebCore::PlatformContextSkia::State::State): + +2012-06-25 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Remove unused backend property accessors + https://bugs.webkit.org/show_bug.cgi?id=89893 + + Reviewed by Darin Fisher. + + Following the "metadata" API addition in trac.webkit.org/changeset/121059 + the IDBXXXBackendInterface types no longer need per-property accessors. + + No new tests - no functional changes. + + * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Remove method implementation. + * Modules/indexeddb/IDBDatabaseBackendImpl.h: Remove methods. + (IDBDatabaseBackendImpl): + * Modules/indexeddb/IDBDatabaseBackendInterface.h: Remove methods. + (IDBDatabaseBackendInterface): + * Modules/indexeddb/IDBIndexBackendImpl.h: Make methods simple accessors. + (IDBIndexBackendImpl): + (WebCore::IDBIndexBackendImpl::name): + (WebCore::IDBIndexBackendImpl::keyPath): + (WebCore::IDBIndexBackendImpl::unique): + (WebCore::IDBIndexBackendImpl::multiEntry): + * Modules/indexeddb/IDBIndexBackendInterface.h: Remove methods. + * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: Remove method implementation. + * Modules/indexeddb/IDBObjectStoreBackendImpl.h: Make methods simple accessors. + (IDBObjectStoreBackendImpl): + (WebCore::IDBObjectStoreBackendImpl::name): + (WebCore::IDBObjectStoreBackendImpl::keyPath): + (WebCore::IDBObjectStoreBackendImpl::autoIncrement): + * Modules/indexeddb/IDBObjectStoreBackendInterface.h: Remove methods. + +2012-06-25 Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com> + + [EFL] Add support for building with ENABLE_MEDIA_STREAM + https://bugs.webkit.org/show_bug.cgi?id=88413 + + Reviewed by Dirk Pranke. + + Add files which are needed for supporting the Media Stream + feature. + + No change in functionality so no new tests. + + * PlatformEfl.cmake: + +2012-06-25 Huang Dongsung <luxtella@company100.net> + + [Texmap] TextureMapperPaintOptions should keep current surface. + https://bugs.webkit.org/show_bug.cgi?id=89266 + + Before this patch, if a replica layer has a descendant replica child, the child + layer does not render the result in the parent layer's surface because + TextureMapperPaintOptions does not keep current surface. + This patch amends that TextureMapperPaintOptions keeps current surface before + calling paintSelfAndChildrenWithReplica recursively, so previous surface could be + restored after paintSelfAndChildrenWithReplica. + + Reviewed by Noam Rosenthal. + + Test: compositing/reflections/animation-inside-reflection.html + + * platform/graphics/texmap/TextureMapperLayer.cpp: + (WebCore::TextureMapperLayer::paintRecursive): + +2012-06-25 Ian Vollick <vollick@chromium.org> + + [chromium] Layer chromium should need a redraw after getting its first non-empty bounds. + https://bugs.webkit.org/show_bug.cgi?id=89784 + + Reviewed by James Robinson. + + Previously, we'd only set needs redraw if the old bounds were zero, + and the new bounds were non-zero, but we should actually have + checked that the old bounds were non-empty. + + Unit test: LayerChromiumTestWithoutFixture.setBoundsTriggersSetNeedsRedrawAfterGettingNonEmptyBounds + + * platform/graphics/chromium/LayerChromium.cpp: + (WebCore::LayerChromium::setBounds): + +2012-06-25 Scott Graham <scottmg@chromium.org> + + Plumb Scrollbar button dimensions down to WebThemeEngine + https://bugs.webkit.org/show_bug.cgi?id=89264 + + Reviewed by James Robinson. + + Rather than making the height of the scrollbar buttons the same as the + width of the scrollbar, delegate to the WebThemeEngine. This allows + matching the Aura theme rather than the standard Windows theme. + + No new tests, as bounds are overridden for DRT. + + * platform/chromium/PlatformSupport.h: + (PlatformSupport): + * platform/chromium/ScrollbarThemeChromiumWin.cpp: + (WebCore::ScrollbarThemeChromiumWin::buttonSize): + +2012-06-25 Antti Koivisto <antti@apple.com> + + Fast path for simple transform parsing + https://bugs.webkit.org/show_bug.cgi?id=89898 + + Reviewed by Anders Carlsson. + + When manipulating transforms using script, the transform value parsing can show up in profiles pretty heavily + (up 4% in some cases). We can optimize it easily by implementing a fast path that does not spin up the full CSS + parser, like we already do for several other common value types. + + The patch implements a fast path for transform(), transformX/Y/Z() and transform3D(). It speeds up parsing by >5x. + + * css/CSSParser.cpp: + (WebCore): + (WebCore::parseTransformArguments): + (WebCore::parseTransformValue): + (WebCore::CSSParser::parseValue): + +2012-06-25 Kwang Yul Seo <skyul@company100.net> + + Remove unused static function shadowFor + https://bugs.webkit.org/show_bug.cgi?id=89824 + + Reviewed by Daniel Bates. + + shadowFor is not used anymore after r117796. No behaviour changes. + + * dom/TreeScopeAdopter.cpp: + +2012-06-25 Kwang Yul Seo <skyul@company100.net> + + Remove unused constant timeWithoutMouseMovementBeforeHidingControls + https://bugs.webkit.org/show_bug.cgi?id=89823 + + Reviewed by Daniel Bates. + + After r87692, timeWithoutMouseMovementBeforeHidingControls is not used anymore. + + * html/HTMLMediaElement.cpp: + (WebCore): + +2012-06-25 Zeev Lieber <zlieber@chromium.org> + + [Chromium] RenderPass textures are evicted at the end of every frame + https://bugs.webkit.org/show_bug.cgi?id=89786 + + Reviewed by Adrienne Walker. + + Removed calls to TextureManager::reduceMemoryToLimit inside + finishDrawingFrame() method. + + Added unit tests to verify new behavior. + + * platform/graphics/chromium/LayerRendererChromium.cpp: + (WebCore::LayerRendererChromium::finishDrawingFrame): + +2012-06-25 Allan Xavier <allan.xavier@undefinedltd.co.uk> + + [GTK] Add graphviz debug output for the gstreamer video pipeline. + https://bugs.webkit.org/show_bug.cgi?id=89660 + + Reviewed by Martin Robinson. + + Dump the current video pipeline as a graphviz DOT file when the + pipeline state changes or when an error occours. + + No new tests as the change is only useful for debugging. + + * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: + (WebCore::MediaPlayerPrivateGStreamer::handleMessage): + +2012-06-25 Adam Barth <abarth@webkit.org> + + ASSERT(m_wheelEventHandlerCount > 0) can fire + https://bugs.webkit.org/show_bug.cgi?id=89856 + + Reviewed by Eric Seidel. + + When a node with a wheel or a touch event is moved from one document to + another, the didAddMumble/didRemoveMumble calls do not balance because + they're called on different documents. This patch twiddles the counts + appropriately in that case. + + Test: fast/events/move-element-with-wheel-and-touch-event-listeners.html + + * dom/EventNames.h: + (WebCore::EventNames::isTouchEventType): + (EventNames): + (WebCore::EventNames::touchEventNames): + * dom/Node.cpp: + (WebCore::Node::didMoveToNewDocument): + +2012-06-25 Eric Seidel <eric@webkit.org> + + Split map* functions out of StyleResolver into a helper object + https://bugs.webkit.org/show_bug.cgi?id=89881 + + Reviewed by Daniel Bates. + + These map* functions are completely independent of the rest of StyleResolver + and only exist to serve StyleBuilder. + CSSToStyleMap doesn't even want to have a StyleResolver pointer, but + currently needs one to access the resolve-lifetime caches for the + current resolve. Once we split out that per-resolve state into + some sort of ResolveState/ResolveInfo object (akin to PaintInfo/LayoutState) + then this object will be even simpler. + + No behavioral change, thus no tests. + + * CMakeLists.txt: + * GNUmakefile.list.am: + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * css/CSSToStyleMap.cpp: Added. + (WebCore): + (WebCore::CSSToStyleMap::style): + (WebCore::CSSToStyleMap::rootElementStyle): + (WebCore::CSSToStyleMap::useSVGZoomRules): + (WebCore::CSSToStyleMap::styleImage): + (WebCore::CSSToStyleMap::mapFillAttachment): + (WebCore::CSSToStyleMap::mapFillClip): + (WebCore::CSSToStyleMap::mapFillComposite): + (WebCore::CSSToStyleMap::mapFillOrigin): + (WebCore::CSSToStyleMap::mapFillImage): + (WebCore::CSSToStyleMap::mapFillRepeatX): + (WebCore::CSSToStyleMap::mapFillRepeatY): + (WebCore::CSSToStyleMap::mapFillSize): + (WebCore::CSSToStyleMap::mapFillXPosition): + (WebCore::CSSToStyleMap::mapFillYPosition): + (WebCore::CSSToStyleMap::mapAnimationDelay): + (WebCore::CSSToStyleMap::mapAnimationDirection): + (WebCore::CSSToStyleMap::mapAnimationDuration): + (WebCore::CSSToStyleMap::mapAnimationFillMode): + (WebCore::CSSToStyleMap::mapAnimationIterationCount): + (WebCore::CSSToStyleMap::mapAnimationName): + (WebCore::CSSToStyleMap::mapAnimationPlayState): + (WebCore::CSSToStyleMap::mapAnimationProperty): + (WebCore::CSSToStyleMap::mapAnimationTimingFunction): + (WebCore::CSSToStyleMap::mapNinePieceImage): + (WebCore::CSSToStyleMap::mapNinePieceImageSlice): + (WebCore::CSSToStyleMap::mapNinePieceImageQuad): + (WebCore::CSSToStyleMap::mapNinePieceImageRepeat): + * css/CSSToStyleMap.h: Added. + (WebCore): + (CSSToStyleMap): + (WebCore::CSSToStyleMap::CSSToStyleMap): + * css/StyleBuilder.cpp: + (WebCore::ApplyPropertyFillLayer::applyValue): + (WebCore::ApplyPropertyBorderImage::applyValue): + (WebCore::ApplyPropertyBorderImageModifier::applyValue): + (WebCore): + (WebCore::ApplyPropertyAnimation::map): + (WebCore::StyleBuilder::StyleBuilder): + * css/StyleResolver.cpp: + (WebCore::StyleResolver::StyleResolver): + (WebCore::StyleResolver::collectMatchingRulesForList): + * css/StyleResolver.h: + (WebCore::StyleResolver::styleMap): + (StyleResolver): + +2012-06-25 Gyuyoung Kim <gyuyoung.kim@samsung.com> + + [EFL] Support screenDepth() functionality. + https://bugs.webkit.org/show_bug.cgi?id=89423 + + Reviewed by Kenneth Rohde Christiansen. + + Support screenDepth() based on ecore_x_window_depth_get(). This functionality may be used by + both WebKit1 and WebKit2. So, concrete function is placed into EflScreenUtilities.cpp. + + This patch can't support existing test cases. Because, EFL DumpRenderTree works without X11 window + by default. + + * platform/efl/EflScreenUtilities.cpp: + (WebCore::getPixelDepth): + (WebCore): + * platform/efl/EflScreenUtilities.h: + (WebCore): + * platform/efl/PlatformScreenEfl.cpp: + (WebCore::screenDepth): + (WebCore::screenDepthPerComponent): + +2012-06-25 Shinya Kawanaka <shinyak@chromium.org> + + [Shadow] Executing Italic and InsertUnorderedList in Shadow DOM causes a crash + https://bugs.webkit.org/show_bug.cgi?id=88495 + + Reviewed by Ryosuke Niwa. + + InsertionPoint::removedFrom(insertionPoint) tries to find its owner ElementShadow from + parentNode or insertionPoint. If the parent node exsits but we cannot reach ElementShadow from + the parent node, InsertionPoint::removedFrom does not try to find ElementShadow anymore. + + It's OK if the ElementShadow is being destructed, but there is a case ElementShadow is not being + destructed in editing. In this case, we should try to find ElementShadow from insertionPoint. + Otherwise it will bring inconsistency to Shadow DOM, and causes a crash. + + Actually checking the existence of parentNode() does not make any sense. We should get + shadowRoot() directly. + + Test: editing/shadow/insertorderedlist-crash.html + + * html/shadow/InsertionPoint.cpp: + (WebCore::InsertionPoint::removedFrom): + +2012-06-25 Kinuko Yasuda <kinuko@chromium.org> + + Remove responseBlob field from XMLHttpResponse.idl + https://bugs.webkit.org/show_bug.cgi?id=89859 + + Reviewed by Eric Seidel. + + Remove XMLHttpResponse.responseBlob from XMLHttpResponse.idl, which + has only been exposed for a very limited time (since r120574) but + probably should not have been done so since XHR2 spec no longer has + the field. A quick search also showed that no one seems to be using the field. + + (More context: the field was added long time ago with a runtime guard + which had never been enabled until the guard was removed in r120574 + to remove XHR_RESPONSE_BLOB on all platforms.) + + No new tests as no tests use this field. + + * xml/XMLHttpRequest.idl: Removed responseBlob field. + +2012-06-25 Huang Dongsung <luxtella@company100.net> + + Add static qualifier to GraphicsContext3D::extractImageData. + https://bugs.webkit.org/show_bug.cgi?id=89866 + + GraphicsContext3D::extractImageData does not use member variables. + Each platform Accelerated-compositing implementation can use this method in + order to get pixel data of an Image or ImageBuffer object. + + Reviewed by Noam Rosenthal. + + No new tests since there's no change on code behavior. + + * platform/graphics/GraphicsContext3D.h: + (GraphicsContext3D): + +2012-06-25 Pavel Feldman <pfeldman@chromium.org> + + Web Inspector: toggling style should not start property edit first. + https://bugs.webkit.org/show_bug.cgi?id=89834 + + Reviewed by Yury Semikhatsky. + + Otherwise property flickers upon toggling. + + * inspector/front-end/StylesSidebarPane.js: + (WebInspector.StylePropertyTreeElement.prototype): + +2012-06-25 Alexander Pavlov <apavlov@chromium.org> + + Web Inspector: "Emulate Touch Events" breaks selecting elements with "touchstart" event listeners for inspection. + https://bugs.webkit.org/show_bug.cgi?id=89861 + + Reviewed by Vsevolod Vlasov. + + Upon a mousepress, Inspector should be queried for the "Inspect element" mode up-front, + before dispatching a synthetic "touchstart" event. + + * page/EventHandler.cpp: + (WebCore::EventHandler::handleMousePressEvent): + +2012-06-25 Alexander Pavlov <apavlov@chromium.org> + + Web Inspector: [Styles] Cannot visually set caret before the first CSS property name character + https://bugs.webkit.org/show_bug.cgi?id=89869 + + Reviewed by Vsevolod Vlasov. + + The issue was due to the "editbox" SPAN having a negative margin, thus the leftmost caret position was getting clipped + by a synthetic SPAN container added by the TextPrompt. + + * inspector/front-end/elementsPanel.css: + (.styles-section .properties > li.child-editing .webkit-css-property): + (.styles-section .properties li.child-editing): + +2012-06-25 Arko Saha <arko@motorola.com> + + Microdata: document.getItems(typeNames) is not returning Microdata items when typeNames argument is not specified. + https://bugs.webkit.org/show_bug.cgi?id=89757 + + Reviewed by Ryosuke Niwa. + + With r120979 change, it creates MicroDataItemList with m_typeNames = "http://webkit.org/microdata/undefinedItemType", + when typeNames argument is not specified. Modified the check in nodeMatches() accordingly. + + This fixes the following failing tests : + fast/dom/MicroData/002.html + fast/dom/MicroData/003.html + fast/dom/MicroData/007.html + fast/dom/MicroData/009.html + fast/dom/MicroData/properties-collection-must-see-the-properties-added-in-itemref.html + + * dom/Document.cpp: + (WebCore::Document::getItems): Use undefinedItemType to avoid String conversion. + * dom/MicroDataItemList.cpp: + (WebCore::MicroDataItemList::undefinedItemType): It defines "http://webkit.org/microdata/undefinedItemType" + string using DEFINE_STATIC_LOCAL to avoid String conversion. + (WebCore::MicroDataItemList::MicroDataItemList): Use document() method of DynamicNodeList to obtain + document of owner element. + (WebCore::MicroDataItemList::~MicroDataItemList): Removed originalTypeNames null check. + (WebCore::MicroDataItemList::nodeMatches): Return true if originalTypeNames is equal to undefinedItemType. + * dom/MicroDataItemList.h: + +2012-06-25 Carlos Garcia Campos <cgarcia@igalia.com> + + Unreviewed. Fix make distcheck. + + * GNUmakefile.list.am: Add missing header file. 2012-06-25 Simon Hausmann <simon.hausmann@nokia.com> diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index 9872e002e..2a1431663 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -1115,6 +1115,7 @@ webcore_modules_sources += \ Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h \ Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.cpp \ Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.h \ + Source/WebCore/Modules/indexeddb/IDBMetadata.h \ Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp \ Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h \ Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h \ @@ -1678,6 +1679,8 @@ webcore_sources += \ Source/WebCore/css/CSSStyleSheet.h \ Source/WebCore/css/CSSTimingFunctionValue.cpp \ Source/WebCore/css/CSSTimingFunctionValue.h \ + Source/WebCore/css/CSSToStyleMap.cpp \ + Source/WebCore/css/CSSToStyleMap.h \ Source/WebCore/css/CSSWrapShapes.cpp \ Source/WebCore/css/CSSWrapShapes.h \ Source/WebCore/css/CSSUnicodeRangeValue.cpp \ diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp index 2759514ef..af1c50444 100644 --- a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp @@ -29,9 +29,11 @@ #if ENABLE(INDEXED_DATABASE) #include "IDBAny.h" +#include "IDBBindingUtilities.h" #include "IDBCallbacks.h" #include "IDBCursorBackendInterface.h" #include "IDBKey.h" +#include "IDBObjectStore.h" #include "IDBRequest.h" #include "IDBTracing.h" #include "IDBTransaction.h" @@ -125,24 +127,37 @@ IDBAny* IDBCursor::source() const PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, ExceptionCode& ec) { IDB_TRACE("IDBCursor::update"); + RefPtr<SerializedScriptValue> value = prpValue; - if (!m_gotValue) { + if (!m_gotValue || isKeyCursor()) { ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } - + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } if (m_transaction->isReadOnly()) { ec = IDBDatabaseException::READ_ONLY_ERR; return 0; } - - RefPtr<SerializedScriptValue> value = prpValue; if (value->blobURLs().size() > 0) { // FIXME: Add Blob/File/FileList support ec = IDBDatabaseException::IDB_DATA_CLONE_ERR; return 0; } + RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); + const IDBKeyPath& keyPath = objectStore->metadata().keyPath; + const bool usesInLineKeys = !keyPath.isNull(); + if (usesInLineKeys) { + RefPtr<IDBKey> keyPathKey = createIDBKeyFromSerializedValueAndKeyPath(value, keyPath); + if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) { + ec = IDBDatabaseException::DATA_ERR; + return 0; + } + } + RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); m_backend->update(value, request, ec); if (ec) { @@ -160,7 +175,7 @@ void IDBCursor::advance(unsigned long count, ExceptionCode& ec) return; } - if (!m_request) { + if (!m_transaction->isActive()) { ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; return; } @@ -188,7 +203,7 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionCode& ec) return; } - if (!m_request) { + if (!m_transaction->isActive()) { ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; return; } @@ -213,6 +228,10 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionCode& ec) PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context, ExceptionCode& ec) { IDB_TRACE("IDBCursor::delete"); + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } if (m_transaction->isReadOnly()) { ec = IDBDatabaseException::READ_ONLY_ERR; return 0; @@ -252,6 +271,14 @@ void IDBCursor::setValueReady() m_valueIsDirty = true; } +PassRefPtr<IDBObjectStore> IDBCursor::effectiveObjectStore() +{ + if (m_source->type() == IDBAny::IDBObjectStoreType) + return m_source->idbObjectStore(); + RefPtr<IDBIndex> index = m_source->idbIndex(); + return index->objectStore(); +} + unsigned short IDBCursor::stringToDirection(const String& directionString, ExceptionCode& ec) { if (directionString == IDBCursor::directionNext()) diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.h b/Source/WebCore/Modules/indexeddb/IDBCursor.h index 3f9d84f98..4f4564eeb 100644 --- a/Source/WebCore/Modules/indexeddb/IDBCursor.h +++ b/Source/WebCore/Modules/indexeddb/IDBCursor.h @@ -91,8 +91,11 @@ public: protected: IDBCursor(PassRefPtr<IDBCursorBackendInterface>, IDBRequest*, IDBAny* source, IDBTransaction*); + virtual bool isKeyCursor() const { return true; } private: + PassRefPtr<IDBObjectStore> effectiveObjectStore(); + RefPtr<IDBCursorBackendInterface> m_backend; RefPtr<IDBRequest> m_request; RefPtr<IDBAny> m_source; diff --git a/Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp index b6246e919..0a14a6f1a 100644 --- a/Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp @@ -93,10 +93,9 @@ void IDBCursorBackendImpl::update(PassRefPtr<SerializedScriptValue> value, PassR { IDB_TRACE("IDBCursorBackendImpl::update"); ASSERT(m_transaction->mode() != IDBTransaction::READ_ONLY); - if (!m_cursor || m_cursorType == IndexKeyCursor) { - ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; - return; - } + + ASSERT(m_cursor); + ASSERT(m_cursorType != IndexKeyCursor); m_objectStore->put(value, m_cursor->primaryKey(), IDBObjectStoreBackendInterface::CursorUpdate, callbacks, m_transaction.get(), ec); } diff --git a/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h b/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h index a1ba14f96..9b396ba35 100644 --- a/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h +++ b/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h @@ -41,6 +41,9 @@ public: // The value attribute defined in the IDL is simply implemented in IDBCursor (but not exposed via // its IDL). This is to make the implementation more simple while matching what the spec says. +protected: + virtual bool isKeyCursor() const OVERRIDE { return false; } + private: IDBCursorWithValue(PassRefPtr<IDBCursorBackendInterface>, IDBRequest*, IDBAny* source, IDBTransaction*); }; diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp index 0a49400bb..ab123c3dc 100644 --- a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp @@ -117,6 +117,10 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_versionChangeTransaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } IDBKeyPath keyPath; if (!options.isUndefinedOrNull()) { @@ -128,6 +132,11 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co keyPath = IDBKeyPath(keyPathString); } + if (m_metadata.objectStores.contains(name)) { + ec = IDBDatabaseException::CONSTRAINT_ERR; + return 0; + } + if (!keyPath.isNull() && !keyPath.isValid()) { ec = IDBDatabaseException::IDB_SYNTAX_ERR; return 0; @@ -162,6 +171,14 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionCode& ec) ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return; } + if (!m_versionChangeTransaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return; + } + if (!m_metadata.objectStores.contains(name)) { + ec = IDBDatabaseException::IDB_NOT_FOUND_ERR; + return; + } m_backend->deleteObjectStore(name, m_versionChangeTransaction->backend(), ec); if (!ec) { diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp index b636d80a6..505ba757b 100644 --- a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp @@ -142,22 +142,10 @@ IDBDatabaseMetadata IDBDatabaseBackendImpl::metadata() const return metadata; } -PassRefPtr<DOMStringList> IDBDatabaseBackendImpl::objectStoreNames() const -{ - RefPtr<DOMStringList> objectStoreNames = DOMStringList::create(); - for (ObjectStoreMap::const_iterator it = m_objectStores.begin(); it != m_objectStores.end(); ++it) - objectStoreNames->append(it->first); - objectStoreNames->sort(); - return objectStoreNames.release(); -} - PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec) { ASSERT(transactionPtr->mode() == IDBTransaction::VERSION_CHANGE); - if (m_objectStores.contains(name)) { - ec = IDBDatabaseException::CONSTRAINT_ERR; - return 0; - } + ASSERT(!m_objectStores.contains(name)); RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(this, name, keyPath, autoIncrement); ASSERT(objectStore->name() == name); @@ -195,12 +183,10 @@ PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::objectStore(c void IDBDatabaseBackendImpl::deleteObjectStore(const String& name, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec) { ASSERT(transactionPtr->mode() == IDBTransaction::VERSION_CHANGE); - RefPtr<IDBObjectStoreBackendImpl> objectStore = m_objectStores.get(name); - if (!objectStore) { - ec = IDBDatabaseException::IDB_NOT_FOUND_ERR; - return; - } + ASSERT(m_objectStores.contains(name)); + RefPtr<IDBDatabaseBackendImpl> database = this; + RefPtr<IDBObjectStoreBackendImpl> objectStore = m_objectStores.get(name); RefPtr<IDBTransactionBackendInterface> transaction = transactionPtr; if (!transaction->scheduleTask(createCallbackTask(&IDBDatabaseBackendImpl::deleteObjectStoreInternal, database, objectStore, transaction), createCallbackTask(&IDBDatabaseBackendImpl::addObjectStoreToMap, database, objectStore))) { diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h index 36eb241fe..21f4f93c1 100644 --- a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h +++ b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h @@ -59,9 +59,6 @@ public: void deleteDatabase(PassRefPtr<IDBCallbacks>); virtual IDBDatabaseMetadata metadata() const; - virtual String name() const { return m_name; } - virtual String version() const { return m_version; } - virtual PassRefPtr<DOMStringList> objectStoreNames() const; virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&); virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&); diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h index d581777f9..0f6b35d60 100644 --- a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h +++ b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h @@ -54,9 +54,6 @@ public: virtual ~IDBDatabaseBackendInterface() { } virtual IDBDatabaseMetadata metadata() const = 0; - virtual String name() const = 0; - virtual String version() const = 0; - virtual PassRefPtr<DOMStringList> objectStoreNames() const = 0; virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) = 0; virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&) = 0; diff --git a/Source/WebCore/Modules/indexeddb/IDBIndex.cpp b/Source/WebCore/Modules/indexeddb/IDBIndex.cpp index 31e7f5d4e..fd9394947 100644 --- a/Source/WebCore/Modules/indexeddb/IDBIndex.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBIndex.cpp @@ -65,6 +65,10 @@ PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, Pas ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } unsigned short direction = IDBCursor::stringToDirection(directionString, ec); if (ec) return 0; @@ -115,6 +119,10 @@ PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, PassRefP ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); m_backend->count(keyRange, request, m_transaction->backend(), ec); if (ec) { @@ -140,6 +148,10 @@ PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } unsigned short direction = IDBCursor::stringToDirection(directionString, ec); if (ec) @@ -200,6 +212,10 @@ PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, PassRefPtr ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } if (!keyRange) { ec = IDBDatabaseException::DATA_ERR; return 0; @@ -231,6 +247,10 @@ PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, PassRef ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } if (!keyRange) { ec = IDBDatabaseException::DATA_ERR; return 0; diff --git a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h index 6410cbac3..98385128f 100644 --- a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h +++ b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h @@ -65,10 +65,6 @@ public: // Implements IDBIndexBackendInterface. virtual IDBIndexMetadata metadata() const; - virtual String name() { return m_name; } - virtual IDBKeyPath keyPath() { return m_keyPath; } - virtual bool unique() { return m_unique; } - virtual bool multiEntry() { return m_multiEntry; } virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); virtual void count(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); @@ -76,6 +72,11 @@ public: virtual void get(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); virtual void getKey(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); + const String& name() { return m_name; } + const IDBKeyPath& keyPath() { return m_keyPath; } + const bool& unique() { return m_unique; } + const bool& multiEntry() { return m_multiEntry; } + private: IDBIndexBackendImpl(const IDBDatabaseBackendImpl*, IDBObjectStoreBackendImpl*, int64_t id, const String& name, const IDBKeyPath&, bool unique, bool multiEntry); IDBIndexBackendImpl(const IDBDatabaseBackendImpl*, IDBObjectStoreBackendImpl*, const String& name, const IDBKeyPath&, bool unique, bool multiEntry); diff --git a/Source/WebCore/Modules/indexeddb/IDBIndexBackendInterface.h b/Source/WebCore/Modules/indexeddb/IDBIndexBackendInterface.h index d35d1177d..5c0a16953 100644 --- a/Source/WebCore/Modules/indexeddb/IDBIndexBackendInterface.h +++ b/Source/WebCore/Modules/indexeddb/IDBIndexBackendInterface.h @@ -46,11 +46,6 @@ class IDBIndexBackendInterface : public ThreadSafeRefCounted<IDBIndexBackendInte public: virtual ~IDBIndexBackendInterface() { } - virtual String name() = 0; - virtual IDBKeyPath keyPath() = 0; - virtual bool unique() = 0; - virtual bool multiEntry() = 0; - virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) = 0; virtual void count(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) = 0; virtual void openKeyCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) = 0; diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp b/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp index 68bc17165..6c0641592 100644 --- a/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp @@ -30,6 +30,7 @@ #include "DOMStringList.h" #include "IDBAny.h" +#include "IDBBindingUtilities.h" #include "IDBDatabase.h" #include "IDBDatabaseException.h" #include "IDBIndex.h" @@ -78,6 +79,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, Pass ec = IDBDatabaseException::DATA_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); m_backend->get(keyRange, request, m_transaction->backend(), ec); if (ec) { @@ -96,65 +101,80 @@ PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, Pass return get(context, keyRange.release(), ec); } -PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> key, ExceptionCode& ec) +PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec) { IDB_TRACE("IDBObjectStore::add"); + return put(IDBObjectStoreBackendInterface::AddOnly, context, value, key, ec); +} + +PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec) +{ + IDB_TRACE("IDBObjectStore::put"); + return put(IDBObjectStoreBackendInterface::AddOrUpdate, context, value, key, ec); +} + +PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMode putMode, ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> prpKey, ExceptionCode& ec) +{ + IDB_TRACE("IDBObjectStore::put"); + RefPtr<SerializedScriptValue> value = prpValue; + RefPtr<IDBKey> key = prpKey; if (m_deleted) { ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } - if (m_transaction->isReadOnly()) { - ec = IDBDatabaseException::READ_ONLY_ERR; + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; return 0; } - - if (key && !key->isValid()) { - ec = IDBDatabaseException::DATA_ERR; + if (m_transaction->isReadOnly()) { + ec = IDBDatabaseException::READ_ONLY_ERR; return 0; } - - RefPtr<SerializedScriptValue> value = prpValue; if (value->blobURLs().size() > 0) { // FIXME: Add Blob/File/FileList support ec = IDBDatabaseException::IDB_DATA_CLONE_ERR; return 0; } - RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); - m_backend->put(value, key, IDBObjectStoreBackendInterface::AddOnly, request, m_transaction->backend(), ec); - if (ec) { - request->markEarlyDeath(); - return 0; - } - return request.release(); -} + const IDBKeyPath& keyPath = m_metadata.keyPath; + const bool usesInLineKeys = !keyPath.isNull(); + const bool hasKeyGenerator = autoIncrement(); -PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> key, ExceptionCode& ec) -{ - IDB_TRACE("IDBObjectStore::put"); - if (m_deleted) { - ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; + if (usesInLineKeys && key) { + ec = IDBDatabaseException::DATA_ERR; return 0; } - if (m_transaction->isReadOnly()) { - ec = IDBDatabaseException::READ_ONLY_ERR; + if (!usesInLineKeys && !hasKeyGenerator && !key) { + ec = IDBDatabaseException::DATA_ERR; return 0; } - + if (usesInLineKeys) { + RefPtr<IDBKey> keyPathKey = createIDBKeyFromSerializedValueAndKeyPath(value, keyPath); + if (keyPathKey && !keyPathKey->isValid()) { + ec = IDBDatabaseException::DATA_ERR; + return 0; + } + if (!hasKeyGenerator && !keyPathKey) { + ec = IDBDatabaseException::DATA_ERR; + return 0; + } + if (hasKeyGenerator && !keyPathKey) { + RefPtr<IDBKey> dummyKey = IDBKey::createNumber(-1); + RefPtr<SerializedScriptValue> valueAfterInjection = injectIDBKeyIntoSerializedValue(dummyKey, value, keyPath); + if (!valueAfterInjection) { + ec = IDBDatabaseException::DATA_ERR; + return 0; + } + } + } if (key && !key->isValid()) { ec = IDBDatabaseException::DATA_ERR; return 0; } - RefPtr<SerializedScriptValue> value = prpValue; - if (value->blobURLs().size() > 0) { - // FIXME: Add Blob/File/FileList support - ec = IDBDatabaseException::IDB_DATA_CLONE_ERR; - return 0; - } - RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); - m_backend->put(value, key, IDBObjectStoreBackendInterface::AddOrUpdate, request, m_transaction->backend(), ec); + // FIXME: Pass through keyPathKey as key to simplify back end implementation. + m_backend->put(value.release(), key.release(), putMode, request, m_transaction->backend(), ec); if (ec) { request->markEarlyDeath(); return 0; @@ -169,11 +189,14 @@ PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* co ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } if (m_transaction->isReadOnly()) { ec = IDBDatabaseException::READ_ONLY_ERR; return 0; } - if (!keyRange) { ec = IDBDatabaseException::DATA_ERR; return 0; @@ -204,6 +227,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::clear(ScriptExecutionContext* context, Ex ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } if (m_transaction->isReadOnly()) { ec = IDBDatabaseException::READ_ONLY_ERR; return 0; @@ -239,11 +266,22 @@ PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const IDBKe ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } - + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } if (!keyPath.isValid()) { ec = IDBDatabaseException::IDB_SYNTAX_ERR; return 0; } + if (name.isNull()) { + ec = IDBDatabaseException::IDB_TYPE_ERR; + return 0; + } + if (m_metadata.indexes.contains(name)) { + ec = IDBDatabaseException::CONSTRAINT_ERR; + return 0; + } bool unique = false; options.get("unique", unique); @@ -304,6 +342,14 @@ void IDBObjectStore::deleteIndex(const String& name, ExceptionCode& ec) ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return; + } + if (!m_metadata.indexes.contains(name)) { + ec = IDBDatabaseException::IDB_NOT_FOUND_ERR; + return; + } m_backend->deleteIndex(name, m_transaction->backend(), ec); if (!ec) { @@ -325,6 +371,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* contex ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } unsigned short direction = IDBCursor::stringToDirection(directionString, ec); if (ec) return 0; @@ -375,6 +425,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, Pa ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; return 0; } + if (!m_transaction->isActive()) { + ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; + return 0; + } RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); m_backend->count(range, request, m_transaction->backend(), ec); if (ec) { diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.h b/Source/WebCore/Modules/indexeddb/IDBObjectStore.h index 8181eb931..67b36f995 100644 --- a/Source/WebCore/Modules/indexeddb/IDBObjectStore.h +++ b/Source/WebCore/Modules/indexeddb/IDBObjectStore.h @@ -95,6 +95,7 @@ public: PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&); PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&); + PassRefPtr<IDBRequest> put(IDBObjectStoreBackendInterface::PutMode, ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, ExceptionCode&); void markDeleted() { m_deleted = true; } void transactionFinished(); @@ -103,7 +104,6 @@ public: private: IDBObjectStore(const IDBObjectStoreMetadata&, PassRefPtr<IDBObjectStoreBackendInterface>, IDBTransaction*); - void removeTransactionFromPendingList(); IDBObjectStoreMetadata m_metadata; RefPtr<IDBObjectStoreBackendInterface> m_backend; diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp index a62dda8b4..af30ef371 100644 --- a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp @@ -42,7 +42,7 @@ #include "IDBKeyPathBackendImpl.h" #include "IDBKeyRange.h" #include "IDBTracing.h" -#include "IDBTransactionBackendInterface.h" +#include "IDBTransactionBackendImpl.h" #include "ScriptExecutionContext.h" namespace WebCore { @@ -80,15 +80,6 @@ IDBObjectStoreMetadata IDBObjectStoreBackendImpl::metadata() const return metadata; } -PassRefPtr<DOMStringList> IDBObjectStoreBackendImpl::indexNames() const -{ - RefPtr<DOMStringList> indexNames = DOMStringList::create(); - for (IndexMap::const_iterator it = m_indexes.begin(); it != m_indexes.end(); ++it) - indexNames->append(it->first); - indexNames->sort(); - return indexNames.release(); -} - void IDBObjectStoreBackendImpl::get(PassRefPtr<IDBKeyRange> prpKeyRange, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) { IDB_TRACE("IDBObjectStoreBackendImpl::get"); @@ -101,7 +92,7 @@ void IDBObjectStoreBackendImpl::get(PassRefPtr<IDBKeyRange> prpKeyRange, PassRef void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKeyRange> keyRange, PassRefPtr<IDBCallbacks> callbacks) { - IDB_TRACE("IDBObjectStoreBackendImpl::getByRangeInternal"); + IDB_TRACE("IDBObjectStoreBackendImpl::getInternal"); RefPtr<IDBKey> key; if (keyRange->isOnlyKey()) key = keyRange->lower(); @@ -157,53 +148,6 @@ void IDBObjectStoreBackendImpl::put(PassRefPtr<SerializedScriptValue> prpValue, RefPtr<IDBCallbacks> callbacks = prpCallbacks; RefPtr<IDBTransactionBackendInterface> transaction = transactionPtr; - if (putMode != CursorUpdate) { - const bool autoIncrement = objectStore->autoIncrement(); - const bool hasKeyPath = !objectStore->m_keyPath.isNull(); - - if (hasKeyPath && key) { - ec = IDBDatabaseException::DATA_ERR; - return; - } - if (!hasKeyPath && !autoIncrement && !key) { - ec = IDBDatabaseException::DATA_ERR; - return; - } - if (hasKeyPath) { - RefPtr<IDBKey> keyPathKey = fetchKeyFromKeyPath(value.get(), objectStore->m_keyPath); - if (keyPathKey && !keyPathKey->isValid()) { - ec = IDBDatabaseException::DATA_ERR; - return; - } - if (!autoIncrement && !keyPathKey) { - ec = IDBDatabaseException::DATA_ERR; - return; - } - if (autoIncrement && !keyPathKey) { - RefPtr<IDBKey> dummyKey = IDBKey::createNumber(-1); - RefPtr<SerializedScriptValue> valueAfterInjection = injectKeyIntoKeyPath(dummyKey, value, objectStore->m_keyPath); - if (!valueAfterInjection) { - ec = IDBDatabaseException::DATA_ERR; - return; - } - } - } - if (key && !key->isValid()) { - ec = IDBDatabaseException::DATA_ERR; - return; - } - } else { - ASSERT(key); - const bool hasKeyPath = !objectStore->m_keyPath.isNull(); - if (hasKeyPath) { - RefPtr<IDBKey> keyPathKey = fetchKeyFromKeyPath(value.get(), objectStore->m_keyPath); - if (!keyPathKey || !keyPathKey->isEqual(key.get())) { - ec = IDBDatabaseException::DATA_ERR; - return; - } - } - } - if (!transaction->scheduleTask( createCallbackTask(&IDBObjectStoreBackendImpl::putInternal, objectStore, value, key, putMode, callbacks, transaction), // FIXME: One of these per put() is overkill, since it's simply a cache invalidation. @@ -468,18 +412,8 @@ bool IDBObjectStoreBackendImpl::populateIndex(IDBBackingStore& backingStore, int PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) { - if (name.isNull()) { - ec = IDBDatabaseException::IDB_TYPE_ERR; - return 0; - } - if (m_indexes.contains(name)) { - ec = IDBDatabaseException::CONSTRAINT_ERR; - return 0; - } - if (transaction->mode() != IDBTransaction::VERSION_CHANGE) { - ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; - return 0; - } + ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); + ASSERT(!m_indexes.contains(name)); RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(m_database, this, name, keyPath, unique, multiEntry); ASSERT(index->name() == name); @@ -529,18 +463,11 @@ PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::index(const Stri void IDBObjectStoreBackendImpl::deleteIndex(const String& name, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) { - if (transaction->mode() != IDBTransaction::VERSION_CHANGE) { - ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; - return; - } - - RefPtr<IDBIndexBackendImpl> index = m_indexes.get(name); - if (!index) { - ec = IDBDatabaseException::IDB_NOT_FOUND_ERR; - return; - } + ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); + ASSERT(m_indexes.contains(name)); RefPtr<IDBObjectStoreBackendImpl> objectStore = this; + RefPtr<IDBIndexBackendImpl> index = m_indexes.get(name); RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; if (!transaction->scheduleTask( createCallbackTask(&IDBObjectStoreBackendImpl::deleteIndexInternal, diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h index 07ab9fce3..1e39ddac3 100644 --- a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h +++ b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h @@ -64,10 +64,6 @@ public: void setId(int64_t id) { m_id = id; } virtual IDBObjectStoreMetadata metadata() const; - virtual String name() const { return m_name; } - virtual IDBKeyPath keyPath() const { return m_keyPath; } - virtual PassRefPtr<DOMStringList> indexNames() const; - virtual bool autoIncrement() const { return m_autoIncrement; } virtual void get(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); virtual void put(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); @@ -83,6 +79,10 @@ public: static bool populateIndex(IDBBackingStore&, int64_t databaseId, int64_t objectStoreId, PassRefPtr<IDBIndexBackendImpl>); + const String& name() { return m_name; } + const IDBKeyPath& keyPath() const { return m_keyPath; } + const bool& autoIncrement() const { return m_autoIncrement; } + private: IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl*, int64_t databaseId, const String& name, const IDBKeyPath&, bool autoIncrement); IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl*, const String& name, const IDBKeyPath&, bool autoIncrement); diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h index 6002d9e48..07f9f7260 100644 --- a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h +++ b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h @@ -48,11 +48,6 @@ class IDBObjectStoreBackendInterface : public ThreadSafeRefCounted<IDBObjectStor public: virtual ~IDBObjectStoreBackendInterface() { } - virtual String name() const = 0; - virtual IDBKeyPath keyPath() const = 0; - virtual PassRefPtr<DOMStringList> indexNames() const = 0; - virtual bool autoIncrement() const = 0; - virtual void get(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) = 0; enum PutMode { diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp index 7087c657e..6ad300723 100644 --- a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp +++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp @@ -84,6 +84,7 @@ IDBTransaction::IDBTransaction(ScriptExecutionContext* context, PassRefPtr<IDBTr , m_backend(backend) , m_database(db) , m_mode(mode) + , m_active(true) , m_transactionFinished(false) , m_contextStopped(false) { @@ -193,6 +194,7 @@ void IDBTransaction::abort() { if (m_transactionFinished) return; + m_active = false; RefPtr<IDBTransaction> selfRef = this; if (m_backend) m_backend->abort(); @@ -242,6 +244,7 @@ void IDBTransaction::unregisterRequest(IDBRequest* request) void IDBTransaction::onAbort() { ASSERT(!m_transactionFinished); + m_active = false; while (!m_childRequests.isEmpty()) { IDBRequest* request = *m_childRequests.begin(); m_childRequests.remove(request); @@ -265,6 +268,7 @@ void IDBTransaction::onAbort() void IDBTransaction::onComplete() { ASSERT(!m_transactionFinished); + m_active = false; m_objectStoreCleanupMap.clear(); closeOpenCursors(); m_database->transactionFinished(this); diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.h b/Source/WebCore/Modules/indexeddb/IDBTransaction.h index 0b2dec6ec..2ce82b1cf 100644 --- a/Source/WebCore/Modules/indexeddb/IDBTransaction.h +++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.h @@ -68,12 +68,13 @@ public: static const AtomicString& modeToString(Mode, ExceptionCode&); IDBTransactionBackendInterface* backend() const; + bool isActive() const { return m_active; } bool isFinished() const; + bool isReadOnly() const { return m_mode == READ_ONLY; } bool isVersionChange() const { return m_mode == VERSION_CHANGE; } // Implement the IDBTransaction IDL const String& mode() const; - bool isReadOnly() const { return m_mode == READ_ONLY; } IDBDatabase* db() const; PassRefPtr<DOMError> error(ExceptionCode&) const; void setError(PassRefPtr<DOMError>); @@ -135,6 +136,7 @@ private: RefPtr<IDBTransactionBackendInterface> m_backend; RefPtr<IDBDatabase> m_database; const Mode m_mode; + bool m_active; bool m_transactionFinished; // Is it possible that we'll fire any more events or allow any new requests? If not, we're finished. bool m_contextStopped; RefPtr<DOMError> m_error; diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfo.cpp b/Source/WebCore/Modules/networkinfo/NetworkInfo.cpp index a627a193b..4838a29e3 100644 --- a/Source/WebCore/Modules/networkinfo/NetworkInfo.cpp +++ b/Source/WebCore/Modules/networkinfo/NetworkInfo.cpp @@ -32,7 +32,7 @@ #if ENABLE(NETWORK_INFO) namespace WebCore { -NetworkInfo::NetworkInfo(long bandwidth, bool metered) +NetworkInfo::NetworkInfo(double bandwidth, bool metered) : m_bandwidth(bandwidth) , m_metered(metered) { diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfo.h b/Source/WebCore/Modules/networkinfo/NetworkInfo.h index d91b6757c..ee8fb714a 100644 --- a/Source/WebCore/Modules/networkinfo/NetworkInfo.h +++ b/Source/WebCore/Modules/networkinfo/NetworkInfo.h @@ -38,15 +38,15 @@ namespace WebCore { class NetworkInfo : public RefCounted<NetworkInfo> { public: - static PassRefPtr<NetworkInfo> create(long bandwidth, bool metered) { return adoptRef(new NetworkInfo(bandwidth, metered)); } + static PassRefPtr<NetworkInfo> create(double bandwidth, bool metered) { return adoptRef(new NetworkInfo(bandwidth, metered)); } - long bandwidth() const { return m_bandwidth; } + double bandwidth() const { return m_bandwidth; } bool metered() const { return m_metered; } private: - NetworkInfo(long bandwidth, bool metered); + NetworkInfo(double bandwidth, bool metered); - long m_bandwidth; + double m_bandwidth; bool m_metered; }; diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoClient.h b/Source/WebCore/Modules/networkinfo/NetworkInfoClient.h index a35d1452b..f026e4dca 100644 --- a/Source/WebCore/Modules/networkinfo/NetworkInfoClient.h +++ b/Source/WebCore/Modules/networkinfo/NetworkInfoClient.h @@ -40,7 +40,7 @@ class NetworkInfoClient { public: virtual ~NetworkInfoClient() { } - virtual unsigned int bandwidth() const = 0; + virtual double bandwidth() const = 0; virtual bool metered() const = 0; virtual void startUpdating() = 0; diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.cpp b/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.cpp index 13f52abbe..159fecc64 100644 --- a/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.cpp +++ b/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.cpp @@ -55,7 +55,7 @@ NetworkInfoConnection::~NetworkInfoConnection() { } -unsigned int NetworkInfoConnection::bandwidth() const +double NetworkInfoConnection::bandwidth() const { if (m_networkInfo) return m_networkInfo->bandwidth(); diff --git a/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.h b/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.h index ea7ab8ab7..18a6c9c6e 100644 --- a/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.h +++ b/Source/WebCore/Modules/networkinfo/NetworkInfoConnection.h @@ -51,7 +51,7 @@ public: ~NetworkInfoConnection(); - unsigned int bandwidth() const; + double bandwidth() const; bool metered() const; void didChangeNetworkInformation(PassRefPtr<Event>, PassRefPtr<NetworkInfo>); diff --git a/Source/WebCore/Modules/webaudio/AudioNode.cpp b/Source/WebCore/Modules/webaudio/AudioNode.cpp index 0e329c2b9..69fd90bb1 100644 --- a/Source/WebCore/Modules/webaudio/AudioNode.cpp +++ b/Source/WebCore/Modules/webaudio/AudioNode.cpp @@ -36,6 +36,10 @@ #include <wtf/Atomics.h> #include <wtf/MainThread.h> +#if DEBUG_AUDIONODE_REFERENCES +#include <stdio.h> +#endif + namespace WebCore { AudioNode::AudioNode(AudioContext* context, float sampleRate) diff --git a/Source/WebCore/PlatformEfl.cmake b/Source/WebCore/PlatformEfl.cmake index 0c19dd26c..22af0e6ca 100644 --- a/Source/WebCore/PlatformEfl.cmake +++ b/Source/WebCore/PlatformEfl.cmake @@ -8,6 +8,7 @@ LIST(APPEND WebCore_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/page/efl" "${WEBCORE_DIR}/platform/efl" "${WEBCORE_DIR}/platform/graphics/efl" + "${WEBCORE_DIR}/platform/mediastream/gstreamer" "${WEBCORE_DIR}/platform/network/soup" "${WEBCORE_DIR}/platform/text/efl" "${WEBCORE_DIR}/plugins/efl" @@ -73,6 +74,8 @@ LIST(APPEND WebCore_SOURCES platform/image-decoders/jpeg/JPEGImageDecoder.cpp platform/image-decoders/png/PNGImageDecoder.cpp platform/image-decoders/webp/WEBPImageDecoder.cpp + platform/mediastream/gstreamer/DeprecatedPeerConnectionHandler.cpp + platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp platform/network/soup/CookieJarSoup.cpp platform/network/soup/CredentialStorageSoup.cpp platform/network/soup/DNSSoup.cpp diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index 67fedd625..4fa72577e 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -466,6 +466,7 @@ SOURCES += \ css/CSSStyleRule.cpp \ css/CSSStyleSheet.cpp \ css/CSSTimingFunctionValue.cpp \ + css/CSSToStyleMap.cpp \ css/CSSUnicodeRangeValue.cpp \ css/CSSValue.cpp \ css/CSSValueList.cpp \ @@ -1648,6 +1649,7 @@ HEADERS += \ css/CSSStyleRule.h \ css/CSSStyleSheet.h \ css/CSSTimingFunctionValue.h \ + css/CSSToStyleMap.h \ css/CSSUnicodeRangeValue.h \ css/CSSValue.cpp \ css/CSSValue.h \ @@ -2035,7 +2037,7 @@ HEADERS += \ html/track/WebVTTParser.h \ html/track/WebVTTToken.h \ html/track/WebVTTTokenizer.h \ - inspector/BindingVisitor.h \ + inspector/BindingVisitors.h \ inspector/ConsoleMessage.h \ inspector/ContentSearchUtils.h \ inspector/DOMEditor.h \ @@ -4144,7 +4146,7 @@ contains(CONFIG, texmap) { platform/graphics/texmap/TextureMapperLayer.cpp \ platform/graphics/texmap/GraphicsLayerTextureMapper.cpp - !win32-*:contains(QT_CONFIG, opengl) { + contains(DEFINES, WTF_USE_TEXTURE_MAPPER_GL=1) { HEADERS += \ platform/graphics/texmap/TextureMapperGL.h \ platform/graphics/texmap/TextureMapperShaderManager.h @@ -4154,7 +4156,6 @@ contains(CONFIG, texmap) { platform/graphics/texmap/TextureMapperShaderManager.cpp CONFIG += opengl-shims - DEFINES += WTF_USE_TEXTURE_MAPPER_GL } } else { HEADERS += platform/graphics/qt/GraphicsLayerQt.h diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index d73e670ea..1054e0725 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -2505,6 +2505,8 @@ 'css/CSSStyleSheet.h', 'css/CSSTimingFunctionValue.cpp', 'css/CSSTimingFunctionValue.h', + 'css/CSSToStyleMap.cpp', + 'css/CSSToStyleMap.h', 'css/CSSUnicodeRangeValue.cpp', 'css/CSSUnicodeRangeValue.h', 'css/CSSUnknownRule.h', @@ -3751,6 +3753,7 @@ 'platform/graphics/chromium/cc/CCProxy.h', 'platform/graphics/chromium/cc/CCQuadCuller.cpp', 'platform/graphics/chromium/cc/CCQuadCuller.h', + 'platform/graphics/chromium/cc/CCRenderingStats.h', 'platform/graphics/chromium/cc/CCRenderPass.cpp', 'platform/graphics/chromium/cc/CCRenderPass.h', 'platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp', diff --git a/Source/WebCore/WebCore.pri b/Source/WebCore/WebCore.pri index e2ccc6186..193f5fea3 100644 --- a/Source/WebCore/WebCore.pri +++ b/Source/WebCore/WebCore.pri @@ -213,7 +213,9 @@ contains(DEFINES, ENABLE_WEBGL=1) { contains(CONFIG, texmap) { DEFINES += WTF_USE_TEXTURE_MAPPER=1 - !win32-*:contains(QT_CONFIG, opengl) { + # TextureMapperGL requires stuff from GraphicsContext3D, hence the WebGL + # dependency. + !win32-*:contains(QT_CONFIG, opengl):contains(DEFINES, ENABLE_WEBGL=1) { DEFINES += WTF_USE_TEXTURE_MAPPER_GL=1 contains(QT_CONFIG, opengles2): LIBS += -lEGL } diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj index a002e29da..d12db566c 100755 --- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj @@ -36635,6 +36635,14 @@ > </File> <File + RelativePath="..\css\CSSToStyleMap.cpp" + > + </File> + <File + RelativePath="..\css\CSSToStyleMap.h" + > + </File> + <File RelativePath="..\css\CSSUnicodeRangeValue.cpp" > <FileConfiguration diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj index 07f929236..cc8344134 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -4187,6 +4187,8 @@ A871DFE40A15376B00B12A68 /* RenderWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = A871DFE00A15376B00B12A68 /* RenderWidget.h */; settings = {ATTRIBUTES = (Private, ); }; }; A871DFE50A15376B00B12A68 /* RenderWidget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A871DFE10A15376B00B12A68 /* RenderWidget.cpp */; }; A8748BE012CBF2DC001FBA41 /* HashTools.h in Headers */ = {isa = PBXBuildFile; fileRef = A8748BDF12CBF2DC001FBA41 /* HashTools.h */; }; + A882DA201593846A000115ED /* CSSToStyleMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A882DA1F1593846A000115ED /* CSSToStyleMap.cpp */; }; + A882DA231593848D000115ED /* CSSToStyleMap.h in Headers */ = {isa = PBXBuildFile; fileRef = A882DA221593848D000115ED /* CSSToStyleMap.h */; }; A883DF270F3D045D00F19BF6 /* VisibleSelection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A883DF250F3D045D00F19BF6 /* VisibleSelection.cpp */; }; A883DF280F3D045D00F19BF6 /* VisibleSelection.h in Headers */ = {isa = PBXBuildFile; fileRef = A883DF260F3D045D00F19BF6 /* VisibleSelection.h */; settings = {ATTRIBUTES = (Private, ); }; }; A88AD52F09524B92001DD196 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A85D7A2F0879EBA9006A9172 /* QuartzCore.framework */; }; @@ -11197,6 +11199,8 @@ A8748BDF12CBF2DC001FBA41 /* HashTools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashTools.h; sourceTree = "<group>"; }; A8748D6612CC3763001FBA41 /* ImageOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageOrientation.h; sourceTree = "<group>"; }; A8748D7412CC3F89001FBA41 /* ImageOrientation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageOrientation.cpp; sourceTree = "<group>"; }; + A882DA1F1593846A000115ED /* CSSToStyleMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSToStyleMap.cpp; sourceTree = "<group>"; }; + A882DA221593848D000115ED /* CSSToStyleMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSToStyleMap.h; sourceTree = "<group>"; }; A883DF250F3D045D00F19BF6 /* VisibleSelection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisibleSelection.cpp; sourceTree = "<group>"; }; A883DF260F3D045D00F19BF6 /* VisibleSelection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisibleSelection.h; sourceTree = "<group>"; }; A886CDC214FBBAA300D279F4 /* WorkerContextWebSocket.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WorkerContextWebSocket.idl; path = Modules/websockets/WorkerContextWebSocket.idl; sourceTree = "<group>"; }; @@ -20997,6 +21001,8 @@ BC9ADD7F0CC4092200098C4C /* WebKitCSSTransformValue.cpp */, BC9ADD220CC4032600098C4C /* WebKitCSSTransformValue.h */, 31611E540E1C4D4A00F6A579 /* WebKitCSSTransformValue.idl */, + A882DA1F1593846A000115ED /* CSSToStyleMap.cpp */, + A882DA221593848D000115ED /* CSSToStyleMap.h */, ); path = css; sourceTree = "<group>"; @@ -25148,6 +25154,7 @@ CE7B2DB51586ABAD0098B3FA /* TextAlternativeWithRange.h in Headers */, 50987C27157D676D00BDA835 /* CustomFilterGlobalContext.h in Headers */, 4F32BB1B14FA85E800F6C1A3 /* MemoryInstrumentation.h in Headers */, + A882DA231593848D000115ED /* CSSToStyleMap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -28200,6 +28207,7 @@ CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */, CE7B2DB61586ABAD0098B3FA /* TextAlternativeWithRange.mm in Sources */, 50987C26157D676D00BDA835 /* CustomFilterGlobalContext.cpp in Sources */, + A882DA201593846A000115ED /* CSSToStyleMap.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp index ba41d21d5..fdb8d0240 100644 --- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp +++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp @@ -2424,9 +2424,8 @@ AccessibilityObject* AccessibilityRenderObject::accessibilityParentForImageMap(H void AccessibilityRenderObject::getDocumentLinks(AccessibilityChildrenVector& result) { Document* document = m_renderer->document(); - HTMLCollection* coll = document->links(); - Node* curr = coll->firstItem(); - while (curr) { + HTMLCollection* links = document->links(); + for (unsigned i = 0; Node* curr = links->item(i); i++) { RenderObject* obj = curr->renderer(); if (obj) { RefPtr<AccessibilityObject> axobj = document->axObjectCache()->getOrCreate(obj); @@ -2444,7 +2443,6 @@ void AccessibilityRenderObject::getDocumentLinks(AccessibilityChildrenVector& re result.append(areaObject); } } - curr = coll->nextItem(); } } diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp index 37968471b..2d17465e0 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -117,8 +117,8 @@ static JSValue namedItemGetter(ExecState* exec, JSValue slotBase, PropertyName p ASSERT(document->isHTMLDocument()); HTMLCollection* collection = document->windowNamedItems(propertyNameToAtomicString(propertyName)); - if (collection->length() == 1) - return toJS(exec, thisObj, collection->firstItem()); + if (collection->hasExactlyOneItem()) + return toJS(exec, thisObj, collection->item(0)); return toJS(exec, thisObj, collection); } diff --git a/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp b/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp index 14bc0f085..fddc5a5d1 100644 --- a/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp @@ -64,12 +64,11 @@ JSValue JSHTMLDocument::nameGetter(ExecState* exec, JSValue slotBase, PropertyNa HTMLCollection* collection = document->documentNamedItems(propertyNameToAtomicString(propertyName)); - unsigned length = collection->length(); - if (!length) + if (!collection->hasAnyItem()) return jsUndefined(); - if (length == 1) { - Node* node = collection->firstItem(); + if (collection->hasExactlyOneItem()) { + Node* node = collection->item(0); Frame* frame; if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) diff --git a/Source/WebCore/bindings/objc/DOMEvents.mm b/Source/WebCore/bindings/objc/DOMEvents.mm index d7ba17f4c..d7ba17f4c 100644..100755 --- a/Source/WebCore/bindings/objc/DOMEvents.mm +++ b/Source/WebCore/bindings/objc/DOMEvents.mm diff --git a/Source/WebCore/bindings/objc/PublicDOMInterfaces.h b/Source/WebCore/bindings/objc/PublicDOMInterfaces.h index 287e4eea8..45e167729 100644 --- a/Source/WebCore/bindings/objc/PublicDOMInterfaces.h +++ b/Source/WebCore/bindings/objc/PublicDOMInterfaces.h @@ -1082,23 +1082,11 @@ - (void)initOverflowEvent:(unsigned short)orient horizontalOverflow:(BOOL)horizontalOverflow verticalOverflow:(BOOL)verticalOverflow; @end -@interface DOMWheelEvent : DOMUIEvent WEBKIT_VERSION_3_0 -@property(readonly) int screenX; -@property(readonly) int screenY; -@property(readonly) int clientX; -@property(readonly) int clientY; -@property(readonly) BOOL ctrlKey; -@property(readonly) BOOL shiftKey; -@property(readonly) BOOL altKey; -@property(readonly) BOOL metaKey; +@interface DOMWheelEvent : DOMMouseEvent WEBKIT_VERSION_3_0 @property(readonly) BOOL isHorizontal; @property(readonly) int wheelDelta; @property(readonly) int wheelDeltaX AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; @property(readonly) int wheelDeltaY AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -@property(readonly) int offsetX AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -@property(readonly) int offsetY AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -@property(readonly) int x AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -@property(readonly) int y AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; - (void)initWheelEvent:(int)wheelDeltaX wheelDeltaY:(int)wheelDeltaY view:(DOMAbstractView *)view screenX:(int)screenX screenY:(int)screenY clientX:(int)clientX clientY:(int)clientY ctrlKey:(BOOL)ctrlKey altKey:(BOOL)altKey shiftKey:(BOOL)shiftKey metaKey:(BOOL)metaKey AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; @end diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 6bfc8898e..269792ff0 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -418,7 +418,7 @@ sub GetBaseClass $parent = shift; return $parent if $parent eq "Object" or IsBaseType($parent); - return "Event" if $parent eq "UIEvent"; + return "Event" if $parent eq "UIEvent" or $parent eq "MouseEvent"; return "CSSValue" if $parent eq "SVGColor" or $parent eq "CSSValueList"; return "Node"; } diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm index a92989a52..254ec9396 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -1724,13 +1724,8 @@ sub GenerateParametersCheck $parameterCheckString .= " EXCEPTION_BLOCK($nativeType, $parameterName, " . JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)", "args.GetIsolate()") . ");\n"; if ($nativeType eq 'Dictionary') { - $parameterCheckString .= " if (args.Length() > $paramIndex && !$parameterName.isUndefinedOrNull() && !$parameterName.isObject()) {\n"; - if (@{$function->raisesExceptions}) { - $parameterCheckString .= " ec = TYPE_MISMATCH_ERR;\n"; - $parameterCheckString .= " V8Proxy::setDOMException(ec, args.GetIsolate());\n"; - } - $parameterCheckString .= " return V8Proxy::throwTypeError(\"Not an object.\");\n"; - $parameterCheckString .= " }\n"; + $parameterCheckString .= " if (!$parameterName.isUndefinedOrNull() && !$parameterName.isObject())\n"; + $parameterCheckString .= " return V8Proxy::throwTypeError(\"Not an object.\", args.GetIsolate());\n"; } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index dd2e6f489..40b8d9dbd 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -1150,17 +1150,15 @@ static v8::Handle<v8::Value> optionsObjectCallback(const v8::Arguments& args) return V8Proxy::throwNotEnoughArgumentsError(args.GetIsolate()); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(Dictionary, oo, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); - if (args.Length() > 0 && !oo.isUndefinedOrNull() && !oo.isObject()) { - return V8Proxy::throwTypeError("Not an object."); - } + if (!oo.isUndefinedOrNull() && !oo.isObject()) + return V8Proxy::throwTypeError("Not an object.", args.GetIsolate()); if (args.Length() <= 1) { imp->optionsObject(oo); return v8::Handle<v8::Value>(); } EXCEPTION_BLOCK(Dictionary, ooo, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); - if (args.Length() > 1 && !ooo.isUndefinedOrNull() && !ooo.isObject()) { - return V8Proxy::throwTypeError("Not an object."); - } + if (!ooo.isUndefinedOrNull() && !ooo.isObject()) + return V8Proxy::throwTypeError("Not an object.", args.GetIsolate()); imp->optionsObject(oo, ooo); return v8::Handle<v8::Value>(); } diff --git a/Source/WebCore/bindings/v8/V8DOMWrapper.cpp b/Source/WebCore/bindings/v8/V8DOMWrapper.cpp index 05c17ab03..f595fe4f8 100644 --- a/Source/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/Source/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -224,6 +224,7 @@ bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value) ASSERT(object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount); + v8::HandleScope scope; v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex); ASSERT(wrapper->IsNumber() || wrapper->IsExternal()); diff --git a/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index 0ea813eb5..c0964ad19 100644 --- a/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -521,9 +521,9 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam if (doc && doc->isHTMLDocument()) { if (static_cast<HTMLDocument*>(doc)->hasNamedItem(propName.impl()) || doc->hasElementWithId(propName.impl())) { HTMLCollection* items = doc->windowNamedItems(propName); - if (items->length() >= 1) { - if (items->length() == 1) - return toV8(items->firstItem(), info.GetIsolate()); + if (items->hasAnyItem()) { + if (items->hasExactlyOneItem()) + return toV8(items->item(0), info.GetIsolate()); return toV8(items, info.GetIsolate()); } } diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp index 6b9d0b327..df5331727 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp @@ -85,11 +85,11 @@ v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocumen return v8::Handle<v8::Value>(); HTMLCollection* items = htmlDocument->documentNamedItems(key); - if (!items->length()) + if (!items->hasAnyItem()) return v8::Handle<v8::Value>(); - if (items->length() == 1) { - Node* node = items->firstItem(); + if (items->hasExactlyOneItem()) { + Node* node = items->item(0); Frame* frame = 0; if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) return toV8(frame->domWindow(), isolate); diff --git a/Source/WebCore/bridge/runtime_object.cpp b/Source/WebCore/bridge/runtime_object.cpp index 71f72fd4b..a1a30ce01 100644 --- a/Source/WebCore/bridge/runtime_object.cpp +++ b/Source/WebCore/bridge/runtime_object.cpp @@ -51,9 +51,7 @@ void RuntimeObject::finishCreation(JSGlobalObject* globalObject) void RuntimeObject::destroy(JSCell* cell) { - RuntimeObject* thisObject = static_cast<RuntimeObject*>(cell); - ASSERT(!thisObject->m_instance); - thisObject->RuntimeObject::~RuntimeObject(); + static_cast<RuntimeObject*>(cell)->RuntimeObject::~RuntimeObject(); } void RuntimeObject::invalidate() diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index 63658cbfe..cc96a2d1f 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -1013,6 +1013,74 @@ static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID prope return true; } +template <typename CharType> +static bool parseTransformArguments(WebKitCSSTransformValue* transformValue, CharType* characters, unsigned length, unsigned start, unsigned expectedCount) +{ + while (expectedCount) { + size_t end = WTF::find(characters, length, expectedCount == 1 ? ')' : ',', start); + if (end == notFound || (expectedCount == 1 && end != length - 1)) + return false; + unsigned argumentLength = end - start; + CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER; + double number; + if (!parseSimpleLength(characters + start, argumentLength, unit, number)) + return false; + if (unit != CSSPrimitiveValue::CSS_PX && (number || unit != CSSPrimitiveValue::CSS_NUMBER)) + return false; + transformValue->append(cssValuePool().createValue(number, unit)); + start = end + 1; + --expectedCount; + } + return true; +} + +static bool parseTransformValue(StylePropertySet* properties, CSSPropertyID propertyID, const String& string, bool important) +{ + if (propertyID != CSSPropertyWebkitTransform) + return false; + static const unsigned shortestValidTransformStringLength = 12; + static const unsigned likelyMultipartTransformStringLengthCutoff = 32; + if (string.length() < shortestValidTransformStringLength || string.length() > likelyMultipartTransformStringLengthCutoff) + return false; + if (!string.startsWith("translate", false)) + return false; + UChar c9 = toASCIILower(string[9]); + UChar c10 = toASCIILower(string[10]); + + WebKitCSSTransformValue::TransformOperationType transformType; + unsigned expectedArgumentCount = 1; + unsigned argumentStart = 11; + if (c9 == 'x' && c10 == '(') + transformType = WebKitCSSTransformValue::TranslateXTransformOperation; + else if (c9 == 'y' && c10 == '(') + transformType = WebKitCSSTransformValue::TranslateYTransformOperation; + else if (c9 == 'z' && c10 == '(') + transformType = WebKitCSSTransformValue::TranslateZTransformOperation; + else if (c9 == '(') { + transformType = WebKitCSSTransformValue::TranslateTransformOperation; + expectedArgumentCount = 2; + argumentStart = 10; + } else if (c9 == '3' && c10 == 'd' && string[11] == '(') { + transformType = WebKitCSSTransformValue::Translate3DTransformOperation; + expectedArgumentCount = 3; + argumentStart = 12; + } else + return false; + + RefPtr<WebKitCSSTransformValue> transformValue = WebKitCSSTransformValue::create(transformType); + bool success; + if (string.is8Bit()) + success = parseTransformArguments(transformValue.get(), string.characters8(), string.length(), argumentStart, expectedArgumentCount); + else + success = parseTransformArguments(transformValue.get(), string.characters16(), string.length(), argumentStart, expectedArgumentCount); + if (!success) + return false; + RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); + result->append(transformValue.release()); + properties->addParsedProperty(CSSProperty(CSSPropertyWebkitTransform, result.release(), important)); + return true; +} + PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& string) { if (string.isEmpty()) @@ -1051,6 +1119,8 @@ bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property return true; if (parseKeywordValue(declaration, propertyID, string, important, contextStyleSheet->parserContext())) return true; + if (parseTransformValue(declaration, propertyID, string, important)) + return true; CSSParserContext context(cssParserMode); if (contextStyleSheet) { @@ -2621,6 +2691,11 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) m_valueList->next(); break; #endif +#if ENABLE(CSS_VARIABLES) + case CSSPropertyVariable: + // FIXME: This should have an actual implementation. + return false; +#endif case CSSPropertyBorderBottomStyle: case CSSPropertyBorderCollapse: case CSSPropertyBorderLeftStyle: @@ -8897,7 +8972,7 @@ restartAfterComment: case CharacterDash: #if ENABLE(CSS_VARIABLES) - if (cssVariablesEnabled() && m_currentCharacter[10] == '-' && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && isIdentifierStartAfterDash(m_currentCharacter + 11)) { + if (cssVariablesEnabled() && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && m_currentCharacter[10] == '-' && isIdentifierStartAfterDash(m_currentCharacter + 11)) { // handle variable declarations m_currentCharacter += 11; parseIdentifier(result, hasEscape); diff --git a/Source/WebCore/css/CSSParserMode.h b/Source/WebCore/css/CSSParserMode.h index d6b211522..5228e9812 100644 --- a/Source/WebCore/css/CSSParserMode.h +++ b/Source/WebCore/css/CSSParserMode.h @@ -26,7 +26,6 @@ * 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 CSSParserMode_h diff --git a/Source/WebCore/css/CSSToStyleMap.cpp b/Source/WebCore/css/CSSToStyleMap.cpp new file mode 100644 index 000000000..e154cecd3 --- /dev/null +++ b/Source/WebCore/css/CSSToStyleMap.cpp @@ -0,0 +1,659 @@ +/* + * Copyright (C) 1999 Lars Knoll (knoll@kde.org) + * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) + * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> + * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> + * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) + * Copyright (c) 2011, Code Aurora Forum. All rights reserved. + * Copyright (C) Research In Motion Limited 2011. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "CSSToStyleMap.h" + +#include "Animation.h" +#include "CSSBorderImageSliceValue.h" +#include "CSSPrimitiveValue.h" +#include "CSSPrimitiveValueMappings.h" +#include "CSSTimingFunctionValue.h" +#include "CSSValueKeywords.h" +#include "FillLayer.h" +#include "Pair.h" +#include "Rect.h" +#include "StyleResolver.h" + +namespace WebCore { + +RenderStyle* CSSToStyleMap::style() const +{ + return m_resolver->style(); +} + +RenderStyle* CSSToStyleMap::rootElementStyle() const +{ + return m_resolver->rootElementStyle(); +} + +bool CSSToStyleMap::useSVGZoomRules() const +{ + return m_resolver->useSVGZoomRules(); +} + +PassRefPtr<StyleImage> CSSToStyleMap::styleImage(CSSPropertyID propertyId, CSSValue* value) +{ + return m_resolver->styleImage(propertyId, value); +} + +void CSSToStyleMap::mapFillAttachment(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setAttachment(FillLayer::initialFillAttachment(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + switch (primitiveValue->getIdent()) { + case CSSValueFixed: + layer->setAttachment(FixedBackgroundAttachment); + break; + case CSSValueScroll: + layer->setAttachment(ScrollBackgroundAttachment); + break; + case CSSValueLocal: + layer->setAttachment(LocalBackgroundAttachment); + break; + default: + return; + } +} + +void CSSToStyleMap::mapFillClip(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setClip(FillLayer::initialFillClip(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + layer->setClip(*primitiveValue); +} + +void CSSToStyleMap::mapFillComposite(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setComposite(FillLayer::initialFillComposite(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + layer->setComposite(*primitiveValue); +} + +void CSSToStyleMap::mapFillOrigin(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setOrigin(FillLayer::initialFillOrigin(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + layer->setOrigin(*primitiveValue); +} + + +void CSSToStyleMap::mapFillImage(CSSPropertyID property, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setImage(FillLayer::initialFillImage(layer->type())); + return; + } + + layer->setImage(styleImage(property, value)); +} + +void CSSToStyleMap::mapFillRepeatX(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + layer->setRepeatX(*primitiveValue); +} + +void CSSToStyleMap::mapFillRepeatY(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + layer->setRepeatY(*primitiveValue); +} + +void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (!value->isPrimitiveValue()) { + layer->setSizeType(SizeNone); + return; + } + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + if (primitiveValue->getIdent() == CSSValueContain) + layer->setSizeType(Contain); + else if (primitiveValue->getIdent() == CSSValueCover) + layer->setSizeType(Cover); + else + layer->setSizeType(SizeLength); + + LengthSize b = FillLayer::initialFillSizeLength(layer->type()); + + if (value->isInitialValue() || primitiveValue->getIdent() == CSSValueContain || primitiveValue->getIdent() == CSSValueCover) { + layer->setSizeLength(b); + return; + } + + float zoomFactor = style()->effectiveZoom(); + + Length firstLength; + Length secondLength; + + if (Pair* pair = primitiveValue->getPairValue()) { + CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first()); + CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second()); + firstLength = first->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor); + secondLength = second->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor); + } else { + firstLength = primitiveValue->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor); + secondLength = Length(); + } + + if (firstLength.isUndefined() || secondLength.isUndefined()) + return; + + b.setWidth(firstLength); + b.setHeight(secondLength); + layer->setSizeLength(b); +} + +void CSSToStyleMap::mapFillXPosition(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + float zoomFactor = style()->effectiveZoom(); + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length length; + if (primitiveValue->isLength()) + length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor); + else if (primitiveValue->isPercentage()) + length = Length(primitiveValue->getDoubleValue(), Percent); + else if (primitiveValue->isCalculatedPercentageWithLength()) + length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor)); + else if (primitiveValue->isViewportPercentageLength()) + length = primitiveValue->viewportPercentageLength(); + else + return; + layer->setXPosition(length); +} + +void CSSToStyleMap::mapFillYPosition(CSSPropertyID, FillLayer* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); + return; + } + + if (!value->isPrimitiveValue()) + return; + + float zoomFactor = style()->effectiveZoom(); + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length length; + if (primitiveValue->isLength()) + length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor); + else if (primitiveValue->isPercentage()) + length = Length(primitiveValue->getDoubleValue(), Percent); + else if (primitiveValue->isCalculatedPercentageWithLength()) + length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor)); + else if (primitiveValue->isViewportPercentageLength()) + length = primitiveValue->viewportPercentageLength(); + else + return; + layer->setYPosition(length); +} + +void CSSToStyleMap::mapAnimationDelay(Animation* animation, CSSValue* value) +{ + if (value->isInitialValue()) { + animation->setDelay(Animation::initialAnimationDelay()); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + animation->setDelay(primitiveValue->computeTime<float, CSSPrimitiveValue::Seconds>()); +} + +void CSSToStyleMap::mapAnimationDirection(Animation* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setDirection(Animation::initialAnimationDirection()); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + switch (primitiveValue->getIdent()) { + case CSSValueNormal: + layer->setDirection(Animation::AnimationDirectionNormal); + break; + case CSSValueAlternate: + layer->setDirection(Animation::AnimationDirectionAlternate); + break; + case CSSValueReverse: + layer->setDirection(Animation::AnimationDirectionReverse); + break; + case CSSValueAlternateReverse: + layer->setDirection(Animation::AnimationDirectionAlternateReverse); + break; + } +} + +void CSSToStyleMap::mapAnimationDuration(Animation* animation, CSSValue* value) +{ + if (value->isInitialValue()) { + animation->setDuration(Animation::initialAnimationDuration()); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + animation->setDuration(primitiveValue->computeTime<float, CSSPrimitiveValue::Seconds>()); +} + +void CSSToStyleMap::mapAnimationFillMode(Animation* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setFillMode(Animation::initialAnimationFillMode()); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + switch (primitiveValue->getIdent()) { + case CSSValueNone: + layer->setFillMode(AnimationFillModeNone); + break; + case CSSValueForwards: + layer->setFillMode(AnimationFillModeForwards); + break; + case CSSValueBackwards: + layer->setFillMode(AnimationFillModeBackwards); + break; + case CSSValueBoth: + layer->setFillMode(AnimationFillModeBoth); + break; + } +} + +void CSSToStyleMap::mapAnimationIterationCount(Animation* animation, CSSValue* value) +{ + if (value->isInitialValue()) { + animation->setIterationCount(Animation::initialAnimationIterationCount()); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + if (primitiveValue->getIdent() == CSSValueInfinite) + animation->setIterationCount(-1); + else + animation->setIterationCount(primitiveValue->getFloatValue()); +} + +void CSSToStyleMap::mapAnimationName(Animation* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setName(Animation::initialAnimationName()); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + if (primitiveValue->getIdent() == CSSValueNone) + layer->setIsNoneAnimation(true); + else + layer->setName(primitiveValue->getStringValue()); +} + +void CSSToStyleMap::mapAnimationPlayState(Animation* layer, CSSValue* value) +{ + if (value->isInitialValue()) { + layer->setPlayState(Animation::initialAnimationPlayState()); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + EAnimPlayState playState = (primitiveValue->getIdent() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying; + layer->setPlayState(playState); +} + +void CSSToStyleMap::mapAnimationProperty(Animation* animation, CSSValue* value) +{ + if (value->isInitialValue()) { + animation->setAnimationMode(Animation::AnimateAll); + animation->setProperty(CSSPropertyInvalid); + return; + } + + if (!value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + if (primitiveValue->getIdent() == CSSValueAll) { + animation->setAnimationMode(Animation::AnimateAll); + animation->setProperty(CSSPropertyInvalid); + } else if (primitiveValue->getIdent() == CSSValueNone) { + animation->setAnimationMode(Animation::AnimateNone); + animation->setProperty(CSSPropertyInvalid); + } else { + animation->setAnimationMode(Animation::AnimateSingleProperty); + animation->setProperty(static_cast<CSSPropertyID>(primitiveValue->getIdent())); + } +} + +void CSSToStyleMap::mapAnimationTimingFunction(Animation* animation, CSSValue* value) +{ + if (value->isInitialValue()) { + animation->setTimingFunction(Animation::initialAnimationTimingFunction()); + return; + } + + if (value->isPrimitiveValue()) { + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + switch (primitiveValue->getIdent()) { + case CSSValueLinear: + animation->setTimingFunction(LinearTimingFunction::create()); + break; + case CSSValueEase: + animation->setTimingFunction(CubicBezierTimingFunction::create()); + break; + case CSSValueEaseIn: + animation->setTimingFunction(CubicBezierTimingFunction::create(0.42, 0.0, 1.0, 1.0)); + break; + case CSSValueEaseOut: + animation->setTimingFunction(CubicBezierTimingFunction::create(0.0, 0.0, 0.58, 1.0)); + break; + case CSSValueEaseInOut: + animation->setTimingFunction(CubicBezierTimingFunction::create(0.42, 0.0, 0.58, 1.0)); + break; + case CSSValueStepStart: + animation->setTimingFunction(StepsTimingFunction::create(1, true)); + break; + case CSSValueStepEnd: + animation->setTimingFunction(StepsTimingFunction::create(1, false)); + break; + } + return; + } + + if (value->isCubicBezierTimingFunctionValue()) { + CSSCubicBezierTimingFunctionValue* cubicTimingFunction = static_cast<CSSCubicBezierTimingFunctionValue*>(value); + animation->setTimingFunction(CubicBezierTimingFunction::create(cubicTimingFunction->x1(), cubicTimingFunction->y1(), cubicTimingFunction->x2(), cubicTimingFunction->y2())); + } else if (value->isStepsTimingFunctionValue()) { + CSSStepsTimingFunctionValue* stepsTimingFunction = static_cast<CSSStepsTimingFunctionValue*>(value); + animation->setTimingFunction(StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart())); + } else if (value->isLinearTimingFunctionValue()) + animation->setTimingFunction(LinearTimingFunction::create()); +} + +void CSSToStyleMap::mapNinePieceImage(CSSPropertyID property, CSSValue* value, NinePieceImage& image) +{ + // If we're not a value list, then we are "none" and don't need to alter the empty image at all. + if (!value || !value->isValueList()) + return; + + // Retrieve the border image value. + CSSValueList* borderImage = static_cast<CSSValueList*>(value); + + // Set the image (this kicks off the load). + CSSPropertyID imageProperty; + if (property == CSSPropertyWebkitBorderImage) + imageProperty = CSSPropertyBorderImageSource; + else if (property == CSSPropertyWebkitMaskBoxImage) + imageProperty = CSSPropertyWebkitMaskBoxImageSource; + else + imageProperty = property; + + for (unsigned i = 0 ; i < borderImage->length() ; ++i) { + CSSValue* current = borderImage->item(i); + + if (current->isImageValue() || current->isImageGeneratorValue() +#if ENABLE(CSS_IMAGE_SET) + || current->isImageSetValue() +#endif + ) + image.setImage(styleImage(imageProperty, current)); + else if (current->isBorderImageSliceValue()) + mapNinePieceImageSlice(current, image); + else if (current->isValueList()) { + CSSValueList* slashList = static_cast<CSSValueList*>(current); + // Map in the image slices. + if (slashList->item(0) && slashList->item(0)->isBorderImageSliceValue()) + mapNinePieceImageSlice(slashList->item(0), image); + + // Map in the border slices. + if (slashList->item(1)) + image.setBorderSlices(mapNinePieceImageQuad(slashList->item(1))); + + // Map in the outset. + if (slashList->item(2)) + image.setOutset(mapNinePieceImageQuad(slashList->item(2))); + } else if (current->isPrimitiveValue()) { + // Set the appropriate rules for stretch/round/repeat of the slices. + mapNinePieceImageRepeat(current, image); + } + } + + if (property == CSSPropertyWebkitBorderImage) { + // We have to preserve the legacy behavior of -webkit-border-image and make the border slices + // also set the border widths. We don't need to worry about percentages, since we don't even support + // those on real borders yet. + if (image.borderSlices().top().isFixed()) + style()->setBorderTopWidth(image.borderSlices().top().value()); + if (image.borderSlices().right().isFixed()) + style()->setBorderRightWidth(image.borderSlices().right().value()); + if (image.borderSlices().bottom().isFixed()) + style()->setBorderBottomWidth(image.borderSlices().bottom().value()); + if (image.borderSlices().left().isFixed()) + style()->setBorderLeftWidth(image.borderSlices().left().value()); + } +} + +void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& image) +{ + if (!value || !value->isBorderImageSliceValue()) + return; + + // Retrieve the border image value. + CSSBorderImageSliceValue* borderImageSlice = static_cast<CSSBorderImageSliceValue*>(value); + + // Set up a length box to represent our image slices. + LengthBox box; + Quad* slices = borderImageSlice->slices(); + if (slices->top()->isPercentage()) + box.m_top = Length(slices->top()->getDoubleValue(), Percent); + else + box.m_top = Length(slices->top()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); + if (slices->bottom()->isPercentage()) + box.m_bottom = Length(slices->bottom()->getDoubleValue(), Percent); + else + box.m_bottom = Length((int)slices->bottom()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); + if (slices->left()->isPercentage()) + box.m_left = Length(slices->left()->getDoubleValue(), Percent); + else + box.m_left = Length(slices->left()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); + if (slices->right()->isPercentage()) + box.m_right = Length(slices->right()->getDoubleValue(), Percent); + else + box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); + image.setImageSlices(box); + + // Set our fill mode. + image.setFill(borderImageSlice->m_fill); +} + +LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) +{ + if (!value || !value->isPrimitiveValue()) + return LengthBox(); + + // Get our zoom value. + float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom(); + + // Retrieve the primitive value. + CSSPrimitiveValue* borderWidths = static_cast<CSSPrimitiveValue*>(value); + + // Set up a length box to represent our image slices. + LengthBox box; // Defaults to 'auto' so we don't have to handle that explicitly below. + Quad* slices = borderWidths->getQuadValue(); + if (slices->top()->isNumber()) + box.m_top = Length(slices->top()->getIntValue(), Relative); + else if (slices->top()->isPercentage()) + box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); + else if (slices->top()->getIdent() != CSSValueAuto) + box.m_top = slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom); + + if (slices->right()->isNumber()) + box.m_right = Length(slices->right()->getIntValue(), Relative); + else if (slices->right()->isPercentage()) + box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); + else if (slices->right()->getIdent() != CSSValueAuto) + box.m_right = slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom); + + if (slices->bottom()->isNumber()) + box.m_bottom = Length(slices->bottom()->getIntValue(), Relative); + else if (slices->bottom()->isPercentage()) + box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); + else if (slices->bottom()->getIdent() != CSSValueAuto) + box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom); + + if (slices->left()->isNumber()) + box.m_left = Length(slices->left()->getIntValue(), Relative); + else if (slices->left()->isPercentage()) + box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); + else if (slices->left()->getIdent() != CSSValueAuto) + box.m_left = slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom); + + return box; +} + +void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& image) +{ + if (!value || !value->isPrimitiveValue()) + return; + + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Pair* pair = primitiveValue->getPairValue(); + if (!pair || !pair->first() || !pair->second()) + return; + + int firstIdentifier = pair->first()->getIdent(); + int secondIdentifier = pair->second()->getIdent(); + + ENinePieceImageRule horizontalRule; + switch (firstIdentifier) { + case CSSValueStretch: + horizontalRule = StretchImageRule; + break; + case CSSValueRound: + horizontalRule = RoundImageRule; + break; + case CSSValueSpace: + horizontalRule = SpaceImageRule; + break; + default: // CSSValueRepeat + horizontalRule = RepeatImageRule; + break; + } + image.setHorizontalRule(horizontalRule); + + ENinePieceImageRule verticalRule; + switch (secondIdentifier) { + case CSSValueStretch: + verticalRule = StretchImageRule; + break; + case CSSValueRound: + verticalRule = RoundImageRule; + break; + case CSSValueSpace: + verticalRule = SpaceImageRule; + break; + default: // CSSValueRepeat + verticalRule = RepeatImageRule; + break; + } + image.setVerticalRule(verticalRule); +} + +}; diff --git a/Source/WebCore/css/CSSToStyleMap.h b/Source/WebCore/css/CSSToStyleMap.h new file mode 100644 index 000000000..8e0fc953d --- /dev/null +++ b/Source/WebCore/css/CSSToStyleMap.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 1999 Lars Knoll (knoll@kde.org) + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef CSSToStyleMap_h +#define CSSToStyleMap_h + +#include "CSSPropertyNames.h" +#include "LengthBox.h" + +namespace WebCore { + +class FillLayer; +class CSSValue; +class Animation; +class StyleImage; +class StyleResolver; +class NinePieceImage; + +class CSSToStyleMap { + WTF_MAKE_NONCOPYABLE(CSSToStyleMap); + WTF_MAKE_FAST_ALLOCATED; + +public: + CSSToStyleMap(StyleResolver* resolver) : m_resolver(resolver) { } + + void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillClip(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillComposite(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillOrigin(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillImage(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillRepeatX(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillRepeatY(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillSize(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillXPosition(CSSPropertyID, FillLayer*, CSSValue*); + void mapFillYPosition(CSSPropertyID, FillLayer*, CSSValue*); + + void mapAnimationDelay(Animation*, CSSValue*); + void mapAnimationDirection(Animation*, CSSValue*); + void mapAnimationDuration(Animation*, CSSValue*); + void mapAnimationFillMode(Animation*, CSSValue*); + void mapAnimationIterationCount(Animation*, CSSValue*); + void mapAnimationName(Animation*, CSSValue*); + void mapAnimationPlayState(Animation*, CSSValue*); + void mapAnimationProperty(Animation*, CSSValue*); + void mapAnimationTimingFunction(Animation*, CSSValue*); + + void mapNinePieceImage(CSSPropertyID, CSSValue*, NinePieceImage&); + void mapNinePieceImageSlice(CSSValue*, NinePieceImage&); + LengthBox mapNinePieceImageQuad(CSSValue*); + void mapNinePieceImageRepeat(CSSValue*, NinePieceImage&); + +private: + // FIXME: These accessors should be replaced by a ResolveState object + // similar to how PaintInfo/LayoutState cache values needed for + // the current paint/layout. + RenderStyle* style() const; + RenderStyle* rootElementStyle() const; + bool useSVGZoomRules() const; + + // FIXME: This should be part of some sort of StyleImageCache object which + // is held by the StyleResolver, and likely provided to this object + // during the resolve. + PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*); + + StyleResolver* m_resolver; +}; + +} + +#endif diff --git a/Source/WebCore/css/CSSValue.h b/Source/WebCore/css/CSSValue.h index b1e262c67..b4e8a89e7 100644 --- a/Source/WebCore/css/CSSValue.h +++ b/Source/WebCore/css/CSSValue.h @@ -30,7 +30,7 @@ namespace WebCore { class StyleSheetContents; - + // FIXME: The current CSSValue and subclasses should be turned into internal types (StyleValue). // The few subtypes that are actually exposed in CSSOM can be seen in the cloneForCSSOM() function. // They should be handled by separate wrapper classes. diff --git a/Source/WebCore/css/CSSVariableValue.h b/Source/WebCore/css/CSSVariableValue.h index 15dbf9d69..2c5b66a6b 100644 --- a/Source/WebCore/css/CSSVariableValue.h +++ b/Source/WebCore/css/CSSVariableValue.h @@ -24,7 +24,6 @@ * 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 CSSVariableValue_h diff --git a/Source/WebCore/css/StyleBuilder.cpp b/Source/WebCore/css/StyleBuilder.cpp index 2139996bd..20d02cc15 100644 --- a/Source/WebCore/css/StyleBuilder.cpp +++ b/Source/WebCore/css/StyleBuilder.cpp @@ -29,6 +29,7 @@ #include "CSSCalculationValue.h" #include "CSSCursorImageValue.h" #include "CSSPrimitiveValueMappings.h" +#include "CSSToStyleMap.h" #include "CSSValueList.h" #include "CursorList.h" #include "Document.h" @@ -496,7 +497,7 @@ template <typename T, void (FillLayer::*setFunction)(typename FillLayerAccessorTypes<T>::Setter), void (FillLayer::*clearFunction)(), typename FillLayerAccessorTypes<T>::Getter (*initialFunction)(EFillLayerType), - void (StyleResolver::*mapFillFunction)(CSSPropertyID, FillLayer*, CSSValue*)> + void (CSSToStyleMap::*mapFillFunction)(CSSPropertyID, FillLayer*, CSSValue*)> class ApplyPropertyFillLayer { public: static void applyInheritValue(StyleResolver* styleResolver) @@ -548,12 +549,12 @@ public: currChild = new FillLayer(fillLayerType); prevChild->setNext(currChild); } - (styleResolver->*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i)); + (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i)); prevChild = currChild; currChild = currChild->next(); } } else { - (styleResolver->*mapFillFunction)(propertyId, currChild, value); + (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, value); currChild = currChild->next(); } while (currChild) { @@ -886,7 +887,7 @@ public: NinePieceImage image; if (borderImageType == Mask) image.setMaskDefaults(); - styleResolver->mapNinePieceImage(property, value, image); + styleResolver->styleMap()->mapNinePieceImage(property, value, image); (styleResolver->style()->*setterFunction)(image); } @@ -953,16 +954,16 @@ public: NinePieceImage image(getValue(styleResolver->style())); switch (modifier) { case Outset: - image.setOutset(styleResolver->mapNinePieceImageQuad(value)); + image.setOutset(styleResolver->styleMap()->mapNinePieceImageQuad(value)); break; case Repeat: - styleResolver->mapNinePieceImageRepeat(value, image); + styleResolver->styleMap()->mapNinePieceImageRepeat(value, image); break; case Slice: - styleResolver->mapNinePieceImageSlice(value, image); + styleResolver->styleMap()->mapNinePieceImageSlice(value, image); break; case Width: - image.setBorderSlices(styleResolver->mapNinePieceImageQuad(value)); + image.setBorderSlices(styleResolver->styleMap()->mapNinePieceImageQuad(value)); break; } setValue(styleResolver->style(), image); @@ -1437,7 +1438,7 @@ template <typename T, bool (Animation::*testFunction)() const, void (Animation::*clearFunction)(), T (*initialFunction)(), - void (StyleResolver::*mapFunction)(Animation*, CSSValue*), + void (CSSToStyleMap::*mapFunction)(Animation*, CSSValue*), AnimationList* (RenderStyle::*animationGetterFunction)(), const AnimationList* (RenderStyle::*immutableAnimationGetterFunction)() const> class ApplyPropertyAnimation { @@ -1447,7 +1448,7 @@ public: static bool test(const Animation* animation) { return (animation->*testFunction)(); } static void clear(Animation* animation) { (animation->*clearFunction)(); } static T initial() { return (*initialFunction)(); } - static void map(StyleResolver* styleResolver, Animation* animation, CSSValue* value) { (styleResolver->*mapFunction)(animation, value); } + static void map(StyleResolver* styleResolver, Animation* animation, CSSValue* value) { (styleResolver->styleMap()->*mapFunction)(animation, value); } static AnimationList* accessAnimations(RenderStyle* style) { return (style->*animationGetterFunction)(); } static const AnimationList* animations(RenderStyle* style) { return (style->*immutableAnimationGetterFunction)(); } @@ -1840,18 +1841,18 @@ StyleBuilder::StyleBuilder() m_propertyMap[i] = PropertyHandler(); // Please keep CSS property list in alphabetical order. - setPropertyHandler(CSSPropertyBackgroundAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyBackgroundAttachment, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &StyleResolver::mapFillAttachment>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundClip, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &StyleResolver::mapFillClip>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyBackgroundAttachment, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSToStyleMap::mapFillAttachment>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundClip, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler()); setPropertyHandler(CSSPropertyBackgroundColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, &RenderStyle::setVisitedLinkBackgroundColor, &RenderStyle::invalidColor>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &StyleResolver::mapFillImage>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &StyleResolver::mapFillOrigin>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSToStyleMap::mapFillImage>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSToStyleMap::mapFillOrigin>::createHandler()); setPropertyHandler(CSSPropertyBackgroundPosition, ApplyPropertyExpanding<SuppressValue, CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundPositionX, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &StyleResolver::mapFillXPosition>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundPositionY, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &StyleResolver::mapFillYPosition>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundPositionX, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSToStyleMap::mapFillXPosition>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundPositionY, ApplyPropertyFillLayer<Length, CSSPropertyBackgroundPositionY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSToStyleMap::mapFillYPosition>::createHandler()); setPropertyHandler(CSSPropertyBackgroundRepeat, ApplyPropertyExpanding<SuppressValue, CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &StyleResolver::mapFillRepeatX>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &StyleResolver::mapFillRepeatY>::createHandler()); - setPropertyHandler(CSSPropertyBackgroundSize, ApplyPropertyFillLayer<FillSize, CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &StyleResolver::mapFillSize>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSToStyleMap::mapFillRepeatX>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyBackgroundRepeatY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSToStyleMap::mapFillRepeatY>::createHandler()); + setPropertyHandler(CSSPropertyBackgroundSize, ApplyPropertyFillLayer<FillSize, CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSToStyleMap::mapFillSize>::createHandler()); setPropertyHandler(CSSPropertyBorder, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderStyle, CSSPropertyBorderWidth, CSSPropertyBorderColor>::createHandler()); setPropertyHandler(CSSPropertyBorderBottom, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderBottomColor, CSSPropertyBorderBottomStyle, CSSPropertyBorderBottomWidth>::createHandler()); setPropertyHandler(CSSPropertyBorderBottomColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor, &RenderStyle::setVisitedLinkBorderBottomColor, &RenderStyle::color>::createHandler()); @@ -1957,19 +1958,19 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyUnicodeBidi, ApplyPropertyUnicodeBidi::createHandler()); setPropertyHandler(CSSPropertyVerticalAlign, ApplyPropertyVerticalAlign::createHandler()); setPropertyHandler(CSSPropertyVisibility, ApplyPropertyDefault<EVisibility, &RenderStyle::visibility, EVisibility, &RenderStyle::setVisibility, EVisibility, &RenderStyle::initialVisibility>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &StyleResolver::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationDirection, ApplyPropertyAnimation<Animation::AnimationDirection, &Animation::direction, &Animation::setDirection, &Animation::isDirectionSet, &Animation::clearDirection, &Animation::initialAnimationDirection, &StyleResolver::mapAnimationDirection, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &StyleResolver::mapAnimationDuration, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationFillMode, ApplyPropertyAnimation<unsigned, &Animation::fillMode, &Animation::setFillMode, &Animation::isFillModeSet, &Animation::clearFillMode, &Animation::initialAnimationFillMode, &StyleResolver::mapAnimationFillMode, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationIterationCount, ApplyPropertyAnimation<double, &Animation::iterationCount, &Animation::setIterationCount, &Animation::isIterationCountSet, &Animation::clearIterationCount, &Animation::initialAnimationIterationCount, &StyleResolver::mapAnimationIterationCount, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationName, ApplyPropertyAnimation<const String&, &Animation::name, &Animation::setName, &Animation::isNameSet, &Animation::clearName, &Animation::initialAnimationName, &StyleResolver::mapAnimationName, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationPlayState, ApplyPropertyAnimation<EAnimPlayState, &Animation::playState, &Animation::setPlayState, &Animation::isPlayStateSet, &Animation::clearPlayState, &Animation::initialAnimationPlayState, &StyleResolver::mapAnimationPlayState, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); - setPropertyHandler(CSSPropertyWebkitAnimationTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &StyleResolver::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationDirection, ApplyPropertyAnimation<Animation::AnimationDirection, &Animation::direction, &Animation::setDirection, &Animation::isDirectionSet, &Animation::clearDirection, &Animation::initialAnimationDirection, &CSSToStyleMap::mapAnimationDirection, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationFillMode, ApplyPropertyAnimation<unsigned, &Animation::fillMode, &Animation::setFillMode, &Animation::isFillModeSet, &Animation::clearFillMode, &Animation::initialAnimationFillMode, &CSSToStyleMap::mapAnimationFillMode, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationIterationCount, ApplyPropertyAnimation<double, &Animation::iterationCount, &Animation::setIterationCount, &Animation::isIterationCountSet, &Animation::clearIterationCount, &Animation::initialAnimationIterationCount, &CSSToStyleMap::mapAnimationIterationCount, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationName, ApplyPropertyAnimation<const String&, &Animation::name, &Animation::setName, &Animation::isNameSet, &Animation::clearName, &Animation::initialAnimationName, &CSSToStyleMap::mapAnimationName, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationPlayState, ApplyPropertyAnimation<EAnimPlayState, &Animation::playState, &Animation::setPlayState, &Animation::isPlayStateSet, &Animation::clearPlayState, &Animation::initialAnimationPlayState, &CSSToStyleMap::mapAnimationPlayState, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); + setPropertyHandler(CSSPropertyWebkitAnimationTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); setPropertyHandler(CSSPropertyWebkitAppearance, ApplyPropertyDefault<ControlPart, &RenderStyle::appearance, ControlPart, &RenderStyle::setAppearance, ControlPart, &RenderStyle::initialAppearance>::createHandler()); setPropertyHandler(CSSPropertyWebkitAspectRatio, ApplyPropertyAspectRatio::createHandler()); setPropertyHandler(CSSPropertyWebkitBackfaceVisibility, ApplyPropertyDefault<EBackfaceVisibility, &RenderStyle::backfaceVisibility, EBackfaceVisibility, &RenderStyle::setBackfaceVisibility, EBackfaceVisibility, &RenderStyle::initialBackfaceVisibility>::createHandler()); setPropertyHandler(CSSPropertyWebkitBackgroundClip, CSSPropertyBackgroundClip); - setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &StyleResolver::mapFillComposite>::createHandler()); + setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler()); setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin); setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize); setPropertyHandler(CSSPropertyWebkitBorderFit, ApplyPropertyDefault<EBorderFit, &RenderStyle::borderFit, EBorderFit, &RenderStyle::setBorderFit, EBorderFit, &RenderStyle::initialBorderFit>::createHandler()); @@ -2037,24 +2038,24 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyWebkitMarginTopCollapse, CSSPropertyWebkitMarginBeforeCollapse); setPropertyHandler(CSSPropertyWebkitMarqueeDirection, ApplyPropertyDefault<EMarqueeDirection, &RenderStyle::marqueeDirection, EMarqueeDirection, &RenderStyle::setMarqueeDirection, EMarqueeDirection, &RenderStyle::initialMarqueeDirection>::createHandler()); setPropertyHandler(CSSPropertyWebkitMarqueeStyle, ApplyPropertyDefault<EMarqueeBehavior, &RenderStyle::marqueeBehavior, EMarqueeBehavior, &RenderStyle::setMarqueeBehavior, EMarqueeBehavior, &RenderStyle::initialMarqueeBehavior>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyWebkitMaskAttachment, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &StyleResolver::mapFillAttachment>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskAttachment, ApplyPropertyFillLayer<EFillAttachment, CSSPropertyWebkitMaskAttachment, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSToStyleMap::mapFillAttachment>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImage, ApplyPropertyBorderImage<Mask, CSSPropertyWebkitMaskBoxImage, &RenderStyle::maskBoxImage, &RenderStyle::setMaskBoxImage>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageOutset, ApplyPropertyBorderImageModifier<Mask, Outset>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageRepeat, ApplyPropertyBorderImageModifier<Mask, Repeat>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageSlice, ApplyPropertyBorderImageModifier<Mask, Slice>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageSource, ApplyPropertyBorderImageSource<CSSPropertyWebkitMaskBoxImageSource, &RenderStyle::maskBoxImageSource, &RenderStyle::setMaskBoxImageSource, &RenderStyle::initialMaskBoxImageSource>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageWidth, ApplyPropertyBorderImageModifier<Mask, Width>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &StyleResolver::mapFillClip>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &StyleResolver::mapFillComposite>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyWebkitMaskImage, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &StyleResolver::mapFillImage>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &StyleResolver::mapFillOrigin>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyWebkitMaskImage, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSToStyleMap::mapFillImage>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSToStyleMap::mapFillOrigin>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskPosition, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitMaskPositionX, CSSPropertyWebkitMaskPositionY>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskPositionX, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &StyleResolver::mapFillXPosition>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskPositionY, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &StyleResolver::mapFillYPosition>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskPositionX, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSToStyleMap::mapFillXPosition>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskPositionY, ApplyPropertyFillLayer<Length, CSSPropertyWebkitMaskPositionY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSToStyleMap::mapFillYPosition>::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskRepeat, ApplyPropertyExpanding<SuppressValue, CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &StyleResolver::mapFillRepeatX>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &StyleResolver::mapFillRepeatY>::createHandler()); - setPropertyHandler(CSSPropertyWebkitMaskSize, ApplyPropertyFillLayer<FillSize, CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &StyleResolver::mapFillSize>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskRepeatX, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSToStyleMap::mapFillRepeatX>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskRepeatY, ApplyPropertyFillLayer<EFillRepeat, CSSPropertyWebkitMaskRepeatY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSToStyleMap::mapFillRepeatY>::createHandler()); + setPropertyHandler(CSSPropertyWebkitMaskSize, ApplyPropertyFillLayer<FillSize, CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSToStyleMap::mapFillSize>::createHandler()); setPropertyHandler(CSSPropertyWebkitNbspMode, ApplyPropertyDefault<ENBSPMode, &RenderStyle::nbspMode, ENBSPMode, &RenderStyle::setNBSPMode, ENBSPMode, &RenderStyle::initialNBSPMode>::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOriginX, ApplyPropertyLength<&RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX, &RenderStyle::initialPerspectiveOriginX>::createHandler()); @@ -2080,10 +2081,10 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyWebkitTransformOriginY, ApplyPropertyLength<&RenderStyle::transformOriginY, &RenderStyle::setTransformOriginY, &RenderStyle::initialTransformOriginY>::createHandler()); setPropertyHandler(CSSPropertyWebkitTransformOriginZ, ApplyPropertyComputeLength<float, &RenderStyle::transformOriginZ, &RenderStyle::setTransformOriginZ, &RenderStyle::initialTransformOriginZ>::createHandler()); setPropertyHandler(CSSPropertyWebkitTransformStyle, ApplyPropertyDefault<ETransformStyle3D, &RenderStyle::transformStyle3D, ETransformStyle3D, &RenderStyle::setTransformStyle3D, ETransformStyle3D, &RenderStyle::initialTransformStyle3D>::createHandler()); - setPropertyHandler(CSSPropertyWebkitTransitionDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &StyleResolver::mapAnimationDelay, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); - setPropertyHandler(CSSPropertyWebkitTransitionDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &StyleResolver::mapAnimationDuration, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); - setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<CSSPropertyID, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &StyleResolver::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); - setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &StyleResolver::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); + setPropertyHandler(CSSPropertyWebkitTransitionDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); + setPropertyHandler(CSSPropertyWebkitTransitionDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); + setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<CSSPropertyID, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &CSSToStyleMap::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); + setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); setPropertyHandler(CSSPropertyWebkitUserDrag, ApplyPropertyDefault<EUserDrag, &RenderStyle::userDrag, EUserDrag, &RenderStyle::setUserDrag, EUserDrag, &RenderStyle::initialUserDrag>::createHandler()); setPropertyHandler(CSSPropertyWebkitUserModify, ApplyPropertyDefault<EUserModify, &RenderStyle::userModify, EUserModify, &RenderStyle::setUserModify, EUserModify, &RenderStyle::initialUserModify>::createHandler()); setPropertyHandler(CSSPropertyWebkitUserSelect, ApplyPropertyDefault<EUserSelect, &RenderStyle::userSelect, EUserSelect, &RenderStyle::setUserSelect, EUserSelect, &RenderStyle::initialUserSelect>::createHandler()); diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp index 252298fc5..de3a0a9bd 100644 --- a/Source/WebCore/css/StyleResolver.cpp +++ b/Source/WebCore/css/StyleResolver.cpp @@ -8,6 +8,7 @@ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) * Copyright (c) 2011, Code Aurora Forum. All rights reserved. * Copyright (C) Research In Motion Limited 2011. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -374,6 +375,7 @@ StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles) , m_scopeStackParent(0) , m_scopeStackParentBoundsIndex(0) #endif + , m_styleMap(this) { Element* root = document->documentElement(); @@ -3740,7 +3742,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor)); NinePieceImage mask; mask.setMaskDefaults(); - mapNinePieceImage(id, reflectValue->mask(), mask); + m_styleMap.mapNinePieceImage(id, reflectValue->mask(), mask); reflection->setMask(mask); m_style->setBoxReflect(reflection.release()); @@ -4158,7 +4160,11 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) m_style->setGridItemRow(row); return; } - +#if ENABLE(CSS_VARIABLES) + case CSSPropertyVariable: + // FIXME: This should have an actual implementation. + return; +#endif // These properties are implemented in the StyleBuilder lookup table. case CSSPropertyBackgroundAttachment: case CSSPropertyBackgroundClip: @@ -4428,74 +4434,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) } } -void StyleResolver::mapFillAttachment(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setAttachment(FillLayer::initialFillAttachment(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - switch (primitiveValue->getIdent()) { - case CSSValueFixed: - layer->setAttachment(FixedBackgroundAttachment); - break; - case CSSValueScroll: - layer->setAttachment(ScrollBackgroundAttachment); - break; - case CSSValueLocal: - layer->setAttachment(LocalBackgroundAttachment); - break; - default: - return; - } -} - -void StyleResolver::mapFillClip(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setClip(FillLayer::initialFillClip(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - layer->setClip(*primitiveValue); -} - -void StyleResolver::mapFillComposite(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setComposite(FillLayer::initialFillComposite(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - layer->setComposite(*primitiveValue); -} - -void StyleResolver::mapFillOrigin(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setOrigin(FillLayer::initialFillOrigin(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - layer->setOrigin(*primitiveValue); -} - PassRefPtr<StyleImage> StyleResolver::styleImage(CSSPropertyID property, CSSValue* value) { if (value->isImageValue()) @@ -4539,532 +4477,6 @@ PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue(CSSPropertyID proper } #endif -void StyleResolver::mapFillImage(CSSPropertyID property, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setImage(FillLayer::initialFillImage(layer->type())); - return; - } - - layer->setImage(styleImage(property, value)); -} - -void StyleResolver::mapFillRepeatX(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - layer->setRepeatX(*primitiveValue); -} - -void StyleResolver::mapFillRepeatY(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - layer->setRepeatY(*primitiveValue); -} - -void StyleResolver::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (!value->isPrimitiveValue()) { - layer->setSizeType(SizeNone); - return; - } - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - if (primitiveValue->getIdent() == CSSValueContain) - layer->setSizeType(Contain); - else if (primitiveValue->getIdent() == CSSValueCover) - layer->setSizeType(Cover); - else - layer->setSizeType(SizeLength); - - LengthSize b = FillLayer::initialFillSizeLength(layer->type()); - - if (value->isInitialValue() || primitiveValue->getIdent() == CSSValueContain || primitiveValue->getIdent() == CSSValueCover) { - layer->setSizeLength(b); - return; - } - - float zoomFactor = m_style->effectiveZoom(); - - Length firstLength; - Length secondLength; - - if (Pair* pair = primitiveValue->getPairValue()) { - CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first()); - CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second()); - firstLength = first->convertToLength<AnyConversion>(style(), m_rootElementStyle, zoomFactor); - secondLength = second->convertToLength<AnyConversion>(style(), m_rootElementStyle, zoomFactor); - } else { - firstLength = primitiveValue->convertToLength<AnyConversion>(style(), m_rootElementStyle, zoomFactor); - secondLength = Length(); - } - - if (firstLength.isUndefined() || secondLength.isUndefined()) - return; - - b.setWidth(firstLength); - b.setHeight(secondLength); - layer->setSizeLength(b); -} - -void StyleResolver::mapFillXPosition(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - float zoomFactor = m_style->effectiveZoom(); - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - Length length; - if (primitiveValue->isLength()) - length = primitiveValue->computeLength<Length>(style(), m_rootElementStyle, zoomFactor); - else if (primitiveValue->isPercentage()) - length = Length(primitiveValue->getDoubleValue(), Percent); - else if (primitiveValue->isCalculatedPercentageWithLength()) - length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), m_rootElementStyle, zoomFactor)); - else if (primitiveValue->isViewportPercentageLength()) - length = primitiveValue->viewportPercentageLength(); - else - return; - layer->setXPosition(length); -} - -void StyleResolver::mapFillYPosition(CSSPropertyID, FillLayer* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); - return; - } - - if (!value->isPrimitiveValue()) - return; - - float zoomFactor = m_style->effectiveZoom(); - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - Length length; - if (primitiveValue->isLength()) - length = primitiveValue->computeLength<Length>(style(), m_rootElementStyle, zoomFactor); - else if (primitiveValue->isPercentage()) - length = Length(primitiveValue->getDoubleValue(), Percent); - else if (primitiveValue->isCalculatedPercentageWithLength()) - length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), m_rootElementStyle, zoomFactor)); - else if (primitiveValue->isViewportPercentageLength()) - length = primitiveValue->viewportPercentageLength(); - else - return; - layer->setYPosition(length); -} - -void StyleResolver::mapAnimationDelay(Animation* animation, CSSValue* value) -{ - if (value->isInitialValue()) { - animation->setDelay(Animation::initialAnimationDelay()); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - animation->setDelay(primitiveValue->computeTime<float, CSSPrimitiveValue::Seconds>()); -} - -void StyleResolver::mapAnimationDirection(Animation* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setDirection(Animation::initialAnimationDirection()); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - switch (primitiveValue->getIdent()) { - case CSSValueNormal: - layer->setDirection(Animation::AnimationDirectionNormal); - break; - case CSSValueAlternate: - layer->setDirection(Animation::AnimationDirectionAlternate); - break; - case CSSValueReverse: - layer->setDirection(Animation::AnimationDirectionReverse); - break; - case CSSValueAlternateReverse: - layer->setDirection(Animation::AnimationDirectionAlternateReverse); - break; - } -} - -void StyleResolver::mapAnimationDuration(Animation* animation, CSSValue* value) -{ - if (value->isInitialValue()) { - animation->setDuration(Animation::initialAnimationDuration()); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - animation->setDuration(primitiveValue->computeTime<float, CSSPrimitiveValue::Seconds>()); -} - -void StyleResolver::mapAnimationFillMode(Animation* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setFillMode(Animation::initialAnimationFillMode()); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - switch (primitiveValue->getIdent()) { - case CSSValueNone: - layer->setFillMode(AnimationFillModeNone); - break; - case CSSValueForwards: - layer->setFillMode(AnimationFillModeForwards); - break; - case CSSValueBackwards: - layer->setFillMode(AnimationFillModeBackwards); - break; - case CSSValueBoth: - layer->setFillMode(AnimationFillModeBoth); - break; - } -} - -void StyleResolver::mapAnimationIterationCount(Animation* animation, CSSValue* value) -{ - if (value->isInitialValue()) { - animation->setIterationCount(Animation::initialAnimationIterationCount()); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - if (primitiveValue->getIdent() == CSSValueInfinite) - animation->setIterationCount(-1); - else - animation->setIterationCount(primitiveValue->getFloatValue()); -} - -void StyleResolver::mapAnimationName(Animation* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setName(Animation::initialAnimationName()); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - if (primitiveValue->getIdent() == CSSValueNone) - layer->setIsNoneAnimation(true); - else - layer->setName(primitiveValue->getStringValue()); -} - -void StyleResolver::mapAnimationPlayState(Animation* layer, CSSValue* value) -{ - if (value->isInitialValue()) { - layer->setPlayState(Animation::initialAnimationPlayState()); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - EAnimPlayState playState = (primitiveValue->getIdent() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying; - layer->setPlayState(playState); -} - -void StyleResolver::mapAnimationProperty(Animation* animation, CSSValue* value) -{ - if (value->isInitialValue()) { - animation->setAnimationMode(Animation::AnimateAll); - animation->setProperty(CSSPropertyInvalid); - return; - } - - if (!value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - if (primitiveValue->getIdent() == CSSValueAll) { - animation->setAnimationMode(Animation::AnimateAll); - animation->setProperty(CSSPropertyInvalid); - } else if (primitiveValue->getIdent() == CSSValueNone) { - animation->setAnimationMode(Animation::AnimateNone); - animation->setProperty(CSSPropertyInvalid); - } else { - animation->setAnimationMode(Animation::AnimateSingleProperty); - animation->setProperty(static_cast<CSSPropertyID>(primitiveValue->getIdent())); - } -} - -void StyleResolver::mapAnimationTimingFunction(Animation* animation, CSSValue* value) -{ - if (value->isInitialValue()) { - animation->setTimingFunction(Animation::initialAnimationTimingFunction()); - return; - } - - if (value->isPrimitiveValue()) { - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - switch (primitiveValue->getIdent()) { - case CSSValueLinear: - animation->setTimingFunction(LinearTimingFunction::create()); - break; - case CSSValueEase: - animation->setTimingFunction(CubicBezierTimingFunction::create()); - break; - case CSSValueEaseIn: - animation->setTimingFunction(CubicBezierTimingFunction::create(0.42, 0.0, 1.0, 1.0)); - break; - case CSSValueEaseOut: - animation->setTimingFunction(CubicBezierTimingFunction::create(0.0, 0.0, 0.58, 1.0)); - break; - case CSSValueEaseInOut: - animation->setTimingFunction(CubicBezierTimingFunction::create(0.42, 0.0, 0.58, 1.0)); - break; - case CSSValueStepStart: - animation->setTimingFunction(StepsTimingFunction::create(1, true)); - break; - case CSSValueStepEnd: - animation->setTimingFunction(StepsTimingFunction::create(1, false)); - break; - } - return; - } - - if (value->isCubicBezierTimingFunctionValue()) { - CSSCubicBezierTimingFunctionValue* cubicTimingFunction = static_cast<CSSCubicBezierTimingFunctionValue*>(value); - animation->setTimingFunction(CubicBezierTimingFunction::create(cubicTimingFunction->x1(), cubicTimingFunction->y1(), cubicTimingFunction->x2(), cubicTimingFunction->y2())); - } else if (value->isStepsTimingFunctionValue()) { - CSSStepsTimingFunctionValue* stepsTimingFunction = static_cast<CSSStepsTimingFunctionValue*>(value); - animation->setTimingFunction(StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart())); - } else if (value->isLinearTimingFunctionValue()) - animation->setTimingFunction(LinearTimingFunction::create()); -} - -void StyleResolver::mapNinePieceImage(CSSPropertyID property, CSSValue* value, NinePieceImage& image) -{ - // If we're not a value list, then we are "none" and don't need to alter the empty image at all. - if (!value || !value->isValueList()) - return; - - // Retrieve the border image value. - CSSValueList* borderImage = static_cast<CSSValueList*>(value); - - // Set the image (this kicks off the load). - CSSPropertyID imageProperty; - if (property == CSSPropertyWebkitBorderImage) - imageProperty = CSSPropertyBorderImageSource; - else if (property == CSSPropertyWebkitMaskBoxImage) - imageProperty = CSSPropertyWebkitMaskBoxImageSource; - else - imageProperty = property; - - for (unsigned i = 0 ; i < borderImage->length() ; ++i) { - CSSValue* current = borderImage->item(i); - - if (current->isImageValue() || current->isImageGeneratorValue() -#if ENABLE(CSS_IMAGE_SET) - || current->isImageSetValue() -#endif - ) - image.setImage(styleImage(imageProperty, current)); - else if (current->isBorderImageSliceValue()) - mapNinePieceImageSlice(current, image); - else if (current->isValueList()) { - CSSValueList* slashList = static_cast<CSSValueList*>(current); - // Map in the image slices. - if (slashList->item(0) && slashList->item(0)->isBorderImageSliceValue()) - mapNinePieceImageSlice(slashList->item(0), image); - - // Map in the border slices. - if (slashList->item(1)) - image.setBorderSlices(mapNinePieceImageQuad(slashList->item(1))); - - // Map in the outset. - if (slashList->item(2)) - image.setOutset(mapNinePieceImageQuad(slashList->item(2))); - } else if (current->isPrimitiveValue()) { - // Set the appropriate rules for stretch/round/repeat of the slices. - mapNinePieceImageRepeat(current, image); - } - } - - if (property == CSSPropertyWebkitBorderImage) { - // We have to preserve the legacy behavior of -webkit-border-image and make the border slices - // also set the border widths. We don't need to worry about percentages, since we don't even support - // those on real borders yet. - if (image.borderSlices().top().isFixed()) - style()->setBorderTopWidth(image.borderSlices().top().value()); - if (image.borderSlices().right().isFixed()) - style()->setBorderRightWidth(image.borderSlices().right().value()); - if (image.borderSlices().bottom().isFixed()) - style()->setBorderBottomWidth(image.borderSlices().bottom().value()); - if (image.borderSlices().left().isFixed()) - style()->setBorderLeftWidth(image.borderSlices().left().value()); - } -} - -void StyleResolver::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& image) -{ - if (!value || !value->isBorderImageSliceValue()) - return; - - // Retrieve the border image value. - CSSBorderImageSliceValue* borderImageSlice = static_cast<CSSBorderImageSliceValue*>(value); - - // Set up a length box to represent our image slices. - LengthBox box; - Quad* slices = borderImageSlice->slices(); - if (slices->top()->isPercentage()) - box.m_top = Length(slices->top()->getDoubleValue(), Percent); - else - box.m_top = Length(slices->top()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); - if (slices->bottom()->isPercentage()) - box.m_bottom = Length(slices->bottom()->getDoubleValue(), Percent); - else - box.m_bottom = Length((int)slices->bottom()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); - if (slices->left()->isPercentage()) - box.m_left = Length(slices->left()->getDoubleValue(), Percent); - else - box.m_left = Length(slices->left()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); - if (slices->right()->isPercentage()) - box.m_right = Length(slices->right()->getDoubleValue(), Percent); - else - box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed); - image.setImageSlices(box); - - // Set our fill mode. - image.setFill(borderImageSlice->m_fill); -} - -LengthBox StyleResolver::mapNinePieceImageQuad(CSSValue* value) -{ - if (!value || !value->isPrimitiveValue()) - return LengthBox(); - - // Get our zoom value. - float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom(); - - // Retrieve the primitive value. - CSSPrimitiveValue* borderWidths = static_cast<CSSPrimitiveValue*>(value); - - // Set up a length box to represent our image slices. - LengthBox box; // Defaults to 'auto' so we don't have to handle that explicitly below. - Quad* slices = borderWidths->getQuadValue(); - if (slices->top()->isNumber()) - box.m_top = Length(slices->top()->getIntValue(), Relative); - else if (slices->top()->isPercentage()) - box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); - else if (slices->top()->getIdent() != CSSValueAuto) - box.m_top = slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom); - - if (slices->right()->isNumber()) - box.m_right = Length(slices->right()->getIntValue(), Relative); - else if (slices->right()->isPercentage()) - box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); - else if (slices->right()->getIdent() != CSSValueAuto) - box.m_right = slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom); - - if (slices->bottom()->isNumber()) - box.m_bottom = Length(slices->bottom()->getIntValue(), Relative); - else if (slices->bottom()->isPercentage()) - box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); - else if (slices->bottom()->getIdent() != CSSValueAuto) - box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom); - - if (slices->left()->isNumber()) - box.m_left = Length(slices->left()->getIntValue(), Relative); - else if (slices->left()->isPercentage()) - box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); - else if (slices->left()->getIdent() != CSSValueAuto) - box.m_left = slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom); - - return box; -} - -void StyleResolver::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& image) -{ - if (!value || !value->isPrimitiveValue()) - return; - - CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); - Pair* pair = primitiveValue->getPairValue(); - if (!pair || !pair->first() || !pair->second()) - return; - - int firstIdentifier = pair->first()->getIdent(); - int secondIdentifier = pair->second()->getIdent(); - - ENinePieceImageRule horizontalRule; - switch (firstIdentifier) { - case CSSValueStretch: - horizontalRule = StretchImageRule; - break; - case CSSValueRound: - horizontalRule = RoundImageRule; - break; - case CSSValueSpace: - horizontalRule = SpaceImageRule; - break; - default: // CSSValueRepeat - horizontalRule = RepeatImageRule; - break; - } - image.setHorizontalRule(horizontalRule); - - ENinePieceImageRule verticalRule; - switch (secondIdentifier) { - case CSSValueStretch: - verticalRule = StretchImageRule; - break; - case CSSValueRound: - verticalRule = RoundImageRule; - break; - case CSSValueSpace: - verticalRule = SpaceImageRule; - break; - default: // CSSValueRepeat - verticalRule = RepeatImageRule; - break; - } - image.setVerticalRule(verticalRule); -} - void StyleResolver::checkForTextSizeAdjust() { if (m_style->textSizeAdjust()) diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h index 29f800e0c..4843eb53a 100644 --- a/Source/WebCore/css/StyleResolver.h +++ b/Source/WebCore/css/StyleResolver.h @@ -23,6 +23,7 @@ #define StyleResolver_h #include "CSSRule.h" +#include "CSSToStyleMap.h" #include "CSSValueList.h" #include "LinkHash.h" #include "MediaQueryExp.h" @@ -411,6 +412,8 @@ public: static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); + CSSToStyleMap* styleMap() { return &m_styleMap; } + private: static RenderStyle* s_styleNotYetAvailable; @@ -419,32 +422,6 @@ private: void cacheBorderAndBackground(); - void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillClip(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillComposite(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillOrigin(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillImage(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillRepeatX(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillRepeatY(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillSize(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillXPosition(CSSPropertyID, FillLayer*, CSSValue*); - void mapFillYPosition(CSSPropertyID, FillLayer*, CSSValue*); - - void mapAnimationDelay(Animation*, CSSValue*); - void mapAnimationDirection(Animation*, CSSValue*); - void mapAnimationDuration(Animation*, CSSValue*); - void mapAnimationFillMode(Animation*, CSSValue*); - void mapAnimationIterationCount(Animation*, CSSValue*); - void mapAnimationName(Animation*, CSSValue*); - void mapAnimationPlayState(Animation*, CSSValue*); - void mapAnimationProperty(Animation*, CSSValue*); - void mapAnimationTimingFunction(Animation*, CSSValue*); - -public: - void mapNinePieceImage(CSSPropertyID, CSSValue*, NinePieceImage&); - void mapNinePieceImageSlice(CSSValue*, NinePieceImage&); - LengthBox mapNinePieceImageQuad(CSSValue*); - void mapNinePieceImageRepeat(CSSValue*, NinePieceImage&); private: bool canShareStyleWithControl(StyledElement*) const; @@ -546,6 +523,8 @@ private: int m_scopeStackParentBoundsIndex; #endif + CSSToStyleMap m_styleMap; + friend class StyleBuilder; friend bool operator==(const MatchedProperties&, const MatchedProperties&); friend bool operator!=(const MatchedProperties&, const MatchedProperties&); diff --git a/Source/WebCore/css/mediaControlsChromiumAndroid.css b/Source/WebCore/css/mediaControlsChromiumAndroid.css index 92f347840..21b647c38 100644 --- a/Source/WebCore/css/mediaControlsChromiumAndroid.css +++ b/Source/WebCore/css/mediaControlsChromiumAndroid.css @@ -30,7 +30,7 @@ body:-webkit-full-page-media { audio { width: 300px; - height: 32px; + height: 35px; } audio:-webkit-full-page-media, video:-webkit-full-page-media { @@ -39,97 +39,74 @@ audio:-webkit-full-page-media, video:-webkit-full-page-media { } audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { - -webkit-user-select: none; - position: relative; - overflow: visible; - bottom: 0; - width: 100%; - height: 32px; - z-index: 0; - background-color: rgba(0, 0, 0, 0.6); + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-align: center; + -webkit-box-pack: center; + bottom: auto; + height: 35px; + background-color: rgba(20, 20, 20, 0.8); } +audio:-webkit-full-page-media::-webkit-media-controls-panel, video:-webkit-full-page-media::-webkit-media-controls-panel { bottom: 0px; } -audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { - display: none; -} - -audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { - -webkit-appearance: media-play-button; - - position: absolute; - top: auto; - bottom: 7px; - left: 7px; - right: 6px; - - width: 18px; - height: 19px; -} - -audio::-webkit-media-controls-timeline-container { - -webkit-appearance: media-timeline-container; - -webkit-user-select: none; - -webkit-box-orient: horizontal; +::-webkit-media-controls { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-box-pack: end; -webkit-box-align: center; - -webkit-box-pack: center; - -webkit-box-flex: 1; +} - position: absolute; - top: auto; +audio::-webkit-media-controls-enclosure, video::-webkit-media-controls-enclosure { + width: 100%; + max-width: 800px; + height: 35px; bottom: 0; - left: 30px; - right: 0; - - width: auto; - height: 32px; - - border-left: 1px solid rgba(255, 255, 255, 0.2); - border-right: 1px solid rgba(255, 255, 255, 0.2); + text-indent: 0; + padding: 0; + box-sizing: border-box; } -video::-webkit-media-controls-timeline-container { - -webkit-appearance: media-timeline-container; - -webkit-user-select: none; - -webkit-box-orient: horizontal; - -webkit-box-align: center; - -webkit-box-pack: center; - -webkit-box-flex: 1; - - position: absolute; - top: auto; - bottom: 0; - left: 30px; - right: 34px; +video::-webkit-media-controls-enclosure { + padding: 0px 5px 5px 5px; + height: 35px; +} - width: auto; - height: 32px; +audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { + display: none; +} - border-left: 1px solid rgba(255, 255, 255, 0.2); - border-right: 1px solid rgba(255, 255, 255, 0.2); +audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { + -webkit-appearance: media-play-button; + display: inline; + border: none; + box-sizing: border-box; + width: 35px; + height: 35px; + line-height: 35px; + margin-left: 9px; + margin-right: 9px; + padding: 0; } -audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { +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 { -webkit-appearance: media-current-time-display; -webkit-user-select: none; - display: -webkit-box; - -webkit-box-flex: 0; - -webkit-box-pack: center; - -webkit-box-align: center; - - overflow: hidden; + display: block; + border: none; cursor: default; - line-height: 21px; - height: 20px; - width: 58px; + height: 35px; + margin: 0 9px 0 0; + padding: 0; - text-align: center; - font-family: Arial; - font-size: 16px; + line-height: 35px; + font-family: Arial, Helvetica, sans-serif; + font-size: 18px; font-weight: bold; color: white; @@ -144,39 +121,51 @@ audio::-webkit-media-controls-current-time-display, video::-webkit-media-control audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { -webkit-appearance: media-slider; display: -webkit-box; - box-sizing: border-box; -webkit-box-flex: 1; - - padding: 0px; - margin: 0px 6px; - height: 18px; - - border-color: rgba(255, 255, 255, 0.2); - border-style: solid; - border-width: 1px; - border-radius: 2px; - background-color: rgba(255, 255, 255, 0.08); - color: rgb(50, 140, 223); + height: 8px; + margin: 0 15px 0 0; + padding: 0; + background-color: transparent; + min-width: 25px; } video::-webkit-media-controls-fullscreen-button { -webkit-appearance: media-enter-fullscreen-button; - position: absolute; - top: auto; - bottom: 0; - right: 0; - left: auto; + display: inline; + border: none; + box-sizing: border-box; + width: 35px; + height: 35px; + line-height: 35px; + margin-left: -5px; + margin-right: 9px; + padding: 0; +} - width: 34px; - height: 32px; +input[type="range"]::-webkit-media-slider-container { + display: -webkit-box; + -webkit-box-align: center; + -webkit-box-orient: horizontal; + -webkit-box-sizing: border-box; + height: 100%; + width: 100%; + border: 1px solid rgba(230, 230, 230, 0.35); + border-radius: 4px; + background-color: transparent; } -audio::-webkit-media-controls-fullscreen-button { - display: none; +input[type="range"]::-webkit-media-slider-thumb { + display: block; + -webkit-appearance: sliderthumb-horizontal; + -webkit-box-sizing: border-box; + position: relative; + bottom: 1px; + margin-left: -7px; + margin-right: -7px; } -audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container { +audio::-webkit-media-controls-fullscreen-button { display: none; } diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index 132680ab0..7f190b269 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -3401,14 +3401,11 @@ void Document::removeStyleSheetCandidateNode(Node* node) void Document::collectActiveStylesheets(Vector<RefPtr<StyleSheet> >& sheets) { - bool matchAuthorAndUserStyles = true; - if (Settings* settings = this->settings()) - matchAuthorAndUserStyles = settings->authorAndUserStylesEnabled(); + if (settings() && !settings()->authorAndUserStylesEnabled()) + return; StyleSheetCandidateListHashSet::iterator begin = m_styleSheetCandidateNodes.begin(); StyleSheetCandidateListHashSet::iterator end = m_styleSheetCandidateNodes.end(); - if (!matchAuthorAndUserStyles) - end = begin; for (StyleSheetCandidateListHashSet::iterator it = begin; it != end; ++it) { Node* n = *it; StyleSheet* sheet = 0; @@ -4581,7 +4578,7 @@ KURL Document::openSearchDescriptionURL() return KURL(); HTMLCollection* children = head()->children(); - for (Node* child = children->firstItem(); child; child = children->nextItem()) { + for (unsigned i = 0; Node* child = children->item(i); i++) { if (!child->hasTagName(linkTag)) continue; HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(child); @@ -5928,7 +5925,7 @@ PassRefPtr<NodeList> Document::getItems(const String& typeNames) { // Since documet.getItem() is allowed for microdata, typeNames will be null string. // In this case we need to create an unique string identifier to map such request in the cache. - String localTypeNames = typeNames.isNull() ? String("http://webkit.org/microdata/undefinedItemType") : typeNames; + String localTypeNames = typeNames.isNull() ? MicroDataItemList::undefinedItemType() : typeNames; return ensureRareData()->ensureNodeLists(this)->addCacheWithName<MicroDataItemList>(this, DynamicNodeList::MicroDataItemListType, localTypeNames); } diff --git a/Source/WebCore/dom/EventNames.h b/Source/WebCore/dom/EventNames.h index 3056d4a39..598bcdde5 100644 --- a/Source/WebCore/dom/EventNames.h +++ b/Source/WebCore/dom/EventNames.h @@ -251,7 +251,21 @@ namespace WebCore { inline bool isTouchEventType(const AtomicString& eventType) const { - return eventType == touchstartEvent || eventType == touchmoveEvent || eventType == touchendEvent || eventType == touchcancelEvent; + return eventType == touchstartEvent + || eventType == touchmoveEvent + || eventType == touchendEvent + || eventType == touchcancelEvent; + } + + Vector<AtomicString> touchEventNames() const + { + Vector<AtomicString> names; + names.reserveCapacity(4); + names.append(touchstartEvent); + names.append(touchmoveEvent); + names.append(touchendEvent); + names.append(touchcancelEvent); + return names; } }; diff --git a/Source/WebCore/dom/MicroDataItemList.cpp b/Source/WebCore/dom/MicroDataItemList.cpp index 7c90dda62..21c170a40 100644 --- a/Source/WebCore/dom/MicroDataItemList.cpp +++ b/Source/WebCore/dom/MicroDataItemList.cpp @@ -38,17 +38,22 @@ namespace WebCore { using namespace HTMLNames; +const String& MicroDataItemList::undefinedItemType() +{ + DEFINE_STATIC_LOCAL(String, undefinedItemTypeString, ("http://webkit.org/microdata/undefinedItemType")); + return undefinedItemTypeString; +} + MicroDataItemList::MicroDataItemList(PassRefPtr<Node> rootNode, const String& typeNames) : DynamicSubtreeNodeList(rootNode) - , m_typeNames(typeNames, node()->document()->inQuirksMode()) + , m_typeNames(typeNames, document()->inQuirksMode()) , m_originalTypeNames(typeNames) { } MicroDataItemList::~MicroDataItemList() { - String localTypeNames = m_originalTypeNames.isNull() ? String("http://webkit.org/microdata/undefinedItemType") : m_originalTypeNames; - m_node->nodeLists()->removeCacheWithName(this, DynamicNodeList::MicroDataItemListType, localTypeNames); + ownerNode()->nodeLists()->removeCacheWithName(this, DynamicNodeList::MicroDataItemListType, m_originalTypeNames); } bool MicroDataItemList::nodeMatches(Element* testNode) const @@ -60,7 +65,7 @@ bool MicroDataItemList::nodeMatches(Element* testNode) const if (!testElement->fastHasAttribute(itemscopeAttr) || testElement->fastHasAttribute(itempropAttr)) return false; - if (!m_typeNames.size()) + if (m_originalTypeNames == undefinedItemType()) return true; return testElement->itemType()->tokens().containsAll(m_typeNames); diff --git a/Source/WebCore/dom/MicroDataItemList.h b/Source/WebCore/dom/MicroDataItemList.h index d4e22947b..fbfc1e03e 100644 --- a/Source/WebCore/dom/MicroDataItemList.h +++ b/Source/WebCore/dom/MicroDataItemList.h @@ -43,6 +43,8 @@ public: virtual ~MicroDataItemList(); + static const String& undefinedItemType(); + private: MicroDataItemList(PassRefPtr<Node> rootNode, const String& typeNames); diff --git a/Source/WebCore/dom/MouseEvent.h b/Source/WebCore/dom/MouseEvent.h index 576b57379..0863893ce 100644 --- a/Source/WebCore/dom/MouseEvent.h +++ b/Source/WebCore/dom/MouseEvent.h @@ -92,9 +92,10 @@ class PlatformMouseEvent; bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, PassRefPtr<EventTarget> relatedTarget, PassRefPtr<Clipboard> clipboard, bool isSimulated); - private: + protected: MouseEvent(); + private: unsigned short m_button; bool m_buttonDown; RefPtr<EventTarget> m_relatedTarget; diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp index 7446cfa04..ae3945be5 100644 --- a/Source/WebCore/dom/Node.cpp +++ b/Source/WebCore/dom/Node.cpp @@ -2309,6 +2309,21 @@ void Node::didMoveToNewDocument(Document* oldDocument) // FIXME: Event listener types for this node should be set on the new owner document here. + const EventListenerVector& wheelListeners = getEventListeners(eventNames().mousewheelEvent); + for (size_t i = 0; i < wheelListeners.size(); ++i) { + oldDocument->didRemoveWheelEventHandler(); + document()->didAddWheelEventHandler(); + } + + Vector<AtomicString> touchEventNames = eventNames().touchEventNames(); + for (size_t i = 0; i < touchEventNames.size(); ++i) { + const EventListenerVector& listeners = getEventListeners(touchEventNames[i]); + for (size_t j = 0; j < listeners.size(); ++j) { + oldDocument->didRemoveTouchEventHandler(); + document()->didAddTouchEventHandler(); + } + } + #if ENABLE(MUTATION_OBSERVERS) if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRegistry()) { for (size_t i = 0; i < registry->size(); ++i) { diff --git a/Source/WebCore/dom/TreeScopeAdopter.cpp b/Source/WebCore/dom/TreeScopeAdopter.cpp index 3db50e98c..88e1a6fd5 100644 --- a/Source/WebCore/dom/TreeScopeAdopter.cpp +++ b/Source/WebCore/dom/TreeScopeAdopter.cpp @@ -32,11 +32,6 @@ namespace WebCore { -static inline ElementShadow* shadowFor(Node* node) -{ - return node->isElementNode() ? toElement(node)->shadow() : 0; -} - void TreeScopeAdopter::moveTreeToNewScope(Node* root) const { ASSERT(needsScopeChange()); diff --git a/Source/WebCore/dom/WebKitMutationObserver.cpp b/Source/WebCore/dom/WebKitMutationObserver.cpp index 6fe6aa778..80c26a577 100644 --- a/Source/WebCore/dom/WebKitMutationObserver.cpp +++ b/Source/WebCore/dom/WebKitMutationObserver.cpp @@ -89,11 +89,6 @@ void WebKitMutationObserver::observe(Node* node, const Dictionary& optionsDictio return; } - if (optionsDictionary.isUndefinedOrNull()) { - ec = TYPE_MISMATCH_ERR; - return; - } - static const struct { const char* name; MutationObserverOptions value; diff --git a/Source/WebCore/dom/WheelEvent.cpp b/Source/WebCore/dom/WheelEvent.cpp index c31112c79..e76c33ace 100644..100755 --- a/Source/WebCore/dom/WheelEvent.cpp +++ b/Source/WebCore/dom/WheelEvent.cpp @@ -42,12 +42,13 @@ WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, const IntPoint& screenLocation, const IntPoint& pageLocation, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice) - : MouseRelatedEvent(eventNames().mousewheelEvent, - true, true, view, 0, screenLocation, pageLocation, + : MouseEvent(eventNames().mousewheelEvent, + true, true, view, 0, screenLocation.x(), screenLocation.y(), + pageLocation.x(), pageLocation.y(), #if ENABLE(POINTER_LOCK) - IntPoint(0, 0), + 0, 0, #endif - ctrlKey, altKey, shiftKey, metaKey) + ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false) , m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * tickMultiplier), static_cast<int>(wheelTicks.y() * tickMultiplier))) , m_rawDelta(roundedIntPoint(rawDelta)) , m_granularity(granularity) @@ -93,6 +94,11 @@ const AtomicString& WheelEvent::interfaceName() const return eventNames().interfaceForWheelEvent; } +bool WheelEvent::isMouseEvent() const +{ + return false; +} + inline static WheelEvent::Granularity granularity(const PlatformWheelEvent& event) { return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::Page : WheelEvent::Pixel; diff --git a/Source/WebCore/dom/WheelEvent.h b/Source/WebCore/dom/WheelEvent.h index 6b36ab9f6..13576890d 100644..100755 --- a/Source/WebCore/dom/WheelEvent.h +++ b/Source/WebCore/dom/WheelEvent.h @@ -26,12 +26,12 @@ #include "EventDispatchMediator.h" #include "FloatPoint.h" -#include "MouseRelatedEvent.h" +#include "MouseEvent.h" namespace WebCore { // extension: mouse wheel event - class WheelEvent : public MouseRelatedEvent { + class WheelEvent : public MouseEvent { public: enum { tickMultiplier = 120 }; @@ -70,11 +70,12 @@ namespace WebCore { bool isHorizontal() const { return m_wheelDelta.x(); } virtual const AtomicString& interfaceName() const; + virtual bool isMouseEvent() const; private: WheelEvent(); WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, - Granularity granularity, PassRefPtr<AbstractView>, + Granularity, PassRefPtr<AbstractView>, const IntPoint& screenLocation, const IntPoint& pageLocation, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice); diff --git a/Source/WebCore/dom/WheelEvent.idl b/Source/WebCore/dom/WheelEvent.idl index 0282525fb..b57fd0e9b 100644 --- a/Source/WebCore/dom/WheelEvent.idl +++ b/Source/WebCore/dom/WheelEvent.idl @@ -20,25 +20,14 @@ module events { - // Based off of proposed IDL interface for WheelEvent: - interface WheelEvent : UIEvent { - readonly attribute long screenX; - readonly attribute long screenY; - readonly attribute long clientX; - readonly attribute long clientY; - readonly attribute boolean ctrlKey; - readonly attribute boolean shiftKey; - readonly attribute boolean altKey; - readonly attribute boolean metaKey; + // Based off http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-wheelevents + interface WheelEvent : MouseEvent + { readonly attribute long wheelDelta; readonly attribute long wheelDeltaX; readonly attribute long wheelDeltaY; - // WebKit Extensions - readonly attribute long offsetX; - readonly attribute long offsetY; - readonly attribute long x; - readonly attribute long y; + // WebKit Extension readonly attribute boolean webkitDirectionInvertedFromDevice; #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C diff --git a/Source/WebCore/editing/AlternativeTextController.cpp b/Source/WebCore/editing/AlternativeTextController.cpp index b199af156..d4a0e43b7 100644 --- a/Source/WebCore/editing/AlternativeTextController.cpp +++ b/Source/WebCore/editing/AlternativeTextController.cpp @@ -273,7 +273,12 @@ void AlternativeTextController::applyAlternativeTextToRange(const Range* range, // Clone the range, since the caller of this method may want to keep the original range around. RefPtr<Range> rangeWithAlternative = range->cloneRange(ec); + + int paragraphStartIndex = TextIterator::rangeLength(Range::create(m_frame->document(), m_frame->document(), 0, paragraphRangeContainingCorrection.get()->startContainer(), paragraphRangeContainingCorrection.get()->startOffset()).get()); applyCommand(SpellingCorrectionCommand::create(rangeWithAlternative, alternative)); + // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526 + paragraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(m_frame->document(), paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length()); + setEnd(paragraphRangeContainingCorrection.get(), m_frame->selection()->selection().start()); RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, alternative.length()); String newText = plainText(replacementRange.get()); diff --git a/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp b/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp index eafd8f7c6..786d61fcc 100644 --- a/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp +++ b/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp @@ -47,7 +47,7 @@ void DeleteFromTextNodeCommand::doApply() { ASSERT(m_node); - if (!m_node->rendererIsEditable()) + if (!m_node->isContentEditable()) return; ExceptionCode ec = 0; diff --git a/Source/WebCore/editing/DeleteSelectionCommand.cpp b/Source/WebCore/editing/DeleteSelectionCommand.cpp index a59ed6182..2e059c840 100644 --- a/Source/WebCore/editing/DeleteSelectionCommand.cpp +++ b/Source/WebCore/editing/DeleteSelectionCommand.cpp @@ -297,18 +297,26 @@ void DeleteSelectionCommand::saveTypingStyleState() bool DeleteSelectionCommand::handleSpecialCaseBRDelete() { + Node* nodeAfterUpstreamStart = m_upstreamStart.computeNodeAfterPosition(); + Node* nodeAfterDownstreamStart = m_downstreamStart.computeNodeAfterPosition(); + // Upstream end will appear before BR due to canonicalization + Node* nodeAfterUpstreamEnd = m_upstreamEnd.computeNodeAfterPosition(); + + if (!nodeAfterUpstreamStart || !nodeAfterDownstreamStart) + return false; + // Check for special-case where the selection contains only a BR on a line by itself after another BR. - bool upstreamStartIsBR = m_upstreamStart.deprecatedNode()->hasTagName(brTag); - bool downstreamStartIsBR = m_downstreamStart.deprecatedNode()->hasTagName(brTag); - bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && m_downstreamStart.deprecatedNode() == m_upstreamEnd.deprecatedNode(); + bool upstreamStartIsBR = nodeAfterUpstreamStart->hasTagName(brTag); + bool downstreamStartIsBR = nodeAfterDownstreamStart->hasTagName(brTag); + bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && nodeAfterDownstreamStart == nodeAfterUpstreamEnd; if (isBROnLineByItself) { - removeNode(m_downstreamStart.deprecatedNode()); + removeNode(nodeAfterDownstreamStart); return true; } - // Not a special-case delete per se, but we can detect that the merging of content between blocks - // should not be done. - if (upstreamStartIsBR && downstreamStartIsBR) { + // FIXME: This code doesn't belong in here. + // We detect the case where the start is an empty line consisting of BR not wrapped in a block element. + if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterUpstreamStart)))) { m_startsAtEmptyLine = true; m_endingPosition = m_downstreamEnd; } diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp index 85cab133b..9018a8949 100644 --- a/Source/WebCore/editing/Editor.cpp +++ b/Source/WebCore/editing/Editor.cpp @@ -2085,7 +2085,7 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect if (result->type == TextCheckingTypeLink && selectionOffset > resultLocation + resultLength + 1) continue; - if (!(shouldPerformReplacement || shouldShowCorrectionPanel || shouldMarkLink) || !doReplacement) + if (!(shouldPerformReplacement || shouldCheckForCorrection || shouldMarkLink) || !doReplacement) continue; String replacedString = plainText(rangeToReplace.get()); @@ -2119,8 +2119,13 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect if (canEditRichly()) applyCommand(CreateLinkCommand::create(m_frame->document(), result->replacement)); } else if (canEdit() && shouldInsertText(result->replacement, rangeToReplace.get(), EditorInsertActionTyped)) { + int paragraphStartIndex = TextIterator::rangeLength(Range::create(m_frame->document(), m_frame->document(), 0, paragraph.paragraphRange()->startContainer(), paragraph.paragraphRange()->startOffset()).get()); + int paragraphLength = TextIterator::rangeLength(paragraph.paragraphRange().get()); applyCommand(SpellingCorrectionCommand::create(rangeToReplace, result->replacement)); - + // Recalculate newParagraphRange, since SpellingCorrectionCommand modifies the DOM, such that the original paragraph range is no longer valid. Radar: 10305315 Bugzilla: 89526 + RefPtr<Range> newParagraphRange = TextIterator::rangeFromLocationAndLength(m_frame->document(), paragraphStartIndex, paragraphLength+replacementLength-resultLength); + paragraph = TextCheckingParagraph(TextIterator::subrange(newParagraphRange.get(), resultLocation, replacementLength), newParagraphRange); + if (AXObjectCache::accessibilityEnabled()) { if (Element* root = m_frame->selection()->selection().rootEditableElement()) m_frame->document()->axObjectCache()->postNotification(root->renderer(), AXObjectCache::AXAutocorrectionOccured, true); diff --git a/Source/WebCore/editing/htmlediting.cpp b/Source/WebCore/editing/htmlediting.cpp index 7d8fc390d..d782d177d 100644 --- a/Source/WebCore/editing/htmlediting.cpp +++ b/Source/WebCore/editing/htmlediting.cpp @@ -78,15 +78,15 @@ int comparePositions(const Position& a, const Position& b) if (!commonScope) return 0; - Node* nodeA = commonScope->ancestorInThisScope(a.deprecatedNode()); + Node* nodeA = commonScope->ancestorInThisScope(a.containerNode()); ASSERT(nodeA); - bool hasDescendentA = nodeA != a.deprecatedNode(); - int offsetA = hasDescendentA ? 0 : a.deprecatedEditingOffset(); + bool hasDescendentA = nodeA != a.containerNode(); + int offsetA = hasDescendentA ? 0 : a.computeOffsetInContainerNode(); - Node* nodeB = commonScope->ancestorInThisScope(b.deprecatedNode()); + Node* nodeB = commonScope->ancestorInThisScope(b.containerNode()); ASSERT(nodeB); - bool hasDescendentB = nodeB != b.deprecatedNode(); - int offsetB = hasDescendentB ? 0 : b.deprecatedEditingOffset(); + bool hasDescendentB = nodeB != b.containerNode(); + int offsetB = hasDescendentB ? 0 : b.computeOffsetInContainerNode(); int bias = 0; if (nodeA == nodeB) { diff --git a/Source/WebCore/html/FormController.cpp b/Source/WebCore/html/FormController.cpp index 84f44ee94..8719443b4 100644 --- a/Source/WebCore/html/FormController.cpp +++ b/Source/WebCore/html/FormController.cpp @@ -22,7 +22,6 @@ #include "FormController.h" #include "HTMLFormControlElementWithState.h" -#include <wtf/text/StringBuilder.h> namespace WebCore { @@ -31,61 +30,38 @@ using namespace HTMLNames; // ---------------------------------------------------------------------------- // Serilized form of FormControlState: +// (',' means strings around it are separated in stateVector.) // // SerializedControlState ::= SkipState | RestoreState -// SkipState ::= '' -// RestoreState ::= (',' EscapedValue )+ -// EscapedValue ::= ('\\' | '\,' | [^\,])+ +// SkipState ::= '0' +// RestoreState ::= UnsignedNumber, ControlValue+ +// UnsignedNumber ::= [0-9]+ +// ControlValue ::= arbitrary string +// +// RestoreState has a sequence of ControlValues. The length of the +// sequence is represented by UnsignedNumber. -String FormControlState::serialize() const +void FormControlState::serializeTo(Vector<String>& stateVector) const { ASSERT(!isFailure()); - if (!m_values.size()) - return emptyString(); - - size_t enoughSize = 0; + stateVector.append(String::number(m_values.size())); for (size_t i = 0; i < m_values.size(); ++i) - enoughSize += 1 + m_values[i].length() * 2; - StringBuilder builder; - builder.reserveCapacity(enoughSize); - for (size_t i = 0; i < m_values.size(); ++i) { - builder.append(','); - builder.appendEscaped(m_values[i], '\\', ','); - } - return builder.toString(); + stateVector.append(m_values[i].isNull() ? emptyString() : m_values[i]); } -FormControlState FormControlState::deserialize(const String& escaped) +FormControlState FormControlState::deserialize(const Vector<String>& stateVector, size_t& index) { - if (!escaped.length()) + if (index >= stateVector.size()) + return FormControlState(TypeFailure); + size_t valueSize = stateVector[index++].toUInt(); + if (!valueSize) return FormControlState(); - if (escaped[0] != ',') + if (index + valueSize > stateVector.size()) return FormControlState(TypeFailure); - - size_t valueSize = 1; - for (unsigned i = 1; i < escaped.length(); ++i) { - if (escaped[i] == '\\') { - if (++i >= escaped.length()) - return FormControlState(TypeFailure); - } else if (escaped[i] == ',') - valueSize++; - } - FormControlState state; state.m_values.reserveCapacity(valueSize); - StringBuilder builder; - for (unsigned i = 1; i < escaped.length(); ++i) { - if (escaped[i] == '\\') { - if (++i >= escaped.length()) - return FormControlState(TypeFailure); - builder.append(escaped[i]); - } else if (escaped[i] == ',') { - state.append(builder.toString()); - builder.clear(); - } else - builder.append(escaped[i]); - } - state.append(builder.toString()); + for (size_t i = 0; i < valueSize; ++i) + state.append(stateVector[index++]); return state; } @@ -105,14 +81,14 @@ static String formStateSignature() // In the legacy version of serialized state, the first item was a name // attribute value of a form control. The following string literal should // contain some characters which are rarely used for name attribute values. - DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state version 4 \n\r=&")); + DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state version 3 \n\r=&")); return signature; } Vector<String> FormController::formElementsState() const { Vector<String> stateVector; - stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 3 + 1); + stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 4 + 1); stateVector.append(formStateSignature()); typedef FormElementListHashSet::const_iterator Iterator; Iterator end = m_formElementsWithState.end(); @@ -122,7 +98,7 @@ Vector<String> FormController::formElementsState() const continue; stateVector.append(elementWithState->name().string()); stateVector.append(elementWithState->formControlType().string()); - stateVector.append(elementWithState->saveFormControlState().serialize()); + elementWithState->saveFormControlState().serializeTo(stateVector); } return stateVector; } @@ -137,15 +113,14 @@ void FormController::setStateForNewFormElements(const Vector<String>& stateVecto typedef FormElementStateMap::iterator Iterator; m_formElementsWithState.clear(); - if (stateVector.size() < 1 || stateVector[0] != formStateSignature()) - return; - if ((stateVector.size() - 1) % 3) + size_t i = 0; + if (stateVector.size() < 1 || stateVector[i++] != formStateSignature()) return; - for (size_t i = 1; i < stateVector.size(); i += 3) { - AtomicString name = stateVector[i]; - AtomicString type = stateVector[i + 1]; - FormControlState state = FormControlState::deserialize(stateVector[i + 2]); + while (i + 2 < stateVector.size()) { + AtomicString name = stateVector[i++]; + AtomicString type = stateVector[i++]; + FormControlState state = FormControlState::deserialize(stateVector, i); if (type.isEmpty() || type.impl()->find(isNotFormControlTypeCharacter) != notFound || state.isFailure()) break; @@ -159,17 +134,16 @@ void FormController::setStateForNewFormElements(const Vector<String>& stateVecto m_stateForNewFormElements.set(key, stateList); } } + if (i != stateVector.size()) + m_stateForNewFormElements.clear(); } -bool FormController::hasStateForNewFormElements() const -{ - return !m_stateForNewFormElements.isEmpty(); -} - -FormControlState FormController::takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type) +FormControlState FormController::takeStateForFormElement(const HTMLFormControlElementWithState& control) { + if (m_stateForNewFormElements.isEmpty()) + return FormControlState(); typedef FormElementStateMap::iterator Iterator; - Iterator it = m_stateForNewFormElements.find(FormElementKey(name, type)); + Iterator it = m_stateForNewFormElements.find(FormElementKey(control.name().impl(), control.type().impl())); if (it == m_stateForNewFormElements.end()) return FormControlState(); ASSERT(it->second.size()); diff --git a/Source/WebCore/html/FormController.h b/Source/WebCore/html/FormController.h index 4de51f524..84156953e 100644 --- a/Source/WebCore/html/FormController.h +++ b/Source/WebCore/html/FormController.h @@ -78,7 +78,7 @@ class FormControlState { public: FormControlState() : m_type(TypeSkip) { } explicit FormControlState(const String& value) : m_type(TypeRestore) { m_values.append(value); } - static FormControlState deserialize(const String&); + static FormControlState deserialize(const Vector<String>& stateVector, size_t& index); FormControlState(const FormControlState& another) : m_type(another.m_type), m_values(another.m_values) { } FormControlState& operator=(const FormControlState&); @@ -86,7 +86,7 @@ public: size_t valueSize() const { return m_values.size(); } const String& operator[](size_t i) const { return m_values[i]; } void append(const String&); - String serialize() const; + void serializeTo(Vector<String>& stateVector) const; private: enum Type { TypeSkip, TypeRestore, TypeFailure }; @@ -125,8 +125,7 @@ public: Vector<String> formElementsState() const; // This should be callled only by Document::setStateForNewFormElements(). void setStateForNewFormElements(const Vector<String>&); - bool hasStateForNewFormElements() const; - FormControlState takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type); + FormControlState takeStateForFormElement(const HTMLFormControlElementWithState&); void registerFormElementWithFormAttribute(FormAssociatedElement*); void unregisterFormElementWithFormAttribute(FormAssociatedElement*); diff --git a/Source/WebCore/html/HTMLCollection.cpp b/Source/WebCore/html/HTMLCollection.cpp index c20c464e8..1129cabd9 100644 --- a/Source/WebCore/html/HTMLCollection.cpp +++ b/Source/WebCore/html/HTMLCollection.cpp @@ -36,16 +36,7 @@ namespace WebCore { using namespace HTMLNames; -HTMLCollection::HTMLCollection(Node* base, CollectionType type) - : m_includeChildren(shouldIncludeChildren(type)) - , m_type(type) - , m_base(base) -{ - ASSERT(m_base); - m_cache.clear(); -} - -bool HTMLCollection::shouldIncludeChildren(CollectionType type) +static bool shouldIncludeChildren(CollectionType type) { switch (type) { case DocAll: @@ -78,6 +69,15 @@ bool HTMLCollection::shouldIncludeChildren(CollectionType type) return false; } +HTMLCollection::HTMLCollection(Node* base, CollectionType type) + : m_includeChildren(shouldIncludeChildren(type)) + , m_type(type) + , m_base(base) +{ + ASSERT(m_base); + m_cache.clear(); +} + PassOwnPtr<HTMLCollection> HTMLCollection::create(Node* base, CollectionType type) { return adoptPtr(new HTMLCollection(base, type)); @@ -199,39 +199,23 @@ unsigned HTMLCollection::length() const Node* HTMLCollection::item(unsigned index) const { - invalidateCacheIfNeeded(); - if (m_cache.current && m_cache.position == index) - return m_cache.current; - if (m_cache.hasLength && m_cache.length <= index) - return 0; - if (!m_cache.current || m_cache.position > index) { - m_cache.current = itemAfter(0); - m_cache.position = 0; - if (!m_cache.current) - return 0; - } - Element* e = m_cache.current; - for (unsigned pos = m_cache.position; e && pos < index; pos++) - e = itemAfter(e); - m_cache.current = e; - m_cache.position = index; - return m_cache.current; -} - -Node* HTMLCollection::firstItem() const -{ - return item(0); -} - -Node* HTMLCollection::nextItem() const -{ - invalidateCacheIfNeeded(); - - // Look for the 'second' item. The first one is currentItem, already given back. - Element* retval = itemAfter(m_cache.current); - m_cache.current = retval; - m_cache.position++; - return retval; + invalidateCacheIfNeeded(); + if (m_cache.current && m_cache.position == index) + return m_cache.current; + if (m_cache.hasLength && m_cache.length <= index) + return 0; + if (!m_cache.current || m_cache.position > index) { + m_cache.current = itemAfter(0); + m_cache.position = 0; + if (!m_cache.current) + return 0; + } + Element* e = m_cache.current; + for (unsigned pos = m_cache.position; e && pos < index; pos++) + e = itemAfter(e); + m_cache.current = e; + m_cache.position = index; + return m_cache.current; } static inline bool nameShouldBeVisibleInDocumentAll(HTMLElement* element) diff --git a/Source/WebCore/html/HTMLCollection.h b/Source/WebCore/html/HTMLCollection.h index fa3ff1ead..ede81c09f 100644 --- a/Source/WebCore/html/HTMLCollection.h +++ b/Source/WebCore/html/HTMLCollection.h @@ -44,19 +44,25 @@ public: void ref() { m_base->ref(); } void deref() { m_base->deref(); } + // DOM API unsigned length() const; - virtual Node* item(unsigned index) const; - virtual Node* nextItem() const; - virtual Node* namedItem(const AtomicString& name) const; + PassRefPtr<NodeList> tags(const String&); - Node* firstItem() const; - + // Non-DOM API bool hasNamedItem(const AtomicString& name) const; void namedItems(const AtomicString& name, Vector<RefPtr<Node> >&) const; - - PassRefPtr<NodeList> tags(const String&); + bool hasAnyItem() const + { + invalidateCacheIfNeeded(); + return (m_cache.hasLength && m_cache.length) || m_cache.current || item(0); + } + bool hasExactlyOneItem() const + { + invalidateCacheIfNeeded(); + return (m_cache.hasLength && m_cache.length == 1) || (m_cache.current && !itemAfter(m_cache.current)) || (item(0) && !item(1)); + } Node* base() const { return m_base; } CollectionType type() const { return static_cast<CollectionType>(m_type); } @@ -98,7 +104,6 @@ protected: } m_cache; private: - static bool shouldIncludeChildren(CollectionType); bool checkForNameMatch(Element*, bool checkName, const AtomicString& name) const; virtual unsigned calcLength() const; diff --git a/Source/WebCore/html/HTMLFormControlElementWithState.cpp b/Source/WebCore/html/HTMLFormControlElementWithState.cpp index a884ee1bd..22940e0d6 100644 --- a/Source/WebCore/html/HTMLFormControlElementWithState.cpp +++ b/Source/WebCore/html/HTMLFormControlElementWithState.cpp @@ -77,12 +77,9 @@ void HTMLFormControlElementWithState::finishParsingChildren() if (!shouldSaveAndRestoreFormControlState()) return; - Document* doc = document(); - if (doc->formController()->hasStateForNewFormElements()) { - FormControlState state = doc->formController()->takeStateForFormElement(name().impl(), type().impl()); - if (state.valueSize() > 0) - restoreFormControlState(state); - } + FormControlState state = document()->formController()->takeStateForFormElement(*this); + if (state.valueSize() > 0) + restoreFormControlState(state); } } // namespace Webcore diff --git a/Source/WebCore/html/HTMLMapElement.cpp b/Source/WebCore/html/HTMLMapElement.cpp index 8f6d6f64c..293eee354 100644 --- a/Source/WebCore/html/HTMLMapElement.cpp +++ b/Source/WebCore/html/HTMLMapElement.cpp @@ -82,8 +82,8 @@ bool HTMLMapElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HTMLImageElement* HTMLMapElement::imageElement() { - HTMLCollection* coll = document()->images(); - for (Node* curr = coll->firstItem(); curr; curr = coll->nextItem()) { + HTMLCollection* images = document()->images(); + for (unsigned i = 0; Node* curr = images->item(i); i++) { if (!curr->hasTagName(imgTag)) continue; diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index bcc87fe0c..fddc42893 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -2708,8 +2708,6 @@ void HTMLMediaElement::endScrubbing() // "15 to 250ms", we choose the slowest frequency static const double maxTimeupdateEventFrequency = 0.25; -static const double timeWithoutMouseMovementBeforeHidingControls = 3; - void HTMLMediaElement::startPlaybackProgressTimer() { if (m_playbackProgressTimer.isActive()) diff --git a/Source/WebCore/html/shadow/CalendarPickerElement.cpp b/Source/WebCore/html/shadow/CalendarPickerElement.cpp index fe1f64e13..5358ccaf7 100644 --- a/Source/WebCore/html/shadow/CalendarPickerElement.cpp +++ b/Source/WebCore/html/shadow/CalendarPickerElement.cpp @@ -151,7 +151,12 @@ static void addJavaScriptString(const String& str, DocumentWriter& writer) { addLiteral("\"", writer); StringBuilder builder; - builder.appendEscaped(str, '\\', '"'); + builder.reserveCapacity(str.length()); + for (unsigned i = 0; i < str.length(); ++i) { + if (str[i] == '\\' || str[i] == '"') + builder.append('\\'); + builder.append(str[i]); + } addString(builder.toString(), writer); addLiteral("\"", writer); } diff --git a/Source/WebCore/html/shadow/InsertionPoint.cpp b/Source/WebCore/html/shadow/InsertionPoint.cpp index 580512862..0794c3449 100644 --- a/Source/WebCore/html/shadow/InsertionPoint.cpp +++ b/Source/WebCore/html/shadow/InsertionPoint.cpp @@ -128,14 +128,13 @@ Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* i void InsertionPoint::removedFrom(ContainerNode* insertionPoint) { if (insertionPoint->inDocument()) { - Node* parent = parentNode(); - if (!parent) - parent = insertionPoint; - if (ShadowRoot* root = parent->shadowRoot()) { - // host can be null when removedFrom() is called from ElementShadow destructor. - if (root->host()) - root->owner()->invalidateDistribution(); - } + ShadowRoot* root = shadowRoot(); + if (!root) + root = insertionPoint->shadowRoot(); + + // host can be null when removedFrom() is called from ElementShadow destructor. + if (root && root->host()) + root->owner()->invalidateDistribution(); // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. clearDistribution(); diff --git a/Source/WebCore/inspector/Inspector.json b/Source/WebCore/inspector/Inspector.json index 880633e1d..0f6448349 100644 --- a/Source/WebCore/inspector/Inspector.json +++ b/Source/WebCore/inspector/Inspector.json @@ -1420,6 +1420,15 @@ { "name": "resourceType", "$ref": "Page.ResourceType", "optional": true, "description": "ResourceType of the entry, available for a file only." } ], "description": "Represents a browser side file or directory." + }, + { + "id": "Metadata", + "type": "object", + "properties": [ + { "name": "modificationTime", "type": "number", "description": "Modification time." }, + { "name": "size", "type": "number", "optional": true, "description": "File size. This field is available only for a file." } + ], + "description": "Represents metadata of a file or entry." } ], "commands": [ @@ -1451,6 +1460,16 @@ { "name": "requestId", "$ref": "RequestId", "description": "Request identifier. Corresponding directoryContentReceived event should have same requestId with this." } ], "description": "Returns content of the directory as directoryContentReceived event." + }, + { + "name": "requestMetadata", + "parameters": [ + { "name": "url", "type": "string", "description": "URL of the entry that the frontend is requesting to get metadata from." } + ], + "returns": [ + { "name": "requestId", "$ref": "RequestId", "description": "Request identifier. Corresponding metadataReceived event should have same requestId with this." } + ], + "description": "Returns metadata of the entry as metadataReceived event." } ], "events": [ @@ -1471,6 +1490,15 @@ { "name": "entries", "type": "array", "items": { "$ref": "FileSystem.Entry" }, "optional": true, "description": "Contains all entries on directory if the command completed successfully." } ], "description": "Completion event of requestDirectoryContent command." + }, + { + "name": "metadataReceived", + "parameters": [ + { "name": "requestId", "type": "integer", "description": "Request Identifier that was returned in response to the corresponding getMetadata request." }, + { "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise, errorCode is set to FileError::ErrorCode value." }, + { "name": "metadata", "$ref": "FileSystem.Metadata", "optional": true, "description": "Contains metadata of the entry if the command completed successfully." } + ], + "description": "Completion event of getMetadata command." } ] }, diff --git a/Source/WebCore/inspector/InspectorFileSystemAgent.cpp b/Source/WebCore/inspector/InspectorFileSystemAgent.cpp index 72a2788c6..06206de26 100644 --- a/Source/WebCore/inspector/InspectorFileSystemAgent.cpp +++ b/Source/WebCore/inspector/InspectorFileSystemAgent.cpp @@ -52,6 +52,8 @@ #include "KURL.h" #include "LocalFileSystem.h" #include "MIMETypeRegistry.h" +#include "Metadata.h" +#include "MetadataCallback.h" #include "SecurityOrigin.h" using WebCore::TypeBuilder::Array; @@ -142,7 +144,7 @@ public: private: bool didHitError(FileError*); - bool gotEntry(Entry*); + bool didGetEntry(Entry*); void reportResult(FileError::ErrorCode errorCode, PassRefPtr<TypeBuilder::FileSystem::Entry> entry) { @@ -180,14 +182,14 @@ void GetFileSystemRootTask::start(ScriptExecutionContext* scriptExecutionContext return; } - RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &GetFileSystemRootTask::gotEntry); + RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &GetFileSystemRootTask::didGetEntry); RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &GetFileSystemRootTask::didHitError); OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, "/"); LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release()); } -bool GetFileSystemRootTask::gotEntry(Entry* entry) +bool GetFileSystemRootTask::didGetEntry(Entry* entry) { RefPtr<TypeBuilder::FileSystem::Entry> result(TypeBuilder::FileSystem::Entry::create().setUrl(entry->toURL()).setName("/").setIsDirectory(true)); reportResult(static_cast<FileError::ErrorCode>(0), result); @@ -216,7 +218,7 @@ private: return true; } - bool gotEntry(Entry*); + bool didGetEntry(Entry*); bool didReadDirectoryEntries(EntryArray*); void reportResult(FileError::ErrorCode errorCode, PassRefPtr<Array<TypeBuilder::FileSystem::Entry> > entries) @@ -252,14 +254,14 @@ void ReadDirectoryTask::start(ScriptExecutionContext* scriptExecutionContext) return; } - RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &ReadDirectoryTask::gotEntry); + RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &ReadDirectoryTask::didGetEntry); RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &ReadDirectoryTask::didHitError); OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path); LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release()); } -bool ReadDirectoryTask::gotEntry(Entry* entry) +bool ReadDirectoryTask::didGetEntry(Entry* entry) { if (!entry->isDirectory()) { reportResult(FileError::TYPE_MISMATCH_ERR, 0); @@ -318,6 +320,86 @@ bool ReadDirectoryTask::didReadDirectoryEntries(EntryArray* entries) return true; } +class GetMetadataTask : public RefCounted<GetMetadataTask> { + WTF_MAKE_NONCOPYABLE(GetMetadataTask); +public: + static PassRefPtr<GetMetadataTask> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url) + { + return adoptRef(new GetMetadataTask(frontendProvider, requestId, url)); + } + + virtual ~GetMetadataTask() + { + reportResult(FileError::ABORT_ERR, 0); + } + + bool didHitError(FileError* error) + { + reportResult(error->code(), 0); + return true; + } + + void start(ScriptExecutionContext*); + bool didGetEntry(Entry*); + bool didGetMetadata(Metadata*); + + void reportResult(FileError::ErrorCode errorCode, PassRefPtr<TypeBuilder::FileSystem::Metadata> metadata) + { + if (!m_frontendProvider || !m_frontendProvider->frontend()) + return; + m_frontendProvider->frontend()->metadataReceived(m_requestId, static_cast<int>(errorCode), metadata); + m_frontendProvider = 0; + } + +private: + GetMetadataTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url) + : m_frontendProvider(frontendProvider) + , m_requestId(requestId) + , m_url(ParsedURLString, url) { } + + RefPtr<FrontendProvider> m_frontendProvider; + int m_requestId; + KURL m_url; + String m_path; + bool m_isDirectory; +}; + +void GetMetadataTask::start(ScriptExecutionContext* scriptExecutionContext) +{ + FileSystemType type; + DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path); + + RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &GetMetadataTask::didGetEntry); + RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &GetMetadataTask::didHitError); + + OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, m_path); + LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release()); +} + +bool GetMetadataTask::didGetEntry(Entry* entry) +{ + if (!entry->filesystem()->scriptExecutionContext()) { + reportResult(FileError::ABORT_ERR, 0); + return true; + } + + RefPtr<MetadataCallback> successCallback = CallbackDispatcherFactory<MetadataCallback>::create(this, &GetMetadataTask::didGetMetadata); + RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &GetMetadataTask::didHitError); + entry->getMetadata(successCallback, errorCallback); + m_isDirectory = entry->isDirectory(); + return true; +} + +bool GetMetadataTask::didGetMetadata(Metadata* metadata) +{ + using TypeBuilder::FileSystem::Metadata; + RefPtr<Metadata> result = Metadata::create().setModificationTime(metadata->modificationTime()); + if (!m_isDirectory) + result->setSize(metadata->size()); + reportResult(static_cast<FileError::ErrorCode>(0), result); + return true; +} + } // static @@ -351,8 +433,10 @@ void InspectorFileSystemAgent::disable(ErrorString*) void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& type, int* requestId) { - if (!m_enabled || !m_frontendProvider) + if (!m_enabled || !m_frontendProvider) { + *error = "FileSystem agent is not enabled"; return; + } ASSERT(m_frontendProvider->frontend()); *requestId = m_nextRequestId++; @@ -362,10 +446,12 @@ void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const S m_frontendProvider->frontend()->fileSystemRootReceived(*requestId, static_cast<int>(FileError::ABORT_ERR), 0); } -void InspectorFileSystemAgent::requestDirectoryContent(ErrorString*, const String& url, int* requestId) +void InspectorFileSystemAgent::requestDirectoryContent(ErrorString* error, const String& url, int* requestId) { - if (!m_enabled || !m_frontendProvider) + if (!m_enabled || !m_frontendProvider) { + *error = "FileSystem agent is not enabled"; return; + } ASSERT(m_frontendProvider->frontend()); *requestId = m_nextRequestId++; @@ -376,6 +462,22 @@ void InspectorFileSystemAgent::requestDirectoryContent(ErrorString*, const Strin m_frontendProvider->frontend()->directoryContentReceived(*requestId, static_cast<int>(FileError::ABORT_ERR), 0); } +void InspectorFileSystemAgent::requestMetadata(ErrorString* error, const String& url, int* requestId) +{ + if (!m_enabled || !m_frontendProvider) { + *error = "FileSystem agent is not enabled"; + return; + } + ASSERT(m_frontendProvider->frontend()); + + *requestId = m_nextRequestId++; + + if (ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextForOrigin(SecurityOrigin::createFromString(url).get())) + GetMetadataTask::create(m_frontendProvider, *requestId, url)->start(scriptExecutionContext); + else + m_frontendProvider->frontend()->metadataReceived(*requestId, static_cast<int>(FileError::ABORT_ERR), 0); +} + void InspectorFileSystemAgent::setFrontend(InspectorFrontend* frontend) { ASSERT(frontend); diff --git a/Source/WebCore/inspector/InspectorFileSystemAgent.h b/Source/WebCore/inspector/InspectorFileSystemAgent.h index 59a16e907..82f95c4b6 100644 --- a/Source/WebCore/inspector/InspectorFileSystemAgent.h +++ b/Source/WebCore/inspector/InspectorFileSystemAgent.h @@ -61,6 +61,7 @@ public: virtual void requestFileSystemRoot(ErrorString*, const String& origin, const String& type, int* requestId) OVERRIDE; virtual void requestDirectoryContent(ErrorString*, const String& url, int* requestId) OVERRIDE; + virtual void requestMetadata(ErrorString*, const String& url, int* requestId) OVERRIDE; virtual void setFrontend(InspectorFrontend*) OVERRIDE; virtual void clearFrontend() OVERRIDE; diff --git a/Source/WebCore/inspector/front-end/FileSystemModel.js b/Source/WebCore/inspector/front-end/FileSystemModel.js index 661e915ff..edb647fa7 100644 --- a/Source/WebCore/inspector/front-end/FileSystemModel.js +++ b/Source/WebCore/inspector/front-end/FileSystemModel.js @@ -235,6 +235,11 @@ WebInspector.FileSystemModel.prototype = { } callback(errorCode, entries); + }, + + requestMetadata: function(entry, callback) + { + this._agentWrapper.requestMetadata(entry.url, callback); } } @@ -325,6 +330,14 @@ WebInspector.FileSystemModel.Entry.prototype = { get isDirectory() { return this._isDirectory; + }, + + /** + * @param {function(number, FileSystemAgent.Metadata)} callback + */ + requestMetadata: function(callback) + { + this.fileSystemModel.requestMetadata(this, callback); } } @@ -394,6 +407,7 @@ WebInspector.FileSystemRequestManager = function() { this._pendingFileSystemRootRequests = {}; this._pendingDirectoryContentRequests = {}; + this._pendingMetadataRequests = {}; InspectorBackend.registerFileSystemDispatcher(new WebInspector.FileSystemDispatcher(this)); FileSystemAgent.enable(); @@ -459,6 +473,31 @@ WebInspector.FileSystemRequestManager.prototype = { return; delete this._pendingDirectoryContentRequests[requestId]; callback(errorCode, backendEntries); + }, + + /** + * @param {string} url + * @param {function(number, FileSystemAgent.Metadata=)} callback + */ + requestMetadata: function(url, callback) + { + var store = this._pendingMetadataRequests; + FileSystemAgent.requestMetadata(url, requestAccepted); + + function requestAccepted(error, requestId) + { + if (!error) + store[requestId] = callback; + } + }, + + _metadataReceived: function(requestId, errorCode, metadata) + { + var callback = this._pendingMetadataRequests[requestId]; + if (!callback) + return; + delete this._pendingMetadataRequests[requestId]; + callback(errorCode, metadata); } } @@ -491,5 +530,15 @@ WebInspector.FileSystemDispatcher.prototype = { directoryContentReceived: function(requestId, errorCode, backendEntries) { this._agentWrapper._directoryContentReceived(requestId, errorCode, backendEntries); + }, + + /** + * @param {number} requestId + * @param {number} errorCode + * @param {FileSystemAgent.Metadata=} metadata + */ + metadataReceived: function(requestId, errorCode, metadata) + { + this._agentWrapper._metadataReceived(requestId, errorCode, metadata); } } diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js b/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js index 007c4a3a9..40b5e3057 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js @@ -379,6 +379,7 @@ WebInspector.HeapSnapshotViewportDataGrid.prototype = { onResize: function() { + WebInspector.HeapSnapshotSortableDataGrid.prototype.onResize.call(this); this.updateVisibleNodes(); }, diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js b/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js index 3c3395bf9..f8c8b4a89 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js @@ -91,7 +91,7 @@ WebInspector.HeapSnapshotGridNode.prototype = { node.dispose(); }, - hasHoverMessage: false, + _reachableFromWindow: false, queryObjectContent: function(callback) { @@ -356,12 +356,12 @@ WebInspector.HeapSnapshotGenericObjectNode = function(tree, node) this.snapshotNodeId = node.id; this.snapshotNodeIndex = node.nodeIndex; if (this._type === "string") - this.hasHoverMessage = true; + this._reachableFromWindow = true; else if (this._type === "object" && this.isWindow(this._name)) { this._name = this.shortenWindowURL(this._name, false); - this.hasHoverMessage = true; + this._reachableFromWindow = true; } else if (node.flags & tree.snapshot.nodeFlags.canBeQueried) - this.hasHoverMessage = true; + this._reachableFromWindow = true; if (node.flags & tree.snapshot.nodeFlags.detachedDOMTreeNode) this.detachedDOMTreeNode = true; }; @@ -435,7 +435,7 @@ WebInspector.HeapSnapshotGenericObjectNode.prototype = { value += "[]"; break; }; - if (this.hasHoverMessage) + if (this._reachableFromWindow) valueStyle += " highlight"; if (value === "Object") value = ""; diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotView.js b/Source/WebCore/inspector/front-end/HeapSnapshotView.js index 9a8dd08ed..5a2fe54fb 100644 --- a/Source/WebCore/inspector/front-end/HeapSnapshotView.js +++ b/Source/WebCore/inspector/front-end/HeapSnapshotView.js @@ -562,10 +562,7 @@ WebInspector.HeapSnapshotView.prototype = { var row = target.enclosingNodeOrSelfWithNodeName("tr"); if (!row) return; - var gridNode = row._dataGridNode; - if (!gridNode.hasHoverMessage) - return; - span.node = gridNode; + span.node = row._dataGridNode; return span; }, diff --git a/Source/WebCore/inspector/front-end/StylesSidebarPane.js b/Source/WebCore/inspector/front-end/StylesSidebarPane.js index c9d4b9c21..ef091cdac 100644 --- a/Source/WebCore/inspector/front-end/StylesSidebarPane.js +++ b/Source/WebCore/inspector/front-end/StylesSidebarPane.js @@ -1693,7 +1693,7 @@ WebInspector.StylePropertyTreeElement.prototype = { enabledCheckboxElement.className = "enabled-button"; enabledCheckboxElement.type = "checkbox"; enabledCheckboxElement.checked = !this.disabled; - enabledCheckboxElement.addEventListener("change", this.toggleEnabled.bind(this), false); + enabledCheckboxElement.addEventListener("click", this.toggleEnabled.bind(this), false); } var nameElement = document.createElement("span"); @@ -1986,6 +1986,7 @@ WebInspector.StylePropertyTreeElement.prototype = { this._parentPane._userOperation = true; this.property.setDisabled(disabled, callback.bind(this)); + event.consume(); }, updateState: function() diff --git a/Source/WebCore/inspector/front-end/elementsPanel.css b/Source/WebCore/inspector/front-end/elementsPanel.css index b4dcfb2cc..6b7455b73 100644 --- a/Source/WebCore/inspector/front-end/elementsPanel.css +++ b/Source/WebCore/inspector/front-end/elementsPanel.css @@ -352,7 +352,7 @@ } .styles-section .properties > li.child-editing .webkit-css-property { - margin-left: -8px; + margin-left: 0; } .styles-section.matched-styles .properties li { @@ -362,6 +362,7 @@ .styles-section .properties li.child-editing { word-wrap: break-word !important; white-space: normal !important; + padding-left: 0; } .styles-section .properties ol { diff --git a/Source/WebCore/loader/archive/Archive.cpp b/Source/WebCore/loader/archive/Archive.cpp index 8f45fbd49..ea76a114d 100644 --- a/Source/WebCore/loader/archive/Archive.cpp +++ b/Source/WebCore/loader/archive/Archive.cpp @@ -35,4 +35,21 @@ Archive::~Archive() { } +void Archive::clearAllSubframeArchives() +{ + Vector<RefPtr<Archive> > clearedArchives; + clearAllSubframeArchivesImpl(&clearedArchives); +} + +void Archive::clearAllSubframeArchivesImpl(Vector<RefPtr<Archive> >* clearedArchives) +{ + for (Vector<RefPtr<Archive> >::iterator it = m_subframeArchives.begin(); it != m_subframeArchives.end(); ++it) { + if (!clearedArchives->contains(*it)) { + clearedArchives->append(*it); + (*it)->clearAllSubframeArchivesImpl(clearedArchives); + } + } + m_subframeArchives.clear(); +} + } diff --git a/Source/WebCore/loader/archive/Archive.h b/Source/WebCore/loader/archive/Archive.h index d41c60872..b7656e579 100644 --- a/Source/WebCore/loader/archive/Archive.h +++ b/Source/WebCore/loader/archive/Archive.h @@ -56,8 +56,12 @@ protected: void setMainResource(PassRefPtr<ArchiveResource> mainResource) { m_mainResource = mainResource; } void addSubresource(PassRefPtr<ArchiveResource> subResource) { m_subresources.append(subResource); } void addSubframeArchive(PassRefPtr<Archive> subframeArchive) { m_subframeArchives.append(subframeArchive); } - + + void clearAllSubframeArchives(); + private: + void clearAllSubframeArchivesImpl(Vector<RefPtr<Archive> >* clearedArchives); + RefPtr<ArchiveResource> m_mainResource; Vector<RefPtr<ArchiveResource> > m_subresources; Vector<RefPtr<Archive> > m_subframeArchives; diff --git a/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp b/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp index b996f2d4b..cb9c7e570 100644 --- a/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp +++ b/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp @@ -96,6 +96,12 @@ MHTMLArchive::MHTMLArchive() { } +MHTMLArchive::~MHTMLArchive() +{ + // Because all frames know about each other we need to perform a deep clearing of the archives graph. + clearAllSubframeArchives(); +} + PassRefPtr<MHTMLArchive> MHTMLArchive::create() { return adoptRef(new MHTMLArchive); @@ -115,7 +121,7 @@ PassRefPtr<MHTMLArchive> MHTMLArchive::create(const KURL& url, SharedBuffer* dat // Since MHTML is a flat format, we need to make all frames aware of all resources. for (size_t i = 0; i < parser.frameCount(); ++i) { RefPtr<MHTMLArchive> archive = parser.frameAt(i); - for (size_t j = 0; j < parser.frameCount(); ++j) { + for (size_t j = 1; j < parser.frameCount(); ++j) { if (i != j) archive->addSubframeArchive(parser.frameAt(j)); } diff --git a/Source/WebCore/loader/archive/mhtml/MHTMLArchive.h b/Source/WebCore/loader/archive/mhtml/MHTMLArchive.h index 037153666..dd14d99c4 100644 --- a/Source/WebCore/loader/archive/mhtml/MHTMLArchive.h +++ b/Source/WebCore/loader/archive/mhtml/MHTMLArchive.h @@ -52,6 +52,8 @@ public: // Binary encoding results in smaller MHTML files but they might not work in other browsers. static PassRefPtr<SharedBuffer> generateMHTMLDataUsingBinaryEncoding(Page*); + virtual ~MHTMLArchive(); + private: static PassRefPtr<SharedBuffer> generateMHTMLData(Page*, bool useBinaryEncoding); diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp index cd5bd2336..3998efd32 100755 --- a/Source/WebCore/loader/cache/CachedResource.cpp +++ b/Source/WebCore/loader/cache/CachedResource.cpp @@ -56,20 +56,21 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type { switch (type) { case CachedResource::CSSStyleSheet: -#if ENABLE(XSLT) - case CachedResource::XSLStyleSheet: -#endif return ResourceLoadPriorityHigh; case CachedResource::Script: -#if ENABLE(SVG) - case CachedResource::SVGDocumentResource: - return ResourceLoadPriorityLow; -#endif case CachedResource::FontResource: case CachedResource::RawResource: return ResourceLoadPriorityMedium; case CachedResource::ImageResource: return ResourceLoadPriorityLow; +#if ENABLE(XSLT) + case CachedResource::XSLStyleSheet: + return ResourceLoadPriorityHigh; +#endif +#if ENABLE(SVG) + case CachedResource::SVGDocumentResource: + return ResourceLoadPriorityLow; +#endif #if ENABLE(LINK_PREFETCH) case CachedResource::LinkPrefetch: return ResourceLoadPriorityVeryLow; diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp index 7e0c8fbfa..90060476c 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp +++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp @@ -267,6 +267,7 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const #if ENABLE(CSS_SHADERS) case CachedResource::ShaderResource: #endif + case CachedResource::RawResource: case CachedResource::ImageResource: case CachedResource::FontResource: { // These resources can corrupt only the frame's pixels. @@ -277,7 +278,6 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const } break; } - case CachedResource::RawResource: #if ENABLE(LINK_PREFETCH) case CachedResource::LinkPrefetch: case CachedResource::LinkSubresource: diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index 82f3300da..367ab0443 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -1484,6 +1484,11 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) { RefPtr<FrameView> protector(m_frame->view()); + if (InspectorInstrumentation::handleMousePress(m_frame->page())) { + invalidateClick(); + return true; + } + #if ENABLE(TOUCH_EVENTS) bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent); if (defaultPrevented) @@ -1527,11 +1532,6 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) m_mousePressNode = targetNode(mev); - if (InspectorInstrumentation::handleMousePress(m_frame->page())) { - invalidateClick(); - return true; - } - Frame* subframe = subframeForHitTestResult(mev); if (subframe && passMousePressEventToSubframe(mev, subframe)) { // Start capturing future events for this frame. We only do this if we didn't clear @@ -2483,11 +2483,19 @@ bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, c { HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active; IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); - HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ false, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius); + HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ true, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius); IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult()); - return findBestClickableCandidate(targetNode, targetPoint, touchCenter, touchRect, *nodeList.get()); + + // FIXME: Should be able to handle targetNode being a shadow DOM node to avoid performing uncessary hit tests + // in the case where further processing on the node is required. Returning the shadow ancestor prevents a + // regression in touchadjustment/html-label.html. Some refinement is required to testing/internals to + // handle targetNode being a shadow DOM node. + bool success = findBestClickableCandidate(targetNode, targetPoint, touchCenter, touchRect, *nodeList.get()); + if (success && targetNode) + targetNode = targetNode->shadowAncestorNode(); + return success; } bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) diff --git a/Source/WebCore/page/EventSource.cpp b/Source/WebCore/page/EventSource.cpp index 2a4db03fa..03f78e988 100644 --- a/Source/WebCore/page/EventSource.cpp +++ b/Source/WebCore/page/EventSource.cpp @@ -315,6 +315,11 @@ void EventSource::parseEventStream() parseEventStreamLine(bufPos, fieldLength, lineLength); bufPos += lineLength + 1; + + // EventSource.close() might've been called by one of the message event handlers. + // Per spec, no further messages should be fired after that. + if (m_state == CLOSED) + break; } if (bufPos == bufSize) diff --git a/Source/WebCore/page/Performance.h b/Source/WebCore/page/Performance.h index deae0aec0..8ba8c5eea 100644 --- a/Source/WebCore/page/Performance.h +++ b/Source/WebCore/page/Performance.h @@ -90,7 +90,6 @@ private: virtual EventTargetData* ensureEventTargetData(); EventTargetData m_eventTargetData; - ScriptExecutionContext *m_scriptExecutionContext; mutable RefPtr<PerformanceNavigation> m_navigation; mutable RefPtr<PerformanceTiming> m_timing; diff --git a/Source/WebCore/page/Settings.h b/Source/WebCore/page/Settings.h index 158d240ab..a464cc86e 100644 --- a/Source/WebCore/page/Settings.h +++ b/Source/WebCore/page/Settings.h @@ -21,7 +21,7 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef Settings_h @@ -333,7 +333,7 @@ namespace WebCore { #if ENABLE(CSS_VARIABLES) void setCSSVariablesEnabled(bool enabled) { m_cssVariablesEnabled = enabled; } - bool cssVariablesEnabled() const { return true; } + bool cssVariablesEnabled() const { return m_cssVariablesEnabled; } #else void setCSSVariablesEnabled(bool) { } bool cssVariablesEnabled() const { return false; } diff --git a/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp b/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp index 0c3b0c329..7cfb86c0f 100644 --- a/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp +++ b/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp @@ -36,6 +36,10 @@ #include "ScrollbarLayerChromium.h" #include "ScrollbarTheme.h" #include "cc/CCProxy.h" +#include <public/WebScrollableLayer.h> + +using WebKit::WebLayer; +using WebKit::WebScrollableLayer; namespace WebCore { @@ -45,33 +49,34 @@ public: ScrollingCoordinatorPrivate() { } ~ScrollingCoordinatorPrivate() { } - void setScrollLayer(LayerChromium* layer) + void setScrollLayer(WebScrollableLayer layer) { m_scrollLayer = layer; - int id = layer ? layer->id() : 0; - if (m_horizontalScrollbarLayer) - m_horizontalScrollbarLayer->setScrollLayerId(id); - if (m_verticalScrollbarLayer) - m_verticalScrollbarLayer->setScrollLayerId(id); + int id = layer.isNull() ? 0 : layer.unwrap<LayerChromium>()->id(); + if (!m_horizontalScrollbarLayer.isNull()) + m_horizontalScrollbarLayer.unwrap<ScrollbarLayerChromium>()->setScrollLayerId(id); + if (!m_verticalScrollbarLayer.isNull()) + m_verticalScrollbarLayer.unwrap<ScrollbarLayerChromium>()->setScrollLayerId(id); } - void setHorizontalScrollbarLayer(PassRefPtr<ScrollbarLayerChromium> layer) + void setHorizontalScrollbarLayer(WebLayer layer) { m_horizontalScrollbarLayer = layer; } - void setVerticalScrollbarLayer(PassRefPtr<ScrollbarLayerChromium> layer) + void setVerticalScrollbarLayer(WebLayer layer) { m_verticalScrollbarLayer = layer; } - LayerChromium* scrollLayer() const { return m_scrollLayer.get(); } + bool hasScrollLayer() const { return !m_scrollLayer.isNull(); } + WebScrollableLayer scrollLayer() const { return m_scrollLayer; } private: - RefPtr<LayerChromium> m_scrollLayer; - RefPtr<ScrollbarLayerChromium> m_horizontalScrollbarLayer; - RefPtr<ScrollbarLayerChromium> m_verticalScrollbarLayer; + WebScrollableLayer m_scrollLayer; + WebLayer m_horizontalScrollbarLayer; + WebLayer m_verticalScrollbarLayer; }; PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) @@ -103,15 +108,15 @@ static GraphicsLayer* scrollLayerForFrameView(FrameView* frameView) #endif } -static PassRefPtr<ScrollbarLayerChromium> createScrollbarLayer(Scrollbar* scrollbar, LayerChromium* scrollLayer, GraphicsLayer* scrollbarGraphicsLayer, FrameView* frameView) +static WebLayer createScrollbarLayer(Scrollbar* scrollbar, WebScrollableLayer scrollLayer, GraphicsLayer* scrollbarGraphicsLayer, FrameView* frameView) { ASSERT(scrollbar); ASSERT(scrollbarGraphicsLayer); - if (!scrollLayer) { + if (scrollLayer.isNull()) { // FIXME: sometimes we get called before setScrollLayer, workaround by finding the scroll layout ourselves. - scrollLayer = scrollLayerForFrameView(frameView)->platformLayer(); - ASSERT(scrollLayer); + scrollLayer = WebScrollableLayer(scrollLayerForFrameView(frameView)->platformLayer()); + ASSERT(!scrollLayer.isNull()); } // Root layer non-overlay scrollbars should be marked opaque to disable @@ -129,15 +134,15 @@ static PassRefPtr<ScrollbarLayerChromium> createScrollbarLayer(Scrollbar* scroll if (!platformSupported || scrollbar->isOverlayScrollbar()) { scrollbarGraphicsLayer->setContentsToMedia(0); scrollbarGraphicsLayer->setDrawsContent(true); - return 0; + return WebLayer(); } - RefPtr<ScrollbarLayerChromium> scrollbarLayer = ScrollbarLayerChromium::create(scrollbar, scrollLayer->id()); + RefPtr<ScrollbarLayerChromium> scrollbarLayer = ScrollbarLayerChromium::create(scrollbar, scrollLayer.unwrap<LayerChromium>()->id()); scrollbarGraphicsLayer->setContentsToMedia(scrollbarLayer.get()); scrollbarGraphicsLayer->setDrawsContent(false); scrollbarLayer->setOpaque(scrollbarGraphicsLayer->contentsOpaque()); - return scrollbarLayer.release(); + return WebLayer(scrollbarLayer.release()); } void ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange(FrameView* frameView, GraphicsLayer* horizontalScrollbarLayer) @@ -158,13 +163,13 @@ void ScrollingCoordinator::frameViewVerticalScrollbarLayerDidChange(FrameView* f void ScrollingCoordinator::setScrollLayer(GraphicsLayer* scrollLayer) { - m_private->setScrollLayer(scrollLayer ? scrollLayer->platformLayer() : 0); + m_private->setScrollLayer(WebScrollableLayer(scrollLayer ? scrollLayer->platformLayer() : 0)); } void ScrollingCoordinator::setNonFastScrollableRegion(const Region& region) { - if (LayerChromium* layer = m_private->scrollLayer()) - layer->setNonFastScrollableRegion(region); + if (m_private->hasScrollLayer()) + m_private->scrollLayer().unwrap<LayerChromium>()->setNonFastScrollableRegion(region); } void ScrollingCoordinator::setScrollParameters(const ScrollParameters&) @@ -174,14 +179,14 @@ void ScrollingCoordinator::setScrollParameters(const ScrollParameters&) void ScrollingCoordinator::setWheelEventHandlerCount(unsigned wheelEventHandlerCount) { - if (LayerChromium* layer = m_private->scrollLayer()) - layer->setHaveWheelEventHandlers(wheelEventHandlerCount > 0); + if (m_private->hasScrollLayer()) + m_private->scrollLayer().setHaveWheelEventHandlers(wheelEventHandlerCount > 0); } void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(bool should) { - if (LayerChromium* layer = m_private->scrollLayer()) - layer->setShouldScrollOnMainThread(should); + if (m_private->hasScrollLayer()) + m_private->scrollLayer().setShouldScrollOnMainThread(should); } bool ScrollingCoordinator::supportsFixedPositionLayers() const diff --git a/Source/WebCore/platform/PlatformExportMacros.h b/Source/WebCore/platform/PlatformExportMacros.h index ae3e30a3a..6c70813ad 100644 --- a/Source/WebCore/platform/PlatformExportMacros.h +++ b/Source/WebCore/platform/PlatformExportMacros.h @@ -35,8 +35,7 @@ // See note in wtf/Platform.h for more info on EXPORT_MACROS. #if USE(EXPORT_MACROS) -#if defined(BUILDING_WebCore) || defined(BUILDING_WebKit) || \ - defined(STATICALLY_LINKED_WITH_WebCore) || defined(STATICALLY_LINKED_WITH_WebKit) +#if defined(BUILDING_WebCore) || defined(BUILDING_WebKit) #define WEBKIT_EXPORTDATA WTF_EXPORT #else #define WEBKIT_EXPORTDATA WTF_IMPORT @@ -46,8 +45,7 @@ #if !PLATFORM(CHROMIUM) && OS(WINDOWS) && !defined(BUILDING_WX__) && !COMPILER(GCC) -#if defined(BUILDING_WebCore) || defined(BUILDING_WebKit) || \ - defined(STATICALLY_LINKED_WITH_WebCore) || defined(STATICALLY_LINKED_WITH_WebKit) +#if defined(BUILDING_WebCore) || defined(BUILDING_WebKit) #define WEBKIT_EXPORTDATA __declspec(dllexport) #else #define WEBKIT_EXPORTDATA __declspec(dllimport) diff --git a/Source/WebCore/platform/chromium/support/Extensions3DChromium.cpp b/Source/WebCore/platform/chromium/support/Extensions3DChromium.cpp index 5cdd4ba6b..75a7689e3 100644 --- a/Source/WebCore/platform/chromium/support/Extensions3DChromium.cpp +++ b/Source/WebCore/platform/chromium/support/Extensions3DChromium.cpp @@ -73,11 +73,6 @@ void Extensions3DChromium::renderbufferStorageMultisample(unsigned long target, m_private->webContext()->renderbufferStorageMultisampleCHROMIUM(target, samples, internalformat, width, height); } -void Extensions3DChromium::postSubBufferCHROMIUM(int x, int y, int width, int height) -{ - m_private->webContext()->postSubBufferCHROMIUM(x, y, width, height); -} - void* Extensions3DChromium::mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access) { return m_private->webContext()->mapBufferSubDataCHROMIUM(target, offset, size, access); @@ -98,26 +93,6 @@ void Extensions3DChromium::unmapTexSubImage2DCHROMIUM(const void* data) m_private->webContext()->unmapTexSubImage2DCHROMIUM(data); } -void Extensions3DChromium::setVisibilityCHROMIUM(bool visibility) -{ - m_private->webContext()->setVisibilityCHROMIUM(visibility); -} - -void Extensions3DChromium::discardFramebufferEXT(GC3Denum target, GC3Dsizei numAttachments, const GC3Denum* attachments) -{ - m_private->webContext()->discardFramebufferEXT(target, numAttachments, attachments); -} - -void Extensions3DChromium::ensureFramebufferCHROMIUM() -{ - m_private->webContext()->ensureFramebufferCHROMIUM(); -} - -void Extensions3DChromium::setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<GpuMemoryAllocationChangedCallbackCHROMIUM> callback) -{ - m_private->setGpuMemoryAllocationChangedCallbackCHROMIUM(callback); -} - Platform3DObject Extensions3DChromium::createVertexArrayOES() { return 0; @@ -141,11 +116,6 @@ String Extensions3DChromium::getTranslatedShaderSourceANGLE(Platform3DObject sha return m_private->webContext()->getTranslatedShaderSourceANGLE(shader); } -void Extensions3DChromium::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<SwapBuffersCompleteCallbackCHROMIUM> callback) -{ - m_private->setSwapBuffersCompleteCallbackCHROMIUM(callback); -} - void Extensions3DChromium::rateLimitOffscreenContextCHROMIUM() { m_private->webContext()->rateLimitOffscreenContextCHROMIUM(); diff --git a/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp b/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp index d020acc38..127fcfa09 100644 --- a/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp +++ b/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp @@ -51,8 +51,6 @@ GraphicsContext3D::~GraphicsContext3D() { m_private->setContextLostCallback(nullptr); m_private->setErrorMessageCallback(nullptr); - m_private->setSwapBuffersCompleteCallbackCHROMIUM(nullptr); - m_private->setGpuMemoryAllocationChangedCallbackCHROMIUM(nullptr); } void GraphicsContext3D::setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback> callback) @@ -83,7 +81,7 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri if (!webContext) return 0; - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), renderStyle, attrs.preserveDrawingBuffer); + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), attrs.preserveDrawingBuffer); } PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const diff --git a/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp b/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp index 1cf6f5cd5..f6b730ddf 100644 --- a/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp +++ b/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp @@ -38,6 +38,7 @@ #include "GrGLInterface.h" #include "ImageBuffer.h" #include <public/WebGraphicsContext3D.h> +#include <public/WebGraphicsMemoryAllocation.h> #include <wtf/text/CString.h> #include <wtf/text/StringHash.h> @@ -68,16 +69,15 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphic GraphicsContext3DPrivate::~GraphicsContext3DPrivate() { if (m_grContext) { + m_impl->setMemoryAllocationChangedCallbackCHROMIUM(0); m_grContext->contextDestroyed(); GrSafeUnref(m_grContext); } } -PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::RenderStyle renderStyle, bool preserveDrawingBuffer) +PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer) { - bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - - RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, renderDirectlyToHostWindow)); + RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, false /* onscreen */)); OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer)); context->m_private = priv.release(); @@ -91,28 +91,27 @@ WebKit::WebGraphicsContext3D* GraphicsContext3DPrivate::extractWebGraphicsContex return context->m_private->webContext(); } -class GrMemoryAllocationChangedCallback : public Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM { +class GrMemoryAllocationChangedCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { public: - GrMemoryAllocationChangedCallback(GraphicsContext3DPrivate* context) + GrMemoryAllocationChangedCallbackAdapter(GrContext* context) : m_context(context) { } - virtual void onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation) + virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE { - GrContext* context = m_context->grContext(); - if (!context) + if (!m_context) return; if (!allocation.gpuResourceSizeInBytes) { - context->freeGpuResources(); - context->setTextureCacheLimits(0, 0); + m_context->freeGpuResources(); + m_context->setTextureCacheLimits(0, 0); } else - context->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes); + m_context->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes); } private: - GraphicsContext3DPrivate* m_context; + GrContext* m_context; }; GrContext* GraphicsContext3DPrivate::grContext() @@ -122,9 +121,8 @@ GrContext* GraphicsContext3DPrivate::grContext() m_grContext = GrContext::Create(kOpenGL_Shaders_GrEngine, reinterpret_cast<GrPlatform3DContext>(interface.get())); if (m_grContext) { m_grContext->setTextureCacheLimits(maxGaneshTextureCacheCount, maxGaneshTextureCacheBytes); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(getExtensions()); - if (extensions3DChromium->supports("GL_CHROMIUM_gpu_memory_manager")) - extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(adoptPtr(new GrMemoryAllocationChangedCallback(this))); + m_grContextMemoryAllocationCallbackAdapter = adoptPtr(new GrMemoryAllocationChangedCallbackAdapter(m_grContext)); + m_impl->setMemoryAllocationChangedCallbackCHROMIUM(m_grContextMemoryAllocationCallbackAdapter.get()); } } return m_grContext; @@ -325,55 +323,4 @@ bool GraphicsContext3DPrivate::isResourceSafe() return m_resourceSafety == ResourceSafe; } -class GraphicsContext3DMemoryAllocationChangedCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { -public: - GraphicsContext3DMemoryAllocationChangedCallbackAdapter(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> callback) - : m_memoryAllocationChangedCallback(callback) { } - - virtual ~GraphicsContext3DMemoryAllocationChangedCallbackAdapter() { } - - virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes) - { - // FIXME: Remove this once clients start using WebGraphicsMemoryAllocation exclusively. - onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation(gpuResourceSizeInBytes, true)); - } - - virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation allocation) - { - if (m_memoryAllocationChangedCallback) - m_memoryAllocationChangedCallback->onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM(allocation.gpuResourceSizeInBytes, allocation.suggestHaveBackbuffer)); - } - -private: - OwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> m_memoryAllocationChangedCallback; -}; - -void GraphicsContext3DPrivate::setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> callback) -{ - m_memoryAllocationChangedCallbackAdapter = adoptPtr(new GraphicsContext3DMemoryAllocationChangedCallbackAdapter(callback)); - m_impl->setMemoryAllocationChangedCallbackCHROMIUM(m_memoryAllocationChangedCallbackAdapter.get()); -} - -class GraphicsContext3DSwapBuffersCompleteCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM { -public: - GraphicsContext3DSwapBuffersCompleteCallbackAdapter(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> callback) - : m_swapBuffersCompleteCallback(callback) { } - virtual ~GraphicsContext3DSwapBuffersCompleteCallbackAdapter() { } - - virtual void onSwapBuffersComplete() - { - if (m_swapBuffersCompleteCallback) - m_swapBuffersCompleteCallback->onSwapBuffersComplete(); - } - -private: - OwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> m_swapBuffersCompleteCallback; -}; - -void GraphicsContext3DPrivate::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> callback) -{ - m_swapBuffersCompleteCallbackAdapter = adoptPtr(new GraphicsContext3DSwapBuffersCompleteCallbackAdapter(callback)); - m_impl->setSwapBuffersCompleteCallbackCHROMIUM(m_swapBuffersCompleteCallbackAdapter.get()); -} - } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.h b/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.h index 42fa7092f..5bbb85a22 100644 --- a/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.h +++ b/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.h @@ -45,15 +45,14 @@ class DrawingBuffer; class Extensions3DChromium; class GraphicsContext3DContextLostCallbackAdapter; class GraphicsContext3DErrorMessageCallbackAdapter; -class GraphicsContext3DMemoryAllocationChangedCallbackAdapter; -class GraphicsContext3DSwapBuffersCompleteCallbackAdapter; +class GrMemoryAllocationChangedCallbackAdapter; class GraphicsContext3DPrivate { public: // Callers must make the context current before using it AND check that the context was created successfully // via ContextLost before using the context in any way. Once made current on a thread, the context cannot // be used on any other thread. - static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::RenderStyle, bool preserveDrawingBuffer = false); + static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDrawingBuffer = false); // Helper function to provide access to the lower-level WebGraphicsContext3D, // which is needed for subordinate contexts like WebGL's to share resources @@ -83,12 +82,6 @@ public: bool isResourceSafe(); - // GL_CHROMIUM_gpu_memory_manager - void setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM>); - - // GL_CHROMIUM_swapbuffers_complete_callback - void setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM>); - bool preserveDrawingBuffer() const { return m_preserveDrawingBuffer; } private: @@ -100,8 +93,7 @@ private: OwnPtr<Extensions3DChromium> m_extensions; OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAdapter; OwnPtr<GraphicsContext3DErrorMessageCallbackAdapter> m_errorMessageCallbackAdapter; - OwnPtr<GraphicsContext3DMemoryAllocationChangedCallbackAdapter> m_memoryAllocationChangedCallbackAdapter; - OwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> m_swapBuffersCompleteCallbackAdapter; + OwnPtr<GrMemoryAllocationChangedCallbackAdapter> m_grContextMemoryAllocationCallbackAdapter; bool m_initializedAvailableExtensions; HashSet<String> m_enabledExtensions; HashSet<String> m_requestableExtensions; diff --git a/Source/WebCore/platform/efl/EflScreenUtilities.cpp b/Source/WebCore/platform/efl/EflScreenUtilities.cpp index e4a727797..e7cd1e46d 100644 --- a/Source/WebCore/platform/efl/EflScreenUtilities.cpp +++ b/Source/WebCore/platform/efl/EflScreenUtilities.cpp @@ -127,6 +127,23 @@ int getDPI() #endif } +int getPixelDepth(const Evas* evas) +{ +#ifdef HAVE_ECORE_X + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(evas); + // FIXME: ecore_evas_software_x11_window_get() can't get Ecore_X_Window during the layout test. + // Because, EFL DumpRenderTree doesn't use X11 window by default. + // See also, http://trac.webkit.org/browser/trunk/Tools/DumpRenderTree/efl/DumpRenderTree.cpp#L69 + Ecore_X_Window window = ecore_evas_software_x11_window_get(ecoreEvas); + if (!window) + return 8; + + return ecore_x_window_depth_get(window); +#else + return 8; +#endif +} + bool isUsingEcoreX(const Evas* evas) { #ifdef HAVE_ECORE_X diff --git a/Source/WebCore/platform/efl/EflScreenUtilities.h b/Source/WebCore/platform/efl/EflScreenUtilities.h index 6ec60ef02..ebf52b64a 100644 --- a/Source/WebCore/platform/efl/EflScreenUtilities.h +++ b/Source/WebCore/platform/efl/EflScreenUtilities.h @@ -27,6 +27,7 @@ namespace WebCore { void applyFallbackCursor(Ecore_Evas*, const char*); int getDPI(); +int getPixelDepth(const Evas*); bool isUsingEcoreX(const Evas*); } // namespace WebCore diff --git a/Source/WebCore/platform/efl/FileSystemEfl.cpp b/Source/WebCore/platform/efl/FileSystemEfl.cpp index d4adb169b..c6bff150a 100644 --- a/Source/WebCore/platform/efl/FileSystemEfl.cpp +++ b/Source/WebCore/platform/efl/FileSystemEfl.cpp @@ -86,50 +86,19 @@ String homeDirectoryPath() Vector<String> listDirectory(const String& path, const String& filter) { - Vector<String> entries; - CString cpath = path.utf8(); + Vector<String> matchingEntries; CString cfilter = filter.utf8(); - char filePath[PATH_MAX]; - char* fileName; - size_t fileNameSpace; - DIR* dir; + const char *f_name; - if (cpath.length() + NAME_MAX >= sizeof(filePath)) - return entries; - // loop invariant: directory part + '/' - memcpy(filePath, cpath.data(), cpath.length()); - fileName = filePath + cpath.length(); - if (cpath.length() > 0 && filePath[cpath.length() - 1] != '/') { - fileName[0] = '/'; - fileName++; + Eina_Iterator* it = eina_file_ls(path.utf8().data()); + EINA_ITERATOR_FOREACH(it, f_name) { + if (!fnmatch(cfilter.data(), f_name, 0)) + matchingEntries.append(String::fromUTF8(f_name)); + eina_stringshare_del(f_name); } - fileNameSpace = sizeof(filePath) - (fileName - filePath) - 1; + eina_iterator_free(it); - dir = opendir(cpath.data()); - if (!dir) - return entries; - - struct dirent* de; - while (de = readdir(dir)) { - size_t nameLen; - if (de->d_name[0] == '.') { - if (de->d_name[1] == '\0') - continue; - if (de->d_name[1] == '.' && de->d_name[2] == '\0') - continue; - } - if (fnmatch(cfilter.data(), de->d_name, 0)) - continue; - - nameLen = strlen(de->d_name); - if (nameLen >= fileNameSpace) - continue; // maybe assert? it should never happen anyway... - - memcpy(fileName, de->d_name, nameLen + 1); - entries.append(filePath); - } - closedir(dir); - return entries; + return matchingEntries; } } diff --git a/Source/WebCore/platform/efl/PlatformScreenEfl.cpp b/Source/WebCore/platform/efl/PlatformScreenEfl.cpp index ca655fbc1..5010f1851 100644 --- a/Source/WebCore/platform/efl/PlatformScreenEfl.cpp +++ b/Source/WebCore/platform/efl/PlatformScreenEfl.cpp @@ -34,6 +34,7 @@ #include "config.h" #include "PlatformScreen.h" +#include "EflScreenUtilities.h" #include "NotImplemented.h" #include "PlatformString.h" #include "Widget.h" @@ -57,14 +58,19 @@ int screenVerticalDPI(Widget* widget) int screenDepth(Widget* widget) { - notImplemented(); - return 8; + if (!widget || !widget->evas()) + return 0; + + return getPixelDepth(widget->evas()); } -int screenDepthPerComponent(Widget*) +int screenDepthPerComponent(Widget* widget) { - notImplemented(); - return 8; + if (!widget || !widget->evas()) + return 0; + + // FIXME: How to support this functionality based on EFL library ? + return getPixelDepth(widget->evas()); } bool screenIsMonochrome(Widget*) diff --git a/Source/WebCore/platform/efl/SharedBufferEfl.cpp b/Source/WebCore/platform/efl/SharedBufferEfl.cpp index 9e7646d1c..8db44a654 100644 --- a/Source/WebCore/platform/efl/SharedBufferEfl.cpp +++ b/Source/WebCore/platform/efl/SharedBufferEfl.cpp @@ -39,32 +39,24 @@ namespace WebCore { PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath) { - FILE* file; - struct stat fileStat; - RefPtr<SharedBuffer> result; - if (filePath.isEmpty()) return 0; - if (!(file = fopen(filePath.utf8().data(), "rb"))) + FILE* file = fopen(filePath.utf8().data(), "rb"); + if (!file) return 0; + struct stat fileStat; if (fstat(fileno(file), &fileStat)) { fclose(file); return 0; } - result = SharedBuffer::create(); - result->m_buffer.resize(fileStat.st_size); - if (result->m_buffer.size() != static_cast<unsigned>(fileStat.st_size)) { - fclose(file); - return 0; - } - - const size_t bytesRead = fread(result->m_buffer.data(), 1, fileStat.st_size, file); + Vector<char> buffer(fileStat.st_size); + const size_t bytesRead = fread(buffer.data(), 1, buffer.size(), file); fclose(file); - return bytesRead == static_cast<unsigned>(fileStat.st_size) ? result.release() : 0; + return (bytesRead == buffer.size()) ? SharedBuffer::adoptVector(buffer) : 0; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp index 73848bd1c..c93166659 100644 --- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp +++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp @@ -32,11 +32,11 @@ namespace WebCore { - -ANGLEWebKitBridge::ANGLEWebKitBridge() : +ANGLEWebKitBridge::ANGLEWebKitBridge(ShShaderOutput shaderOutput) : builtCompilers(false), m_fragmentCompiler(0), - m_vertexCompiler(0) + m_vertexCompiler(0), + m_shaderOutput(shaderOutput) { ShInitialize(); } @@ -69,8 +69,8 @@ void ANGLEWebKitBridge::setResources(ShBuiltInResources resources) bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog) { if (!builtCompilers) { - m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_WEBGL_SPEC, SH_GLSL_OUTPUT, &m_resources); - m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_WEBGL_SPEC, SH_GLSL_OUTPUT, &m_resources); + m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_WEBGL_SPEC, m_shaderOutput, &m_resources); + m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_WEBGL_SPEC, m_shaderOutput, &m_resources); if (!m_fragmentCompiler || !m_vertexCompiler) { cleanupCompilers(); return false; diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h index 7d6ad7895..d75b5f298 100644 --- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h +++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h @@ -47,7 +47,7 @@ enum ANGLEShaderType { class ANGLEWebKitBridge { public: - ANGLEWebKitBridge(); + ANGLEWebKitBridge(ShShaderOutput = SH_GLSL_OUTPUT); ~ANGLEWebKitBridge(); ShBuiltInResources getResources() { return m_resources; } @@ -64,6 +64,8 @@ private: ShHandle m_fragmentCompiler; ShHandle m_vertexCompiler; + ShShaderOutput m_shaderOutput; + ShBuiltInResources m_resources; }; diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h index 2f1969e43..64c81c791 100644 --- a/Source/WebCore/platform/graphics/BitmapImage.h +++ b/Source/WebCore/platform/graphics/BitmapImage.h @@ -272,8 +272,8 @@ protected: mutable IntSize m_sizeRespectingOrientation; size_t m_currentFrame; // The index of the current frame of animation. - Vector<FrameData> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache. - + Vector<FrameData, 1> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache. + Timer<BitmapImage>* m_frameTimer; int m_repetitionCount; // How many total animation loops we should do. This will be cAnimationNone if this image type is incapable of animation. RepetitionCountStatus m_repetitionCountStatus; diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h index b6c1b6441..dbd9dfede 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h @@ -555,7 +555,7 @@ public: // return the suggested GL error indicating the cause of the failure: // INVALID_VALUE if width/height is negative or overflow happens. // INVALID_ENUM if format/type is illegal. - GC3Denum computeImageSizeInBytes(GC3Denum format, + static GC3Denum computeImageSizeInBytes(GC3Denum format, GC3Denum type, GC3Dsizei width, GC3Dsizei height, @@ -567,7 +567,7 @@ public: // packing the pixel data according to the given format and type, // and obeying the flipY, premultiplyAlpha, and ignoreGammaAndColorProfile // flags. Returns true upon success. - bool extractImageData(Image* image, + static bool extractImageData(Image*, GC3Denum format, GC3Denum type, bool flipY, @@ -579,7 +579,7 @@ public: // packing the pixel data according to the given format and type, // and obeying the flipY and premultiplyAlpha flags. Returns true // upon success. - bool extractImageData(ImageData*, + static bool extractImageData(ImageData*, GC3Denum format, GC3Denum type, bool flipY, @@ -591,7 +591,7 @@ public: // If the data is not tightly packed according to the passed // unpackAlignment, the output data will be tightly packed. // Returns true if successful, false if any error occurred. - bool extractTextureData(unsigned int width, unsigned int height, + static bool extractTextureData(unsigned int width, unsigned int height, GC3Denum format, GC3Denum type, unsigned int unpackAlignment, bool flipY, bool premultiplyAlpha, @@ -599,7 +599,7 @@ public: Vector<uint8_t>& data); // Flips the given image data vertically, in-place. - void flipVertically(void* imageData, + static void flipVertically(void* imageData, unsigned int width, unsigned int height, unsigned int bytesPerPixel, @@ -888,7 +888,7 @@ public: // // No vertical flip of the image data is performed by this // method. - bool getImageData(Image* image, + static bool getImageData(Image*, GC3Denum format, GC3Denum type, bool premultiplyAlpha, @@ -909,7 +909,7 @@ public: // A sourceUnpackAlignment of zero indicates that the source // data is tightly packed. Non-zero values may take a slow path. // Destination data will have no gaps between rows. - bool packPixels(const uint8_t* sourceData, + static bool packPixels(const uint8_t* sourceData, SourceDataFormat sourceDataFormat, unsigned int width, unsigned int height, diff --git a/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h b/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h index 82787f400..ff7ed7e29 100644 --- a/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h +++ b/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h @@ -90,49 +90,12 @@ public: COMMANDS_ISSUED_CHROMIUM = 0x84F2 }; - // GL_CHROMIUM_post_sub_buffer - void postSubBufferCHROMIUM(int x, int y, int width, int height); - // GL_CHROMIUM_map_sub void* mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access); void unmapBufferSubDataCHROMIUM(const void*); void* mapTexSubImage2DCHROMIUM(unsigned target, int level, int xoffset, int yoffset, int width, int height, unsigned format, unsigned type, unsigned access); void unmapTexSubImage2DCHROMIUM(const void*); - // GL_CHROMIUM_set_visibility - void setVisibilityCHROMIUM(bool); - - // GL_EXT_discard_framebuffer - virtual void discardFramebufferEXT(GC3Denum target, GC3Dsizei numAttachments, const GC3Denum* attachments); - virtual void ensureFramebufferCHROMIUM(); - - // GL_CHROMIUM_gpu_memory_manager - struct GpuMemoryAllocationCHROMIUM { - size_t gpuResourceSizeInBytes; - bool suggestHaveBackbuffer; - - GpuMemoryAllocationCHROMIUM(size_t gpuResourceSizeInBytes, bool suggestHaveBackbuffer) - : gpuResourceSizeInBytes(gpuResourceSizeInBytes) - , suggestHaveBackbuffer(suggestHaveBackbuffer) - { - } - }; - class GpuMemoryAllocationChangedCallbackCHROMIUM { - public: - - virtual void onGpuMemoryAllocationChanged(GpuMemoryAllocationCHROMIUM) = 0; - virtual ~GpuMemoryAllocationChangedCallbackCHROMIUM() { } - }; - void setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<GpuMemoryAllocationChangedCallbackCHROMIUM>); - - // GL_CHROMIUM_swapbuffers_complete_callback - class SwapBuffersCompleteCallbackCHROMIUM { - public: - virtual void onSwapBuffersComplete() = 0; - virtual ~SwapBuffersCompleteCallbackCHROMIUM() { } - }; - void setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr<SwapBuffersCompleteCallbackCHROMIUM>); - // GL_CHROMIUM_rate_limit_offscreen_context void rateLimitOffscreenContextCHROMIUM(); diff --git a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp index a2c43ce1b..743bcc1f7 100644 --- a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp +++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp @@ -31,9 +31,10 @@ #include "FrameBufferSkPictureCanvasLayerTextureUpdater.h" #include "LayerPainterChromium.h" +#include "SharedGraphicsContext3D.h" #include "SkCanvas.h" #include "SkGpuDevice.h" -#include "cc/CCGraphicsContext.h" +#include "cc/CCProxy.h" namespace WebCore { @@ -67,9 +68,12 @@ FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture() { } -void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCGraphicsContext* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect) +void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCGraphicsContext*, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect) { - textureUpdater()->updateTextureRect(context, allocator, texture(), sourceRect, destRect); + RefPtr<GraphicsContext3D> sharedContext = CCProxy::hasImplThread() ? SharedGraphicsContext3D::getForImplThread() : SharedGraphicsContext3D::get(); + if (!sharedContext) + return; + textureUpdater()->updateTextureRect(sharedContext.release(), allocator, texture(), sourceRect, destRect); } PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> FrameBufferSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter) @@ -97,21 +101,15 @@ LayerTextureUpdater::SampledTexelFormat FrameBufferSkPictureCanvasLayerTextureUp return LayerTextureUpdater::SampledTexelFormatRGBA; } -void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(CCGraphicsContext* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) +void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(PassRefPtr<GraphicsContext3D> prpContext, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { - GraphicsContext3D* context3d = context->context3D(); - if (!context3d) { - // FIXME: Implement this path for software compositing. - return; - } + RefPtr<GraphicsContext3D> context(prpContext); // Make sure ganesh uses the correct GL context. - context3d->makeContextCurrent(); - // Notify ganesh to sync its internal GL state. - context3d->grContext()->resetContext(); + context->makeContextCurrent(); // Create an accelerated canvas to draw on. - OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context3d, allocator, texture); + OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context.get(), allocator, texture); // The compositor expects the textures to be upside-down so it can flip // the final composited image. Ganesh renders the image upright so we @@ -127,7 +125,10 @@ void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(CCGraphics drawPicture(canvas.get()); // Flush ganesh context so that all the rendered stuff appears on the texture. - context3d->grContext()->flush(); + context->grContext()->flush(); + + // Flush the GL context so rendering results from this context are visible in the compositor's context. + context->flush(); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h index abeaf523d..1f2f20cce 100644 --- a/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h +++ b/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h @@ -56,7 +56,7 @@ public: virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*) OVERRIDE; virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) OVERRIDE; - void updateTextureRect(CCGraphicsContext*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); + void updateTextureRect(PassRefPtr<GraphicsContext3D>, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); private: explicit FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>); diff --git a/Source/WebCore/platform/graphics/chromium/GeometryBinding.cpp b/Source/WebCore/platform/graphics/chromium/GeometryBinding.cpp index a859aae73..1a4568bb0 100644 --- a/Source/WebCore/platform/graphics/chromium/GeometryBinding.cpp +++ b/Source/WebCore/platform/graphics/chromium/GeometryBinding.cpp @@ -29,13 +29,13 @@ #include "GeometryBinding.h" -#include "GraphicsContext.h" #include "GraphicsContext3D.h" #include "LayerRendererChromium.h" +#include <public/WebGraphicsContext3D.h> namespace WebCore { -GeometryBinding::GeometryBinding(GraphicsContext3D* context) +GeometryBinding::GeometryBinding(WebKit::WebGraphicsContext3D* context) : m_context(context) , m_quadVerticesVbo(0) , m_quadElementsVbo(0) diff --git a/Source/WebCore/platform/graphics/chromium/GeometryBinding.h b/Source/WebCore/platform/graphics/chromium/GeometryBinding.h index ec199703e..20b2d5a00 100644 --- a/Source/WebCore/platform/graphics/chromium/GeometryBinding.h +++ b/Source/WebCore/platform/graphics/chromium/GeometryBinding.h @@ -28,20 +28,20 @@ #if USE(ACCELERATED_COMPOSITING) -#include "PlatformString.h" +namespace WebKit { +class WebGraphicsContext3D; +} namespace WebCore { -class GraphicsContext3D; - class GeometryBinding { public: - explicit GeometryBinding(GraphicsContext3D*); + explicit GeometryBinding(WebKit::WebGraphicsContext3D*); ~GeometryBinding(); bool initialized() const { return m_initialized; } - GraphicsContext3D* context() const { return m_context; } + WebKit::WebGraphicsContext3D* context() const { return m_context; } unsigned quadVerticesVbo() const { return m_quadVerticesVbo; } unsigned quadElementsVbo() const { return m_quadElementsVbo; } @@ -54,7 +54,7 @@ public: static int texCoordAttribLocation() { return 1; } private: - GraphicsContext3D* m_context; + WebKit::WebGraphicsContext3D* m_context; unsigned m_quadVerticesVbo; unsigned m_quadElementsVbo; bool m_initialized; diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp index 5aed1c7f9..1a4038a4f 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp @@ -228,7 +228,7 @@ void LayerChromium::setBounds(const IntSize& size) if (bounds() == size) return; - bool firstResize = !bounds().width() && !bounds().height() && size.width() && size.height(); + bool firstResize = bounds().isEmpty() && !size.isEmpty(); m_bounds = size; diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp index 595cae2e9..ca2d1902a 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp @@ -38,7 +38,6 @@ #include "FloatQuad.h" #include "GeometryBinding.h" #include "GrTexture.h" -#include "GraphicsContext3D.h" #include "ManagedTexture.h" #include "NativeImageSkia.h" #include "NotImplemented.h" @@ -67,11 +66,15 @@ #include "cc/CCTileDrawQuad.h" #include "cc/CCVideoLayerImpl.h" #include "cc/CCYUVVideoDrawQuad.h" +#include <public/WebGraphicsContext3D.h> #include <public/WebVideoFrame.h> #include <wtf/CurrentTime.h> #include <wtf/MainThread.h> +#include <wtf/text/StringHash.h> using namespace std; +using WebKit::WebGraphicsContext3D; +using WebKit::WebGraphicsMemoryAllocation; using WebKit::WebTransformationMatrix; namespace WebCore { @@ -112,35 +115,10 @@ static WebTransformationMatrix screenMatrix(int x, int y, int width, int height) return screen; } -bool contextSupportsAcceleratedPainting(GraphicsContext3D* context) -{ - WebCore::Extensions3D* extensions = context->getExtensions(); - if (extensions->supports("GL_EXT_texture_format_BGRA8888")) - extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888"); - else - return false; - - if (extensions->supports("GL_EXT_read_format_bgra")) - extensions->ensureEnabled("GL_EXT_read_format_bgra"); - else - return false; - - if (!context->grContext()) - return false; - - return true; -} - -bool needsLionIOSurfaceReadbackWorkaround() +bool needsIOSurfaceReadbackWorkaround() { #if OS(DARWIN) - static SInt32 systemVersion = 0; - if (!systemVersion) { - if (Gestalt(gestaltSystemVersion, &systemVersion) != noErr) - return false; - } - - return systemVersion >= 0x1070; + return true; #else return false; #endif @@ -166,66 +144,7 @@ protected: } // anonymous namespace -class LayerRendererSwapBuffersCompleteCallbackAdapter : public Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM { -public: - static PassOwnPtr<LayerRendererSwapBuffersCompleteCallbackAdapter> create(LayerRendererChromium* layerRenderer) - { - return adoptPtr(new LayerRendererSwapBuffersCompleteCallbackAdapter(layerRenderer)); - } - virtual ~LayerRendererSwapBuffersCompleteCallbackAdapter() { } - - virtual void onSwapBuffersComplete() - { - m_layerRenderer->onSwapBuffersComplete(); - } - -private: - explicit LayerRendererSwapBuffersCompleteCallbackAdapter(LayerRendererChromium* layerRenderer) - { - m_layerRenderer = layerRenderer; - } - - LayerRendererChromium* m_layerRenderer; -}; - -class LayerRendererGpuMemoryAllocationChangedCallbackAdapter : public Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM { -public: - static PassOwnPtr<LayerRendererGpuMemoryAllocationChangedCallbackAdapter> create(LayerRendererChromium* layerRenderer) - { - return adoptPtr(new LayerRendererGpuMemoryAllocationChangedCallbackAdapter(layerRenderer)); - } - virtual ~LayerRendererGpuMemoryAllocationChangedCallbackAdapter() { } - - virtual void onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation) - { - // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread. - if (m_bindToImplThread) { - ASSERT(CCProxy::isMainThread()); - DebugScopedSetImplThread impl; - onGpuMemoryAllocationChangedOnImpl(allocation); - } else { - ASSERT(CCProxy::isImplThread()); - onGpuMemoryAllocationChangedOnImpl(allocation); - } - } - -private: - explicit LayerRendererGpuMemoryAllocationChangedCallbackAdapter(LayerRendererChromium* layerRenderer) - : m_layerRenderer(layerRenderer), m_bindToImplThread(!CCProxy::hasImplThread()) - { - } - - void onGpuMemoryAllocationChangedOnImpl(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation) - { - ASSERT(CCProxy::isImplThread()); - m_layerRenderer->setGpuMemoryAllocation(allocation); - } - - LayerRendererChromium* m_layerRenderer; - bool m_bindToImplThread; -}; - -PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(CCRendererClient* client, PassRefPtr<GraphicsContext3D> context, TextureUploaderOption textureUploaderSetting) +PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(CCRendererClient* client, WebGraphicsContext3D* context, TextureUploaderOption textureUploaderSetting) { OwnPtr<LayerRendererChromium> layerRenderer(adoptPtr(new LayerRendererChromium(client, context, textureUploaderSetting))); if (!layerRenderer->initialize()) @@ -235,7 +154,7 @@ PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(CCRendererClient } LayerRendererChromium::LayerRendererChromium(CCRendererClient* client, - PassRefPtr<GraphicsContext3D> context, + WebGraphicsContext3D* context, TextureUploaderOption textureUploaderSetting) : CCRenderer(client) , m_currentRenderPass(0) @@ -249,96 +168,65 @@ LayerRendererChromium::LayerRendererChromium(CCRendererClient* client, , m_visible(true) , m_textureUploaderSetting(textureUploaderSetting) { - ASSERT(m_context.get()); + ASSERT(m_context); } -class ContextLostCallbackAdapter : public GraphicsContext3D::ContextLostCallback { -public: - static PassOwnPtr<ContextLostCallbackAdapter> create(CCRendererClient* client) - { - return adoptPtr(new ContextLostCallbackAdapter(client)); - } - - virtual void onContextLost() - { - m_client->didLoseContext(); - } - -private: - explicit ContextLostCallbackAdapter(CCRendererClient* client) - : m_client(client) { } - - CCRendererClient* m_client; -}; - bool LayerRendererChromium::initialize() { if (!m_context->makeContextCurrent()) return false; - m_context->setContextLostCallback(ContextLostCallbackAdapter::create(m_client)); + m_context->setContextLostCallback(this); + + String extensionsString = m_context->getString(GraphicsContext3D::EXTENSIONS); + Vector<String> extensionsList; + extensionsString.split(' ', extensionsList); + HashSet<String> extensions; + for (size_t i = 0; i < extensionsList.size(); ++i) + extensions.add(extensionsList[i]); - if (settings().acceleratePainting && contextSupportsAcceleratedPainting(m_context.get())) + if (settings().acceleratePainting && extensions.contains("GL_EXT_texture_format_BGRA8888") + && extensions.contains("GL_EXT_read_format_bgra")) m_capabilities.usingAcceleratedPainting = true; + else + m_capabilities.usingAcceleratedPainting = false; - WebCore::Extensions3D* extensions = m_context->getExtensions(); - m_capabilities.contextHasCachedFrontBuffer = extensions->supports("GL_CHROMIUM_front_buffer_cached"); - if (m_capabilities.contextHasCachedFrontBuffer) - extensions->ensureEnabled("GL_CHROMIUM_front_buffer_cached"); - m_capabilities.usingPartialSwap = CCSettings::partialSwapEnabled() && extensions->supports("GL_CHROMIUM_post_sub_buffer"); - if (m_capabilities.usingPartialSwap) - extensions->ensureEnabled("GL_CHROMIUM_post_sub_buffer"); + m_capabilities.contextHasCachedFrontBuffer = extensions.contains("GL_CHROMIUM_front_buffer_cached"); - m_capabilities.usingMapSub = extensions->supports("GL_CHROMIUM_map_sub"); - if (m_capabilities.usingMapSub) - extensions->ensureEnabled("GL_CHROMIUM_map_sub"); + m_capabilities.usingPartialSwap = CCSettings::partialSwapEnabled() && extensions.contains("GL_CHROMIUM_post_sub_buffer"); + + m_capabilities.usingMapSub = extensions.contains("GL_CHROMIUM_map_sub"); // Use the swapBuffers callback only with the threaded proxy. if (CCProxy::hasImplThread()) - m_capabilities.usingSwapCompleteCallback = extensions->supports("GL_CHROMIUM_swapbuffers_complete_callback"); + m_capabilities.usingSwapCompleteCallback = extensions.contains("GL_CHROMIUM_swapbuffers_complete_callback"); if (m_capabilities.usingSwapCompleteCallback) { - extensions->ensureEnabled("GL_CHROMIUM_swapbuffers_complete_callback"); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions); - extensions3DChromium->setSwapBuffersCompleteCallbackCHROMIUM(LayerRendererSwapBuffersCompleteCallbackAdapter::create(this)); + m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); } - if (extensions->supports("GL_EXT_texture_format_BGRA8888")) - extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888"); - - m_capabilities.usingSetVisibility = extensions->supports("GL_CHROMIUM_set_visibility"); - if (m_capabilities.usingSetVisibility) - extensions->ensureEnabled("GL_CHROMIUM_set_visibility"); + m_capabilities.usingSetVisibility = extensions.contains("GL_CHROMIUM_set_visibility"); - if (extensions->supports("GL_CHROMIUM_iosurface")) { - ASSERT(extensions->supports("GL_ARB_texture_rectangle")); - extensions->ensureEnabled("GL_ARB_texture_rectangle"); - extensions->ensureEnabled("GL_CHROMIUM_iosurface"); + if (extensions.contains("GL_CHROMIUM_iosurface")) { + ASSERT(extensions.contains("GL_ARB_texture_rectangle")); } - m_capabilities.usingTextureUsageHint = extensions->supports("GL_ANGLE_texture_usage"); - if (m_capabilities.usingTextureUsageHint) - extensions->ensureEnabled("GL_ANGLE_texture_usage"); + m_capabilities.usingTextureUsageHint = extensions.contains("GL_ANGLE_texture_usage"); - m_capabilities.usingTextureStorageExtension = extensions->supports("GL_EXT_texture_storage"); - if (m_capabilities.usingTextureStorageExtension) - extensions->ensureEnabled("GL_EXT_texture_storage"); + m_capabilities.usingTextureStorageExtension = extensions.contains("GL_EXT_texture_storage"); - m_capabilities.usingGpuMemoryManager = extensions->supports("GL_CHROMIUM_gpu_memory_manager"); - if (m_capabilities.usingGpuMemoryManager) { - extensions->ensureEnabled("GL_CHROMIUM_gpu_memory_manager"); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions); - extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(LayerRendererGpuMemoryAllocationChangedCallbackAdapter::create(this)); - } else { + m_capabilities.usingGpuMemoryManager = extensions.contains("GL_CHROMIUM_gpu_memory_manager"); + if (m_capabilities.usingGpuMemoryManager) + m_context->setMemoryAllocationChangedCallbackCHROMIUM(this); + else m_client->setMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize())); - } - m_capabilities.usingDiscardFramebuffer = extensions->supports("GL_CHROMIUM_discard_framebuffer"); - if (m_capabilities.usingDiscardFramebuffer) - extensions->ensureEnabled("GL_CHROMIUM_discard_framebuffer"); + m_capabilities.usingDiscardFramebuffer = extensions.contains("GL_CHROMIUM_discard_framebuffer"); + + m_capabilities.usingEglImage = extensions.contains("GL_OES_EGL_image_external"); GLC(m_context, m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_capabilities.maxTextureSize)); - m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context.get()); + m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context, extensions.contains("GL_EXT_texture_format_BGRA8888")); if (!initializeSharedObjects()) return false; @@ -351,18 +239,18 @@ bool LayerRendererChromium::initialize() LayerRendererChromium::~LayerRendererChromium() { ASSERT(CCProxy::isImplThread()); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(m_context->getExtensions()); - extensions3DChromium->setSwapBuffersCompleteCallbackCHROMIUM(nullptr); - extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(nullptr); + m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); + m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); + m_context->setContextLostCallback(0); cleanupSharedObjects(); } -GraphicsContext3D* LayerRendererChromium::context() +WebGraphicsContext3D* LayerRendererChromium::context() { - return m_context.get(); + return m_context; } -void LayerRendererChromium::debugGLCall(GraphicsContext3D* context, const char* command, const char* file, int line) +void LayerRendererChromium::debugGLCall(WebGraphicsContext3D* context, const char* command, const char* file, int line) { unsigned long error = context->getError(); if (error != GraphicsContext3D::NO_ERROR) @@ -378,8 +266,7 @@ void LayerRendererChromium::setVisible(bool visible) // TODO: Replace setVisibilityCHROMIUM with an extension to explicitly manage front/backbuffers // crbug.com/116049 if (m_capabilities.usingSetVisibility) { - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(m_context->getExtensions()); - extensions3DChromium->setVisibilityCHROMIUM(visible); + m_context->setVisibilityCHROMIUM(visible); } } @@ -1047,7 +934,7 @@ void LayerRendererChromium::drawStreamVideoQuad(const CCStreamVideoDrawQuad* qua { static float glMatrix[16]; - ASSERT(context()->getExtensions()->supports("GL_OES_EGL_image_external") && context()->getExtensions()->isEnabled("GL_OES_EGL_image_external")); + ASSERT(m_capabilities.usingEglImage); const VideoStreamTextureProgram* program = videoStreamTextureProgram(); GLC(context(), context()->useProgram(program->program())); @@ -1165,8 +1052,9 @@ void LayerRendererChromium::drawHeadsUpDisplay(ManagedTexture* hudTexture, const const HeadsUpDisplayProgram* program = headsUpDisplayProgram(); ASSERT(program && program->initialized()); GLC(m_context, m_context->activeTexture(GraphicsContext3D::TEXTURE0)); - RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(m_context); - hudTexture->bindTexture(ccContext.get(), m_implTextureAllocator.get()); + if (!hudTexture->textureId()) + hudTexture->allocate(m_implTextureAllocator.get()); + GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, hudTexture->textureId())); GLC(m_context, m_context->useProgram(program->program())); GLC(m_context, m_context->uniform1i(program->fragmentShader().samplerLocation(), 0)); @@ -1184,12 +1072,6 @@ void LayerRendererChromium::finishDrawingFrame() GLC(m_context, m_context->disable(GraphicsContext3D::BLEND)); m_implTextureManager->unprotectAllTextures(); - - size_t contentsMemoryUseBytes = m_contentsTextureAllocator->currentMemoryUseBytes(); - size_t reclaimLimit = TextureManager::reclaimLimitBytes(viewportSize()); - size_t preferredLimit = reclaimLimit > contentsMemoryUseBytes ? reclaimLimit - contentsMemoryUseBytes : 0; - m_implTextureManager->setPreferredMemoryLimitBytes(preferredLimit); - m_implTextureManager->reduceMemoryToLimit(preferredLimit); m_implTextureManager->deleteEvictedTextures(m_implTextureAllocator.get()); } @@ -1267,22 +1149,6 @@ void LayerRendererChromium::copyTextureToFramebuffer(int textureId, const IntSiz -1); } -void LayerRendererChromium::setGpuMemoryAllocation(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation) -{ - if (m_visible && !allocation.gpuResourceSizeInBytes) - return; - - if (!allocation.suggestHaveBackbuffer && !m_visible) - discardFramebuffer(); - - if (!allocation.gpuResourceSizeInBytes) { - releaseRenderPassTextures(); - m_client->releaseContentsTextures(); - GLC(m_context, m_context->flush()); - } else - m_client->setMemoryAllocationLimitBytes(allocation.gpuResourceSizeInBytes); -} - void LayerRendererChromium::finish() { TRACE_EVENT("LayerRendererChromium::finish", this, 0); @@ -1301,12 +1167,11 @@ bool LayerRendererChromium::swapBuffers(const IntRect& subBuffer) // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport) IntRect clippedSubBuffer = subBuffer; clippedSubBuffer.intersect(IntRect(IntPoint::zero(), viewportSize())); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(m_context->getExtensions()); int flippedYPosOfRectBottom = viewportHeight() - clippedSubBuffer.y() - clippedSubBuffer.height(); - extensions3DChromium->postSubBufferCHROMIUM(clippedSubBuffer.x(), flippedYPosOfRectBottom, clippedSubBuffer.width(), clippedSubBuffer.height()); + m_context->postSubBufferCHROMIUM(clippedSubBuffer.x(), flippedYPosOfRectBottom, clippedSubBuffer.width(), clippedSubBuffer.height()); } else // Note that currently this has the same effect as swapBuffers; we should - // consider exposing a different entry point on GraphicsContext3D. + // consider exposing a different entry point on WebGraphicsContext3D. m_context->prepareTexture(); return true; @@ -1317,6 +1182,35 @@ void LayerRendererChromium::onSwapBuffersComplete() m_client->onSwapBuffersComplete(); } +void LayerRendererChromium::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocation) +{ + // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread. + if (!CCProxy::hasImplThread()) { + ASSERT(CCProxy::isMainThread()); + DebugScopedSetImplThread impl; + onMemoryAllocationChangedOnImplThread(allocation); + } else { + ASSERT(CCProxy::isImplThread()); + onMemoryAllocationChangedOnImplThread(allocation); + } +} + +void LayerRendererChromium::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation allocation) +{ + if (m_visible && !allocation.gpuResourceSizeInBytes) + return; + + if (!allocation.suggestHaveBackbuffer && !m_visible) + discardFramebuffer(); + + if (!allocation.gpuResourceSizeInBytes) { + releaseRenderPassTextures(); + m_client->releaseContentsTextures(); + GLC(m_context, m_context->flush()); + } else + m_client->setMemoryAllocationLimitBytes(allocation.gpuResourceSizeInBytes); +} + void LayerRendererChromium::discardFramebuffer() { if (m_isFramebufferDiscarded) @@ -1325,10 +1219,8 @@ void LayerRendererChromium::discardFramebuffer() if (!m_capabilities.usingDiscardFramebuffer) return; - Extensions3D* extensions = m_context->getExtensions(); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions); // FIXME: Update attachments argument to appropriate values once they are no longer ignored. - extensions3DChromium->discardFramebufferEXT(GraphicsContext3D::TEXTURE_2D, 0, 0); + m_context->discardFramebufferEXT(GraphicsContext3D::TEXTURE_2D, 0, 0); m_isFramebufferDiscarded = true; // Damage tracker needs a full reset every time framebuffer is discarded. @@ -1343,12 +1235,16 @@ void LayerRendererChromium::ensureFramebuffer() if (!m_capabilities.usingDiscardFramebuffer) return; - Extensions3D* extensions = m_context->getExtensions(); - Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions); - extensions3DChromium->ensureFramebufferCHROMIUM(); + m_context->ensureFramebufferCHROMIUM(); m_isFramebufferDiscarded = false; } +void LayerRendererChromium::onContextLost() +{ + m_client->didLoseContext(); +} + + void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& rect) { ASSERT(rect.maxX() <= viewportWidth() && rect.maxY() <= viewportHeight()); @@ -1358,43 +1254,42 @@ void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& re makeContextCurrent(); - bool doWorkaround = needsLionIOSurfaceReadbackWorkaround(); + bool doWorkaround = needsIOSurfaceReadbackWorkaround(); Platform3DObject temporaryTexture = NullPlatform3DObject; Platform3DObject temporaryFBO = NullPlatform3DObject; - GraphicsContext3D* context = m_context.get(); if (doWorkaround) { - // On Mac OS X 10.7, calling glReadPixels against an FBO whose color attachment is an + // On Mac OS X, calling glReadPixels against an FBO whose color attachment is an // IOSurface-backed texture causes corruption of future glReadPixels calls, even those on // different OpenGL contexts. It is believed that this is the root cause of top crasher // http://crbug.com/99393. <rdar://problem/10949687> - temporaryTexture = context->createTexture(); - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, temporaryTexture)); - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); + temporaryTexture = m_context->createTexture(); + GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, temporaryTexture)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); // Copy the contents of the current (IOSurface-backed) framebuffer into a temporary texture. - GLC(context, context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, rect.maxX(), rect.maxY(), 0)); - temporaryFBO = context->createFramebuffer(); + GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, rect.maxX(), rect.maxY(), 0)); + temporaryFBO = m_context->createFramebuffer(); // Attach this texture to an FBO, and perform the readback from that FBO. - GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, temporaryFBO)); - GLC(context, context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, temporaryTexture, 0)); + GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, temporaryFBO)); + GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, temporaryTexture, 0)); - ASSERT(context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); + ASSERT(m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); } - GLC(context, context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(), + GLC(m_context, m_context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels)); if (doWorkaround) { // Clean up. - GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)); - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); - GLC(context, context->deleteFramebuffer(temporaryFBO)); - GLC(context, context->deleteTexture(temporaryTexture)); + GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)); + GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); + GLC(m_context, m_context->deleteFramebuffer(temporaryFBO)); + GLC(m_context, m_context->deleteTexture(temporaryTexture)); } if (!m_visible) { @@ -1411,8 +1306,9 @@ bool LayerRendererChromium::getFramebufferTexture(ManagedTexture* texture, const if (!texture->reserve(deviceRect.size(), GraphicsContext3D::RGB)) return false; - RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(m_context); - texture->bindTexture(ccContext.get(), m_implTextureAllocator.get()); + if (!texture->textureId()) + texture->allocate(m_implTextureAllocator.get()); + GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->textureId())); GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, texture->format(), deviceRect.x(), deviceRect.y(), deviceRect.width(), deviceRect.height(), 0)); return true; @@ -1452,8 +1348,9 @@ bool LayerRendererChromium::bindFramebufferToTexture(ManagedTexture* texture, co { GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_offscreenFramebufferId)); - RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(m_context); - texture->framebufferTexture2D(ccContext.get(), m_implTextureAllocator.get()); + if (!texture->textureId()) + texture->allocate(m_implTextureAllocator.get()); + GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->textureId(), 0)); #if !defined ( NDEBUG ) if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { @@ -1518,23 +1415,23 @@ bool LayerRendererChromium::initializeSharedObjects() // We will always need these programs to render, so create the programs eagerly so that the shader compilation can // start while we do other work. Other programs are created lazily on first access. - m_sharedGeometry = adoptPtr(new GeometryBinding(m_context.get())); - m_renderPassProgram = adoptPtr(new RenderPassProgram(m_context.get())); - m_tileProgram = adoptPtr(new TileProgram(m_context.get())); - m_tileProgramOpaque = adoptPtr(new TileProgramOpaque(m_context.get())); + m_sharedGeometry = adoptPtr(new GeometryBinding(m_context)); + m_renderPassProgram = adoptPtr(new RenderPassProgram(m_context)); + m_tileProgram = adoptPtr(new TileProgram(m_context)); + m_tileProgramOpaque = adoptPtr(new TileProgramOpaque(m_context)); GLC(m_context, m_context->flush()); m_implTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()), TextureManager::reclaimLimitBytes(viewportSize()), m_capabilities.maxTextureSize); - m_textureCopier = AcceleratedTextureCopier::create(m_context.get()); + m_textureCopier = AcceleratedTextureCopier::create(m_context); if (m_textureUploaderSetting == ThrottledUploader) - m_textureUploader = ThrottledTextureUploader::create(m_context.get()); + m_textureUploader = ThrottledTextureUploader::create(m_context); else m_textureUploader = UnthrottledTextureUploader::create(); - m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context.get()); - m_implTextureAllocator = TrackingTextureAllocator::create(m_context.get()); + m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context); + m_implTextureAllocator = TrackingTextureAllocator::create(m_context); if (m_capabilities.usingTextureUsageHint) m_implTextureAllocator->setTextureUsageHint(TrackingTextureAllocator::FramebufferAttachment); if (m_capabilities.usingTextureStorageExtension) { @@ -1548,10 +1445,10 @@ bool LayerRendererChromium::initializeSharedObjects() const LayerRendererChromium::TileCheckerboardProgram* LayerRendererChromium::tileCheckerboardProgram() { if (!m_tileCheckerboardProgram) - m_tileCheckerboardProgram = adoptPtr(new TileCheckerboardProgram(m_context.get())); + m_tileCheckerboardProgram = adoptPtr(new TileCheckerboardProgram(m_context)); if (!m_tileCheckerboardProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::checkerboardProgram::initalize", this, 0); - m_tileCheckerboardProgram->initialize(m_context.get()); + m_tileCheckerboardProgram->initialize(m_context); } return m_tileCheckerboardProgram.get(); } @@ -1559,10 +1456,10 @@ const LayerRendererChromium::TileCheckerboardProgram* LayerRendererChromium::til const LayerRendererChromium::SolidColorProgram* LayerRendererChromium::solidColorProgram() { if (!m_solidColorProgram) - m_solidColorProgram = adoptPtr(new SolidColorProgram(m_context.get())); + m_solidColorProgram = adoptPtr(new SolidColorProgram(m_context)); if (!m_solidColorProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::solidColorProgram::initialize", this, 0); - m_solidColorProgram->initialize(m_context.get()); + m_solidColorProgram->initialize(m_context); } return m_solidColorProgram.get(); } @@ -1570,10 +1467,10 @@ const LayerRendererChromium::SolidColorProgram* LayerRendererChromium::solidColo const LayerRendererChromium::HeadsUpDisplayProgram* LayerRendererChromium::headsUpDisplayProgram() { if (!m_headsUpDisplayProgram) - m_headsUpDisplayProgram = adoptPtr(new HeadsUpDisplayProgram(m_context.get())); + m_headsUpDisplayProgram = adoptPtr(new HeadsUpDisplayProgram(m_context)); if (!m_headsUpDisplayProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::headsUpDisplayProgram::initialize", this, 0); - m_headsUpDisplayProgram->initialize(m_context.get()); + m_headsUpDisplayProgram->initialize(m_context); } return m_headsUpDisplayProgram.get(); } @@ -1583,7 +1480,7 @@ const LayerRendererChromium::RenderPassProgram* LayerRendererChromium::renderPas ASSERT(m_renderPassProgram); if (!m_renderPassProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::renderPassProgram::initialize", this, 0); - m_renderPassProgram->initialize(m_context.get()); + m_renderPassProgram->initialize(m_context); } return m_renderPassProgram.get(); } @@ -1591,10 +1488,10 @@ const LayerRendererChromium::RenderPassProgram* LayerRendererChromium::renderPas const LayerRendererChromium::RenderPassProgramAA* LayerRendererChromium::renderPassProgramAA() { if (!m_renderPassProgramAA) - m_renderPassProgramAA = adoptPtr(new RenderPassProgramAA(m_context.get())); + m_renderPassProgramAA = adoptPtr(new RenderPassProgramAA(m_context)); if (!m_renderPassProgramAA->initialized()) { TRACE_EVENT("LayerRendererChromium::renderPassProgramAA::initialize", this, 0); - m_renderPassProgramAA->initialize(m_context.get()); + m_renderPassProgramAA->initialize(m_context); } return m_renderPassProgramAA.get(); } @@ -1602,10 +1499,10 @@ const LayerRendererChromium::RenderPassProgramAA* LayerRendererChromium::renderP const LayerRendererChromium::RenderPassMaskProgram* LayerRendererChromium::renderPassMaskProgram() { if (!m_renderPassMaskProgram) - m_renderPassMaskProgram = adoptPtr(new RenderPassMaskProgram(m_context.get())); + m_renderPassMaskProgram = adoptPtr(new RenderPassMaskProgram(m_context)); if (!m_renderPassMaskProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::renderPassMaskProgram::initialize", this, 0); - m_renderPassMaskProgram->initialize(m_context.get()); + m_renderPassMaskProgram->initialize(m_context); } return m_renderPassMaskProgram.get(); } @@ -1613,10 +1510,10 @@ const LayerRendererChromium::RenderPassMaskProgram* LayerRendererChromium::rende const LayerRendererChromium::RenderPassMaskProgramAA* LayerRendererChromium::renderPassMaskProgramAA() { if (!m_renderPassMaskProgramAA) - m_renderPassMaskProgramAA = adoptPtr(new RenderPassMaskProgramAA(m_context.get())); + m_renderPassMaskProgramAA = adoptPtr(new RenderPassMaskProgramAA(m_context)); if (!m_renderPassMaskProgramAA->initialized()) { TRACE_EVENT("LayerRendererChromium::renderPassMaskProgramAA::initialize", this, 0); - m_renderPassMaskProgramAA->initialize(m_context.get()); + m_renderPassMaskProgramAA->initialize(m_context); } return m_renderPassMaskProgramAA.get(); } @@ -1626,7 +1523,7 @@ const LayerRendererChromium::TileProgram* LayerRendererChromium::tileProgram() ASSERT(m_tileProgram); if (!m_tileProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::tileProgram::initialize", this, 0); - m_tileProgram->initialize(m_context.get()); + m_tileProgram->initialize(m_context); } return m_tileProgram.get(); } @@ -1636,7 +1533,7 @@ const LayerRendererChromium::TileProgramOpaque* LayerRendererChromium::tileProgr ASSERT(m_tileProgramOpaque); if (!m_tileProgramOpaque->initialized()) { TRACE_EVENT("LayerRendererChromium::tileProgramOpaque::initialize", this, 0); - m_tileProgramOpaque->initialize(m_context.get()); + m_tileProgramOpaque->initialize(m_context); } return m_tileProgramOpaque.get(); } @@ -1644,10 +1541,10 @@ const LayerRendererChromium::TileProgramOpaque* LayerRendererChromium::tileProgr const LayerRendererChromium::TileProgramAA* LayerRendererChromium::tileProgramAA() { if (!m_tileProgramAA) - m_tileProgramAA = adoptPtr(new TileProgramAA(m_context.get())); + m_tileProgramAA = adoptPtr(new TileProgramAA(m_context)); if (!m_tileProgramAA->initialized()) { TRACE_EVENT("LayerRendererChromium::tileProgramAA::initialize", this, 0); - m_tileProgramAA->initialize(m_context.get()); + m_tileProgramAA->initialize(m_context); } return m_tileProgramAA.get(); } @@ -1655,10 +1552,10 @@ const LayerRendererChromium::TileProgramAA* LayerRendererChromium::tileProgramAA const LayerRendererChromium::TileProgramSwizzle* LayerRendererChromium::tileProgramSwizzle() { if (!m_tileProgramSwizzle) - m_tileProgramSwizzle = adoptPtr(new TileProgramSwizzle(m_context.get())); + m_tileProgramSwizzle = adoptPtr(new TileProgramSwizzle(m_context)); if (!m_tileProgramSwizzle->initialized()) { TRACE_EVENT("LayerRendererChromium::tileProgramSwizzle::initialize", this, 0); - m_tileProgramSwizzle->initialize(m_context.get()); + m_tileProgramSwizzle->initialize(m_context); } return m_tileProgramSwizzle.get(); } @@ -1666,10 +1563,10 @@ const LayerRendererChromium::TileProgramSwizzle* LayerRendererChromium::tileProg const LayerRendererChromium::TileProgramSwizzleOpaque* LayerRendererChromium::tileProgramSwizzleOpaque() { if (!m_tileProgramSwizzleOpaque) - m_tileProgramSwizzleOpaque = adoptPtr(new TileProgramSwizzleOpaque(m_context.get())); + m_tileProgramSwizzleOpaque = adoptPtr(new TileProgramSwizzleOpaque(m_context)); if (!m_tileProgramSwizzleOpaque->initialized()) { TRACE_EVENT("LayerRendererChromium::tileProgramSwizzleOpaque::initialize", this, 0); - m_tileProgramSwizzleOpaque->initialize(m_context.get()); + m_tileProgramSwizzleOpaque->initialize(m_context); } return m_tileProgramSwizzleOpaque.get(); } @@ -1677,10 +1574,10 @@ const LayerRendererChromium::TileProgramSwizzleOpaque* LayerRendererChromium::ti const LayerRendererChromium::TileProgramSwizzleAA* LayerRendererChromium::tileProgramSwizzleAA() { if (!m_tileProgramSwizzleAA) - m_tileProgramSwizzleAA = adoptPtr(new TileProgramSwizzleAA(m_context.get())); + m_tileProgramSwizzleAA = adoptPtr(new TileProgramSwizzleAA(m_context)); if (!m_tileProgramSwizzleAA->initialized()) { TRACE_EVENT("LayerRendererChromium::tileProgramSwizzleAA::initialize", this, 0); - m_tileProgramSwizzleAA->initialize(m_context.get()); + m_tileProgramSwizzleAA->initialize(m_context); } return m_tileProgramSwizzleAA.get(); } @@ -1688,10 +1585,10 @@ const LayerRendererChromium::TileProgramSwizzleAA* LayerRendererChromium::tilePr const LayerRendererChromium::TextureProgram* LayerRendererChromium::textureProgram() { if (!m_textureProgram) - m_textureProgram = adoptPtr(new TextureProgram(m_context.get())); + m_textureProgram = adoptPtr(new TextureProgram(m_context)); if (!m_textureProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::textureProgram::initialize", this, 0); - m_textureProgram->initialize(m_context.get()); + m_textureProgram->initialize(m_context); } return m_textureProgram.get(); } @@ -1699,10 +1596,10 @@ const LayerRendererChromium::TextureProgram* LayerRendererChromium::textureProgr const LayerRendererChromium::TextureProgramFlip* LayerRendererChromium::textureProgramFlip() { if (!m_textureProgramFlip) - m_textureProgramFlip = adoptPtr(new TextureProgramFlip(m_context.get())); + m_textureProgramFlip = adoptPtr(new TextureProgramFlip(m_context)); if (!m_textureProgramFlip->initialized()) { TRACE_EVENT("LayerRendererChromium::textureProgramFlip::initialize", this, 0); - m_textureProgramFlip->initialize(m_context.get()); + m_textureProgramFlip->initialize(m_context); } return m_textureProgramFlip.get(); } @@ -1710,10 +1607,10 @@ const LayerRendererChromium::TextureProgramFlip* LayerRendererChromium::textureP const LayerRendererChromium::TextureIOSurfaceProgram* LayerRendererChromium::textureIOSurfaceProgram() { if (!m_textureIOSurfaceProgram) - m_textureIOSurfaceProgram = adoptPtr(new TextureIOSurfaceProgram(m_context.get())); + m_textureIOSurfaceProgram = adoptPtr(new TextureIOSurfaceProgram(m_context)); if (!m_textureIOSurfaceProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::textureIOSurfaceProgram::initialize", this, 0); - m_textureIOSurfaceProgram->initialize(m_context.get()); + m_textureIOSurfaceProgram->initialize(m_context); } return m_textureIOSurfaceProgram.get(); } @@ -1721,10 +1618,10 @@ const LayerRendererChromium::TextureIOSurfaceProgram* LayerRendererChromium::tex const LayerRendererChromium::VideoYUVProgram* LayerRendererChromium::videoYUVProgram() { if (!m_videoYUVProgram) - m_videoYUVProgram = adoptPtr(new VideoYUVProgram(m_context.get())); + m_videoYUVProgram = adoptPtr(new VideoYUVProgram(m_context)); if (!m_videoYUVProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::videoYUVProgram::initialize", this, 0); - m_videoYUVProgram->initialize(m_context.get()); + m_videoYUVProgram->initialize(m_context); } return m_videoYUVProgram.get(); } @@ -1732,10 +1629,10 @@ const LayerRendererChromium::VideoYUVProgram* LayerRendererChromium::videoYUVPro const LayerRendererChromium::VideoStreamTextureProgram* LayerRendererChromium::videoStreamTextureProgram() { if (!m_videoStreamTextureProgram) - m_videoStreamTextureProgram = adoptPtr(new VideoStreamTextureProgram(m_context.get())); + m_videoStreamTextureProgram = adoptPtr(new VideoStreamTextureProgram(m_context)); if (!m_videoStreamTextureProgram->initialized()) { TRACE_EVENT("LayerRendererChromium::streamTextureProgram::initialize", this, 0); - m_videoStreamTextureProgram->initialize(m_context.get()); + m_videoStreamTextureProgram->initialize(m_context); } return m_videoStreamTextureProgram.get(); } @@ -1747,46 +1644,46 @@ void LayerRendererChromium::cleanupSharedObjects() m_sharedGeometry.clear(); if (m_tileProgram) - m_tileProgram->cleanup(m_context.get()); + m_tileProgram->cleanup(m_context); if (m_tileProgramOpaque) - m_tileProgramOpaque->cleanup(m_context.get()); + m_tileProgramOpaque->cleanup(m_context); if (m_tileProgramSwizzle) - m_tileProgramSwizzle->cleanup(m_context.get()); + m_tileProgramSwizzle->cleanup(m_context); if (m_tileProgramSwizzleOpaque) - m_tileProgramSwizzleOpaque->cleanup(m_context.get()); + m_tileProgramSwizzleOpaque->cleanup(m_context); if (m_tileProgramAA) - m_tileProgramAA->cleanup(m_context.get()); + m_tileProgramAA->cleanup(m_context); if (m_tileProgramSwizzleAA) - m_tileProgramSwizzleAA->cleanup(m_context.get()); + m_tileProgramSwizzleAA->cleanup(m_context); if (m_tileCheckerboardProgram) - m_tileCheckerboardProgram->cleanup(m_context.get()); + m_tileCheckerboardProgram->cleanup(m_context); if (m_renderPassMaskProgram) - m_renderPassMaskProgram->cleanup(m_context.get()); + m_renderPassMaskProgram->cleanup(m_context); if (m_renderPassProgram) - m_renderPassProgram->cleanup(m_context.get()); + m_renderPassProgram->cleanup(m_context); if (m_renderPassMaskProgramAA) - m_renderPassMaskProgramAA->cleanup(m_context.get()); + m_renderPassMaskProgramAA->cleanup(m_context); if (m_renderPassProgramAA) - m_renderPassProgramAA->cleanup(m_context.get()); + m_renderPassProgramAA->cleanup(m_context); if (m_textureProgram) - m_textureProgram->cleanup(m_context.get()); + m_textureProgram->cleanup(m_context); if (m_textureProgramFlip) - m_textureProgramFlip->cleanup(m_context.get()); + m_textureProgramFlip->cleanup(m_context); if (m_textureIOSurfaceProgram) - m_textureIOSurfaceProgram->cleanup(m_context.get()); + m_textureIOSurfaceProgram->cleanup(m_context); if (m_videoYUVProgram) - m_videoYUVProgram->cleanup(m_context.get()); + m_videoYUVProgram->cleanup(m_context); if (m_videoStreamTextureProgram) - m_videoStreamTextureProgram->cleanup(m_context.get()); + m_videoStreamTextureProgram->cleanup(m_context); if (m_solidColorProgram) - m_solidColorProgram->cleanup(m_context.get()); + m_solidColorProgram->cleanup(m_context); if (m_headsUpDisplayProgram) - m_headsUpDisplayProgram->cleanup(m_context.get()); + m_headsUpDisplayProgram->cleanup(m_context); if (m_offscreenFramebufferId) GLC(m_context, m_context->deleteFramebuffer(m_offscreenFramebufferId)); @@ -1799,7 +1696,7 @@ void LayerRendererChromium::cleanupSharedObjects() bool LayerRendererChromium::isContextLost() { - return (m_context.get()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR); + return (m_context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h index f7ccb651f..34254b00b 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h @@ -40,6 +40,10 @@ #include "cc/CCRenderer.h" #include <wtf/PassOwnPtr.h> +namespace WebKit { +class WebGraphicsContext3D; +} + namespace WebCore { class CCCheckerboardDrawQuad; @@ -53,22 +57,23 @@ class CCTextureDrawQuad; class CCTileDrawQuad; class CCYUVVideoDrawQuad; class GeometryBinding; -class GraphicsContext3D; -class LayerRendererSwapBuffersCompleteCallbackAdapter; class ManagedTexture; class ScopedEnsureFramebufferAllocation; // Class that handles drawing of composited render layers using GL. -class LayerRendererChromium : public CCRenderer { +class LayerRendererChromium : public CCRenderer, + public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM, + public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM , + public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { WTF_MAKE_NONCOPYABLE(LayerRendererChromium); public: - static PassOwnPtr<LayerRendererChromium> create(CCRendererClient*, PassRefPtr<GraphicsContext3D>, TextureUploaderOption); + static PassOwnPtr<LayerRendererChromium> create(CCRendererClient*, WebKit::WebGraphicsContext3D*, TextureUploaderOption); virtual ~LayerRendererChromium(); virtual const LayerRendererCapabilities& capabilities() const OVERRIDE { return m_capabilities; } - GraphicsContext3D* context(); + WebKit::WebGraphicsContext3D* context(); virtual void viewportChanged() OVERRIDE; @@ -88,7 +93,7 @@ public: // puts backbuffer onscreen virtual bool swapBuffers(const IntRect& subBuffer) OVERRIDE; - static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line); + static void debugGLCall(WebKit::WebGraphicsContext3D*, const char* command, const char* file, int line); const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); } @@ -111,14 +116,11 @@ public: float width, float height, float opacity, const FloatQuad&, int matrixLocation, int alphaLocation, int quadLocation); void copyTextureToFramebuffer(int textureId, const IntSize& bounds, const WebKit::WebTransformationMatrix& drawMatrix); - void setGpuMemoryAllocation(Extensions3DChromium::GpuMemoryAllocationCHROMIUM); protected: - void discardFramebuffer(); - void ensureFramebuffer(); - bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; } + LayerRendererChromium(CCRendererClient*, WebKit::WebGraphicsContext3D*, TextureUploaderOption); - LayerRendererChromium(CCRendererClient*, PassRefPtr<GraphicsContext3D>, TextureUploaderOption); + bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; } bool initialize(); private: @@ -154,8 +156,17 @@ private: bool initializeSharedObjects(); void cleanupSharedObjects(); - friend class LayerRendererSwapBuffersCompleteCallbackAdapter; - void onSwapBuffersComplete(); + // WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM implementation. + virtual void onSwapBuffersComplete() OVERRIDE; + + // WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation. + virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation) OVERRIDE; + void onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation); + void discardFramebuffer(); + void ensureFramebuffer(); + + // WebGraphicsContext3D::WebGraphicsContextLostCallback implementation. + virtual void onContextLost() OVERRIDE; LayerRendererCapabilities m_capabilities; @@ -252,7 +263,7 @@ private: OwnPtr<TrackingTextureAllocator> m_contentsTextureAllocator; OwnPtr<TrackingTextureAllocator> m_implTextureAllocator; - RefPtr<GraphicsContext3D> m_context; + WebKit::WebGraphicsContext3D* m_context; const CCRenderPass* m_defaultRenderPass; diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureSubImage.cpp b/Source/WebCore/platform/graphics/chromium/LayerTextureSubImage.cpp index 4bea9042f..4aa9965e7 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTextureSubImage.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerTextureSubImage.cpp @@ -89,7 +89,7 @@ void LayerTextureSubImage::uploadWithTexSubImage(const uint8_t* image, const Int pixelSource = &m_subImage[0]; } - GraphicsContext3D* context3d = context->context3D(); + WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. return; @@ -102,7 +102,7 @@ void LayerTextureSubImage::uploadWithMapTexSubImage(const uint8_t* image, const GC3Denum format, CCGraphicsContext* context) { TRACE_EVENT("LayerTextureSubImage::uploadWithMapTexSubImage", this, 0); - GraphicsContext3D* context3d = context->context3D(); + WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. return; @@ -112,8 +112,7 @@ void LayerTextureSubImage::uploadWithMapTexSubImage(const uint8_t* image, const IntPoint offset(sourceRect.x() - imageRect.x(), sourceRect.y() - imageRect.y()); // Upload tile data via a mapped transfer buffer - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context3d->getExtensions()); - uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), format, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY)); + uint8_t* pixelDest = static_cast<uint8_t*>(context3d->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), format, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY)); if (!pixelDest) { uploadWithTexSubImage(image, imageRect, sourceRect, destRect, format, context); @@ -137,7 +136,7 @@ void LayerTextureSubImage::uploadWithMapTexSubImage(const uint8_t* image, const &image[4 * (offset.x() + (offset.y() + row) * imageRect.width())], destRect.width() * componentsPerPixel * bytesPerComponent); } - GLC(context3d, extensions->unmapTexSubImage2DCHROMIUM(pixelDest)); + GLC(context3d, context3d->unmapTexSubImage2DCHROMIUM(pixelDest)); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp index b06aaa91b..4dabf1beb 100644 --- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp +++ b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp @@ -30,6 +30,9 @@ #include "GraphicsContext3D.h" #include "cc/CCGraphicsContext.h" +#include <public/WebGraphicsContext3D.h> + +using WebKit::WebGraphicsContext3D; namespace WebCore { @@ -120,7 +123,7 @@ void ManagedTexture::allocate(TextureAllocator* allocator) void ManagedTexture::bindTexture(CCGraphicsContext* context, TextureAllocator* allocator) { allocate(allocator); - GraphicsContext3D* context3d = context->context3D(); + WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. return; @@ -128,17 +131,6 @@ void ManagedTexture::bindTexture(CCGraphicsContext* context, TextureAllocator* a context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); } -void ManagedTexture::framebufferTexture2D(CCGraphicsContext* context, TextureAllocator* allocator) -{ - allocate(allocator); - GraphicsContext3D* context3d = context->context3D(); - if (!context3d) { - // FIXME: Implement this path for software compositing. - return; - } - context3d->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0); -} - PassOwnPtr<ManagedTexture> ManagedTexture::steal() { OwnPtr<ManagedTexture> texture = adoptPtr(new ManagedTexture(m_textureManager, m_token, m_size, m_format, m_textureId)); diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h index 8a6566c31..6e67ebf68 100644 --- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h +++ b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h @@ -59,7 +59,6 @@ public: void allocate(TextureAllocator*); void bindTexture(CCGraphicsContext*, TextureAllocator*); - void framebufferTexture2D(CCGraphicsContext*, TextureAllocator*); IntSize size() const { return m_size; } unsigned format() const { return m_format; } diff --git a/Source/WebCore/platform/graphics/chromium/PlatformColor.h b/Source/WebCore/platform/graphics/chromium/PlatformColor.h index ab6545dce..a855215bd 100644 --- a/Source/WebCore/platform/graphics/chromium/PlatformColor.h +++ b/Source/WebCore/platform/graphics/chromium/PlatformColor.h @@ -29,6 +29,7 @@ #include "Extensions3D.h" #include "GraphicsContext3D.h" #include "SkTypes.h" +#include <public/WebGraphicsContext3D.h> namespace WebCore { @@ -40,14 +41,14 @@ public: } // Returns the most efficient texture format for this platform. - static GC3Denum bestTextureFormat(GraphicsContext3D* context) + static GC3Denum bestTextureFormat(WebKit::WebGraphicsContext3D* context, bool supportsBGRA8888) { GC3Denum textureFormat = GraphicsContext3D::RGBA; switch (format()) { case GraphicsContext3D::SourceFormatRGBA8: break; case GraphicsContext3D::SourceFormatBGRA8: - if (context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888")) + if (supportsBGRA8888) textureFormat = Extensions3D::BGRA_EXT; break; default: diff --git a/Source/WebCore/platform/graphics/chromium/ProgramBinding.cpp b/Source/WebCore/platform/graphics/chromium/ProgramBinding.cpp index 376434e62..6afbb34ae 100644 --- a/Source/WebCore/platform/graphics/chromium/ProgramBinding.cpp +++ b/Source/WebCore/platform/graphics/chromium/ProgramBinding.cpp @@ -29,12 +29,13 @@ #include "ProgramBinding.h" -#include "Extensions3D.h" #include "GeometryBinding.h" -#include "GraphicsContext.h" #include "GraphicsContext3D.h" #include "LayerRendererChromium.h" #include "TraceEvent.h" +#include <public/WebGraphicsContext3D.h> + +using WebKit::WebGraphicsContext3D; namespace WebCore { @@ -51,19 +52,19 @@ ProgramBindingBase::~ProgramBindingBase() ASSERT(!m_initialized); } -static bool contextLost(GraphicsContext3D* context) +static bool contextLost(WebGraphicsContext3D* context) { - return (context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR); + return (context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR); } -void ProgramBindingBase::init(GraphicsContext3D* context, const String& vertexShader, const String& fragmentShader) +void ProgramBindingBase::init(WebGraphicsContext3D* context, const String& vertexShader, const String& fragmentShader) { m_program = createShaderProgram(context, vertexShader, fragmentShader); ASSERT(m_program || contextLost(context)); } -void ProgramBindingBase::cleanup(GraphicsContext3D* context) +void ProgramBindingBase::cleanup(WebGraphicsContext3D* context) { m_initialized = false; if (!m_program) @@ -74,13 +75,13 @@ void ProgramBindingBase::cleanup(GraphicsContext3D* context) m_program = 0; } -unsigned ProgramBindingBase::loadShader(GraphicsContext3D* context, unsigned type, const String& shaderSource) +unsigned ProgramBindingBase::loadShader(WebGraphicsContext3D* context, unsigned type, const String& shaderSource) { unsigned shader = context->createShader(type); if (!shader) return 0; String sourceString(shaderSource); - GLC(context, context->shaderSource(shader, sourceString)); + GLC(context, context->shaderSource(shader, sourceString.utf8().data())); GLC(context, context->compileShader(shader)); #ifndef NDEBUG int compiled = 0; @@ -93,9 +94,9 @@ unsigned ProgramBindingBase::loadShader(GraphicsContext3D* context, unsigned typ return shader; } -unsigned ProgramBindingBase::createShaderProgram(GraphicsContext3D* context, const String& vertexShaderSource, const String& fragmentShaderSource) +unsigned ProgramBindingBase::createShaderProgram(WebGraphicsContext3D* context, const String& vertexShaderSource, const String& fragmentShaderSource) { - TRACE_EVENT("ProgramBindingBase::createShaderProgram", this, 0); + TRACE_EVENT0("cc", "ProgramBindingBase::createShaderProgram"); unsigned vertexShader = loadShader(context, GraphicsContext3D::VERTEX_SHADER, vertexShaderSource); if (!vertexShader) { if (!contextLost(context)) diff --git a/Source/WebCore/platform/graphics/chromium/ProgramBinding.h b/Source/WebCore/platform/graphics/chromium/ProgramBinding.h index aea285689..39048f903 100644 --- a/Source/WebCore/platform/graphics/chromium/ProgramBinding.h +++ b/Source/WebCore/platform/graphics/chromium/ProgramBinding.h @@ -28,27 +28,29 @@ #if USE(ACCELERATED_COMPOSITING) -#include "PlatformString.h" +#include <wtf/text/WTFString.h> -namespace WebCore { +namespace WebKit { +class WebGraphicsContext3D; +} -class GraphicsContext3D; +namespace WebCore { class ProgramBindingBase { public: ProgramBindingBase(); ~ProgramBindingBase(); - void init(GraphicsContext3D*, const String& vertexShader, const String& fragmentShader); - void cleanup(GraphicsContext3D*); + void init(WebKit::WebGraphicsContext3D*, const String& vertexShader, const String& fragmentShader); + void cleanup(WebKit::WebGraphicsContext3D*); unsigned program() const { ASSERT(m_initialized); return m_program; } bool initialized() const { return m_initialized; } protected: - unsigned loadShader(GraphicsContext3D*, unsigned type, const String& shaderSource); - unsigned createShaderProgram(GraphicsContext3D*, const String& vertexShaderSource, const String& fragmentShaderSource); + unsigned loadShader(WebKit::WebGraphicsContext3D*, unsigned type, const String& shaderSource); + unsigned createShaderProgram(WebKit::WebGraphicsContext3D*, const String& vertexShaderSource, const String& fragmentShaderSource); unsigned m_program; bool m_initialized; @@ -57,12 +59,12 @@ protected: template<class VertexShader, class FragmentShader> class ProgramBinding : public ProgramBindingBase { public: - explicit ProgramBinding(GraphicsContext3D* context) + explicit ProgramBinding(WebKit::WebGraphicsContext3D* context) { ProgramBindingBase::init(context, m_vertexShader.getShaderString(), m_fragmentShader.getShaderString()); } - void initialize(GraphicsContext3D* context) + void initialize(WebKit::WebGraphicsContext3D* context) { ASSERT(context); ASSERT(m_program); diff --git a/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp b/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp index 6ed6f4a8e..2a140d1d7 100644 --- a/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp @@ -29,12 +29,13 @@ #include "ShaderChromium.h" -#include "GraphicsContext.h" -#include "GraphicsContext3D.h" +#include <public/WebGraphicsContext3D.h> #define SHADER0(Src) #Src #define SHADER(Src) SHADER0(Src) +using WebKit::WebGraphicsContext3D; + namespace WebCore { VertexShaderPosTex::VertexShaderPosTex() @@ -42,7 +43,7 @@ VertexShaderPosTex::VertexShaderPosTex() { } -void VertexShaderPosTex::init(GraphicsContext3D* context, unsigned program) +void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program) { m_matrixLocation = context->getUniformLocation(program, "matrix"); ASSERT(m_matrixLocation != -1); @@ -70,7 +71,7 @@ VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() { } -void VertexShaderPosTexYUVStretch::init(GraphicsContext3D* context, unsigned program) +void VertexShaderPosTexYUVStretch::init(WebGraphicsContext3D* context, unsigned program) { m_matrixLocation = context->getUniformLocation(program, "matrix"); m_yWidthScaleFactorLocation = context->getUniformLocation(program, "y_widthScaleFactor"); @@ -103,7 +104,7 @@ VertexShaderPos::VertexShaderPos() { } -void VertexShaderPos::init(GraphicsContext3D* context, unsigned program) +void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program) { m_matrixLocation = context->getUniformLocation(program, "matrix"); ASSERT(m_matrixLocation != -1); @@ -127,7 +128,7 @@ VertexShaderPosTexTransform::VertexShaderPosTexTransform() { } -void VertexShaderPosTexTransform::init(GraphicsContext3D* context, unsigned program) +void VertexShaderPosTexTransform::init(WebGraphicsContext3D* context, unsigned program) { m_matrixLocation = context->getUniformLocation(program, "matrix"); m_texTransformLocation = context->getUniformLocation(program, "texTransform"); @@ -169,7 +170,7 @@ String VertexShaderPosTexIdentity::getShaderString() const ); } -void VertexShaderQuad::init(GraphicsContext3D* context, unsigned program) +void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program) { m_matrixLocation = context->getUniformLocation(program, "matrix"); m_pointLocation = context->getUniformLocation(program, "point"); @@ -205,7 +206,7 @@ VertexShaderTile::VertexShaderTile() { } -void VertexShaderTile::init(GraphicsContext3D* context, unsigned program) +void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program) { m_matrixLocation = context->getUniformLocation(program, "matrix"); m_pointLocation = context->getUniformLocation(program, "point"); @@ -242,7 +243,7 @@ VertexShaderVideoTransform::VertexShaderVideoTransform() { } -bool VertexShaderVideoTransform::init(GraphicsContext3D* context, unsigned program) +bool VertexShaderVideoTransform::init(WebGraphicsContext3D* context, unsigned program) { m_matrixLocation = context->getUniformLocation(program, "matrix"); m_texMatrixLocation = context->getUniformLocation(program, "texMatrix"); @@ -271,7 +272,7 @@ FragmentTexAlphaBinding::FragmentTexAlphaBinding() { } -void FragmentTexAlphaBinding::init(GraphicsContext3D* context, unsigned program) +void FragmentTexAlphaBinding::init(WebGraphicsContext3D* context, unsigned program) { m_samplerLocation = context->getUniformLocation(program, "s_texture"); m_alphaLocation = context->getUniformLocation(program, "alpha"); @@ -284,7 +285,7 @@ FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() { } -void FragmentTexOpaqueBinding::init(GraphicsContext3D* context, unsigned program) +void FragmentTexOpaqueBinding::init(WebGraphicsContext3D* context, unsigned program) { m_samplerLocation = context->getUniformLocation(program, "s_texture"); @@ -306,7 +307,7 @@ String FragmentShaderRGBATexFlipAlpha::getShaderString() const ); } -bool FragmentShaderOESImageExternal::init(GraphicsContext3D* context, unsigned program) +bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigned program) { m_samplerLocation = context->getUniformLocation(program, "s_texture"); @@ -436,7 +437,7 @@ FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() { } -void FragmentShaderRGBATexAlphaAA::init(GraphicsContext3D* context, unsigned program) +void FragmentShaderRGBATexAlphaAA::init(WebGraphicsContext3D* context, unsigned program) { m_samplerLocation = context->getUniformLocation(program, "s_texture"); m_alphaLocation = context->getUniformLocation(program, "alpha"); @@ -478,7 +479,7 @@ FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() { } -void FragmentTexClampAlphaAABinding::init(GraphicsContext3D* context, unsigned program) +void FragmentTexClampAlphaAABinding::init(WebGraphicsContext3D* context, unsigned program) { m_samplerLocation = context->getUniformLocation(program, "s_texture"); m_alphaLocation = context->getUniformLocation(program, "alpha"); @@ -549,7 +550,7 @@ FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask() { } -void FragmentShaderRGBATexAlphaMask::init(GraphicsContext3D* context, unsigned program) +void FragmentShaderRGBATexAlphaMask::init(WebGraphicsContext3D* context, unsigned program) { m_samplerLocation = context->getUniformLocation(program, "s_texture"); m_maskSamplerLocation = context->getUniformLocation(program, "s_mask"); @@ -582,7 +583,7 @@ FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() { } -void FragmentShaderRGBATexAlphaMaskAA::init(GraphicsContext3D* context, unsigned program) +void FragmentShaderRGBATexAlphaMaskAA::init(WebGraphicsContext3D* context, unsigned program) { m_samplerLocation = context->getUniformLocation(program, "s_texture"); m_maskSamplerLocation = context->getUniformLocation(program, "s_mask"); @@ -628,7 +629,7 @@ FragmentShaderYUVVideo::FragmentShaderYUVVideo() { } -void FragmentShaderYUVVideo::init(GraphicsContext3D* context, unsigned program) +void FragmentShaderYUVVideo::init(WebGraphicsContext3D* context, unsigned program) { m_yTextureLocation = context->getUniformLocation(program, "y_texture"); m_uTextureLocation = context->getUniformLocation(program, "u_texture"); @@ -671,7 +672,7 @@ FragmentShaderColor::FragmentShaderColor() { } -void FragmentShaderColor::init(GraphicsContext3D* context, unsigned program) +void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program) { m_colorLocation = context->getUniformLocation(program, "color"); ASSERT(m_colorLocation != -1); @@ -696,7 +697,7 @@ FragmentShaderCheckerboard::FragmentShaderCheckerboard() { } -void FragmentShaderCheckerboard::init(GraphicsContext3D* context, unsigned program) +void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned program) { m_alphaLocation = context->getUniformLocation(program, "alpha"); m_texTransformLocation = context->getUniformLocation(program, "texTransform"); diff --git a/Source/WebCore/platform/graphics/chromium/ShaderChromium.h b/Source/WebCore/platform/graphics/chromium/ShaderChromium.h index 9277ecca5..475b78962 100644 --- a/Source/WebCore/platform/graphics/chromium/ShaderChromium.h +++ b/Source/WebCore/platform/graphics/chromium/ShaderChromium.h @@ -31,15 +31,17 @@ #include "PlatformString.h" #include "SkColorPriv.h" -namespace WebCore { +namespace WebKit { +class WebGraphicsContext3D; +} -class GraphicsContext3D; +namespace WebCore { class VertexShaderPosTex { public: VertexShaderPosTex(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int matrixLocation() const { return m_matrixLocation; } @@ -52,7 +54,7 @@ class VertexShaderPosTexYUVStretch { public: VertexShaderPosTexYUVStretch(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int matrixLocation() const { return m_matrixLocation; } @@ -69,7 +71,7 @@ class VertexShaderPos { public: VertexShaderPos(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int matrixLocation() const { return m_matrixLocation; } @@ -80,7 +82,7 @@ private: class VertexShaderPosTexIdentity { public: - void init(GraphicsContext3D*, unsigned program) { } + void init(WebKit::WebGraphicsContext3D*, unsigned program) { } String getShaderString() const; }; @@ -88,7 +90,7 @@ class VertexShaderPosTexTransform { public: VertexShaderPosTexTransform(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int matrixLocation() const { return m_matrixLocation; } @@ -103,7 +105,7 @@ class VertexShaderQuad { public: VertexShaderQuad(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int matrixLocation() const { return m_matrixLocation; } @@ -118,7 +120,7 @@ class VertexShaderTile { public: VertexShaderTile(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int matrixLocation() const { return m_matrixLocation; } @@ -135,7 +137,7 @@ class VertexShaderVideoTransform { public: VertexShaderVideoTransform(); - bool init(GraphicsContext3D*, unsigned program); + bool init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int matrixLocation() const { return m_matrixLocation; } @@ -150,7 +152,7 @@ class FragmentTexAlphaBinding { public: FragmentTexAlphaBinding(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int alphaLocation() const { return m_alphaLocation; } int edgeLocation() const { return -1; } int fragmentTexTransformLocation() const { return -1; } @@ -165,7 +167,7 @@ class FragmentTexOpaqueBinding { public: FragmentTexOpaqueBinding(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int alphaLocation() const { return -1; } int edgeLocation() const { return -1; } int fragmentTexTransformLocation() const { return -1; } @@ -221,7 +223,7 @@ public: class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding { public: String getShaderString() const; - bool init(GraphicsContext3D*, unsigned program); + bool init(WebKit::WebGraphicsContext3D*, unsigned program); private: int m_samplerLocation; }; @@ -230,7 +232,7 @@ class FragmentShaderRGBATexAlphaAA { public: FragmentShaderRGBATexAlphaAA(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); String getShaderString() const; int alphaLocation() const { return m_alphaLocation; } @@ -247,7 +249,7 @@ class FragmentTexClampAlphaAABinding { public: FragmentTexClampAlphaAABinding(); - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int alphaLocation() const { return m_alphaLocation; } int samplerLocation() const { return m_samplerLocation; } int fragmentTexTransformLocation() const { return m_fragmentTexTransformLocation; } @@ -276,7 +278,7 @@ public: FragmentShaderRGBATexAlphaMask(); String getShaderString() const; - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int alphaLocation() const { return m_alphaLocation; } int samplerLocation() const { return m_samplerLocation; } int maskSamplerLocation() const { return m_maskSamplerLocation; } @@ -292,7 +294,7 @@ public: FragmentShaderRGBATexAlphaMaskAA(); String getShaderString() const; - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int alphaLocation() const { return m_alphaLocation; } int samplerLocation() const { return m_samplerLocation; } int maskSamplerLocation() const { return m_maskSamplerLocation; } @@ -310,7 +312,7 @@ public: FragmentShaderYUVVideo(); String getShaderString() const; - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int yTextureLocation() const { return m_yTextureLocation; } int uTextureLocation() const { return m_uTextureLocation; } @@ -333,7 +335,7 @@ public: FragmentShaderColor(); String getShaderString() const; - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int colorLocation() const { return m_colorLocation; } private: @@ -345,7 +347,7 @@ public: FragmentShaderCheckerboard(); String getShaderString() const; - void init(GraphicsContext3D*, unsigned program); + void init(WebKit::WebGraphicsContext3D*, unsigned program); int alphaLocation() const { return m_alphaLocation; } int texTransformLocation() const { return m_texTransformLocation; } int frequencyLocation() const { return m_frequencyLocation; } diff --git a/Source/WebCore/platform/graphics/chromium/TextureCopier.cpp b/Source/WebCore/platform/graphics/chromium/TextureCopier.cpp index a29c28551..0f2309068 100644 --- a/Source/WebCore/platform/graphics/chromium/TextureCopier.cpp +++ b/Source/WebCore/platform/graphics/chromium/TextureCopier.cpp @@ -25,16 +25,19 @@ #include "config.h" #include "TextureCopier.h" -#include "TraceEvent.h" +#include "GraphicsContext3D.h" #include "LayerRendererChromium.h" // For the GLC() macro +#include "TraceEvent.h" +#include <public/WebGraphicsContext3D.h> namespace WebCore { #if USE(ACCELERATED_COMPOSITING) -AcceleratedTextureCopier::AcceleratedTextureCopier(PassRefPtr<GraphicsContext3D> context) +AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context) : m_context(context) { + ASSERT(m_context); GLC(m_context, m_fbo = m_context->createFramebuffer()); GLC(m_context, m_positionBuffer = m_context->createBuffer()); @@ -45,17 +48,17 @@ AcceleratedTextureCopier::AcceleratedTextureCopier(PassRefPtr<GraphicsContext3D> {-1, 1, 0, 1} }; - GLC(m_context.get(), m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_positionBuffer)); - GLC(m_context.get(), m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof(kPositions), kPositions, GraphicsContext3D::STATIC_DRAW)); - GLC(m_context.get(), m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); + GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_positionBuffer)); + GLC(m_context, m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof(kPositions), kPositions, GraphicsContext3D::STATIC_DRAW)); + GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); - m_blitProgram = adoptPtr(new BlitProgram(m_context.get())); + m_blitProgram = adoptPtr(new BlitProgram(m_context)); } AcceleratedTextureCopier::~AcceleratedTextureCopier() { if (m_blitProgram) - m_blitProgram->cleanup(m_context.get()); + m_blitProgram->cleanup(m_context); if (m_positionBuffer) GLC(m_context, m_context->deleteBuffer(m_positionBuffer)); if (m_fbo) @@ -66,7 +69,7 @@ void AcceleratedTextureCopier::copyTexture(CCGraphicsContext* ccContext, unsigne { TRACE_EVENT("TextureCopier::copyTexture", this, 0); - GraphicsContext3D* context = ccContext->context3D(); + WebKit::WebGraphicsContext3D* context = ccContext->context3D(); if (!context) { // FIXME: Implement this path for software compositing. return; diff --git a/Source/WebCore/platform/graphics/chromium/TextureCopier.h b/Source/WebCore/platform/graphics/chromium/TextureCopier.h index 3ac2d1191..646189ab6 100644 --- a/Source/WebCore/platform/graphics/chromium/TextureCopier.h +++ b/Source/WebCore/platform/graphics/chromium/TextureCopier.h @@ -29,9 +29,13 @@ #include "ProgramBinding.h" #include "ShaderChromium.h" #include "cc/CCGraphicsContext.h" -#include <wtf/PassRefPtr.h> + +namespace WebKit { +class WebGraphicsContext3D; +} namespace WebCore { +class IntSize; class TextureCopier { public: @@ -49,7 +53,7 @@ protected: class AcceleratedTextureCopier : public TextureCopier { WTF_MAKE_NONCOPYABLE(AcceleratedTextureCopier); public: - static PassOwnPtr<AcceleratedTextureCopier> create(PassRefPtr<GraphicsContext3D> context) + static PassOwnPtr<AcceleratedTextureCopier> create(WebKit::WebGraphicsContext3D* context) { return adoptPtr(new AcceleratedTextureCopier(context)); } @@ -58,12 +62,12 @@ public: virtual void copyTexture(CCGraphicsContext*, unsigned sourceTextureId, unsigned destTextureId, const IntSize&); protected: - explicit AcceleratedTextureCopier(PassRefPtr<GraphicsContext3D>); + explicit AcceleratedTextureCopier(WebKit::WebGraphicsContext3D*); private: typedef ProgramBinding<VertexShaderPosTexIdentity, FragmentShaderRGBATex> BlitProgram; - RefPtr<GraphicsContext3D> m_context; + WebKit::WebGraphicsContext3D* m_context; Platform3DObject m_fbo; Platform3DObject m_positionBuffer; OwnPtr<BlitProgram> m_blitProgram; diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.h b/Source/WebCore/platform/graphics/chromium/TextureManager.h index 7ca14f437..47a189bcc 100644 --- a/Source/WebCore/platform/graphics/chromium/TextureManager.h +++ b/Source/WebCore/platform/graphics/chromium/TextureManager.h @@ -28,7 +28,6 @@ #include "GraphicsContext3D.h" #include "IntRect.h" #include "IntSize.h" - #include <wtf/FastAllocBase.h> #include <wtf/HashMap.h> #include <wtf/HashSet.h> diff --git a/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.cpp b/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.cpp index f5cf2a4e1..a8253d065 100644 --- a/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.cpp +++ b/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.cpp @@ -27,6 +27,7 @@ #include "ThrottledTextureUploader.h" #include "Extensions3DChromium.h" +#include <public/WebGraphicsContext3D.h> namespace { @@ -37,57 +38,52 @@ static const size_t maxPendingQueries = 2; namespace WebCore { -ThrottledTextureUploader::Query::Query(PassRefPtr<GraphicsContext3D> context) +ThrottledTextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context) : m_context(context) , m_queryId(0) { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions()); - m_queryId = extensions->createQueryEXT(); + m_queryId = m_context->createQueryEXT(); } ThrottledTextureUploader::Query::~Query() { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions()); - extensions->deleteQueryEXT(m_queryId); + m_context->deleteQueryEXT(m_queryId); } void ThrottledTextureUploader::Query::begin() { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions()); - extensions->beginQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM, m_queryId); + m_context->beginQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM, m_queryId); } void ThrottledTextureUploader::Query::end() { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions()); - extensions->endQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM); + m_context->endQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM); } bool ThrottledTextureUploader::Query::isPending() { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions()); unsigned available = 1; - extensions->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_AVAILABLE_EXT, &available); + m_context->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_AVAILABLE_EXT, &available); return !available; } void ThrottledTextureUploader::Query::wait() { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions()); unsigned result; - extensions->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_EXT, &result); + m_context->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_EXT, &result); } -ThrottledTextureUploader::ThrottledTextureUploader(PassRefPtr<GraphicsContext3D> context) +ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context) : m_context(context) , m_maxPendingQueries(maxPendingQueries) { } -ThrottledTextureUploader::ThrottledTextureUploader(PassRefPtr<GraphicsContext3D> context, size_t pendingUploadLimit) +ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context, size_t pendingUploadLimit) : m_context(context) , m_maxPendingQueries(pendingUploadLimit) { + ASSERT(m_context); } ThrottledTextureUploader::~ThrottledTextureUploader() diff --git a/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.h b/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.h index dea3d354c..ae5b7491f 100644 --- a/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.h +++ b/Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.h @@ -29,16 +29,20 @@ #include <wtf/Deque.h> +namespace WebKit { +class WebGraphicsContext3D; +} + namespace WebCore { class ThrottledTextureUploader : public TextureUploader { WTF_MAKE_NONCOPYABLE(ThrottledTextureUploader); public: - static PassOwnPtr<ThrottledTextureUploader> create(PassRefPtr<GraphicsContext3D> context) + static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContext3D* context) { return adoptPtr(new ThrottledTextureUploader(context)); } - static PassOwnPtr<ThrottledTextureUploader> create(PassRefPtr<GraphicsContext3D> context, size_t pendingUploadLimit) + static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContext3D* context, size_t pendingUploadLimit) { return adoptPtr(new ThrottledTextureUploader(context, pendingUploadLimit)); } @@ -52,7 +56,7 @@ public: private: class Query { public: - static PassOwnPtr<Query> create(PassRefPtr<GraphicsContext3D> context) { return adoptPtr(new Query(context)); } + static PassOwnPtr<Query> create(WebKit::WebGraphicsContext3D* context) { return adoptPtr(new Query(context)); } virtual ~Query(); @@ -62,18 +66,18 @@ private: void wait(); private: - explicit Query(PassRefPtr<GraphicsContext3D>); + explicit Query(WebKit::WebGraphicsContext3D*); - RefPtr<GraphicsContext3D> m_context; + WebKit::WebGraphicsContext3D* m_context; unsigned m_queryId; }; - ThrottledTextureUploader(PassRefPtr<GraphicsContext3D>); - ThrottledTextureUploader(PassRefPtr<GraphicsContext3D>, size_t pendingUploadLimit); + ThrottledTextureUploader(WebKit::WebGraphicsContext3D*); + ThrottledTextureUploader(WebKit::WebGraphicsContext3D*, size_t pendingUploadLimit); void processQueries(); - RefPtr<GraphicsContext3D> m_context; + WebKit::WebGraphicsContext3D* m_context; size_t m_maxPendingQueries; Deque<OwnPtr<Query> > m_pendingQueries; Deque<OwnPtr<Query> > m_availableQueries; diff --git a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp index 957711eaa..8e586e25a 100644 --- a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp +++ b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp @@ -27,17 +27,19 @@ #include "TrackingTextureAllocator.h" #include "Extensions3DChromium.h" +#include "GraphicsContext3D.h" #include "IntRect.h" #include "LayerRendererChromium.h" // For the GLC() macro namespace WebCore { -TrackingTextureAllocator::TrackingTextureAllocator(PassRefPtr<GraphicsContext3D> context) +TrackingTextureAllocator::TrackingTextureAllocator(WebKit::WebGraphicsContext3D* context) : m_context(context) , m_currentMemoryUseBytes(0) , m_textureUsageHint(Any) , m_useTextureStorageExt(false) { + ASSERT(m_context); } TrackingTextureAllocator::~TrackingTextureAllocator() @@ -72,23 +74,22 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format); unsigned textureId = 0; - GLC(m_context.get(), textureId = m_context->createTexture()); - GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); + GLC(m_context, textureId = m_context->createTexture()); + GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); // Do basic linear filtering on resize. - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE. - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); if (m_textureUsageHint == FramebufferAttachment) - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Extensions3DChromium::GL_TEXTURE_USAGE_ANGLE, Extensions3DChromium::GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); + GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Extensions3DChromium::GL_TEXTURE_USAGE_ANGLE, Extensions3DChromium::GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions()); GC3Denum storageFormat = textureToStorageFormat(format); - extensions->texStorage2DEXT(GraphicsContext3D::TEXTURE_2D, 1, storageFormat, size.width(), size.height()); + m_context->texStorage2DEXT(GraphicsContext3D::TEXTURE_2D, 1, storageFormat, size.width(), size.height()); } else - GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE)); + GLC(m_context, m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE, 0)); m_allocatedTextureIds.add(textureId); return textureId; } @@ -96,7 +97,8 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& size, GC3Denum format) { m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format); - GLC(m_context.get(), m_context->deleteTexture(textureId)); + GLC(m_context, m_context->deleteTexture(textureId)); + GLC(m_context, m_context->deleteTexture(textureId)); ASSERT(m_allocatedTextureIds.contains(textureId)); m_allocatedTextureIds.remove(textureId); } @@ -104,7 +106,7 @@ void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& void TrackingTextureAllocator::deleteAllTextures() { for (HashSet<unsigned>::const_iterator it = m_allocatedTextureIds.begin(); it != m_allocatedTextureIds.end(); ++it) - GLC(m_context.get(), m_context->deleteTexture(*it)); + GLC(m_context, m_context->deleteTexture(*it)); m_currentMemoryUseBytes = 0; m_allocatedTextureIds.clear(); } diff --git a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h index 980b94e12..c10c25721 100644 --- a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h +++ b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h @@ -25,17 +25,20 @@ #ifndef TrackingTextureAllocator_h #define TrackingTextureAllocator_h -#include "GraphicsContext3D.h" #include "TextureManager.h" #include <wtf/HashSet.h> #include <wtf/PassRefPtr.h> +namespace WebKit { +class WebGraphicsContext3D; +} + namespace WebCore { class TrackingTextureAllocator : public TextureAllocator { WTF_MAKE_NONCOPYABLE(TrackingTextureAllocator); public: - static PassOwnPtr<TrackingTextureAllocator> create(PassRefPtr<GraphicsContext3D> context) + static PassOwnPtr<TrackingTextureAllocator> create(WebKit::WebGraphicsContext3D* context) { return adoptPtr(new TrackingTextureAllocator(context)); } @@ -53,9 +56,9 @@ public: void setUseTextureStorageExt(bool useStorageExt) { m_useTextureStorageExt = useStorageExt; } protected: - explicit TrackingTextureAllocator(PassRefPtr<GraphicsContext3D>); + explicit TrackingTextureAllocator(WebKit::WebGraphicsContext3D*); - RefPtr<GraphicsContext3D> m_context; + WebKit::WebGraphicsContext3D* m_context; size_t m_currentMemoryUseBytes; TextureUsageHint m_textureUsageHint; bool m_useTextureStorageExt; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h b/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h index 395f18c34..43536a421 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h @@ -26,32 +26,33 @@ #ifndef CCGraphicsContext_h #define CCGraphicsContext_h -#include "GraphicsContext3D.h" -#include <wtf/PassRefPtr.h> +#include <public/WebGraphicsContext3D.h> +#include <wtf/Noncopyable.h> +#include <wtf/OwnPtr.h> namespace WebCore { -class GraphicsContext3D; -class CCGraphicsContext : public RefCounted<CCGraphicsContext> { +class CCGraphicsContext { + WTF_MAKE_NONCOPYABLE(CCGraphicsContext); public: - static PassRefPtr<CCGraphicsContext> create2D() + static PassOwnPtr<CCGraphicsContext> create2D() { - return adoptRef(new CCGraphicsContext()); + return adoptPtr(new CCGraphicsContext()); } - static PassRefPtr<CCGraphicsContext> create3D(PassRefPtr<GraphicsContext3D> context3D) + static PassOwnPtr<CCGraphicsContext> create3D(PassOwnPtr<WebKit::WebGraphicsContext3D> context3D) { - return adoptRef(new CCGraphicsContext(context3D)); + return adoptPtr(new CCGraphicsContext(context3D)); } - GraphicsContext3D* context3D() { return m_context3D.get(); } + WebKit::WebGraphicsContext3D* context3D() { return m_context3D.get(); } private: CCGraphicsContext() { } - explicit CCGraphicsContext(PassRefPtr<GraphicsContext3D> context3D) + explicit CCGraphicsContext(PassOwnPtr<WebKit::WebGraphicsContext3D> context3D) : m_context3D(context3D) { } - RefPtr<GraphicsContext3D> m_context3D; + OwnPtr<WebKit::WebGraphicsContext3D> m_context3D; }; } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp index 1b61317cc..f3d415dcf 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp @@ -35,6 +35,7 @@ #include "cc/CCDebugRectHistory.h" #include "cc/CCFrameRateCounter.h" #include "cc/CCLayerTreeHostImpl.h" +#include <public/WebGraphicsContext3D.h> #include <wtf/text/WTFString.h> namespace WebCore { @@ -68,7 +69,7 @@ bool CCHeadsUpDisplay::showDebugRects(const CCLayerTreeSettings& settings) const void CCHeadsUpDisplay::draw(CCLayerTreeHostImpl* layerTreeHostImpl) { CCRenderer* layerRenderer = layerTreeHostImpl->layerRenderer(); - GraphicsContext3D* context = layerTreeHostImpl->context()->context3D(); + WebKit::WebGraphicsContext3D* context = layerTreeHostImpl->context()->context3D(); if (!context) { // FIXME: Implement this path for software compositing. return; @@ -106,13 +107,12 @@ void CCHeadsUpDisplay::draw(CCLayerTreeHostImpl* layerTreeHostImpl) m_hudTexture->bindTexture(layerTreeHostImpl->context(), layerRenderer->implTextureAllocator()); bool uploadedViaMap = false; if (layerRenderer->capabilities().usingMapSub) { - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions()); - uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY)); + uint8_t* pixelDest = static_cast<uint8_t*>(context->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY)); if (pixelDest) { uploadedViaMap = true; memcpy(pixelDest, locker.pixels(), hudSize.width() * hudSize.height() * 4); - extensions->unmapTexSubImage2DCHROMIUM(pixelDest); + context->unmapTexSubImage2DCHROMIUM(pixelDest); } } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp index f8446670a..ce3b38e96 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp @@ -29,13 +29,14 @@ #include "cc/CCIOSurfaceLayerImpl.h" -#include "Extensions3DChromium.h" +#include "Extensions3D.h" #include "LayerRendererChromium.h" #include "TextStream.h" #include "cc/CCGraphicsContext.h" #include "cc/CCIOSurfaceDrawQuad.h" #include "cc/CCLayerTreeHostImpl.h" #include "cc/CCQuadCuller.h" +#include <public/WebGraphicsContext3D.h> namespace WebCore { @@ -54,7 +55,7 @@ CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl() CCGraphicsContext* context = layerTreeHostImpl()->context(); // FIXME: Implement this path for software compositing. - GraphicsContext3D* context3d = context->context3D(); + WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (context3d) context3d->deleteTexture(m_ioSurfaceTextureId); } @@ -64,14 +65,11 @@ void CCIOSurfaceLayerImpl::willDraw(CCRenderer* layerRenderer, CCGraphicsContext CCLayerImpl::willDraw(layerRenderer, context); if (m_ioSurfaceChanged) { - GraphicsContext3D* context3d = context->context3D(); + WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. return; } - Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context3d->getExtensions()); - ASSERT(extensions->supports("GL_CHROMIUM_iosurface")); - ASSERT(extensions->supports("GL_ARB_texture_rectangle")); // FIXME: Do this in a way that we can track memory usage. if (!m_ioSurfaceTextureId) @@ -83,11 +81,11 @@ void CCIOSurfaceLayerImpl::willDraw(CCRenderer* layerRenderer, CCGraphicsContext GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); - extensions->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_ARB, - m_ioSurfaceSize.width(), - m_ioSurfaceSize.height(), - m_ioSurfaceId, - 0); + context3d->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_ARB, + m_ioSurfaceSize.width(), + m_ioSurfaceSize.height(), + m_ioSurfaceId, + 0); // Do not check for error conditions. texImageIOSurface2DCHROMIUM is supposed to hold on to // the last good IOSurface if the new one is already closed. This is only a possibility // during live resizing of plugins. However, it seems that this is not sufficient to diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp index 7d14cf5da..351112bd5 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp @@ -39,6 +39,7 @@ #include "cc/CCLayerTreeHostImpl.h" #include "cc/CCOcclusionTracker.h" #include "cc/CCOverdrawMetrics.h" +#include "cc/CCRenderingStats.h" #include "cc/CCSettings.h" #include "cc/CCSingleThreadProxy.h" #include "cc/CCThreadProxy.h" @@ -72,7 +73,8 @@ CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCLayerTre , m_animating(false) , m_needsAnimateLayers(false) , m_client(client) - , m_frameNumber(0) + , m_animationFrameNumber(0) + , m_commitNumber(0) , m_layerRendererInitialized(false) , m_contextLost(false) , m_numTimesRecreateShouldFail(0) @@ -211,6 +213,8 @@ void CCLayerTreeHost::updateAnimations(double monotonicFrameBeginTime) m_client->updateAnimations(monotonicFrameBeginTime); animateLayers(monotonicFrameBeginTime); m_animating = false; + + m_animationFrameNumber++; } void CCLayerTreeHost::layout() @@ -243,14 +247,14 @@ void CCLayerTreeHost::finishCommitOnImplThread(CCLayerTreeHostImpl* hostImpl) if (rootLayer() && m_needsAnimateLayers) hostImpl->setNeedsAnimateLayers(); - hostImpl->setSourceFrameNumber(frameNumber()); + hostImpl->setSourceFrameNumber(commitNumber()); hostImpl->setViewportSize(viewportSize()); hostImpl->setDeviceScaleFactor(deviceScaleFactor()); hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFactor, m_maxPageScaleFactor); hostImpl->setBackgroundColor(m_backgroundColor); hostImpl->setHasTransparentBackground(m_hasTransparentBackground); - m_frameNumber++; + m_commitNumber++; } void CCLayerTreeHost::commitComplete() @@ -260,9 +264,8 @@ void CCLayerTreeHost::commitComplete() m_client->didCommit(); } -PassRefPtr<CCGraphicsContext> CCLayerTreeHost::createContext() +PassOwnPtr<CCGraphicsContext> CCLayerTreeHost::createContext() { - RefPtr<CCGraphicsContext> context; if (settings().forceSoftwareCompositing) return CCGraphicsContext::create2D(); return CCGraphicsContext::create3D(m_client->createContext3D()); @@ -282,12 +285,6 @@ void CCLayerTreeHost::didLoseContext() setNeedsCommit(); } -// Temporary hack until WebViewImpl context creation gets simplified -CCGraphicsContext* CCLayerTreeHost::context() -{ - return m_proxy->context(); -} - bool CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect) { m_triggerIdlePaints = false; @@ -303,6 +300,12 @@ void CCLayerTreeHost::finishAllRendering() m_proxy->finishAllRendering(); } +void CCLayerTreeHost::renderingStats(CCRenderingStats& stats) const +{ + m_proxy->implSideRenderingStats(stats); + stats.numAnimationFrames = animationFrameNumber(); +} + const LayerRendererCapabilities& CCLayerTreeHost::layerRendererCapabilities() const { return m_proxy->layerRendererCapabilities(); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h index 6f6946e31..23ac33140 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h @@ -46,12 +46,13 @@ class CCGraphicsContext; class CCLayerChromium; class CCLayerTreeHostImpl; class CCLayerTreeHostImplClient; -struct CCScrollAndScaleSet; class CCTextureUpdater; class ManagedTexture; class Region; class TextureAllocator; class TextureManager; +struct CCRenderingStats; +struct CCScrollAndScaleSet; class CCLayerTreeHostClient { public: @@ -61,7 +62,7 @@ public: virtual void updateAnimations(double frameBeginTime) = 0; virtual void layout() = 0; virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0; - virtual PassRefPtr<GraphicsContext3D> createContext3D() = 0; + virtual PassOwnPtr<WebKit::WebGraphicsContext3D> createContext3D() = 0; virtual void didRecreateContext(bool success) = 0; virtual void willCommit() = 0; virtual void didCommit() = 0; @@ -117,6 +118,7 @@ struct LayerRendererCapabilities { , usingTextureStorageExtension(false) , usingGpuMemoryManager(false) , usingDiscardFramebuffer(false) + , usingEglImage(false) , maxTextureSize(0) { } GC3Denum bestTextureFormat; @@ -130,6 +132,7 @@ struct LayerRendererCapabilities { bool usingTextureStorageExtension; bool usingGpuMemoryManager; bool usingDiscardFramebuffer; + bool usingEglImage; int maxTextureSize; }; @@ -146,6 +149,7 @@ public: static bool needsFilterContext() { return s_needsFilterContext; } static void setNeedsFilterContext(bool needsFilterContext) { s_needsFilterContext = needsFilterContext; } + bool needsSharedContext() const { return needsFilterContext() || settings().acceleratePainting; } // CCLayerTreeHost interface to CCProxy. void willBeginFrame() { m_client->willBeginFrame(); } @@ -155,7 +159,7 @@ public: void beginCommitOnImplThread(CCLayerTreeHostImpl*); void finishCommitOnImplThread(CCLayerTreeHostImpl*); void commitComplete(); - PassRefPtr<CCGraphicsContext> createContext(); + PassOwnPtr<CCGraphicsContext> createContext(); virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient*); void didLoseContext(); enum RecreateResult { @@ -181,10 +185,6 @@ public: void composite(); void scheduleComposite(); - // NOTE: The returned value can only be used to make GL calls or make the - // context current on the thread the compositor is running on! - CCGraphicsContext* context(); - // Composites and attempts to read back the result into the provided // buffer. If it wasn't possible, e.g. due to context lost, will return // false. @@ -192,7 +192,11 @@ public: void finishAllRendering(); - int frameNumber() const { return m_frameNumber; } + int animationFrameNumber() const { return m_animationFrameNumber; } + + int commitNumber() const { return m_commitNumber; } + + void renderingStats(CCRenderingStats&) const; const LayerRendererCapabilities& layerRendererCapabilities() const; @@ -284,7 +288,8 @@ private: CCLayerTreeHostClient* m_client; - int m_frameNumber; + int m_animationFrameNumber; + int m_commitNumber; OwnPtr<CCProxy> m_proxy; bool m_layerRendererInitialized; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp index 9a11bd280..1dca36a60 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp @@ -114,7 +114,7 @@ PassOwnPtr<CCLayerTreeHostImpl> CCLayerTreeHostImpl::create(const CCLayerTreeSet CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CCLayerTreeHostImplClient* client) : m_client(client) , m_sourceFrameNumber(-1) - , m_frameNumber(0) + , m_sourceAnimationFrameNumber(0) , m_rootScrollLayerImpl(0) , m_currentlyScrollingLayerImpl(0) , m_scrollingLayerIdFromPreviousTree(-1) @@ -519,7 +519,7 @@ void CCLayerTreeHostImpl::drawLayers(const FrameData& frame) m_layerRenderer->finishDrawingFrame(); - ++m_frameNumber; + ++m_sourceAnimationFrameNumber; // The next frame should start by assuming nothing has changed, and changes are noted as they occur. m_rootLayerImpl->resetAllChangeTrackingForSubtree(); @@ -649,9 +649,9 @@ void CCLayerTreeHostImpl::setVisible(bool visible) setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); } -bool CCLayerTreeHostImpl::initializeLayerRenderer(PassRefPtr<CCGraphicsContext> context, TextureUploaderOption textureUploader) +bool CCLayerTreeHostImpl::initializeLayerRenderer(PassOwnPtr<CCGraphicsContext> context, TextureUploaderOption textureUploader) { - GraphicsContext3D* context3d = context->context3D(); + WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. return false; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h index 939e42e6b..726037f17 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h @@ -119,9 +119,9 @@ public: void setFontAtlas(PassOwnPtr<CCFontAtlas>); void finishAllRendering(); - int frameNumber() const { return m_frameNumber; } + int sourceAnimationFrameNumber() const { return m_sourceAnimationFrameNumber; } - bool initializeLayerRenderer(PassRefPtr<CCGraphicsContext>, TextureUploaderOption); + bool initializeLayerRenderer(PassOwnPtr<CCGraphicsContext>, TextureUploaderOption); bool isContextLost(); CCRenderer* layerRenderer() { return m_layerRenderer.get(); } const LayerRendererCapabilities& layerRendererCapabilities() const; @@ -196,7 +196,7 @@ protected: CCLayerTreeHostImplClient* m_client; int m_sourceFrameNumber; - int m_frameNumber; + int m_sourceAnimationFrameNumber; private: void computeDoubleTapZoomDeltas(CCScrollAndScaleSet* scrollInfo); @@ -224,7 +224,7 @@ private: void dumpRenderSurfaces(TextStream&, int indent, const CCLayerImpl*) const; - RefPtr<CCGraphicsContext> m_context; + OwnPtr<CCGraphicsContext> m_context; OwnPtr<CCRenderer> m_layerRenderer; OwnPtr<CCLayerImpl> m_rootLayerImpl; CCLayerImpl* m_rootScrollLayerImpl; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCOverdrawMetrics.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCOverdrawMetrics.cpp index 7b57c89b1..0cc2fa5ec 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCOverdrawMetrics.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCOverdrawMetrics.cpp @@ -131,9 +131,9 @@ template<typename LayerTreeHostType> void CCOverdrawMetrics::recordMetricsInternal(MetricsType metricsType, const LayerTreeHostType* layerTreeHost) const { // This gives approximately 10x the percentage of pixels to fill the viewport once. - float normalization = 1000.f / (layerTreeHost->viewportSize().width() * layerTreeHost->viewportSize().height()); + float normalization = 1000.f / (layerTreeHost->deviceViewportSize().width() * layerTreeHost->deviceViewportSize().height()); // This gives approximately 100x the percentage of tiles to fill the viewport once, if all tiles were 256x256. - float tileNormalization = 10000.f / (layerTreeHost->viewportSize().width() / 256.f * layerTreeHost->viewportSize().height() / 256.f); + float tileNormalization = 10000.f / (layerTreeHost->deviceViewportSize().width() / 256.f * layerTreeHost->deviceViewportSize().height() / 256.f); switch (metricsType) { case DrawingToScreen: @@ -142,8 +142,8 @@ void CCOverdrawMetrics::recordMetricsInternal(MetricsType metricsType, const Lay WebKit::Platform::current()->histogramCustomCounts("Renderer4.pixelCountCulled_Draw", static_cast<int>(normalization * m_pixelsCulledForDrawing), 100, 1000000, 50); { - TRACE_COUNTER_ID1("webkit", "DrawPixelsCulled", layerTreeHost, m_pixelsCulledForDrawing); - TRACE_EVENT2("webkit", "CCOverdrawMetrics", "PixelsDrawnOpaque", m_pixelsDrawnOpaque, "PixelsDrawnTranslucent", m_pixelsDrawnTranslucent); + TRACE_COUNTER_ID1("cc", "DrawPixelsCulled", layerTreeHost, m_pixelsCulledForDrawing); + TRACE_EVENT2("cc", "CCOverdrawMetrics", "PixelsDrawnOpaque", m_pixelsDrawnOpaque, "PixelsDrawnTranslucent", m_pixelsDrawnTranslucent); } break; case UpdateAndCommit: @@ -153,12 +153,12 @@ void CCOverdrawMetrics::recordMetricsInternal(MetricsType metricsType, const Lay WebKit::Platform::current()->histogramCustomCounts("Renderer4.tileCountCulled_Upload", static_cast<int>(tileNormalization * m_tilesCulledForUpload), 100, 10000000, 50); { - TRACE_COUNTER_ID1("webkit", "UploadTilesCulled", layerTreeHost, m_tilesCulledForUpload); - TRACE_EVENT2("webkit", "CCOverdrawMetrics", "PixelsUploadedOpaque", m_pixelsUploadedOpaque, "PixelsUploadedTranslucent", m_pixelsUploadedTranslucent); + TRACE_COUNTER_ID1("cc", "UploadTilesCulled", layerTreeHost, m_tilesCulledForUpload); + TRACE_EVENT2("cc", "CCOverdrawMetrics", "PixelsUploadedOpaque", m_pixelsUploadedOpaque, "PixelsUploadedTranslucent", m_pixelsUploadedTranslucent); } { // This must be in a different scope than the TRACE_EVENT2 above. - TRACE_EVENT1("webkit", "CCOverdrawPaintMetrics", "PixelsPainted", m_pixelsPainted); + TRACE_EVENT1("cc", "CCOverdrawPaintMetrics", "PixelsPainted", m_pixelsPainted); } break; } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h index 1c2f9cafd..f19032abb 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h @@ -36,6 +36,7 @@ namespace WebCore { class CCFontAtlas; class CCThread; class CCGraphicsContext; +struct CCRenderingStats; struct LayerRendererCapabilities; // Abstract class responsible for proxying commands from the main-thread side of @@ -81,6 +82,8 @@ public: virtual int compositorIdentifier() const = 0; + virtual void implSideRenderingStats(CCRenderingStats&) = 0; + virtual const LayerRendererCapabilities& layerRendererCapabilities() const = 0; virtual void setNeedsAnimate() = 0; @@ -113,9 +116,6 @@ public: static void setMainThreadBlocked(bool); #endif - // Temporary hack while render_widget still does scheduling for CCLayerTreeHostMainThreadI - virtual CCGraphicsContext* context() = 0; - // Testing hooks virtual void loseContext() = 0; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h b/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h new file mode 100644 index 000000000..f69c8e026 --- /dev/null +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2012 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. 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 CCRenderingStats_h +#define CCRenderingStats_h + +namespace WebCore { + +struct CCRenderingStats { + int numAnimationFrames; + int numFramesSentToScreen; + + CCRenderingStats() + : numAnimationFrames(0) + , numFramesSentToScreen(0) + { + } +}; + +} + +#endif diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp index f54ba7750..d69e4bc45 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp @@ -31,6 +31,7 @@ #include "cc/CCFontAtlas.h" #include "cc/CCGraphicsContext.h" #include "cc/CCLayerTreeHost.h" +#include "cc/CCRenderingStats.h" #include "cc/CCTextureUpdater.h" #include "cc/CCTimer.h" #include <wtf/CurrentTime.h> @@ -39,26 +40,6 @@ using namespace WTF; namespace WebCore { -class CCSingleThreadProxyAnimationTimer : public CCTimer, CCTimerClient { -public: - static PassOwnPtr<CCSingleThreadProxyAnimationTimer> create(CCSingleThreadProxy* proxy) { return adoptPtr(new CCSingleThreadProxyAnimationTimer(proxy)); } - - virtual void onTimerFired() OVERRIDE - { - if (m_proxy->m_layerRendererInitialized) - m_proxy->compositeImmediately(); - } - -private: - explicit CCSingleThreadProxyAnimationTimer(CCSingleThreadProxy* proxy) - : CCTimer(CCProxy::mainThread(), this) - , m_proxy(proxy) - { - } - - CCSingleThreadProxy* m_proxy; -}; - PassOwnPtr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost) { return adoptPtr(new CCSingleThreadProxy(layerTreeHost)); @@ -68,7 +49,6 @@ CCSingleThreadProxy::CCSingleThreadProxy(CCLayerTreeHost* layerTreeHost) : m_layerTreeHost(layerTreeHost) , m_contextLost(false) , m_compositorIdentifier(-1) - , m_animationTimer(CCSingleThreadProxyAnimationTimer::create(this)) , m_layerRendererInitialized(false) , m_nextFrameIsNewlyCommittedFrame(false) { @@ -113,15 +93,6 @@ void CCSingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration); } -CCGraphicsContext* CCSingleThreadProxy::context() -{ - ASSERT(CCProxy::isMainThread()); - if (m_contextBeforeInitialization) - return m_contextBeforeInitialization.get(); - DebugScopedSetImplThread impl; - return m_layerTreeHostImpl->context(); -} - void CCSingleThreadProxy::finishAllRendering() { ASSERT(CCProxy::isMainThread()); @@ -140,11 +111,10 @@ bool CCSingleThreadProxy::isStarted() const bool CCSingleThreadProxy::initializeContext() { ASSERT(CCProxy::isMainThread()); - RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); + OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); if (!context) return false; - ASSERT(context->hasOneRef()); - m_contextBeforeInitialization = context; + m_contextBeforeInitialization = context.release(); return true; } @@ -169,9 +139,7 @@ bool CCSingleThreadProxy::initializeLayerRenderer() if (ok) { m_layerRendererInitialized = true; m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities(); - } else - // If we couldn't initialize the layer renderer, we shouldn't process any future animation events. - m_animationTimer->stop(); + } return ok; } @@ -183,16 +151,15 @@ bool CCSingleThreadProxy::recreateContext() ASSERT(CCProxy::isMainThread()); ASSERT(m_contextLost); - RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); + OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); if (!context) return false; - ASSERT(context->hasOneRef()); bool initialized; { DebugScopedSetImplThread impl; m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator()); - initialized = m_layerTreeHostImpl->initializeLayerRenderer(context, UnthrottledUploader); + initialized = m_layerTreeHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader); if (initialized) { m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities(); } @@ -204,6 +171,11 @@ bool CCSingleThreadProxy::recreateContext() return initialized; } +void CCSingleThreadProxy::implSideRenderingStats(CCRenderingStats& stats) +{ + stats.numFramesSentToScreen = m_layerTreeHostImpl->sourceAnimationFrameNumber(); +} + const LayerRendererCapabilities& CCSingleThreadProxy::layerRendererCapabilities() const { ASSERT(m_layerRendererInitialized); @@ -279,7 +251,6 @@ bool CCSingleThreadProxy::commitRequested() const void CCSingleThreadProxy::didAddAnimation() { - m_animationTimer->startOneShot(animationTimerDelay()); } void CCSingleThreadProxy::stop() @@ -320,11 +291,6 @@ void CCSingleThreadProxy::compositeImmediately() } } -double CCSingleThreadProxy::animationTimerDelay() -{ - return 1 / 60.0; -} - void CCSingleThreadProxy::forceSerializeOnSwapBuffers() { { diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h index 46cb302ac..e8aa75515 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h @@ -34,7 +34,6 @@ namespace WebCore { class CCLayerTreeHost; -class CCSingleThreadProxyAnimationTimer; class CCSingleThreadProxy : public CCProxy, CCLayerTreeHostImplClient { public: @@ -44,7 +43,6 @@ public: // CCProxy implementation virtual bool compositeAndReadback(void *pixels, const IntRect&) OVERRIDE; virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration) OVERRIDE; - virtual CCGraphicsContext* context() OVERRIDE; virtual void finishAllRendering() OVERRIDE; virtual bool isStarted() const OVERRIDE; virtual bool initializeContext() OVERRIDE; @@ -53,6 +51,7 @@ public: virtual bool initializeLayerRenderer() OVERRIDE; virtual bool recreateContext() OVERRIDE; virtual int compositorIdentifier() const OVERRIDE { return m_compositorIdentifier; } + virtual void implSideRenderingStats(CCRenderingStats&) OVERRIDE; virtual const LayerRendererCapabilities& layerRendererCapabilities() const OVERRIDE; virtual void loseContext() OVERRIDE; virtual void setNeedsAnimate() OVERRIDE; @@ -77,12 +76,7 @@ public: // Called by the legacy path where RenderWidget does the scheduling. void compositeImmediately(); - // Measured in seconds. - static double animationTimerDelay(); - private: - friend class CCSingleThreadProxyAnimationTimer; - explicit CCSingleThreadProxy(CCLayerTreeHost*); bool commitAndComposite(); @@ -97,9 +91,7 @@ private: // Holds on to the context between initializeContext() and initializeLayerRenderer() calls. Shouldn't // be used for anything else. - RefPtr<CCGraphicsContext> m_contextBeforeInitialization; - - OwnPtr<CCSingleThreadProxyAnimationTimer> m_animationTimer; + OwnPtr<CCGraphicsContext> m_contextBeforeInitialization; // Used on the CCThread, but checked on main thread during initialization/shutdown. OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp index 1fd0c736e..c3299939b 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp @@ -129,7 +129,7 @@ void CCTextureUpdater::update(CCGraphicsContext* context, TextureAllocator* allo // before letting the main thread proceed as it may make draw calls to the source texture of one of // our copy operations. if (m_copyEntries.size()) { - GraphicsContext3D* context3d = context->context3D(); + WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (context3d) context3d->flush(); // FIXME: Implement this path for software compositing. diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp index e2ecb9c58..382274746 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp @@ -36,6 +36,7 @@ #include "cc/CCGraphicsContext.h" #include "cc/CCInputHandler.h" #include "cc/CCLayerTreeHost.h" +#include "cc/CCRenderingStats.h" #include "cc/CCScheduler.h" #include "cc/CCScopedThreadProxy.h" #include "cc/CCTextureUpdater.h" @@ -156,11 +157,6 @@ void CCThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPos m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scale, monotonicallyIncreasingTime(), duration); } -CCGraphicsContext* CCThreadProxy::context() -{ - return 0; -} - void CCThreadProxy::finishAllRendering() { ASSERT(CCProxy::isMainThread()); @@ -180,17 +176,12 @@ bool CCThreadProxy::isStarted() const bool CCThreadProxy::initializeContext() { TRACE_EVENT("CCThreadProxy::initializeContext", this, 0); - RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); + OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); if (!context) return false; - ASSERT(context->hasOneRef()); - - // Leak the context pointer so we can transfer ownership of it to the other side... - CCGraphicsContext* contextPtr = context.release().leakRef(); - ASSERT(contextPtr->hasOneRef()); CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::initializeContextOnImplThread, - AllowCrossThreadAccess(contextPtr))); + AllowCrossThreadAccess(context.leakPtr()))); return true; } @@ -249,19 +240,13 @@ bool CCThreadProxy::recreateContext() ASSERT(isMainThread()); // Try to create the context. - RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); + OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext(); if (!context) return false; - if (CCLayerTreeHost::needsFilterContext() && !m_layerTreeHost->settings().forceSoftwareCompositing) + if (m_layerTreeHost->needsSharedContext() && !m_layerTreeHost->settings().forceSoftwareCompositing) if (!SharedGraphicsContext3D::createForImplThread()) return false; - ASSERT(context->hasOneRef()); - - // Leak the context pointer so we can transfer ownership of it to the other side... - CCGraphicsContext* contextPtr = context.release().leakRef(); - ASSERT(contextPtr->hasOneRef()); - // Make a blocking call to recreateContextOnImplThread. The results of that // call are pushed into the recreateSucceeded and capabilities local // variables. @@ -270,7 +255,7 @@ bool CCThreadProxy::recreateContext() LayerRendererCapabilities capabilities; CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::recreateContextOnImplThread, AllowCrossThreadAccess(&completion), - AllowCrossThreadAccess(contextPtr), + AllowCrossThreadAccess(context.leakPtr()), AllowCrossThreadAccess(&recreateSucceeded), AllowCrossThreadAccess(&capabilities))); completion.wait(); @@ -286,6 +271,17 @@ int CCThreadProxy::compositorIdentifier() const return m_compositorIdentifier; } +void CCThreadProxy::implSideRenderingStats(CCRenderingStats& stats) +{ + ASSERT(isMainThread()); + + CCCompletionEvent completion; + CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::implSideRenderingStatsOnImplThread, + AllowCrossThreadAccess(&completion), + AllowCrossThreadAccess(&stats))); + completion.wait(); +} + const LayerRendererCapabilities& CCThreadProxy::layerRendererCapabilities() const { ASSERT(m_layerRendererInitialized); @@ -480,7 +476,7 @@ void CCThreadProxy::beginFrame() return; } - if (CCLayerTreeHost::needsFilterContext() && !m_layerTreeHost->settings().forceSoftwareCompositing && !SharedGraphicsContext3D::haveForImplThread()) + if (m_layerTreeHost->needsSharedContext() && !m_layerTreeHost->settings().forceSoftwareCompositing && !SharedGraphicsContext3D::haveForImplThread()) SharedGraphicsContext3D::createForImplThread(); OwnPtr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.release()); @@ -621,7 +617,6 @@ void CCThreadProxy::scheduledActionCommit() m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); - m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); m_layerTreeHostImpl->commitComplete(); @@ -629,6 +624,9 @@ void CCThreadProxy::scheduledActionCommit() m_commitCompletionEventOnImplThread->signal(); m_commitCompletionEventOnImplThread = 0; + + // SetVisible kicks off the next scheduler action, so this must be last. + m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); } void CCThreadProxy::scheduledActionBeginContextRecreation() @@ -828,7 +826,7 @@ void CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context) { TRACE_EVENT("CCThreadProxy::initializeContextOnImplThread", this, 0); ASSERT(isImplThread()); - m_contextBeforeInitializationOnImplThread = adoptRef(context); + m_contextBeforeInitializationOnImplThread = adoptPtr(context); } void CCThreadProxy::initializeLayerRendererOnImplThread(CCCompletionEvent* completion, bool* initializeSucceeded, LayerRendererCapabilities* capabilities) @@ -887,7 +885,7 @@ void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); ASSERT(isImplThread()); m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator()); - *recreateSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(adoptRef(contextPtr), textureUploader); + *recreateSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(adoptPtr(contextPtr), textureUploader); if (*recreateSucceeded) { *capabilities = m_layerTreeHostImpl->layerRendererCapabilities(); m_schedulerOnImplThread->didRecreateContext(); @@ -895,4 +893,11 @@ void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C completion->signal(); } +void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* completion, CCRenderingStats* stats) +{ + ASSERT(isImplThread()); + stats->numFramesSentToScreen = m_layerTreeHostImpl->sourceAnimationFrameNumber(); + completion->signal(); +} + } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h index 572f9f488..e10c3dcb0 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h @@ -51,7 +51,6 @@ public: // CCProxy implementation virtual bool compositeAndReadback(void *pixels, const IntRect&) OVERRIDE; virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double duration) OVERRIDE; - virtual CCGraphicsContext* context() OVERRIDE; virtual void finishAllRendering() OVERRIDE; virtual bool isStarted() const OVERRIDE; virtual bool initializeContext() OVERRIDE; @@ -60,6 +59,7 @@ public: virtual bool initializeLayerRenderer() OVERRIDE; virtual bool recreateContext() OVERRIDE; virtual int compositorIdentifier() const OVERRIDE; + virtual void implSideRenderingStats(CCRenderingStats&) OVERRIDE; virtual const LayerRendererCapabilities& layerRendererCapabilities() const OVERRIDE; virtual void loseContext() OVERRIDE; virtual void setNeedsAnimate() OVERRIDE; @@ -142,6 +142,7 @@ private: void setFullRootLayerDamageOnImplThread(); void acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEvent*); void recreateContextOnImplThread(CCCompletionEvent*, CCGraphicsContext*, bool* recreateSucceeded, LayerRendererCapabilities*); + void implSideRenderingStatsOnImplThread(CCCompletionEvent*, CCRenderingStats*); CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool forcedDraw); void setFontAtlasOnImplThread(PassOwnPtr<CCFontAtlas>); void forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent*); @@ -171,7 +172,7 @@ private: // Holds on to the context we might use for compositing in between initializeContext() // and initializeLayerRenderer() calls. - RefPtr<CCGraphicsContext> m_contextBeforeInitializationOnImplThread; + OwnPtr<CCGraphicsContext> m_contextBeforeInitializationOnImplThread; // Set when the main thread is waiting on a scheduledActionBeginFrame to be issued. CCCompletionEvent* m_beginFrameCompletionEventOnImplThread; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp index dbb07a004..3e1f58135 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp @@ -213,7 +213,7 @@ void CCVideoLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadSta FloatRect uvRect(0, 0, 1, 1); #if defined(OS_CHROMEOS) && defined(__ARMEL__) bool flipped = true; // Under the covers, implemented by OpenMAX IL. -#elif defined(OS_WINDOWS) +#elif OS(WINDOWS) bool flipped = true; // Under the covers, implemented by DXVA. #else bool flipped = false; // LibVA (cros/intel), MacOS. @@ -288,7 +288,7 @@ bool CCVideoLayerImpl::FramePlane::allocateData(CCGraphicsContext* context) if (textureId) return true; - GraphicsContext3D* context3D = context->context3D(); + WebKit::WebGraphicsContext3D* context3D = context->context3D(); if (!context3D) return false; @@ -301,7 +301,7 @@ bool CCVideoLayerImpl::FramePlane::allocateData(CCGraphicsContext* context) GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); - GLC(context3D, context3D->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE)); + GLC(context3D, context3D->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE, 0)); return textureId; } @@ -311,7 +311,7 @@ void CCVideoLayerImpl::FramePlane::freeData(CCGraphicsContext* context) if (!textureId) return; - GraphicsContext3D* context3D = context->context3D(); + WebKit::WebGraphicsContext3D* context3D = context->context3D(); if (!context3D) return; @@ -351,7 +351,7 @@ bool CCVideoLayerImpl::copyPlaneData(CCRenderer* layerRenderer, CCGraphicsContex if (!softwarePlaneCount) return true; - GraphicsContext3D* context3d = context->context3D(); + WebKit::WebGraphicsContext3D* context3d = context->context3D(); if (!context3d) { // FIXME: Implement this path for software compositing. return false; diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index d2854486b..e9d1bc119 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -749,6 +749,8 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message) gst_message_parse_error(message, &err.outPtr(), &debug.outPtr()); LOG_VERBOSE(Media, "Error: %d, %s", err->code, err->message); + GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin), GST_DEBUG_GRAPH_SHOW_ALL, "webkit-video.error"); + error = MediaPlayer::Empty; if (err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND || err->code == GST_STREAM_ERROR_WRONG_TYPE @@ -788,8 +790,19 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message) // Ignore state changes from internal elements. They are // forwarded to playbin2 anyway. - if (GST_MESSAGE_SRC(message) == reinterpret_cast<GstObject*>(m_playBin)) + if (GST_MESSAGE_SRC(message) == reinterpret_cast<GstObject*>(m_playBin)) { updateStates(); + + // Construct a filename for the graphviz dot file output. + GstState oldState, newState; + gst_message_parse_state_changed(message, &oldState, &newState, 0); + + CString dotFileName = String::format("webkit-video.%s_%s", + gst_element_state_get_name(oldState), + gst_element_state_get_name(newState)).utf8(); + + GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin), GST_DEBUG_GRAPH_SHOW_ALL, dotFileName.data()); + } break; case GST_MESSAGE_BUFFERING: processBufferingStats(message); diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp index 2f5262195..7be2c5e05 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp @@ -35,6 +35,7 @@ #include "SharedBuffer.h" #if HAVE(QT5) #include <QWindow> +#include <qpa/qplatformpixmap.h> #endif #include <wtf/UnusedParam.h> #include <wtf/text/CString.h> @@ -312,6 +313,7 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool) : m_currentWidth(0) , m_currentHeight(0) + , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT) , m_attrs(attrs) , m_texture(0) , m_compositorTexture(0) @@ -412,6 +414,7 @@ GraphicsContext3D::~GraphicsContext3D() // If GraphicsContext3D init failed in constructor, m_private set to nullptr and no buffers are allocated. if (!m_private) return; + makeContextCurrent(); glDeleteTextures(1, &m_texture); glDeleteFramebuffers(1, &m_fbo); @@ -484,25 +487,46 @@ bool GraphicsContext3D::getImageData(Image* image, UNUSED_PARAM(ignoreGammaAndColorProfile); if (!image) return false; - QImage nativeImage; + + QImage qtImage; // Is image already loaded? If not, load it. if (image->data()) - nativeImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size()).convertToFormat(QImage::Format_ARGB32); + qtImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size()); else { QPixmap* nativePixmap = image->nativeImageForCurrentFrame(); - nativeImage = nativePixmap->toImage().convertToFormat(QImage::Format_ARGB32); +#if HAVE(QT5) + // With QPA, we can avoid a deep copy. + qtImage = *nativePixmap->handle()->buffer(); +#else + // This might be a deep copy, depending on other references to the pixmap. + qtImage = nativePixmap->toImage(); +#endif + } + + AlphaOp alphaOp = AlphaDoNothing; + switch (qtImage.format()) { + case QImage::Format_ARGB32: + if (premultiplyAlpha) + alphaOp = AlphaDoPremultiply; + break; + case QImage::Format_ARGB32_Premultiplied: + if (!premultiplyAlpha) + alphaOp = AlphaDoUnmultiply; + break; + default: + // The image has a format that is not supported in packPixels. We have to convert it here. + qtImage = qtImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32); + break; } - AlphaOp neededAlphaOp = AlphaDoNothing; - if (premultiplyAlpha) - neededAlphaOp = AlphaDoPremultiply; unsigned int packedSize; // Output data is tightly packed (alignment == 1). if (computeImageSizeInBytes(format, type, image->width(), image->height(), 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR) return false; + outputVector.resize(packedSize); - return packPixels(nativeImage.bits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, neededAlphaOp, outputVector.data()); + return packPixels(qtImage.bits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data()); } void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>) diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp index ee8b92248..ac3d929bc 100644 --- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp @@ -202,12 +202,7 @@ void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) { - if (src == dst) - return true; - // If we're rendering into a deferred canvas, we need to make a deep copy of the source pixels because Skia does not - // retain a reference to the actual pixels otherwise. We check if we're drawing into a deferred canvas by seeing if the - // device's bitmap configuration is set or not - if it's not, then we must not have a bitmap target yet. - return dst->platformContext()->canvas()->getDevice()->config() == SkBitmap::kNo_Config; + return dst->platformContext()->isDeferred() || src == dst; } void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp index d7bab4392..74a4f38cf 100644 --- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp @@ -122,7 +122,11 @@ PlatformContextSkia::State::State() , m_lineJoin(SkPaint::kDefault_Join) , m_dash(0) , m_textDrawingMode(TextModeFill) +#if USE(LOW_QUALITY_IMAGE_INTERPOLATION) + , m_interpolationQuality(InterpolationLow) +#else , m_interpolationQuality(InterpolationHigh) +#endif { } @@ -182,6 +186,7 @@ PlatformContextSkia::PlatformContextSkia(SkCanvas* canvas) , m_trackOpaqueRegion(false) , m_printing(false) , m_accelerated(false) + , m_deferred(false) , m_drawingToImageBuffer(false) { m_stateStack.append(State()); diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h index 1c85ec928..b9fcb7b42 100644 --- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h +++ b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h @@ -186,6 +186,12 @@ public: bool isAccelerated() const { return m_accelerated; } void setAccelerated(bool accelerated) { m_accelerated = accelerated; } + // True if this context is deferring draw calls to be executed later. + // We need to know this for context-to-context draws, in order to know if + // the source bitmap needs to be copied. + bool isDeferred() const { return m_deferred; } + void setDeferred(bool deferred) { m_deferred = deferred; } + void setTrackOpaqueRegion(bool track) { m_trackOpaqueRegion = track; } // This will be an empty region unless tracking is enabled. @@ -235,6 +241,7 @@ private: FloatSize m_imageResamplingHintDstSize; bool m_printing; bool m_accelerated; + bool m_deferred; bool m_drawingToImageBuffer; }; diff --git a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp index a8fe4ddc2..84312def2 100644 --- a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp +++ b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp @@ -88,6 +88,12 @@ void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, cons glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, 0, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glPopAttrib(); + + // According to IOSurface's documentation, glBindFramebuffer is the one triggering an update of the surface's cache. + // If the web process starts rendering and unlocks the surface before this happens, we might copy contents + // of the currently rendering frame on our texture instead of the previously completed frame. + // Flush the command buffer to reduce the odds of this happening, this would not be necessary with double buffering. + glFlush(); } void GraphicsSurface::platformCopyFromFramebuffer(uint32_t originFbo, const IntRect& sourceRect) @@ -168,18 +174,14 @@ static int ioSurfaceLockOptions(int lockOptions) return options; } -static int ioSurfaceUnlockOptions(int lockOptions) -{ - int options = 0; - if (lockOptions & GraphicsSurface::ReadOnly) - options |= (kIOSurfaceLockAvoidSync | kIOSurfaceLockReadOnly); - return options; -} - char* GraphicsSurface::platformLock(const IntRect& rect, int* outputStride, LockOptions lockOptions) { m_lockOptions = lockOptions; - IOSurfaceLock(m_platformSurface, ioSurfaceLockOptions(m_lockOptions), 0); + IOReturn status = IOSurfaceLock(m_platformSurface, ioSurfaceLockOptions(m_lockOptions), 0); + if (status == kIOReturnCannotLock) { + m_lockOptions |= RetainPixels; + IOSurfaceLock(m_platformSurface, ioSurfaceLockOptions(m_lockOptions), 0); + } int stride = IOSurfaceGetBytesPerRow(m_platformSurface); if (outputStride) @@ -191,7 +193,7 @@ char* GraphicsSurface::platformLock(const IntRect& rect, int* outputStride, Lock void GraphicsSurface::platformUnlock() { - IOSurfaceUnlock(m_platformSurface, ioSurfaceUnlockOptions(m_lockOptions) & (~kIOSurfaceLockAvoidSync), 0); + IOSurfaceUnlock(m_platformSurface, ioSurfaceLockOptions(m_lockOptions), 0); } void GraphicsSurface::platformDestroy() diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp index 6e176e865..6db7d6f0d 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp +++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp @@ -22,6 +22,7 @@ #include "TextureMapperGL.h" #include "GraphicsContext.h" +#include "GraphicsContext3D.h" #include "Image.h" #include "TextureMapperShaderManager.h" #include "Timer.h" @@ -36,9 +37,8 @@ #endif #if PLATFORM(QT) -#if QT_VERSION >= 0x050000 +#if HAVE(QT5) #include <QOpenGLContext> -#include <qpa/qplatformpixmap.h> #else #include <QGLContext> #endif // QT_VERSION @@ -50,12 +50,6 @@ #include <GL/glx.h> #endif -#if USE(CAIRO) -#include "CairoUtilities.h" -#include "RefPtrCairo.h" -#include <cairo.h> -#endif - #define GL_CMD(...) do { __VA_ARGS__; ASSERT_ARG(__VA_ARGS__, !glGetError()); } while (0) namespace WebCore { struct TextureMapperGLData { @@ -447,26 +441,6 @@ bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags) #define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_BYTE #endif -static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride = 0) -{ - stride = stride ? stride : rect.width(); - for (int y = rect.y(); y < rect.maxY(); ++y) { - uint32_t* p = data + y * stride; - for (int x = rect.x(); x < rect.maxX(); ++x) - p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); - } -} - -static bool driverSupportsBGRASwizzling() -{ -#if defined(TEXMAP_OPENGL_ES_2) - // FIXME: Implement reliable detection. See also https://bugs.webkit.org/show_bug.cgi?id=81103. - return false; -#else - return true; -#endif -} - static bool driverSupportsSubImage() { #if defined(TEXMAP_OPENGL_ES_2) @@ -486,57 +460,50 @@ void BitmapTextureGL::didReset() if (m_textureSize == contentSize()) return; - GLuint format = driverSupportsBGRASwizzling() ? GL_BGRA : GL_RGBA; - m_textureSize = contentSize(); GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id)); GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); - GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0)); + GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, GL_RGBA, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0)); } void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine) { - GLuint glFormat = GL_RGBA; GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id)); - if (driverSupportsBGRASwizzling()) - glFormat = GL_BGRA; - else - swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(const_cast<void*>(data)), IntRect(sourceOffset, targetRect.size()), bytesPerLine / 4); - - if (bytesPerLine == targetRect.width() / 4 && sourceOffset == IntPoint::zero()) { - GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); + const unsigned bytesPerPixel = 4; + if (bytesPerLine == targetRect.width() * bytesPerPixel && sourceOffset == IntPoint::zero()) { + GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), GL_RGBA, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); return; } // For ES drivers that don't support sub-images. if (!driverSupportsSubImage()) { const char* bits = static_cast<const char*>(data); - const char* src = bits + sourceOffset.y() * bytesPerLine + sourceOffset.x() * 4; - Vector<char> temporaryData(targetRect.width() * targetRect.height() * 4); + const char* src = bits + sourceOffset.y() * bytesPerLine + sourceOffset.x() * bytesPerPixel; + Vector<char> temporaryData(targetRect.width() * targetRect.height() * bytesPerPixel); char* dst = temporaryData.data(); - const int targetBytesPerLine = targetRect.width() * 4; + const int targetBytesPerLine = targetRect.width() * bytesPerPixel; for (int y = 0; y < targetRect.height(); ++y) { memcpy(dst, src, targetBytesPerLine); src += bytesPerLine; dst += targetBytesPerLine; } - GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, temporaryData.data())); + GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), GL_RGBA, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, temporaryData.data())); return; } #if !defined(TEXMAP_OPENGL_ES_2) // Use the OpenGL sub-image extension, now that we know it's available. - GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / 4)); + GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel)); GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y())); GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x())); - GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); + GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), GL_RGBA, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)); GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, 0)); GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0)); @@ -547,31 +514,12 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co { if (!image) return; - NativeImagePtr frameImage = image->nativeImageForCurrentFrame(); - if (!frameImage) - return; - int bytesPerLine; - const char* imageData; - -#if PLATFORM(QT) - QImage qtImage; -#if HAVE(QT5) - // With QPA, we can avoid a deep copy. - qtImage = *frameImage->handle()->buffer(); -#else - // This might be a deep copy, depending on other references to the pixmap. - qtImage = frameImage->toImage(); -#endif - imageData = reinterpret_cast<const char*>(qtImage.constBits()); - bytesPerLine = qtImage.bytesPerLine(); -#elif USE(CAIRO) - cairo_surface_t* surface = frameImage->surface(); - imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface)); - bytesPerLine = cairo_image_surface_get_stride(surface); -#endif + Vector<uint8_t> imageData; + GraphicsContext3D::extractImageData(image, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, false /* flipY */, true /* premultiplyAlpha */, false /* ignoreGammaAndColorProfile */, imageData); - updateContents(imageData, targetRect, offset, bytesPerLine); + const unsigned bytesPerPixel = 4; + updateContents(imageData.data(), targetRect, offset, image->width() * bytesPerPixel); } #if ENABLE(CSS_FILTERS) diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp index c138912ec..fd4bf2f7a 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp +++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp @@ -351,9 +351,6 @@ void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options TextureMapperPaintOptions paintOptions(options); paintOptions.mask = maskTexture.get(); - IntRect surfaceRect; - - RefPtr<BitmapTexture> surface; if (!shouldPaintToIntermediateSurface()) { paintOptions.opacity = opacity; @@ -363,8 +360,9 @@ void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options // Prepare a surface to paint into. // We paint into the surface ignoring the opacity/transform of the current layer. - surfaceRect = intermediateSurfaceRect(); - surface = options.textureMapper->acquireTextureFromPool(surfaceRect.size()); + IntRect surfaceRect = intermediateSurfaceRect(); + RefPtr<BitmapTexture> surface = options.textureMapper->acquireTextureFromPool(surfaceRect.size()); + paintOptions.surface = surface; options.textureMapper->bindSurface(surface.get()); paintOptions.opacity = 1; diff --git a/Source/WebCore/platform/image-decoders/ImageDecoder.h b/Source/WebCore/platform/image-decoders/ImageDecoder.h index e92ba7dae..2611be900 100644 --- a/Source/WebCore/platform/image-decoders/ImageDecoder.h +++ b/Source/WebCore/platform/image-decoders/ImageDecoder.h @@ -362,7 +362,7 @@ namespace WebCore { int scaledY(int origY, int searchStart = 0); RefPtr<SharedBuffer> m_data; // The encoded data. - Vector<ImageFrame> m_frameBufferCache; + Vector<ImageFrame, 1> m_frameBufferCache; // FIXME: Do we need m_colorProfile any more, for any port? ColorProfile m_colorProfile; bool m_scaled; diff --git a/Source/WebCore/platform/text/LocaleICU.cpp b/Source/WebCore/platform/text/LocaleICU.cpp index 56d6a7760..f6b4ef80f 100644 --- a/Source/WebCore/platform/text/LocaleICU.cpp +++ b/Source/WebCore/platform/text/LocaleICU.cpp @@ -272,13 +272,18 @@ bool LocaleICU::initializeShortDateFormat() { if (m_didCreateShortDateFormat) return m_shortDateFormat; - const UChar gmtTimezone[3] = {'G', 'M', 'T'}; - UErrorCode status = U_ZERO_ERROR; - m_shortDateFormat = udat_open(UDAT_NONE, UDAT_SHORT, m_locale.data(), gmtTimezone, WTF_ARRAY_LENGTH(gmtTimezone), 0, -1, &status); + m_shortDateFormat = openDateFormat(UDAT_NONE, UDAT_SHORT); m_didCreateShortDateFormat = true; return m_shortDateFormat; } +UDateFormat* LocaleICU::openDateFormat(UDateFormatStyle timeStyle, UDateFormatStyle dateStyle) const +{ + const UChar gmtTimezone[3] = {'G', 'M', 'T'}; + UErrorCode status = U_ZERO_ERROR; + return udat_open(timeStyle, dateStyle, m_locale.data(), gmtTimezone, WTF_ARRAY_LENGTH(gmtTimezone), 0, -1, &status); +} + double LocaleICU::parseLocalizedDate(const String& input) { if (!initializeShortDateFormat()) @@ -313,6 +318,23 @@ String LocaleICU::formatLocalizedDate(const DateComponents& dateComponents) } #if ENABLE(CALENDAR_PICKER) +static String getDateFormatPattern(const UDateFormat* dateFormat) +{ + if (!dateFormat) + return emptyString(); + + UErrorCode status = U_ZERO_ERROR; + int32_t length = udat_toPattern(dateFormat, TRUE, 0, 0, &status); + if (status != U_BUFFER_OVERFLOW_ERROR || !length) + return emptyString(); + Vector<UChar> buffer(length); + status = U_ZERO_ERROR; + udat_toPattern(dateFormat, TRUE, buffer.data(), length, &status); + if (U_FAILURE(status)) + return emptyString(); + return String::adopt(buffer); +} + static inline bool isICUYearSymbol(UChar letter) { return letter == 'y' || letter == 'Y'; @@ -330,12 +352,12 @@ static inline bool isICUDayInMonthSymbol(UChar letter) // Specification of the input: // http://icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details -static String localizeFormat(const Vector<UChar>& buffer) +static String localizeFormat(const String& buffer) { StringBuilder builder; UChar lastChar = 0; bool inQuote = false; - for (unsigned i = 0; i < buffer.size(); ++i) { + for (unsigned i = 0; i < buffer.length(); ++i) { if (inQuote) { if (buffer[i] == '\'') { inQuote = false; @@ -374,16 +396,7 @@ void LocaleICU::initializeLocalizedDateFormatText() m_localizedDateFormatText = emptyString(); if (!initializeShortDateFormat()) return; - UErrorCode status = U_ZERO_ERROR; - int32_t length = udat_toPattern(m_shortDateFormat, TRUE, 0, 0, &status); - if (status != U_BUFFER_OVERFLOW_ERROR) - return; - Vector<UChar> buffer(length); - status = U_ZERO_ERROR; - udat_toPattern(m_shortDateFormat, TRUE, buffer.data(), length, &status); - if (U_FAILURE(status)) - return; - m_localizedDateFormatText = localizeFormat(buffer); + m_localizedDateFormatText = localizeFormat(getDateFormatPattern(m_shortDateFormat)); } String LocaleICU::localizedDateFormatText() @@ -392,23 +405,23 @@ String LocaleICU::localizedDateFormatText() return m_localizedDateFormatText; } -PassOwnPtr<Vector<String> > LocaleICU::createLabelVector(UDateFormatSymbolType type, int32_t startIndex, int32_t size) +PassOwnPtr<Vector<String> > LocaleICU::createLabelVector(const UDateFormat* dateFormat, UDateFormatSymbolType type, int32_t startIndex, int32_t size) { - if (!m_shortDateFormat) + if (!dateFormat) return PassOwnPtr<Vector<String> >(); - if (udat_countSymbols(m_shortDateFormat, type) != startIndex + size) + if (udat_countSymbols(dateFormat, type) != startIndex + size) return PassOwnPtr<Vector<String> >(); OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>()); labels->reserveCapacity(size); for (int32_t i = 0; i < size; ++i) { UErrorCode status = U_ZERO_ERROR; - int32_t length = udat_getSymbols(m_shortDateFormat, type, startIndex + i, 0, 0, &status); + int32_t length = udat_getSymbols(dateFormat, type, startIndex + i, 0, 0, &status); if (status != U_BUFFER_OVERFLOW_ERROR) return PassOwnPtr<Vector<String> >(); Vector<UChar> buffer(length); status = U_ZERO_ERROR; - udat_getSymbols(m_shortDateFormat, type, startIndex + i, buffer.data(), length, &status); + udat_getSymbols(dateFormat, type, startIndex + i, buffer.data(), length, &status); if (U_FAILURE(status)) return PassOwnPtr<Vector<String> >(); labels->append(String::adopt(buffer)); @@ -452,11 +465,11 @@ void LocaleICU::initializeCalendar() } m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UCAL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY; - m_monthLabels = createLabelVector(UDAT_MONTHS, UCAL_JANUARY, 12); + m_monthLabels = createLabelVector(m_shortDateFormat, UDAT_MONTHS, UCAL_JANUARY, 12); if (!m_monthLabels) m_monthLabels = createFallbackMonthLabels(); - m_weekDayShortLabels = createLabelVector(UDAT_SHORT_WEEKDAYS, UCAL_SUNDAY, 7); + m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKDAYS, UCAL_SUNDAY, 7); if (!m_weekDayShortLabels) m_weekDayShortLabels = createFallbackWeekDayShortLabels(); } diff --git a/Source/WebCore/platform/text/LocaleICU.h b/Source/WebCore/platform/text/LocaleICU.h index 77360a2aa..8c9b39e73 100644 --- a/Source/WebCore/platform/text/LocaleICU.h +++ b/Source/WebCore/platform/text/LocaleICU.h @@ -75,10 +75,11 @@ private: unsigned matchedDecimalSymbolIndex(const String& input, unsigned& position); bool initializeShortDateFormat(); + UDateFormat* openDateFormat(UDateFormatStyle timeStyle, UDateFormatStyle dateStyle) const; #if ENABLE(CALENDAR_PICKER) void initializeLocalizedDateFormatText(); - PassOwnPtr<Vector<String> > createLabelVector(UDateFormatSymbolType, int32_t startIndex, int32_t size); + PassOwnPtr<Vector<String> > createLabelVector(const UDateFormat*, UDateFormatSymbolType, int32_t startIndex, int32_t size); void initializeCalendar(); #endif diff --git a/Source/WebCore/platform/win/DragDataWin.cpp b/Source/WebCore/platform/win/DragDataWin.cpp index 29f0e7671..6a9aeaf88 100644 --- a/Source/WebCore/platform/win/DragDataWin.cpp +++ b/Source/WebCore/platform/win/DragDataWin.cpp @@ -140,17 +140,17 @@ void DragData::asFilenames(Vector<String>& result) const STGMEDIUM medium; if (FAILED(m_platformDragData->GetData(cfHDropFormat(), &medium))) return; - - HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal); + + HDROP hdrop = reinterpret_cast<HDROP>(GlobalLock(medium.hGlobal)); if (!hdrop) return; const unsigned numFiles = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0); for (unsigned i = 0; i < numFiles; i++) { - if (!DragQueryFileW(hdrop, 0, filename, WTF_ARRAY_LENGTH(filename))) + if (!DragQueryFileW(hdrop, i, filename, WTF_ARRAY_LENGTH(filename))) continue; - result.append((UChar*)filename); + result.append(static_cast<UChar*>(filename)); } // Free up memory from drag diff --git a/Source/WebCore/rendering/AutoTableLayout.cpp b/Source/WebCore/rendering/AutoTableLayout.cpp index 7a64e7a10..019b11d53 100644 --- a/Source/WebCore/rendering/AutoTableLayout.cpp +++ b/Source/WebCore/rendering/AutoTableLayout.cpp @@ -498,8 +498,11 @@ void AutoTableLayout::layout() int available = tableLogicalWidth; size_t nEffCols = m_table->numEffCols(); + // FIXME: It is possible to be called without having properly updated our internal representation. + // This means that our preferred logical widths were not recomputed as expected. if (nEffCols != m_layoutStruct.size()) { fullRecalc(); + // FIXME: Table layout shouldn't modify our table structure (but does due to columns and column-groups). nEffCols = m_table->numEffCols(); } diff --git a/Source/WebCore/rendering/FixedTableLayout.cpp b/Source/WebCore/rendering/FixedTableLayout.cpp index 41dd906e1..8649a08d3 100644 --- a/Source/WebCore/rendering/FixedTableLayout.cpp +++ b/Source/WebCore/rendering/FixedTableLayout.cpp @@ -207,6 +207,15 @@ void FixedTableLayout::layout() { int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAndSpacingInRowDirection(); unsigned nEffCols = m_table->numEffCols(); + + // FIXME: It is possible to be called without having properly updated our internal representation. + // This means that our preferred logical widths were not recomputed as expected. + if (nEffCols != m_width.size()) { + calcWidthArray(tableLogicalWidth); + // FIXME: Table layout shouldn't modify our table structure (but does due to columns and column-groups). + nEffCols = m_table->numEffCols(); + } + Vector<int> calcWidth(nEffCols, 0); unsigned numAuto = 0; diff --git a/Source/WebCore/rendering/RenderBoxModelObject.cpp b/Source/WebCore/rendering/RenderBoxModelObject.cpp index b77438d96..a35a206e2 100644 --- a/Source/WebCore/rendering/RenderBoxModelObject.cpp +++ b/Source/WebCore/rendering/RenderBoxModelObject.cpp @@ -1070,7 +1070,7 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, h = imageIntrinsicSize.height(); } - return IntSize(max(1, w), max(1, h)); + return IntSize(max(0, w), max(0, h)); } case SizeNone: { // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any. diff --git a/Source/WebCore/rendering/RenderGeometryMap.cpp b/Source/WebCore/rendering/RenderGeometryMap.cpp index af19ba4e2..a1f50ed33 100644 --- a/Source/WebCore/rendering/RenderGeometryMap.cpp +++ b/Source/WebCore/rendering/RenderGeometryMap.cpp @@ -46,25 +46,6 @@ public: { } - FloatPoint mapPoint(const FloatPoint& p) const - { - if (!m_transform) - return p + m_offset; - - return m_transform->mapPoint(p); - } - - FloatQuad mapQuad(const FloatQuad& quad) const - { - if (!m_transform) { - FloatQuad q = quad; - q.move(m_offset); - return q; - } - - return m_transform->mapQuad(quad); - } - const RenderObject* m_renderer; LayoutSize m_offset; OwnPtr<TransformationMatrix> m_transform; // Includes offset if non-null. @@ -216,8 +197,11 @@ void RenderGeometryMap::push(const RenderObject* renderer, const TransformationM ASSERT(m_insertionPosition != notFound); OwnPtr<RenderGeometryMapStep> step = adoptPtr(new RenderGeometryMapStep(renderer, accumulatingTransform, isNonUniform, isFixedPosition, hasTransform)); - step->m_transform = adoptPtr(new TransformationMatrix(t)); - + if (!t.isIntegerTranslation()) + step->m_transform = adoptPtr(new TransformationMatrix(t)); + else + step->m_offset = LayoutSize(t.e(), t.f()); + stepInserted(*step.get()); m_mapping.insert(m_insertionPosition, step.release()); } diff --git a/Source/WebCore/rendering/RenderImage.cpp b/Source/WebCore/rendering/RenderImage.cpp index e3aea912d..6e1109c7b 100644 --- a/Source/WebCore/rendering/RenderImage.cpp +++ b/Source/WebCore/rendering/RenderImage.cpp @@ -453,6 +453,14 @@ void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style()->colorSpace(), alignedRect, compositeOperator, shouldRespectImageOrientation(), useLowQualityScaling); } +bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const +{ + if (!RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(bleedAvoidance)) + return false; + + return !backgroundIsObscured(); +} + bool RenderImage::backgroundIsObscured() const { if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) diff --git a/Source/WebCore/rendering/RenderImage.h b/Source/WebCore/rendering/RenderImage.h index e7092e11c..b6725f005 100644 --- a/Source/WebCore/rendering/RenderImage.h +++ b/Source/WebCore/rendering/RenderImage.h @@ -91,6 +91,8 @@ private: virtual void notifyFinished(CachedResource*); virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE; + virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFlowBox*) const OVERRIDE; + IntSize imageSizeForError(CachedImage*) const; void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0); bool updateIntrinsicSizeIfNeeded(const IntSize&, bool imageSizeChanged); diff --git a/Source/WebCore/rendering/RenderTable.cpp b/Source/WebCore/rendering/RenderTable.cpp index ab3187794..64337bd5e 100644 --- a/Source/WebCore/rendering/RenderTable.cpp +++ b/Source/WebCore/rendering/RenderTable.cpp @@ -273,7 +273,8 @@ LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& st bool isCSSTable = !node() || !node()->hasTagName(tableTag); if (isCSSTable && styleLogicalWidth.isFixed() && styleLogicalWidth.isPositive()) { recalcBordersInRowDirection(); - borders = borderStart() + borderEnd() + (collapseBorders() ? ZERO_LAYOUT_UNIT : paddingStart() + paddingEnd()); + if (style()->boxSizing() == CONTENT_BOX) + borders = borderStart() + borderEnd() + (collapseBorders() ? ZERO_LAYOUT_UNIT : paddingStart() + paddingEnd()); } return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + borders; } @@ -397,7 +398,10 @@ void RenderTable::layout() LayoutUnit computedLogicalHeight = 0; if (logicalHeightLength.isFixed()) { // HTML tables size as though CSS height includes border/padding, CSS tables do not. - LayoutUnit borders = node() && node()->hasTagName(tableTag) ? (borderAndPaddingBefore + borderAndPaddingAfter) : ZERO_LAYOUT_UNIT; + LayoutUnit borders = ZERO_LAYOUT_UNIT; + // FIXME: We cannot apply box-sizing: content-box on <table> which other browsers allow. + if ((node() && node()->hasTagName(tableTag)) || style()->boxSizing() == BORDER_BOX) + borders = borderAndPaddingBefore + borderAndPaddingAfter; computedLogicalHeight = logicalHeightLength.value() - borders; } else if (logicalHeightLength.isPercent()) computedLogicalHeight = computePercentageLogicalHeight(logicalHeightLength); diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 805aff79d..d0702691c 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -19,6 +19,7 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. + * */ #ifndef RenderStyle_h diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.h b/Source/WebCore/rendering/style/StyleRareInheritedData.h index 8bd3bf9ce..93908e446 100644 --- a/Source/WebCore/rendering/style/StyleRareInheritedData.h +++ b/Source/WebCore/rendering/style/StyleRareInheritedData.h @@ -19,6 +19,7 @@ * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. + * */ #ifndef StyleRareInheritedData_h diff --git a/Source/WebCore/rendering/style/StyleVariableData.h b/Source/WebCore/rendering/style/StyleVariableData.h index b1e42dbee..bb45989f1 100644 --- a/Source/WebCore/rendering/style/StyleVariableData.h +++ b/Source/WebCore/rendering/style/StyleVariableData.h @@ -26,7 +26,6 @@ * 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. - * */ diff --git a/Source/WebCore/svg/animation/SMILTimeContainer.cpp b/Source/WebCore/svg/animation/SMILTimeContainer.cpp index 156653315..b032f3158 100644 --- a/Source/WebCore/svg/animation/SMILTimeContainer.cpp +++ b/Source/WebCore/svg/animation/SMILTimeContainer.cpp @@ -112,10 +112,11 @@ void SMILTimeContainer::pause() void SMILTimeContainer::resume() { - if (!m_beginTime) - return; ASSERT(isPaused()); - m_accumulatedPauseTime += currentTime() - m_pauseTime; + + if (m_beginTime) + m_accumulatedPauseTime += currentTime() - m_pauseTime; + m_pauseTime = 0; startTimer(0); } @@ -131,8 +132,12 @@ void SMILTimeContainer::setElapsed(SMILTime time) if (m_beginTime) m_timer.stop(); - m_beginTime = currentTime() - time.value(); + double now = currentTime(); + m_beginTime = now - time.value(); + m_accumulatedPauseTime = 0; + if (m_pauseTime) + m_pauseTime = now; Vector<SVGSMILElement*> toReset; copyToVector(m_scheduledAnimations, toReset); diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp index 44ef4d5c5..2270b4acc 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -1005,7 +1005,7 @@ void Internals::setBatteryStatus(Document* document, const String& eventType, bo #endif } -void Internals::setNetworkInformation(Document* document, const String& eventType, long bandwidth, bool metered, ExceptionCode& ec) +void Internals::setNetworkInformation(Document* document, const String& eventType, double bandwidth, bool metered, ExceptionCode& ec) { if (!document || !document->page()) { ec = INVALID_ACCESS_ERR; @@ -1028,6 +1028,14 @@ bool Internals::hasSpellingMarker(Document* document, int from, int length, Exce return document->frame()->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); } + +bool Internals::hasAutocorrectedMarker(Document* document, int from, int length, ExceptionCode&) +{ + if (!document || !document->frame()) + return 0; + + return document->frame()->editor()->selectionStartHasMarkerFor(DocumentMarker::Autocorrected, from, length); +} #if ENABLE(INSPECTOR) unsigned Internals::numberOfLiveNodes() const diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h index cac206be2..beac6f039 100644 --- a/Source/WebCore/testing/Internals.h +++ b/Source/WebCore/testing/Internals.h @@ -158,6 +158,7 @@ public: bool hasSpellingMarker(Document*, int from, int length, ExceptionCode&); bool hasGrammarMarker(Document*, int from, int length, ExceptionCode&); + bool hasAutocorrectedMarker(Document*, int from, int length, ExceptionCode&); unsigned numberOfScrollableAreas(Document*, ExceptionCode&); @@ -169,7 +170,7 @@ public: void setBatteryStatus(Document*, const String& eventType, bool charging, double chargingTime, double dischargingTime, double level, ExceptionCode&); - void setNetworkInformation(Document*, const String& eventType, long bandwidth, bool metered, ExceptionCode&); + void setNetworkInformation(Document*, const String& eventType, double bandwidth, bool metered, ExceptionCode&); void suspendAnimations(Document*, ExceptionCode&) const; void resumeAnimations(Document*, ExceptionCode&) const; diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl index b3a249f66..2f17f5558 100644 --- a/Source/WebCore/testing/Internals.idl +++ b/Source/WebCore/testing/Internals.idl @@ -132,6 +132,7 @@ module window { boolean hasSpellingMarker(in Document document, in long from, in long length) raises (DOMException); boolean hasGrammarMarker(in Document document, in long from, in long length) raises (DOMException); + boolean hasAutocorrectedMarker(in Document document, in long from, in long length) raises (DOMException); unsigned long numberOfScrollableAreas(in Document document) raises (DOMException); @@ -149,7 +150,7 @@ module window { #endif #if defined(ENABLE_NETWORK_INFO) && ENABLE_NETWORK_INFO - void setNetworkInformation(in Document document, in DOMString eventType, in long bandwidth, in boolean metered) raises (DOMException); + void setNetworkInformation(in Document document, in DOMString eventType, in double bandwidth, in boolean metered) raises (DOMException); #endif [Conditional=INSPECTOR] unsigned long numberOfLiveNodes(); diff --git a/Source/WebCore/xml/XMLHttpRequest.idl b/Source/WebCore/xml/XMLHttpRequest.idl index 045398194..095f4dc5c 100644 --- a/Source/WebCore/xml/XMLHttpRequest.idl +++ b/Source/WebCore/xml/XMLHttpRequest.idl @@ -93,8 +93,6 @@ module xml { getter raises(DOMException); readonly attribute Document responseXML getter raises(DOMException); - readonly attribute Blob responseBlob - getter raises(DOMException); attribute DOMString responseType setter raises(DOMException); |