Implement the form-action Content Security Policy directive.
https://bugs.webkit.org/show_bug.cgi?id=93777

Patch by Mike West <mkwst@chromium.org> on 2012-08-16
Reviewed by Jochen Eisinger.

Source/WebCore:

The CSP 1.1 editor's draft defines the 'form-action' directive as a
mechanism for whitelisting valid targets for form submission from a
protected resource. A web author might desire to restrict form
submissions to the same origin as the protected resource itself via
a Content Security Policy of "form-action 'self'", or ensure that all
submissions were sent over an SSL connection via "form-action https:".

Specification details available at: https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#form-action--experimental

This experimental directive is gated on the ENABLE_CSP_NEXT flag, which
is currently only enabled in Chromium.

Tests: http/tests/security/contentSecurityPolicy/1.1/form-action-src-allowed.html
       http/tests/security/contentSecurityPolicy/1.1/form-action-src-blocked.html
       http/tests/security/contentSecurityPolicy/1.1/form-action-src-default-ignored.html
       http/tests/security/contentSecurityPolicy/1.1/form-action-src-get-allowed.html
       http/tests/security/contentSecurityPolicy/1.1/form-action-src-get-blocked.html
       http/tests/security/contentSecurityPolicy/1.1/form-action-src-javascript-blocked.html
       http/tests/security/contentSecurityPolicy/1.1/form-action-src-redirect-blocked.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::checkIfFormActionAllowedByCSP):
    Adding a callback to FrameLoader in order to allow the
    MainResourceLoader to check the relevant CSP status without knowing
    anything about CSP.
(WebCore):
* loader/FrameLoader.h:
(FrameLoader):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::willSendRequest):
    Check against the protected resource's Content Security Policy when
    presented with a request that is itself a form submission, or is the
    result of a redirect in response to a form submission. If CSP would
    block the target, cancel the request.
* page/ContentSecurityPolicy.cpp:
(CSPDirectiveList):
(WebCore::CSPDirectiveList::checkSourceAndReportViolation):
    Added explanatory text to the source violation console warning that
    specifically calls out sending form data (as opposed to "connect to"
    or "load the").
(WebCore::CSPDirectiveList::allowFormAction):
    Check a URL against a directive list's the 'form-action' source list.
(WebCore):
(WebCore::CSPDirectiveList::addDirective):
    Recognize the 'form-action' CSP directive.
(WebCore::ContentSecurityPolicy::allowFormAction):
    Public interface to check a form action.
* page/ContentSecurityPolicy.h:

LayoutTests:

* http/tests/navigation/resources/redirection-response.php:
    Allow for the specification of alternate hosts for the redirect. We
    need this capability in order to check that an initial submission
    followed by a blocked redirect results in the correct behavior.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-allowed-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-allowed.html: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-blocked-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-blocked.html: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-default-ignored-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-default-ignored.html: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-get-allowed-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-get-allowed.html: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-get-blocked-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-get-blocked.html: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-javascript-blocked-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-javascript-blocked.html: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-redirect-blocked-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/form-action-src-redirect-blocked.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make GraphicsSurface double buffered by default.
https://bugs.webkit.org/show_bug.cgi?id=93252

Create only a single GraphicsSurface per canvas
on both supported platforms Mac/Linux.
The GraphicsSurface on Mac internally uses two IOSurface
to provide a front and a back buffer.
The GLX implementation of GraphicsSurface uses
an XWindow which already provides a front and a back buffer.

Reviewed by Noam Rosenthal.

Source/WebCore:

* platform/graphics/qt/GraphicsContext3DQt.cpp:
(GraphicsContext3DPrivate):
    Remove creation of second GraphicsSurface.
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::copyToGraphicsSurface):
(WebCore):
(WebCore::GraphicsContext3DPrivate::graphicsSurfaceToken):
(WebCore::GraphicsContext3DPrivate::createGraphicsSurfaces):
* platform/graphics/surfaces/GraphicsSurface.cpp:
(WebCore::GraphicsSurface::create):
    Adjust token type to uint64_t.
(WebCore::GraphicsSurface::exportToken):
    Adjust return type to uint64_t.
(WebCore::GraphicsSurface::frontBuffer):
(WebCore):
(WebCore::GraphicsSurface::swapBuffers):
    Add forwarding function to swap buffers inside GraphicsSurface.
* platform/graphics/surfaces/GraphicsSurface.h:
(GraphicsSurface):
    Add SupportsSingleBuffered flag to allow for single buffered implementations.
    Currently single buffered surfaces are either not implemented or disabled.
* platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
    Move implementation details into GraphicsSurfacePrivate.
    This way the platform specific code can be hidden in the specific cpp file
    instead of polluting the global GraphicsSurface header.
(WebCore::createTexture):
(GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::swapBuffers):
(WebCore::GraphicsSurfacePrivate::token):
(WebCore::GraphicsSurfacePrivate::frontBufferTextureID):
(WebCore::GraphicsSurfacePrivate::backBufferTextureID):
(WebCore::GraphicsSurfacePrivate::frontBuffer):
(WebCore::GraphicsSurfacePrivate::backBuffer):
(WebCore):
(WebCore::GraphicsSurface::platformExport):
(WebCore::GraphicsSurface::platformGetTextureID):
(WebCore::GraphicsSurface::platformCopyToGLTexture):
(WebCore::GraphicsSurface::platformCopyFromFramebuffer):
(WebCore::GraphicsSurface::platformFrontBuffer):
(WebCore::GraphicsSurface::platformSwapBuffers):
(WebCore::GraphicsSurface::platformCreate):
(WebCore::GraphicsSurface::platformImport):
(WebCore::ioSurfaceLockOptions):
(WebCore::GraphicsSurface::platformLock):
(WebCore::GraphicsSurface::platformUnlock):
(WebCore::GraphicsSurface::platformDestroy):
* platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp:
(WebCore::OffScreenRootWindow::get):
(WebCore::GraphicsSurfacePrivate::swapBuffers):
    Make sure that framebuffer bindings remain consistent
    after swapping buffers on the XWindow.
(WebCore::GraphicsSurface::platformExport):
    Make sure the GLXPixmap is only bound to the texture once.
(WebCore::GraphicsSurface::platformGetTextureID):
(WebCore::GraphicsSurface::platformCopyFromFramebuffer):
(WebCore):
(WebCore::GraphicsSurface::platformFrontBuffer):
    The GLX surface does not know how to destinguish between
    the front and the back buffer by an id. This is not necessary
    for GraphicsSurfaceGLX, because the texture can just be
    read from the XWindow at any time.
(WebCore::GraphicsSurface::platformSwapBuffers):
(WebCore::GraphicsSurface::platformCreate):
(WebCore::GraphicsSurface::platformImport):
* platform/graphics/texmap/TextureMapperBackingStore.cpp:
    Remove code that was used for switching between two GraphicsSurfaces,
    as this is now handled directly inside GraphicsSurface.
(WebCore::TextureMapperSurfaceBackingStore::setGraphicsSurface):
(WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
(WebCore::TextureMapperSurfaceBackingStore::setSurface):
(WebCore):
* platform/graphics/texmap/TextureMapperBackingStore.h:
    Remove GraphicsSurfaceData struct. This class is not needed anymore
    as we do not keep track of more than one GraphicsSurface at the time.
(WebCore):
(TextureMapperSurfaceBackingStore):
(WebCore::TextureMapperSurfaceBackingStore::graphicsSurface):
(WebCore::TextureMapperSurfaceBackingStore::TextureMapperSurfaceBackingStore):
* platform/graphics/texmap/TextureMapperPlatformLayer.h:
(WebCore::TextureMapperPlatformLayer::graphicsSurfaceToken):

Source/WebKit2:

* Shared/ShareableSurface.h:
(Handle):
    Change the type of GraphicsSurface token to uint64_t.
* UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:
(WebKit::LayerTreeCoordinatorProxy::syncCanvas):
    Add a parameter that denotes the current front buffer of the
    GraphicsSurface.
* UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:
(LayerTreeCoordinatorProxy):
* UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
* UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
(WebKit::LayerTreeRenderer::syncCanvas):
* UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
(LayerTreeRenderer):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::syncCanvas):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayerClient):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
(WebKit::LayerTreeCoordinator::syncCanvas):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:
(LayerTreeCoordinator):

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