Remote Layer Tree: Clean up transaction logging
https://bugs.webkit.org/show_bug.cgi?id=123116

Reviewed by Anders Carlsson.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::RemoteLayerTreeTextStream):
(WebKit::RemoteLayerTreeTextStream::increaseIndent):
(WebKit::RemoteLayerTreeTextStream::decreaseIndent):
(WebKit::RemoteLayerTreeTextStream::writeIndent):
(WebKit::RemoteLayerTreeTextStream::operator<<):
Add some stream operator overrides for various types we need to dump.
Add a notion of current indent to our TextStream subclass to make it
easy to keep track of where we are.

(WebKit::dumpProperty):
Added, hand any arbitrary type to RemoteLayerTreeTransaction.

(WebKit::dumpChangedLayers):
(WebKit::RemoteLayerTreeTransaction::dump):
Make use of TextStream.

* WebCore.exp.in:
Export some TextStream functions.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157731 268f45cc-cd09-0410-ab3c-d52691b4dbfc
MediaStreamTrack now tracks its own state
https://bugs.webkit.org/show_bug.cgi?id=123025

Patch by Thiago de Barros Lacerda <thiago.lacerda@openbossa.org> on 2013-10-21
Reviewed by Jer Noble.

The spec says that a MediaStreamSource can be shared by different tracks,
so a track must have its own state tracking, synchronizing with its MediaStreamSource when
the underlying MediaStreamSource changes the readyState.
In the old implementation if a user invoked the stop method, its readyState method was still
returning the MediaStreamSource state, which was wrong.
This also adds a setEnabled method, which can be used to set the state of a track when a
remote peer ends it, for instance.

No new tests needed.

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::readyState):
(WebCore::MediaStreamTrack::setState):
(WebCore::MediaStreamTrack::stopProducingData):
(WebCore::MediaStreamTrack::ended):
(WebCore::MediaStreamTrack::sourceStateChanged):
(WebCore::MediaStreamTrack::trackDidEnd):
* Modules/mediastream/MediaStreamTrack.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Maybe a Lion build fix after r157731.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::operator<<):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157734 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Limit use of display sleep assertion when <video> element is off-screen.
https://bugs.webkit.org/show_bug.cgi?id=123041

Reviewed by Darin Adler.

Use page visibility changes to suspend and resume the use of sleep assertions in
HTMLMediaElement.

Page will propogate the page visibility change notifications to its Documents, which
will further propogate those notifications to registered elements.  Upon receiving
these notifications, HTMLMediaElement will release or take a DisplaySleepDisabler
token if necessary.

Also, rename HTMLMediaElement's updateDisableSleep() to updateSleepDisabling() and wrap
the implementation in a PLATFORM(MAC) guard rather than at each call site.

* dom/Document.cpp:
(WebCore::Document::registerForVisibilityStateCallbacks): Added registration method.
(WebCore::Document::unregisterForVisibilityStateCallbacks): Added unregistration method.
(WebCore::Document::visibilityStateChanged): Call all registered clients.
* dom/Document.h:
* dom/Element.h:
(WebCore::Element::visibilityStateChanged): Added default virtual method to be overridden
    by subclasses.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Register for the notification, and check the
    current status of Document::hidden().
(WebCore::HTMLMediaElement::~HTMLMediaElement): Unregister for the notification.
(WebCore::HTMLMediaElement::visibilityStateChanged): Set m_displaySleepDisablingSuspended
    and call updateSleepDisabling().
(WebCore::HTMLMediaElement::shouldDisableSleep): Add a check for m_displaySleepDisablingSuspended.
* html/HTMLMediaElement.h:
* page/Page.cpp:
(WebCore::Page::setVisibilityState): Pass to every child document.

Rename updateDisableSleep() -> updateSleepDisabling():
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::parseAttribute):
(WebCore::HTMLMediaElement::mediaPlayerRateChanged):
(WebCore::HTMLMediaElement::clearMediaPlayer):
(WebCore::HTMLMediaElement::stop):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use pink layer borders for compositing layers with a contents layer
https://bugs.webkit.org/show_bug.cgi?id=123118

Reviewed by Dean Jackson.

With the existing layer border colors, it's not possible to distinguish an empty
layer from one with solid color, image or video contents. So use a pink color
for those. This makes it easier to diagnose bugs like 122784.

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::getDebugBorderInfo):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WIN] Unreviewed build correction.

* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: Handle new JIT files as C++ implementation
  sources, not header files.
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157737 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Grammar markers are not updated when switching between 1x and 2x
https://bugs.webkit.org/show_bug.cgi?id=122146

Patch by Myles C. Maxfield <mmaxfield@apple.com> on 2013-10-21
Reviewed by Dean Jackson.

Source/WebCore:

When running editing/spelling/grammar-markers-hidpi.html, the 2x
grammar/spelling dot resources are cached. If you then run
editing/spelling/grammar-markers.html without tearing down WebKit,
it re-uses the 2x dots. The difference between the two tests is a call
to testRunner.setBackingScaleFactor().

We create a NSColor from an NSImage, and remember it in a static
variable. However, NSColor inspects the current graphics context to
determine which resolution to use, and then remembers that decision.
Therefore, we want to recreate the NSColor whenever the device pixel
ratio changes. This patch adds a new static function to GraphicsContext
which recreates this NSColor every time the ratio changes.

Tests: editing/spelling/grammar-markers.html
       editing/spelling/inline_spelling_markers.html

* platform/graphics/mac/GraphicsContextMac.mm:
(WebCore::makePattern):
(WebCore::GraphicsContext::drawLineForDocumentMarker):

LayoutTests:

* platform/mac/editing/spelling/grammar-markers-expected.png:
* platform/mac/editing/spelling/inline_spelling_markers-expected.png:

* platform/graphics/mac/GraphicsContextMac.mm:
(WebCore::makePattern):
(WebCore::GraphicsContext::drawLineForDocumentMarker):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Avoid JSC debugger overhead unless needed.
https://bugs.webkit.org/show_bug.cgi?id=123084.

Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

- If no breakpoints are set, we now avoid calling the debug hook callbacks.
- If no break on exception is set, we also avoid exception event debug callbacks.
- When we return from the ScriptDebugServer to the JSC::Debugger, we may no
  longer call the debug hook callbacks if not needed. Hence, the m_currentCallFrame
  pointer in the ScriptDebugServer may become stale. To avoid this issue, before
  returning, the ScriptDebugServer will clear its m_currentCallFrame if
  needsOpDebugCallbacks() is false.

* debugger/Debugger.cpp:
(JSC::Debugger::Debugger):
(JSC::Debugger::setNeedsExceptionCallbacks):
(JSC::Debugger::setShouldPause):
(JSC::Debugger::updateNumberOfBreakpoints):
(JSC::Debugger::updateNeedForOpDebugCallbacks):
* debugger/Debugger.h:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::unwind):
(JSC::Interpreter::debug):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_debug):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_debug):
* llint/LLIntOffsetsExtractor.cpp:
* llint/LowLevelInterpreter.asm:

Source/WebCore: 

No new tests.

- If no breakpoints are set, we now avoid calling the debug hook callbacks.
- If no break on exception is set, we also avoid exception event debug callbacks.
- When we return from the ScriptDebugServer to the JSC::Debugger, we may no
  longer call the debug hook callbacks if not needed. Hence, the m_currentCallFrame
  pointer in the ScriptDebugServer may become stale. To avoid this issue, before
  returning, the ScriptDebugServer will clear its m_currentCallFrame if
  needsOpDebugCallbacks() is false.

* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::setBreakpoint):
(WebCore::ScriptDebugServer::removeBreakpoint):
(WebCore::ScriptDebugServer::clearBreakpoints):
(WebCore::ScriptDebugServer::setPauseOnExceptionsState):
(WebCore::ScriptDebugServer::setPauseOnNextStatement):
(WebCore::ScriptDebugServer::breakProgram):
(WebCore::ScriptDebugServer::stepIntoStatement):
(WebCore::ScriptDebugServer::dispatchDidContinue):
(WebCore::ScriptDebugServer::exception):
(WebCore::ScriptDebugServer::didReachBreakpoint):
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::reset):

Source/WebKit/mac: 

* WebView/WebScriptDebugger.mm:
(WebScriptDebugger::WebScriptDebugger):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157746 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Style checker should allow a space after the @property keyword
https://bugs.webkit.org/show_bug.cgi?id=123117

Reviewed by Anders Carlsson.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_spacing_for_function_call): Allow a space between @property and the following (
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest.test_spacing_for_fncall): Added a test case.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157747 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Cocoa] Back/forward list UI process API
https://bugs.webkit.org/show_bug.cgi?id=123109

Reviewed by Darin Adler.

* CMakeLists.txt: Updated for renames.
* GNUmakefile.list.am: Ditto.

* Shared/Cocoa: Added.
* Shared/Cocoa/WKNSArray.h: Added. WKNSArray is an internal NSArray subclass backed by
a WebKit::ImmutableArray.
* Shared/Cocoa/WKNSArray.mm: Added.
(+[WKNSArray web_arrayWithImmutableArray:]): Added.
(-[WKNSArray web_initWithImmutableArray:]): Added.
(-[WKNSArray count]): Added.
(-[WKNSArray objectAtIndex:]): Added.
(-[WKNSArray copyWithZone:]): Added.

* Shared/Cocoa/WKNSObjectExtras.h: Added. Declares a category on NSObject that allows us to
vend WebKit API objects as Objective-C objects.
* Shared/Cocoa/WKNSObjectExtras.mm: Added.
(-[WKObject initWithAPIObject:]): WKObject is the generic Cocoa wrapper for API objects.
(-[WKObject isEqual:]): Check for equality of the underlying object.
(-[WKObject hash]): Return a pointer to the underlying object.
(-[WKObject description]): Added.
(+[NSObject _web_objectWithAPIObject:]): Added. Returns an appropriate Objective-C object
for the given API object. Currently returns a WKBackForwardListItem for a back/forward list
item and a generic WKObject for all other types.

* UIProcess/API/C/WKBackForwardList.cpp: Renamed.
* UIProcess/API/C/WKBackForwardList.h: Renamed.
* UIProcess/API/C/WKBackForwardListItem.cpp: Renamed.
* UIProcess/API/C/WKBackForwardListItem.h: Renamed.
* UIProcess/API/C/WKBackForwardListItemRef.cpp: Copied from Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp.
* UIProcess/API/C/WKBackForwardListItemRef.h: Copied from Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h.
* UIProcess/API/C/WKBackForwardListRef.cpp: Copied from Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp.
* UIProcess/API/C/WKBackForwardListRef.h: Copied from Source/WebKit2/UIProcess/API/C/WKBackForwardList.h.

* UIProcess/API/C/WebKit2_C.h: Updated for header renames.

* UIProcess/API/efl/ewk_back_forward_list.cpp: Updated for rename.
* UIProcess/API/efl/ewk_back_forward_list_item.cpp: Ditto.

* UIProcess/API/mac/WKBrowsingContextController.h: Declared backForwardList property.
* UIProcess/API/mac/WKBrowsingContextController.mm:
(-[WKBrowsingContextController backForwardList]): Added this accessor.

* UIProcess/Cocoa: Added.
* UIProcess/Cocoa/WKBackForwardList.h: Added.
* UIProcess/Cocoa/WKBackForwardList.mm: Added.
(toWKBackForwardListItem): Added this helper.
(-[WKBackForwardList currentItem]): Added.
(-[WKBackForwardList backItem]): Added.
(-[WKBackForwardList forwardItem]): Added.
(-[WKBackForwardList itemAtIndex:]): Added.
(-[WKBackForwardList backListCount]): Added.
(-[WKBackForwardList forwardListCount]): Added.
(-[WKBackForwardList backListWithLimit:]): Added.
(-[WKBackForwardList forwardListWithLimit:]): Added.
(-[WKBackForwardList _initWithList:]): Added.
* UIProcess/Cocoa/WKBackForwardListInternal.h: Added.

* UIProcess/Cocoa/WKBackForwardListItem.h: Added.
* UIProcess/Cocoa/WKBackForwardListItem.mm: Added.
(-[WKBackForwardListItem URL]): Added.
(-[WKBackForwardListItem title]): Added.
(-[WKBackForwardListItem originalURL]): Added.
(-[WKBackForwardListItem isEqual:]): Check for equality of the underlying object.
(-[WKBackForwardListItem hash]): Return a pointer to the underlying object
(-[WKBackForwardListItem _initWithItem:]): Added.
* UIProcess/Cocoa/WKBackForwardListItemInternal.h: Added.

* WebKit2.xcodeproj/project.pbxproj: Updated for renames and additions.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157748 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed build fix; unprotect the declaration of updateSleepDisabling();

* html/HTMLMediaElement.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Maybe a Lion build fix after r157731, part 2.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::operator<<):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
New flakiness dashboard show test time, modifiers, and flaky tests
https://bugs.webkit.org/show_bug.cgi?id=123119

Reviewed by Tim Horton.

* api/failing-tests.php: Manually serialize each row in the results to avoid hitting the memory limit.
* include/db.php:
(Database::query): Added.
(Database::fetch_next_row): Added.
* include/init-database.sql: Added modifiers and time columns to results table.
* include/test-results.php:
(store_test_results): Update start_time and end_time to the union of the new interval and the existing interval.
(recursively_add_test_results): Handle empty $full_name to eliminate the loop over tests in store_test_results.
Also verify that each test name, expected and actual results conform to the specific format to prevent XSS.
Also use insert_row instead of select_or_insert_row to avoid issuing an unnecessary SQL query.
(format_result): Extracted from format_result_rows. Used in failing-tests.php.
* index.html:
(TestResultsView): Added _currentBuilderFailureType and _currentBuilderDays.
(TestResultsView._createResultCell): Show the test time and the expected result.
(TestResultsView._createTestResultRow): Compute the slowest run and also round time to tenth of second for time
less than 10s or second if it's more than 10s so that the test time will always be shown in two digits.
Also show the bug number and the latest expected result on the left columns after linkifying the bug numbers.
(TestResultsView._matchesFailureType): Added. Determines whether results is of a particular failure type.
(TestResultsView._populateBuilderPane):
(TestResultsView.fetchFailingTestsForBuilder): Store the failure type such as flaky, wrongtestexpectations.
(TestResultsView.updateLocationHash):
(TestResultsView.loadTestsFromLocationHash):
(fetchManifest):
* js/dom.js:
(element): appendChild if an item is a Node. Otherwise, e.g. integer, create a text node out of toString() call.
* main.css: Updated styles.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Give up on building RemoteLayerTreeTransaction::dump on Lion, it just won't work.

This definitely ought to fix the build.

* Shared/mac/RemoteLayerTreeTransaction.h:
* Shared/mac/RemoteLayerTreeTransaction.mm:
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::commit):


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