Web Inspector: display cause for style recalculation and layout on Timeline
https://bugs.webkit.org/show_bug.cgi?id=95000

Reviewed by Pavel Feldman.

Source/WebCore:

Added instrumentation for didInvalidateLayout and didScheduleStyleRecalculation;
Dispaly stacks of the above records in Layout and Recalculate Style as "call site" stacks (need a better wording?);
Display synchronous Layout records in red, provide a warning that these may affect performance;

* English.lproj/localizedStrings.js: +"Note" and a warning test for sync layout;
* inspector/InspectorInstrumentation.cpp: Plumbing new instrumentation methods through to timeline;
(WebCore):
(WebCore::InspectorInstrumentation::didInvalidateLayoutImpl):
(WebCore::InspectorInstrumentation::didScheduleStyleRecalculationImpl):
* inspector/InspectorInstrumentation.h: ditto.
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::didInvalidateLayout):
(WebCore):
* inspector/InspectorTimelineAgent.cpp: ditto.
(TimelineRecordType):
(WebCore::InspectorTimelineAgent::didInvalidateLayout):
(WebCore):
(WebCore::InspectorTimelineAgent::didScheduleStyleRecalculation):
* inspector/InspectorTimelineAgent.h: ditto.
(InspectorTimelineAgent):
* inspector/front-end/TimelineModel.js:
* inspector/front-end/TimelinePanel.js:
(WebInspector.TimelineRecordListRow.prototype.update): Display records with warnings in their own style;
* inspector/front-end/TimelinePresentationModel.js:
(WebInspector.TimelinePresentationModel._initRecordStyles): Renamed, added new records;
(WebInspector.TimelinePresentationModel.recordStyle): Added new records;
(WebInspector.TimelinePresentationModel.prototype.reset):
(WebInspector.TimelinePresentationModel.prototype._innerAddRecord): Add support for new records, make 'em hidden;
(WebInspector.TimelinePresentationModel.Record): Add support for hidden records;
(WebInspector.TimelinePresentationModel.Record.prototype._generatePopupContentWithImagePreview):
(WebInspector.TimelinePresentationModel.Record.prototype._linkifyTopCallFrame): Linkify originator's top frame if no own stack is present;
* inspector/front-end/timelinePanel.css:
(.timeline-tree-item.warning): Reddish text for records with warnings;
* page/FrameView.cpp:
(WebCore::FrameView::scheduleRelayout): Added call to InspectorInstrumentation::didInvalidateLayout()
(WebCore::FrameView::scheduleRelayoutOfSubtree): Ditto.

LayoutTests:

- added new events (ScheduleStyleRecalculation and InvlidateLayout)
- rebaselined a test due to a new event;

* inspector/timeline/timeline-enum-stability-expected.txt:
* inspector/timeline/timeline-script-tag-1-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126754 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION(r126524): Heap-buffer-overflow in WebCore::StylePropertySet::copyPropertiesFrom
<http://webkit.org/b/95005>

Reviewed by Antti Koivisto.

Remove incorrect assertion that the StylePropertySet is empty before properties are copied
into it, as this is no guarantee in editing code.
This regressed when splitting the code into mutable/immutable paths. Covered by assertions
on existing tests.

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::copyPropertiesFrom):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126755 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GStreamer][Qt] WebAudio support
https://bugs.webkit.org/show_bug.cgi?id=94806

Reviewed by Simon Hausmann.

Source/WebCore:

Build system changes to support WebAudio and its GStreamer
backend. A new AudioBusQt implementation is also needed to locate
and load local .wav files. Note: WebAudio is still disabled by default in
build-webkit. Use --web-audio to explicitely enable it at build time.

* DerivedSources.pri:
* Target.pri:
* WebCore.pri:
* WebCore.qrc:
* platform/audio/HRTFElevation.cpp:
(WebCore): Use concatenated HRTF impulse response for increased
performance, just like GTK, Mac and EFL ports.
* platform/audio/gstreamer/AudioFileReaderGStreamer.cpp: Undef the
signals macro so gio.h can be properly included.
* platform/audio/qt/AudioBusQt.cpp: Added.
(WebCore):
(WebCore::AudioBus::loadPlatformResource):

Source/WebKit2:

New boolean webAudioEnabled WebSetting to be used at runtime to
toggle WebAudio support on or off.

* UIProcess/API/qt/qwebpreferences.cpp:
(QWebPreferencesPrivate::testAttribute):
(QWebPreferencesPrivate::setAttribute):
(QWebPreferences::webAudioEnabled):
(QWebPreferences::setWebAudioEnabled):
* UIProcess/API/qt/qwebpreferences_p.h:
* UIProcess/API/qt/qwebpreferences_p_p.h:

Tools:

* MiniBrowser/qt/qml/BrowserWindow.qml: Enable WebAudio support.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126756 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GStreamer][Qt] WebAudio support
https://bugs.webkit.org/show_bug.cgi?id=94806

Reviewed by Simon Hausmann.

Build fix after r126756 in which I forgot to add the new
AudioBusQt.cpp file.

* platform/audio/qt/AudioBusQt.cpp: Added.
(WebCore):
(WebCore::AudioBus::loadPlatformResource):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126757 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: filter out weak references from retainers tree
https://bugs.webkit.org/show_bug.cgi?id=95082

Reviewed by Yury Semikhatsky.

Weak references don't retain objects.

* inspector/front-end/HeapSnapshotGridNodes.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Implement GraphicsSurface::paintToTextureMapper.
https://bugs.webkit.org/show_bug.cgi?id=95077

Forward paintToTextureMapper call directly into
GraphicsSurface. This allows getting rid of platform
specific code in TextureMapperSurfaceBackingStore.

Reviewed by Noam Rosenthal.

* platform/graphics/surfaces/GraphicsSurface.cpp:
(WebCore::GraphicsSurface::paintToTextureMapper):
(WebCore):
* platform/graphics/surfaces/GraphicsSurface.h:
(WebCore):
(GraphicsSurface):
* platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
(WebCore):
* platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp:
(WebCore):
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
* platform/graphics/texmap/TextureMapperBackingStore.cpp:
(WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126759 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Chromium] Implementing a global limit on memory consumed by deferred 2D canvases
https://bugs.webkit.org/show_bug.cgi?id=94386

Patch by Justin Novosad <junov@chromium.org> on 2012-08-27
Reviewed by Stephen White.

Source/WebCore:

Before this change, there was no global bound on memory that could be
consumed for the purpose of recording 2d canvas deferred draw commands.
There was only a per canvas limit. It is possible for canvases to get
dereferenced without flushing pending draw commands, which may lock
resources until the canvas element is garbage collected. This makes
it possible to grow memory consumption indefinitely by hitting reload
successively on some canvas-intensive web pages.

The solution implemented in this change consists in maintaining a
global registry of deferred canvas layers and tracking the sum of
memory allocated by all canvases for the purpose of storing deferred
draw commands. When memory consumption reaches the allowed limit,
caches are cleared and draw operations are flushed on one or several
canvases, starting with the least recently used, until memory
consumption is below a target level.

New tests: webkit_unit_tests DeferredLayerManagerTest*

* WebCore.gypi:
* platform/graphics/chromium/Canvas2DLayerBridge.cpp:
(WebCore::Canvas2DLayerBridge::Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::~Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::storageAllocatedForRecordingChanged):
Overloaded from SkDeferredCanvas::NotificationClient. Called when
there is a change in the number of bytes allocated by the deferred
canvas.
(WebCore):
(WebCore::Canvas2DLayerBridge::flushedDrawCommands):
Overloaded from SkDeferredCanvas::NotificationClient. Called when
pending draw commands are flush by the deferred canvas.
(WebCore::Canvas2DLayerBridge::freeMemoryIfPossible):
Called by the Canvas2DLayerManager to request the release of unlocked
memory resources (caches). Request is relayed to SkDeferredCanvas.
returns number of bytes freed.
(WebCore::Canvas2DLayerBridge::flush):
Requests that pending draw commands be flushed immediately from the
deferred canvas queue. Request is relayed to SkDeferredCanvas.
(WebCore::Canvas2DLayerBridge::contextAcquired):
* platform/graphics/chromium/Canvas2DLayerBridge.h:
(Canvas2DLayerBridge):
(WebCore::Canvas2DLayerBridge::bytesAllocated):
(WebCore::Canvas2DLayerBridge::updateBytesAllocated):
* platform/graphics/chromium/Canvas2DLayerManager.cpp: Added.
(WebCore):
(WebCore::Canvas2DLayerManager::Canvas2DLayerManager):
(WebCore::Canvas2DLayerManager::~Canvas2DLayerManager):
(WebCore::Canvas2DLayerManager::init):
Sets the global limit for the maximum total number of bytes allocated
by deferred layers.
(WebCore::Canvas2DLayerManager::get):
Singleton accessor
(WebCore::Canvas2DLayerManager::layerDidDraw):
Called by Canvas2DLayerBridge to indicate that the layer was drawn to.
(WebCore::Canvas2DLayerManager::addLayerToList):
(WebCore::Canvas2DLayerManager::layerAllocatedStorageChanged):
Called by Canvas2DLayerBridge to indicate thet the memory consumed by
the layer has changed.
(WebCore::Canvas2DLayerManager::layerDidFlush):
Called by Canvas2DLayerBridge to indicated that the pending draw
commands of the layer were flushed.
(WebCore::Canvas2DLayerManager::layerToBeDestroyed):
Called by Canvas2DLayerBridge upon destruction.
(WebCore::Canvas2DLayerManager::freeMemoryIfNecessary):
Called internally. Check that current memory consumption is below
the tolerated limit.  If check fails, intiates resource releases.
(WebCore::Canvas2DLayerManager::removeLayerFromList):
(WebCore::Canvas2DLayerManager::isInList):
(WebCore::Canvas2DLayerManager::updateBytesAllocated):
* platform/graphics/chromium/Canvas2DLayerManager.h: Added.
(WebCore):
(Canvas2DLayerManager):

Source/WebKit/chromium:

Adding unit tests for WebCore::Canvas2DLayerManager

* WebKit.gypi:

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