Objective-C API: Need a good way to reference event handlers without causing cycles
https://bugs.webkit.org/show_bug.cgi?id=111088

Reviewed by Geoffrey Garen.

JSManagedValue is like a special kind of weak value. When you create a JSManagedValue, you can
supply an Objective-C object as its "owner". As long as the Objective-C owner object remains
alive and its wrapper remains accessible to the JSC garbage collector (e.g. by being marked by 
the global object), the reference to the JavaScript value is strong. As soon as the Objective-C
owner is deallocated or its wrapper becomes inaccessible to the garbage collector, the reference
becomes weak.

If you do not supply an owner or you use the weakValueWithValue: convenience class method, the
returned JSManagedValue behaves as a normal weak reference.

This new class allows clients to maintain references to JavaScript values in the Objective-C
heap without creating reference cycles/leaking memory.

* API/JSAPIWrapperObject.cpp: Added.
(JSC):
(JSC::::createStructure):
(JSC::JSAPIWrapperObject::JSAPIWrapperObject): This is a special JSObject for the Objective-C API that knows
for the purposes of garbage collection/marking that it wraps an opaque Objective-C object.
(JSC::JSAPIWrapperObject::visitChildren): We add the pointer to the wrapped Objective-C object to the set of
opaque roots so that the weak handle owner for JSManagedValues can find it later.
* API/JSAPIWrapperObject.h: Added.
(JSC):
(JSAPIWrapperObject):
(JSC::JSAPIWrapperObject::wrappedObject):
(JSC::JSAPIWrapperObject::setWrappedObject):
* API/JSBase.cpp:
(JSSynchronousGarbageCollect):
* API/JSBasePrivate.h:
* API/JSCallbackObject.cpp:
(JSC):
* API/JSCallbackObject.h:
(JSC::JSCallbackObject::destroy): Moved this to the header so that we don't get link errors with JSAPIWrapperObject.
* API/JSContext.mm:
(-[JSContext initWithVirtualMachine:]): We weren't adding manually allocated/initialized JSVirtualMachine objects to 
the global cache of virtual machines. The init methods handle this now rather than contextWithGlobalContextRef, since 
not everyone is guaranteed to use the latter.
(-[JSContext initWithGlobalContextRef:]):
(+[JSContext contextWithGlobalContextRef:]):
* API/JSManagedValue.h: Added.
* API/JSManagedValue.mm: Added.
(JSManagedValueHandleOwner):
(managedValueHandleOwner):
(+[JSManagedValue weakValueWithValue:]):
(+[JSManagedValue managedValueWithValue:owner:]):
(-[JSManagedValue init]): We explicitly call the ARC entrypoints to initialize/get the weak owner field since we don't 
use ARC when building our framework.
(-[JSManagedValue initWithValue:]):
(-[JSManagedValue initWithValue:owner:]):
(-[JSManagedValue dealloc]):
(-[JSManagedValue value]):
(-[JSManagedValue weakOwner]):
(JSManagedValueHandleOwner::isReachableFromOpaqueRoots): If the Objective-C owner is still alive (i.e. loading the weak field
returns non-nil) and that value was added to the set of opaque roots by the wrapper for that Objective-C owner, then the the 
JSObject to which the JSManagedObject refers is still alive.
* API/JSObjectRef.cpp: We have to add explicit checks for the JSAPIWrapperObject, just like the other types of JSCallbackObjects.
(JSObjectGetPrivate):
(JSObjectSetPrivate):
(JSObjectGetPrivateProperty):
(JSObjectSetPrivateProperty):
(JSObjectDeletePrivateProperty):
* API/JSValue.mm:
(objectToValueWithoutCopy):
* API/JSValueRef.cpp:
(JSValueIsObjectOfClass):
* API/JSVirtualMachine.mm:
(-[JSVirtualMachine initWithContextGroupRef:]):
(+[JSVirtualMachine virtualMachineWithContextGroupRef:]):
* API/JSWrapperMap.mm:
(wrapperFinalize):
(makeWrapper): This is our own internal version of JSObjectMake which creates JSAPIWrapperObjects, the Obj-C API 
version of JSCallbackObjects.
(createObjectWithCustomBrand):
(-[JSObjCClassInfo wrapperForObject:]):
(tryUnwrapObjcObject):
* API/JavaScriptCore.h:
* API/tests/testapi.mm: Added new tests for the strong and weak uses of JSManagedValue in the context of an 
onclick handler for an Objective-C object inserted into a JSContext.
(-[TextXYZ setWeakOnclick:]):
(-[TextXYZ setOnclick:]):
(-[TextXYZ weakOnclick]):
(-[TextXYZ onclick]):
(-[TextXYZ click]):
* CMakeLists.txt: Various build system additions.
* GNUmakefile.list.am:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/JSGlobalObject.cpp: Added the new canonical Structure for the JSAPIWrapperObject class.
(JSC::JSGlobalObject::reset):
(JSC):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSGlobalObject):
(JSC::JSGlobalObject::objcWrapperObjectStructure):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145119 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Prevent text selection inside Colour and Date/Time input fields
https://bugs.webkit.org/show_bug.cgi?id=111733

Reviewed by Rob Buis.

PR 305194.

Prevent selection for popup input fields as they are buttons.

Informally Reviewed Gen Mak.

* WebCoreSupport/EditorClientBlackBerry.cpp:
(WebCore::EditorClientBlackBerry::shouldChangeSelectedRange):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[nrwt] handle corrupt http server pid files cleanly
https://bugs.webkit.org/show_bug.cgi?id=111628

Reviewed by Eric Seidel.

If the pid file from a previous http server is corrupt for some
reason, NRWT will just raise errors and not clean it up or recover.
This patch fixes that to at least delete the pid file and
not throw; not that we may still have stale http servers left on
the system, since there's no way to know which pid to kill if
the file was corrupted.

* Scripts/webkitpy/layout_tests/servers/http_server_base.py:
(HttpServerBase.start):
(HttpServerBase.stop):
(HttpServerBase._remove_pid_file):
* Scripts/webkitpy/layout_tests/servers/http_server_base_unittest.py: Added.
(TestHttpServerBase):
(TestHttpServerBase.test_corrupt_pid_file):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145122 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r145097.
http://trac.webkit.org/changeset/145097
https://bugs.webkit.org/show_bug.cgi?id=111765

Triggers an ASSERT in the Chromium port (Requested by abarth
on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2013-03-07

Source/WebCore:

* html/FileInputType.cpp:
(WebCore::FileInputType::appendFormData):
* platform/network/FormData.cpp:
(WebCore::FormData::appendKeyValuePairItems):

LayoutTests:

* http/tests/local/formdata/send-form-data-with-empty-blob-filename-expected.txt: Removed.
* http/tests/local/formdata/send-form-data-with-empty-blob-filename.html: Removed.
* http/tests/local/formdata/send-form-data-with-empty-file-filename-expected.txt: Removed.
* http/tests/local/formdata/send-form-data-with-empty-file-filename.html: Removed.
* http/tests/xmlhttprequest/resources/multipart-post-echo-filenames.php: Removed.
* platform/wk2/TestExpectations:

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

* platform/chromium/compositing/overflow/composited-scrolling-paint-phases-expected.txt: Added.
* platform/chromium/platform/chromium/virtual/gpu/compositedscrolling/overflow/composited-scrolling-paint-phases-expected.txt: Added.
* platform/chromium/platform/chromium/virtual/softwarecompositing/overflow/composited-scrolling-paint-phases-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Chromium] Update some #includes for WebMessagePortChannel.h
https://bugs.webkit.org/show_bug.cgi?id=111752

Reviewed by James Robinson.

In anticipation of removing
WK/chromium/public/WebMessagePortChannel.h (once all downstream
references have been updated)

* public/WebDOMMessageEvent.h:
* public/WebFrame.h:
* public/WebSharedWorkerClient.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145125 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Move side-effects on hover/active state out of hit-testing
https://bugs.webkit.org/show_bug.cgi?id=98168

Reviewed by Julien Chaffraix.

Original patch by Allan Sandfeld Jensen; I'm just tweaking things.

Document::updateHoverActiveState is currently called during hit testing
to update the hover and active states of elements effected by mouse
movements (or their keyboard equivalents). This conflates the hit test
algorithm itself with side-effects associated with specific use-cases.

This conflation makes it very difficult to reuse the hover/active logic
for things other than hit testing. 'mouseenter'/'mouseleave' events[1]
are one example of a feature that would be simple to implement on top of
this existing logic if we split it out from the hit testing path, and
instead call it explicitly when necessary. An explicit split between
hit testing and its side-effects will also enable us to simplify the
logic in future patches with well-named parameters, rather than relying
on stuffing properties into HitTestRequest.

This patch drops the call to Document::updateHoverActiveState from
RenderView::hitTest, and adjusts the three call-sites in EventHandler
to explicitly call out to it rather than Document::updateStyleIfNeeded.
The latter call is still necessary but has been folded into
updateHoverActiveState, as the former is never called without calling
the latter.

[1]: http://wkbug.com/18930

* dom/Document.h:
* dom/Document.cpp:
(WebCore::Document::updateHoverActiveState):
    First, this function must now only be called from contexts that were
    performing a read/write hit-test: the code asserts this
    precondition.

    Second, rather than accepting a HitTestResult, the function accepts
    an Element* from which to begin the hover/active chain changes.

    Third, we have to explicitly update the hover/active states for
    documents between the updated element and the top-level document.
    The hit-testing logic was taking care of this for us, now we need to
    take care of it ourselves.

    Fourth, call out to updateStyleIfNeeded rather than making our
    caller do so. The calls were always paired; now that's explicit.
(WebCore::Document::prepareMouseEvent):
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::EventHandler::hoverTimerFired):
    Call out to updateHoverActiveState rather than updateStyleIfNeeded.
* rendering/RenderView.cpp:
(WebCore::RenderView::hitTest):
    Drop the call to updateHoverActiveState.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145126 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] allow iOS to use CaptionUserPreferencesMac
https://bugs.webkit.org/show_bug.cgi?id=111770

Reviewed by Dean Jackson.

No new tests, covered by existing tests.

* page/CaptionUserPreferencesMac.h:
* page/CaptionUserPreferencesMac.mm:
(WebCore::userCaptionPreferencesChangedNotificationCallback): Respond to notifications on
    the web thread.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Re-enable Win EWS tests.

* Scripts/webkitpy/tool/commands/earlywarningsystem.py:
(WinEWS):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145128 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Build fix for AppleWin VS2010.

* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145129 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Bump libsoup dependency to 2.40.3 to fix regressions
https://bugs.webkit.org/show_bug.cgi?id=111756

Reviewed by Kenneth Rohde Christiansen.

.:

Update libsoup required version to v2.40.3 for EFL port.

* Source/cmake/OptionsEfl.cmake:

Tools:

Bump libsoup to v2.40.3 to fix the regressions introduced by
previous v2.40.0 bump.

* efl/jhbuild.modules:

LayoutTests:

Unskip several tests that are passing after the libsoup dependency
bump to 2.40.3.

* platform/efl/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145130 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[chromium] Stop using WebTransformationMatrix on WebLayer
https://bugs.webkit.org/show_bug.cgi?id=111635

Reviewed by Adrienne Walker.

Source/Platform:

WebLayer supports setting transforms by using either SkMatrix44 or WebTransformationMatrix,
both of which are wrappers around 16 doubles. There's no need to have both.

* chromium/public/WebLayer.h:
(WebKit):
(WebLayer):

Source/WebCore:

Switches over to the SkMatrix44 transform setters.

* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::transformToSkMatrix44):
  Utility for convering a WebCore::TransformationMatrix to an SkMatrix44.
  Will move to a more common location once it gets more callers.
(WebCore::GraphicsLayerChromium::updateTransform):
(WebCore::GraphicsLayerChromium::updateChildrenTransform):

Source/WebKit/chromium:

* src/LinkHighlight.cpp:
(WebKit::LinkHighlight::computeEnclosingCompositingLayer):
* tests/GraphicsLayerChromiumTest.cpp:
(GraphicsLayerChromiumTest):

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

* fast/borders/border-fit-expected.txt: Renamed from LayoutTests/platform/chromium/fast/borders/border-fit-expected.txt.
* platform/chromium-mac/fast/borders/border-fit-expected.txt: Renamed from LayoutTests/platform/mac/fast/borders/border-fit-expected.txt.
* platform/chromium-win/fast/borders/border-fit-expected.txt:
* platform/efl/fast/borders/border-fit-expected.txt: Removed.
* platform/gtk/fast/borders/border-fit-expected.txt: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145132 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add a didFocusTextField callback to the injected bundle form client
https://bugs.webkit.org/show_bug.cgi?id=111771

Reviewed by Andreas Kling.

Source/WebCore:

Export a symbol needed by WebKit2.

* WebCore.exp.in:

Source/WebKit2:

Add a new client callback that's invoked whenever a text input field is focused.

* Shared/APIClientTraits.cpp:
(WebKit):
* Shared/APIClientTraits.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
(WebKit::InjectedBundlePageFormClient::didFocusTextField):
(WebKit):
* WebProcess/InjectedBundle/InjectedBundlePageFormClient.h:
(InjectedBundlePageFormClient):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::focusedNodeChanged):

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

* platform/chromium-mac/fast/repaint/border-fit-lines-expected.txt: Renamed from LayoutTests/platform/chromium/fast/repaint/border-fit-lines-expected.txt.
* platform/chromium-win/fast/repaint/border-fit-lines-expected.txt:

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

* platform/chromium/TestExpectations: http/tests/security/cross-origin-css.html

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145135 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: provide reasons why a layer was composited in the LayerTreeAgent
https://bugs.webkit.org/show_bug.cgi?id=111703

Source/WebCore:

Introduce a new LayerTree.reasonsForCompositingLayer(layerId) method which returns
the list of reasons why the provided layer was composited as an object with an
optional property for each possible reason. The RenderLayerCompositor already knows
how to provide this information via its own reasonsForCompositing() method, and we
process the returned bitmask to populate the object sent to the front-end.

Reviewed by Timothy Hatcher.

Test: inspector-protocol/layers/layers-compositing-reasons.html

* inspector/Inspector.json:
* inspector/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::reasonsForCompositingLayer):
(WebCore):
* inspector/InspectorLayerTreeAgent.h:
(InspectorLayerTreeAgent):

LayoutTests:

New test for LayerTree.reasonsForCompositingLayer(layerId).

Reviewed by Timothy Hatcher.

* inspector-protocol/layers/layers-compositing-reasons-expected.txt: Added.
* inspector-protocol/layers/layers-compositing-reasons.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145136 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION: fast/border/border-fit-2.html needs updating
https://bugs.webkit.org/show_bug.cgi?id=111776

Reviewed by Simon Fraser.

Source/WebCore: 

This test is incorrectly shrinking the border image now.
We need to apply some clamping to the border-fit like the
old code did. The pixel results *are* still changing though,
since a layout-time shrinkage will not result in right-aligned
boxes in an LTR block when the left edge gets chopped. We'll
have to see if this behavioral change ends up being a problem,
but for now we'll rebaseline and assume it will be ok.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::fitBorderToLinesIfNeeded):

LayoutTests: 

* platform/mac/fast/borders/border-fit-2-expected.png:
* platform/mac/fast/borders/border-fit-2-expected.txt:



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

* platform/win/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145140 268f45cc-cd09-0410-ab3c-d52691b4dbfc
run-perf-tests fails due to svn_revision not working on a pure git clone
https://bugs.webkit.org/show_bug.cgi?id=110839

Reviewed by Ryosuke Niwa.

Previously we would call git svn find-rev to look up the commit for
a given revision, and that'll hang in a pure git checkout.

This patch changes the way we look up svn revisions in a git
repository to use git log --grep 'git-svn-id', which is much faster
than grepping ourselves. It also renames timestamp_of_latest_commit()
to timestamp_of_revision() in order to accurately reflect what
the method is doing. Note that this patch only changes the logic
inside latest_revision() and svn_revision(). I'll file a separate
bug to change git_commit_from_svn_revision().

This patch also contains some fixes to unit tests that had bit-rotted
or were otherwise fragile, so that test-webkitpy --all would pass
cleanly, and a fix to outputcapture so that
test-webkitpy -p would work correctly again.

* Scripts/webkitpy/common/checkout/scm/git.py:
(Git.svn_revision):
(Git.timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/scm.py:
(SCM.svn_revision):
(SCM.timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/scm_mock.py:
(MockSCM.timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
(_shared_test_commit_with_message):
(test_commit_without_authorization):
(test_timestamp_of_revision):
* Scripts/webkitpy/common/checkout/scm/svn.py:
(SVN.timestamp_of_revision):
* Scripts/webkitpy/common/system/outputcapture.py:
  Importing unittest2 directly may not be safe if this module is
  imported before the autoinstaller gets a chance to set things up
  properly. We don't actually need unittest2 here.
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner._generate_results_dict):

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