[CSS Shaders] Validate types of built-in vertex attributes
https://bugs.webkit.org/show_bug.cgi?id=98972

Patch by Max Vujovic <mvujovic@adobe.com> on 2012-10-18
Reviewed by Dean Jackson.

Source/WebCore:

Reject custom filters in which the author defined built-in attributes with the wrong type.
For example, the GLSL declaration "attribute float a_position" is incorrect because
a_position should be a vec4, not a float.

Test: css3/filters/custom/invalid-custom-filter-attribute-types.html

* platform/graphics/ANGLEWebKitBridge.h:
(WebCore::ANGLEShaderSymbol::isSampler):
    Add const qualifier to isSampler method.
* platform/graphics/filters/CustomFilterValidatedProgram.cpp:
(WebCore):
(WebCore::builtInAttributeNameToTypeMap):
    New file static function. Returns a map of the CSS Custom Filters built-in attribute
    names and their expected types.
(WebCore::validateSymbols):
    New file static function. Loop through all of the symbols. Reject the shader if we find
    a built-in attribute defined with the wrong type.
(WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
    Call the new validateSymbols function. If it returns false, exit the constructor early,
    which rejects the program.
    Move the loop that checks if any uniform is a sampler into the the validateSymbols
    function.

LayoutTests:

invalid-custom-filter-attribute-types.html uses a set of vertex shaders. Each vertex shader
defines a specific attribute with the wrong type. None of the vertex shaders in the test
should execute. If a vertex shader does execute, its associated fragment shader will render
a green div as red.

* css3/filters/custom/invalid-custom-filter-attribute-types-expected.html: Added.
* css3/filters/custom/invalid-custom-filter-attribute-types.html: Added.
* css3/filters/resources/invalid-type-a-mesh-coord.vs: Added.
* css3/filters/resources/invalid-type-a-position.vs: Added.
* css3/filters/resources/invalid-type-a-tex-coord.vs: Added.
* css3/filters/resources/invalid-type-a-triangle-coord.vs: Added.
* css3/filters/resources/invalid-type-attribute-array.vs: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[chromium] Implement deferred image decoding
https://bugs.webkit.org/show_bug.cgi?id=94240

Reviewed by Stephen White.

Source/WebCore:

Objectives:

To record image decoding operations during painting and to defer
decoding operations until rasterization.

Rationale:

This is a key feature that enables impl-side painting which requires
fast recording of drawing operations. The existing decode-on-draw
restricts that recording has to block on expensive decoding operations.
This change allows recording of image decoding operations during paint
time.

Design:

Image decoding happens when a BitmapImage is drawn into a
GraphicsContext. When per-tile painting is enabled GraphicsContext
is backed by SkCanvas in recording mode. This SkCanvas records drawing
and image decoding operations to minimize recording time.

An image decoding operation is recorded as a SkPixelRef object
implemented by LazyDecodingPixelRef. This object references raw encoded
data, regions to be decoded and scaling information.

When used in conjunction with per-tile painting this feature defers
image decoding until the SkCanvas referencing the image is rasterized.

Both recording and rasterization happen on the main thread.

Performance Impact:

This feature is enabled by WebKit::setDeferredImageDecodingEnabled()
and does not have an impact when disabled.

This feature is disabled by default.

Upcoming Changes:

1. Implement a full-featured image cache in ImageDecodingStore.
2. Allow rasterization and decoding on impl thread.

Classes Involved:

BitmapImage

BitmapImage is the entry point for deferred image decoding. When
drawing a BitmapImage into a GraphicsContext it makes a request to
create a NativeImageSkia. We substitute the content in NativeImageSkia
such that it is lazily decoded.

DeferredImageDecoder

This is the platform implementation of a image decoder for Chromium.
This is a bridge layer that either delegates calls to the actual
ImageDecoder or create a lazily-decoded SkBitmap and delegates calls
to ImageDecodingStore.

ImageDecodingStore

This object manages all encoded images. It keeps track of encoded
data and the corresponding ImageDecoder for doing actual decoding. It
is also responsible for generating lazily decoded SkBitmaps. This
SkBitmap contains a LazyDecodingPixelRef object which references to an
image entry in ImageDecodingStore.

ScaledImageFragment

A container for a scaled image fragment. In addition to bitmap pixels
it contains information about the ID of the image, scale and clipping.

ImageFrameGenerator

This object is responsible for generating decoded pixels. It is also
a container for encoded image data and corresponding image decoder.

LazyDecodingPixelRef

This object is embedded in a SkBitmap to enable lazy decoding. When
SkBitmap needs to access pixels LazyDecodingPixelRef is locked. It
contains information to locate an image and scaling info, these
information is submitted to ImageDecodingStore to access actual pixels.

Layout tests. There are about 80 tests in this virtual test suite
running this feature in this directory:

platform/chromium/virtual/deferred/fast/images

Unit tests. Added DeferredImageDecoderTest to verify deferred
image decoding behavior.

* WebCore.gypi:
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::setData):
* platform/graphics/ImageSource.h:
(WebCore):
(ImageSource):
* platform/graphics/chromium/DeferredImageDecoder.cpp: Added.
(WebCore):
(WebCore::DeferredImageDecoder::DeferredImageDecoder):
(WebCore::DeferredImageDecoder::~DeferredImageDecoder):
(WebCore::DeferredImageDecoder::create):
(WebCore::DeferredImageDecoder::createForTesting):
(WebCore::DeferredImageDecoder::filenameExtension):
(WebCore::DeferredImageDecoder::frameBufferAtIndex):
(WebCore::DeferredImageDecoder::setData):
(WebCore::DeferredImageDecoder::isSizeAvailable):
(WebCore::DeferredImageDecoder::size):
(WebCore::DeferredImageDecoder::frameSizeAtIndex):
(WebCore::DeferredImageDecoder::frameCount):
(WebCore::DeferredImageDecoder::repetitionCount):
(WebCore::DeferredImageDecoder::clearFrameBufferCache):
(WebCore::DeferredImageDecoder::frameHasAlphaAtIndex):
(WebCore::DeferredImageDecoder::frameBytesAtIndex):
* platform/graphics/chromium/DeferredImageDecoder.h: Added.
(WebCore):
(DeferredImageDecoder):
* platform/graphics/chromium/ImageDecodingStore.cpp: Added.
(WebCore::ImageDecodingStore::ImageDecodingStore):
(WebCore):
(WebCore::ImageDecodingStore::~ImageDecodingStore):
(WebCore::ImageDecodingStore::instanceOnMainThread):
(WebCore::ImageDecodingStore::initializeOnMainThread):
(WebCore::ImageDecodingStore::shutdown):
(WebCore::ImageDecodingStore::isLazyDecoded):
(WebCore::ImageDecodingStore::createLazyDecodedSkBitmap):
(WebCore::ImageDecodingStore::resizeLazyDecodedSkBitmap):
(WebCore::ImageDecodingStore::setData):
(WebCore::ImageDecodingStore::lockPixels):
(WebCore::ImageDecodingStore::unlockPixels):
(WebCore::ImageDecodingStore::frameGeneratorBeingDestroyed):
(WebCore::ImageDecodingStore::calledOnValidThread):
(WebCore::ImageDecodingStore::lookupFrameCache):
(WebCore::ImageDecodingStore::deleteFrameCache):
* platform/graphics/chromium/ImageDecodingStore.h: Added.
(WebCore):
(ImageDecodingStore):
(WebCore::ImageDecodingStore::create):
* platform/graphics/chromium/ScaledImageFragment.cpp: Added.
(WebCore):
(WebCore::ScaledImageFragment::~ScaledImageFragment):
(WebCore::ScaledImageFragment::ScaledImageFragment):
(WebCore::ScaledImageFragment::isEqual):
* platform/graphics/chromium/ScaledImageFragment.h: Added.
(WebCore):
(ScaledImageFragment):
(WebCore::ScaledImageFragment::create):
(WebCore::ScaledImageFragment::bitmap):
(WebCore::ScaledImageFragment::isComplete):
* platform/graphics/chromium/ImageFrameGenerator.cpp: Added.
(WebCore):
(WebCore::ImageFrameGenerator::ImageFrameGenerator):
(WebCore::ImageFrameGenerator::~ImageFrameGenerator):
(WebCore::ImageFrameGenerator::decoder):
(WebCore::ImageFrameGenerator::setData):
* platform/graphics/chromium/ImageFrameGenerator.h: Added.
(WebCore):
(ImageFrameGenerator):
(WebCore::ImageFrameGenerator::create):
(WebCore::ImageFrameGenerator::size):
(WebCore::ImageFrameGenerator::imageId):
* platform/graphics/chromium/LazyDecodingPixelRef.cpp: Added.
(WebCore):
(WebCore::LazyDecodingPixelRef::LazyDecodingPixelRef):
(WebCore::LazyDecodingPixelRef::~LazyDecodingPixelRef):
(WebCore::LazyDecodingPixelRef::isScaled):
(WebCore::LazyDecodingPixelRef::isClipped):
(WebCore::LazyDecodingPixelRef::onLockPixels):
(WebCore::LazyDecodingPixelRef::onUnlockPixels):
(WebCore::LazyDecodingPixelRef::onLockPixelsAreWritable):
* platform/graphics/chromium/LazyDecodingPixelRef.h: Added.
(WebCore):
(LazyDecodingPixelRef):
(WebCore::LazyDecodingPixelRef::frameGenerator):
* platform/graphics/skia/NativeImageSkia.cpp:
(WebCore::NativeImageSkia::resizedBitmap):
* platform/image-decoders/ImageDecoder.h:
(ImageFrame):
(WebCore::ImageFrame::setSkBitmap):
(WebCore::ImageFrame::getSkBitmap):

Source/WebKit/chromium:

Adding new unit tests for deferred image decoding.
These tests are defined in DeferredImageDecoderTest.cpp. They verify
image decoding happens only when SkPicture is rasterized for both
scaled and non-scaled cases.

Tests: DeferredImageDecoderTest.drawIntoSkPicture
       DeferredImageDecoderTest.drawScaledIntoSkPicture

* WebKit.gypi:
* public/WebSettings.h:
* src/WebKit.cpp:
(WebKit::shutdown):
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setDeferredImageDecodingEnabled):
(WebKit):
* src/WebSettingsImpl.h:
(WebSettingsImpl):
* tests/DeferredImageDecoderTest.cpp: Added.
(WebCore):
(DeferredImageDecoderTest):
(WebCore::DeferredImageDecoderTest::SetUp):
(WebCore::DeferredImageDecoderTest::TearDown):
(WebCore::TEST_F):
* tests/MockImageDecoder.h: Added.
(WebCore):
(MockImageDecoder):
(WebCore::MockImageDecoder::MockImageDecoder):
(WebCore::MockImageDecoder::filenameExtension):
(WebCore::MockImageDecoder::frameBufferAtIndex):
(WebCore::MockImageDecoder::frameBufferRequestCount):

Tools:

Add --enable-deferred-image-decoding to DRT.

* DumpRenderTree/chromium/DumpRenderTree.cpp:
(main):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::TestShell):
(TestShell::resetWebSettings):
* DumpRenderTree/chromium/TestShell.h:
(TestShell::setDeferredImageDecodingEnabled):
(TestShell):
* DumpRenderTree/chromium/WebPreferences.cpp:
(WebPreferences::reset):
(WebPreferences::applyTo):
* DumpRenderTree/chromium/WebPreferences.h:
(WebPreferences):
* Scripts/webkitpy/layout_tests/port/chromium.py:
(ChromiumPort.virtual_test_suites):

LayoutTests:

Adding a virtual test suite for Chromium to test deferred image
decoding.

platform/chromium/virtual/deferred/fast/images will be tested with
--force-compositing --enable-per-tile-painting --enable-deferred-image-decoding.

* platform/chromium/virtual/deferred/fast/images/README.txt: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[chromium] update ML-specific failures
https://bugs.webkit.org/show_bug.cgi?id=99505

Unreviewed, expectations change.

* platform/chromium-mac-mountainlion/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add layout tests for wildcarded hosts in CSP directives.
https://bugs.webkit.org/show_bug.cgi?id=99693

Reviewed by Adam Barth.

Adds four test cases to ensure that wildcarded hosts in Content Security
Policy source expressions function correctly with and without paths,
and with wildcarded ports.

* http/tests/security/contentSecurityPolicy/source-list-parsing-09-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/source-list-parsing-09.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
MediaStream API: Do some cleanup in the chromium WebKit API
https://bugs.webkit.org/show_bug.cgi?id=99713

Reviewed by Adam Barth.

Source/Platform:

Removing the deprecated version of WebMediaStreamDescriptor::initialize and making
the two constructSDP functions in WebMediaStreamCenter optional to override.
This is part of the preparation to remove PeerConnection00.

* chromium/public/WebMediaStreamCenter.h:
(WebKit::WebMediaStreamCenter::constructSDP):
* chromium/public/WebMediaStreamDescriptor.h:
(WebMediaStreamDescriptor):

Source/WebCore:

Removing the deprecated version of WebMediaStreamDescriptor::initialize.

No testing needed since only an unused function is removed.

* platform/chromium/support/WebMediaStreamDescriptor.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r131810.
http://trac.webkit.org/changeset/131810
https://bugs.webkit.org/show_bug.cgi?id=99762

Broke linux debug webkit_unit_tests (Requested by
danakj|gardening on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-10-18

Source/WebCore:

* WebCore.gypi:
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::setData):
* platform/graphics/ImageSource.h:
(WebCore):
(ImageSource):
* platform/graphics/chromium/DeferredImageDecoder.cpp: Removed.
* platform/graphics/chromium/DeferredImageDecoder.h: Removed.
* platform/graphics/chromium/ImageDecodingStore.cpp: Removed.
* platform/graphics/chromium/ImageDecodingStore.h: Removed.
* platform/graphics/chromium/ImageFrameGenerator.cpp: Removed.
* platform/graphics/chromium/ImageFrameGenerator.h: Removed.
* platform/graphics/chromium/LazyDecodingPixelRef.cpp: Removed.
* platform/graphics/chromium/LazyDecodingPixelRef.h: Removed.
* platform/graphics/chromium/ScaledImageFragment.cpp: Removed.
* platform/graphics/chromium/ScaledImageFragment.h: Removed.
* platform/graphics/skia/NativeImageSkia.cpp:
(WebCore::NativeImageSkia::resizedBitmap):
* platform/image-decoders/ImageDecoder.h:
(ImageFrame):

Source/WebKit/chromium:

* WebKit.gypi:
* public/WebSettings.h:
* src/WebKit.cpp:
(WebKit::shutdown):
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::WebSettingsImpl):
* src/WebSettingsImpl.h:
(WebSettingsImpl):
* tests/DeferredImageDecoderTest.cpp: Removed.
* tests/MockImageDecoder.h: Removed.

Tools:

* DumpRenderTree/chromium/DumpRenderTree.cpp:
(main):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::TestShell):
(TestShell::resetWebSettings):
* DumpRenderTree/chromium/TestShell.h:
(TestShell):
* DumpRenderTree/chromium/WebPreferences.cpp:
(WebPreferences::reset):
(WebPreferences::applyTo):
* DumpRenderTree/chromium/WebPreferences.h:
(WebPreferences):
* Scripts/webkitpy/layout_tests/port/chromium.py:
(ChromiumPort.virtual_test_suites):

LayoutTests:

* platform/chromium/TestExpectations:
* platform/chromium/virtual/deferred/fast/images/README.txt: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131815 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Page viewport aspect ratio not kept on navigating back
https://bugs.webkit.org/show_bug.cgi?id=99760

Reviewed by Rob Buis.
Patch by Jacky Jiang  <zhajiang@rim.com>.
Internally reviewed by Konrad Piascik.

PR: 190469
This was added in r127628 which was trying to fix some rendering
defects on maps.google.com and news.qq.com, however it was very harmful
and caused regressions.
zoomToFitScale() depends on the current contents size. During history
navigation and device rotation, if zoomToFitScale() is based on the
final contents size which is expected, there will still be a scale
calculation like this afterwards
screenSize.width()/screenSize.height()*zoomToFitScale() which will
result in a wrong scale. During the history navigation, if
zoomToFitScale() isn't based on the final contents size, then we will
get the wrong scale as well for sure.
This issue will be fixed by removing the wrong calculation.
The original issue of r127628 was fixed by the patch of PR225981.

* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::restoreViewState):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131816 268f45cc-cd09-0410-ab3c-d52691b4dbfc