Web Inspector: provide a way to reload page with given script preprocessor.
https://bugs.webkit.org/show_bug.cgi?id=80992

Reviewed by Yury Semikhatsky.

Source/WebCore:

This change introduces a way to inject 'preprocessor' script that would process
each JavaScript file before it gets into the VM for compilation. That way inspector
can expose capabilities such as assessing code coverage or tracing all the calls.

Preprocessor script is stored in the page agent where it waits for reload to happen.
Upon reload, ScriptDebugServer is using it to patch the script sources.

Test: inspector/debugger/debugger-script-preprocessor.html

* bindings/js/ScriptDebugServer.h:
(WebCore::ScriptDebugServer::setScriptPreprocessor):
(ScriptDebugServer):
* bindings/v8/DebuggerScript.js:
* bindings/v8/ScriptDebugServer.cpp:
(ScriptDebugServer::ScriptPreprocessor):
(WebCore::ScriptDebugServer::ScriptPreprocessor::ScriptPreprocessor):
(WebCore::ScriptDebugServer::ScriptPreprocessor::preprocessSourceCode):
(WebCore::ScriptDebugServer::ScriptPreprocessor::~ScriptPreprocessor):
(WebCore):
(WebCore::ScriptDebugServer::~ScriptDebugServer):
(WebCore::ScriptDebugServer::setScriptSource):
(WebCore::ScriptDebugServer::setScriptPreprocessor):
(WebCore::ScriptDebugServer::handleV8DebugEvent):
* bindings/v8/ScriptDebugServer.h:
(ScriptDebugServer):
* bindings/v8/custom/V8InjectedScriptManager.cpp:
(WebCore::InjectedScriptManager::createInjectedScript):
* inspector/Inspector.json:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/InspectorDebuggerAgent.h:
(InspectorDebuggerAgent):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::reload):
(WebCore::InspectorPageAgent::frameNavigated):
* inspector/InspectorPageAgent.h:
(WebCore::InspectorPageAgent::page):
(WebCore::InspectorPageAgent::scriptPreprocessor):
(InspectorPageAgent):
* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::create):
(WebCore::PageDebuggerAgent::PageDebuggerAgent):
(WebCore::PageDebuggerAgent::startListeningScriptDebugServer):
(WebCore::PageDebuggerAgent::stopListeningScriptDebugServer):
(WebCore::PageDebuggerAgent::injectedScriptForEval):
(WebCore::PageDebuggerAgent::didClearMainFrameWindowObject):
(WebCore):
* inspector/PageDebuggerAgent.h:
(WebCore):
(PageDebuggerAgent):

LayoutTests:

* http/tests/inspector/inspector-test.js:
(initialize_InspectorTest.InspectorTest.hardReloadPage):
(initialize_InspectorTest.InspectorTest.reloadPage):
(initialize_InspectorTest.InspectorTest._innerReloadPage):
* inspector/debugger/debugger-script-preprocessor-expected.txt: Added.
* inspector/debugger/debugger-script-preprocessor.html: Added.
* platform/chromium/inspector/debugger/debugger-script-preprocessor-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: [Chromium] Ctrl + ']' "Goto right panel" keyboard shortcut doesn't work
https://bugs.webkit.org/show_bug.cgi?id=104250

Reviewed by Pavel Feldman.

Ignore "keypress" event resulting from a WM_CHAR message emitted by Win7 upon Ctrl + ']' keypress.

* inspector/front-end/InspectorView.js:
(WebInspector.InspectorView.prototype._keyPress): Ignore all events with charCode < 32.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136950 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Chromium] Move WorkerContextProxy::create out of PlatformSupport
https://bugs.webkit.org/show_bug.cgi?id=104151

Reviewed by Kentaro Hara.

Doesn't really solve the layering violation as much as kick it
down the road a bit. Part of a refactoring series; see tracking
bug 82948.

* WebKit.gyp:
* src/PlatformSupport.cpp:
(WebCore):
* src/WorkerContextProxy.cpp: Added.
(WebCore):
(WebCore::WebCore::WorkerContextProxy::create):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Fix build warning in StyleResolver.cpp using gcc 4.7.2
https://bugs.webkit.org/show_bug.cgi?id=104262

Patch by Sujin Park <sujjin.park@gmail.com> on 2012-12-07
Reviewed by Alexis Menard.

EFL port treats build warning as compile error and there are
maybe-uninitialized when building with gcc 4.7.2.
This patch adds default case to resolve a build break.

* css/StyleResolver.cpp:
(WebCore::getFontAndGlyphOrientation):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136952 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[TexMap] Can not do multiple accelerated animations
https://bugs.webkit.org/show_bug.cgi?id=104364

Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

By removing all animations with the same name, it is not possible to animate more than one property accelerated.
Instead only remove any animations with both same name and property.

Covered by animations/opacity-transform-animation.html.

* platform/graphics/GraphicsLayerAnimation.cpp:
(WebCore::GraphicsLayerAnimations::add):
(WebCore::GraphicsLayerAnimations::remove):
* platform/graphics/GraphicsLayerAnimation.h:
(GraphicsLayerAnimations):

LayoutTests:

Unskip test animating multiple accelerated properties.

* platform/qt/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION(r136947): Made two tests fail on all platforms (Requested by tonikitoo-ll on #webkit).
https://bugs.webkit.org/show_bug.cgi?id=104368

Unreviewed partial rollout.

r136947 was too aggressive in the sense of fixing RenderBox::canBeScrolledAndHasScrollableArea
as part of itself. Revert the related changes in order to fix both
fast/events/autoscroll-should-not-stop-on-keypress.html and
fast/events/autoscroll-in-textfield.html

Patch by Antonio Gomes <a1.gomes@sisa.samsung.com> on 2012-12-07

* rendering/RenderBox.cpp:
(WebCore::RenderBox::canBeScrolledAndHasScrollableArea):
* rendering/RenderBox.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136954 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed GTK gardening.

Adding an image mismatch expectation for fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002.html.

* platform/gtk/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Throw away StyleResolvers that haven't been used for a long time.
<http://webkit.org/b/104314>

Reviewed by Antti Koivisto.

A lot of memory gets tied up in StyleResolver and the structures and caches that hang from it.
Add a mechanism to throw it away after it's been unused for a while (1 minute.)
This frees up large amounts of memory on inactive pages (background tabs) and static content.

We already have a number of scenarios where the document style is invalidated by throwing away
the StyleResolver so the major code paths are prepared for having a null StyleResolver* on occasion.

~20MB progression on Membuster3.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::styleForElement):
(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::pseudoStyleForElement):
(WebCore::StyleResolver::styleForPage):

    Call document()->didAccessStyleResolver() from the relevant parts of StyleResolver's public API.
    This prevents Document from throwing the StyleResolver away for 1 minute after it's used.

* dom/Document.h:
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::createStyleResolver):
(WebCore::Document::didAccessStyleResolver):
(WebCore::Document::styleResolverThrowawayTimerFired):

    Add a mechanism to call clearStyleResolver() on a refreshing timer.

* dom/Element.cpp:
(WebCore::Element::attributeChanged):

    If an attribute change occurs while the document doesn't have a StyleResolver, dirty the element style
    since we can't be sure that the attribute change didn't affect any rules.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Fix tools for WebKit2-only builds
https://bugs.webkit.org/show_bug.cgi?id=103904

Patch by KyungTae Kim <ktf.kim@samsung.com> on 2012-12-07
Reviewed by Laszlo Gombos.

The libewebkit2.so should be used for library path for EFL WebKit2.

* Scripts/webkitdirs.pm:
(builtDylibPathForName):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136957 268f45cc-cd09-0410-ab3c-d52691b4dbfc
IndexedDB: Check SSV version when opening database
https://bugs.webkit.org/show_bug.cgi?id=102243

Reviewed by Tony Chang.

Ensure that the data format (SerializedScriptValue) isn't "from the future" when opening
a backing store. Treat an unknown version the same as an unknown schema version.

Chromium-side test at https://codereview.chromium.org/11470013/ (same as other schema version tests)

* Modules/indexeddb/IDBBackingStore.cpp:
(WebCore):
(WebCore::isSchemaKnown): Check data version as well.
(WebCore::setUpMetadata): Ensure data version is recorded; bump schema version.
* Modules/indexeddb/IDBLevelDBCoding.cpp: Encoding for "DataVersion" global metadata entry.
(IDBLevelDBCoding):
(WebCore::IDBLevelDBCoding::compare):
(WebCore::IDBLevelDBCoding::DataVersionKey::encode):
* Modules/indexeddb/IDBLevelDBCoding.h:
(DataVersionKey):
(IDBLevelDBCoding):
* bindings/js/SerializedScriptValue.cpp:
(SerializedScriptValue::wireFormatVersion): New method (JSC side).
* bindings/js/SerializedScriptValue.h:
* bindings/v8/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::wireFormatVersion): New method (V8 side).
(WebCore):
* bindings/v8/SerializedScriptValue.h:
(SerializedScriptValue):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Provide the backend for exposing the layer tree to the Web Inspector
https://bugs.webkit.org/show_bug.cgi?id=103513

Patch by Antoine Quint <graouts@apple.com> on 2012-12-07
Reviewed by Pavel Feldman.

Source/WebCore:

The purpose of this patch is to provide a new agent enabling the Web Inspector to interface
with WebCore to access information about the render layer tree and, more specifically, expose
useful information about layers backed by textures composited on the GPU such as metrics and
backing store. Thus we now provide a LayerTreeAgent which will inform the front-end of
changes to the render layer tree via a new layerTreeDidChange event, providing an object
containing the entire hierarchy of RenderLayers for the inspected document. This hierarchy
can be queried at any time using the .getLayerTree() method on the LayerTreeAgent. Finally,
the LayerTreeAgent also exposes a .nodeIdForLayerId() method allowing to get the id of the
node associated with the RenderLayer with the provided layer id.

In terms of implementation, RenderLayerCompositor has been changed such that in its
updateCompositingLayers() method we call the layerTreeDidChange method on the
InspectorLayerTreeAgent instance via the InspectorInstrumentation.

Test: inspector-protocol/layer-tree.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* inspector/Inspector.json: Define new types IntRect (x, y, width, height) and Layer, which
holds the information for a RenderLayer (layerId, bounds, isComposited, memory,
compositedBounds) and its children (childLayers). We also define the methods of the
LayerTreeAgent object (enable, disable, getLayerTree, nodeIdForLayerId) and the
layerTreeDidChange event it
fires.
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::pushNodePathForRenderLayerToFrontend): New method facilitating
pushing the node associated with a given RenderLayer to the front-end.
(WebCore):
* inspector/InspectorDOMAgent.h:
(InspectorDOMAgent):
* inspector/InspectorInstrumentation.cpp:
(WebCore):
(WebCore::InspectorInstrumentation::didCommitLoadImpl):
(WebCore::InspectorInstrumentation::layerTreeDidChangeImpl):
(WebCore::InspectorInstrumentation::renderLayerDestroyedImpl):
* inspector/InspectorInstrumentation.h:
(WebCore):
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::layerTreeDidChange):
(WebCore::InspectorInstrumentation::renderLayerDestroyed):
* inspector/InspectorLayerTreeAgent.cpp: Added.
(WebCore):
(LayerTreeAgentState):
(WebCore::InspectorLayerTreeAgent::InspectorLayerTreeAgent):
(WebCore::InspectorLayerTreeAgent::~InspectorLayerTreeAgent):
(WebCore::InspectorLayerTreeAgent::setFrontend):
(WebCore::InspectorLayerTreeAgent::clearFrontend):
(WebCore::InspectorLayerTreeAgent::restore):
(WebCore::InspectorLayerTreeAgent::reset):
(WebCore::InspectorLayerTreeAgent::enable):
(WebCore::InspectorLayerTreeAgent::disable):
(WebCore::InspectorLayerTreeAgent::layerTreeDidChange):
(WebCore::InspectorLayerTreeAgent::renderLayerDestroyed):
(WebCore::InspectorLayerTreeAgent::getLayerTree):
(WebCore::InspectorLayerTreeAgent::buildObjectForRootLayer):
(WebCore::InspectorLayerTreeAgent::buildObjectForLayer): Build the entire hierarchy of
RenderLayers from the provided RenderLayer.
(WebCore::InspectorLayerTreeAgent::buildObjectForIntRect):
(WebCore::InspectorLayerTreeAgent::bind):
(WebCore::InspectorLayerTreeAgent::unbind):
(WebCore::InspectorLayerTreeAgent::nodeIdForLayerId):
* inspector/InspectorLayerTreeAgent.h: Added.
(WebCore):
(InspectorLayerTreeAgent):
(WebCore::InspectorLayerTreeAgent::create):
* inspector/InstrumentingAgents.h:
(WebCore):
(WebCore::InstrumentingAgents::InstrumentingAgents):
(InstrumentingAgents):
(WebCore::InstrumentingAgents::inspectorLayerTreeAgent):
(WebCore::InstrumentingAgents::setInspectorLayerTreeAgent):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateCompositingLayers): Call the layerTreeDidChange method
on the LayerTreeAgent via the InspectorInstrumentation to inform the front-end that the
RenderLayer hierarchy has changed.
(WebCore):
(WebCore::RenderLayerCompositor::layerBecameNonComposited): Call the renderLayerDestroyed
method on the LayerTreeAgent via the InspectorInstrumentation to unbind the layer that is
being destroyed.
* rendering/RenderLayerCompositor.h:
(RenderLayerCompositor):

LayoutTests:

Adding a LayoutTest that exercises the various APIs and event exposed by the LayerTreeAgent.
This test is skipped on EFL where ACCELERATED_COMPOSITING is not available.

* inspector-protocol/layer-tree-expected.txt: Added.
* inspector-protocol/layer-tree.html: Added.
* platform/efl/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Double zoom animation when focusing on input field.
https://bugs.webkit.org/show_bug.cgi?id=104375

Patch by Andrew Lo <anlo@rim.com> on 2012-12-07
Reviewed by Rob Buis.
Internally reviewed by Jakob Petsovits.

UI thread does not need to be notified of a scale change if the WebKit
thread scale has not changed.

This caused issues when two viewport resizes occured one after the other.
Before the scale change due to the first resize could be set in the WK
thread's scale value, it caused WK thread to dispatch a scaleChanged,
overwritting & resetting the new UI thread scale value, resulting in the
double zoom animation.

The larger issue dealing with synchronization between the threads where
scale changes could occur on either thread, however that is beyond the
scope of this change.

Internal PR253122

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::shouldZoomAboutPoint):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136961 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add 'CHROMIUM_DEVEL_SANDBOX' to the environment variables to copy for layout test drivers
https://bugs.webkit.org/show_bug.cgi?id=104355

Reviewed by Dirk Pranke.

This enables chromium's content_shell driver to run with the full SUID
sandbox.

* Scripts/webkitpy/layout_tests/port/base.py:
(Port.to.setup_environ_for_server):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
fast/frames/sandboxed-iframe-scripting.html contains very misleading comments.
https://bugs.webkit.org/show_bug.cgi?id=104363

Reviewed by Darin Adler.

The comments in this test describe a state that is in fact the opposite
of what's being tested. That confused me. This patch corrects the
comments to make it clear that adding a sandbox attribute at runtime has
no effect on the frame; the sandboxing flags are set when the nested
browsing context is _navigated_, not when the attribute changes value.

Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-iframe-element.html#attr-iframe-sandbox

* fast/frames/resources/sandboxed-iframe-script-dynamic.html:
* fast/frames/sandboxed-iframe-scripting-expected.txt:
* fast/frames/sandboxed-iframe-scripting.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136963 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove unnecessary casts in transformations.
https://bugs.webkit.org/show_bug.cgi?id=104376

Reviewed by Simon Fraser.

Several casts from float-to-double are performed prior to
storing the result in a double type. These casts are unnecessary
overhead and reduce the clarity of the source code.

No new tests. Covered by existing CSS test cases.

* platform/graphics/transforms/RotateTransformOperation.cpp:
* platform/graphics/transforms/TransformationMatrix.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Update BlackBerry Port to use new Graphics::createBuffer BufferType enum values.
https://bugs.webkit.org/show_bug.cgi?id=104121

Patch by Mike Lattanzio <mlattanzio@rim.com> on 2012-12-07
Reviewed by Rob Buis.

Source/WebKit/blackberry:

Update createBuffer calls to reflect new BufferType enum.
Set buffers opaque if possible to avoid unnecessary blends.
Internal PR 254649
Internal Review: Jakob Petsovits

* WebKitSupport/BackingStoreTile.cpp:
(BlackBerry::WebKit::TileBuffer::nativeBuffer):

Tools:

Update createBuffer call to reflect new BufferType enum.
Internal PR 254649
Internal Review: Jakob Petsovits

DRT is always backed for maximum compatibility.

* DumpRenderTree/blackberry/PixelDumpSupportBlackBerry.cpp:
(createBitmapContextFromWebView):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136965 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Improve r136754 by hardening checks of expected values for background-position.
https://bugs.webkit.org/show_bug.cgi?id=104380

Reviewed by Antti Koivisto.

r136754 was landed to fix the problem of checking successively two calc
values with validUnit. It was asserting as validUnit expect you to use
the parsed value of the calc after the call. In this case we pre-check the
background-position longhand to count how many values it has to then
call the right parsing functions accordingly. While r136754 is not
wrong it is better to harden isPotentialPositionValue with the real
expected units and keywords. For this matter we can reuse the
ReleaseParsedCalcValueCondition enum which was created with the same
idea as this patch. If you are not interested of the calc parsed
value when calling validUnit() you can now specify it, I believe it is
good to have it explicit to avoid mistake in the future.

No new tests : this is covered by css3/*, fast/backgrounds/*.

* css/CSSParser.cpp:
(WebCore::CSSParser::validCalculationUnit):
(WebCore::CSSParser::validUnit):
(WebCore::CSSParser::isPotentialPositionValue):
* css/CSSParser.h:
(WebCore::CSSParser::validUnit):
(CSSParser):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136966 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION(r127163): Content is offset to the right at rea.ru
https://bugs.webkit.org/show_bug.cgi?id=103116

Reviewed by David Hyatt.

Source/WebCore:

The top margin edge of a self-collapsing block that clears a float intrudes up into it by the height of the margin,
so to ensure any child floats of the self-collapsing block only go as far as the top content edge
add the margin back in to the block's current height before placing them.

Tests: fast/block/margin-collapse/self-collapsing-block-with-float-child-collapsed-margins.html
       fast/block/margin-collapse/self-collapsing-block-with-float-child.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::skipLeadingWhitespace):

LayoutTests:

* fast/block/margin-collapse/self-collapsing-block-with-float-child-collapsed-margins-expected.html: Added.
* fast/block/margin-collapse/self-collapsing-block-with-float-child-collapsed-margins.html: Added.
* fast/block/margin-collapse/self-collapsing-block-with-float-child-expected.html: Added.
* fast/block/margin-collapse/self-collapsing-block-with-float-child.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136967 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Chromium] Enable Intel's Resource Timing tests
https://bugs.webkit.org/show_bug.cgi?id=104330

Reviewed by Tony Gentilcore.

* platform/chromium/TestExpectations: 2 fail because they rely on iframes.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136968 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] GeolocationClientBB should show file system path in prompts when host is not avaliable
https://bugs.webkit.org/show_bug.cgi?id=103785

PR 247656

Patch by Otto Derek Cheung <otcheung@rim.com> on 2012-12-07
Reviewed by Rob Buis.

Adding a special case for origins with protocol "file". We will use the filepath as
an origin when asking for geolocation permission.

If the origin is unique (ie. from a sandboxed iframe), we will fail the location request
right away.

* WebCoreSupport/GeolocationClientBlackBerry.cpp:
(getOrigin):
(GeolocationClientBlackBerry::requestPermission):
(GeolocationClientBlackBerry::cancelPermissionRequest):

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