CSS: Add a property cascading pass to style application.
<https://webkit.org/b/125213>

Add an intermediate pass to style application where we cascade all
style properties to figure out their final values before starting
to build RenderStyles.

This opens up various opportunities for further optimization.

Reviewed by Antti Koivisto.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::CascadedProperties::Property::Property):
(WebCore::StyleResolver::CascadedProperties::CascadedProperties):
(WebCore::StyleResolver::CascadedProperties::property):
(WebCore::StyleResolver::CascadedProperties::set):
(WebCore::StyleResolver::CascadedProperties::addStyleProperties):
(WebCore::StyleResolver::CascadedProperties::addMatches):
(WebCore::StyleResolver::CascadedProperties::Property::apply):

    Added. CascadedProperties is something of a container class
    that takes CSS property/value/linkMatchType as input and boils
    them down to the final values that will actually be used.

    Most properties are poked into an unfancy array where latest
    is greatest (unless !important, of course.) Some properties are
    queued up to be applied in parse order, more on that below.

(WebCore::StyleResolver::applyCascadedProperties):
(WebCore::StyleResolver::applyMatchedProperties):

    The brains of this patch. applyMatchedProperties() now creates
    a CascadedProperties and uses it to figure out the final values
    and uses applyCascadedProperties() to apply them. Deferred
    properties (parse order) are applied last.

    We may discover during property application that we won't be
    able to use a matched properties cache item. This happens if
    the effective zoom or font changes. If that happens, we start
    the process over, now with the cache disabled. This may need
    some optimization work.

(WebCore::extractDirectionAndWritingMode):

    Directional properties ending in e.g -before or -after depend on
    the direction and writing mode in effect, so we must begin with
    resolving those properties before doing the full cascade.

    This is done by simply walking the set of matched properties and
    manually applying '-webkit-writing-mode' and 'direction'.

    If this starts showing up in profiles, we can easily cache some
    of the information in e.g RuleData to avoid the traversal here.

(WebCore::elementTypeHasAppearanceFromUAStyle):

    To determine whether a form element is styled beyond the default
    UA style sheet, StyleResolver caches the border and background
    values from RenderStyle after applying the UA style sheet.

    Those values are then compared against after all style is applied
    and if some (platform-dependent) values differ, the element is
    considered "styled."

    This really only affects elements with -webkit-appearance values
    in the default UA style sheet, so this function determines if an
    element should take the goofy slow path for this.

(WebCore::shouldApplyPropertyInParseOrder):
(WebCore::StyleResolver::CascadedProperties::setDeferred):
(WebCore::StyleResolver::CascadedProperties::applyDeferredProperties):

    Some CSS properties will write to the same RenderStyle fields when
    applied, so in order to maintain previous behavior, we must apply
    them in the order they were parsed.

    We accomplish this by keeping an ordered queue of such properties
    to apply separately after all the other properties.

(WebCore::StyleResolver::CascadedProperties::setPropertyInternal):

    Helper for poking values into a CascadedProperties::Property.

* css/StyleResolver.h:
(WebCore::StyleResolver::state):

    Expose the StyleResolver::State so CascadedProperties can access it.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160806 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: Remove leftover code from InspectorController after r108965
https://bugs.webkit.org/show_bug.cgi?id=125956

Reviewed by Joseph Pecoraro.

No new tests, no changes in behavior.

* inspector/InspectorController.h: PostWorkerNotificationToFrontendTask was removed in r108965.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160807 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Cocoa] Allow the web process plug-in to intercept resource requests
https://bugs.webkit.org/show_bug.cgi?id=125959

Reviewed by Anders Carlsson.

* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h: Declared new
delegate method.
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(willSendRequestForFrame): Implemented this WKBundlePageResourceClient callback by calling
the load delegate.
(setUpResourceLoadClient): Added. Initializes the resource load client with the above
function.
(-[WKWebProcessPlugInBrowserContextController setLoadDelegate:]): Added calls to initialize
and clear the resource load client.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[MSE][Mac] Add AVSampleBufferAudioRenderer support.
https://bugs.webkit.org/show_bug.cgi?id=125905

Reviewed by Eric Carlson.

On platforms which support AVSampleBufferAudioRenderer, add support
for playback of audio CMSampleBufferRefs generated by AVStreamDataParser.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable): Require AVSampleBufferAudioRenderer.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVolume): Pass through to every audio renderer.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setMuted): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer): Slave the renderer's
    timebase to the master clock.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeAudioRenderer):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): Drive by fix; initialize
    m_enabledVideoTrackID.
(WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): Call destroyRenderers().
(WebCore::callProcessCodedFrameForEachSample): Drive by fix; convert the bool return to an OSErr.
(WebCore::SourceBufferPrivateAVFObjC::destroyRenderers): Added; flush and destroy the audio
    renderers.
(WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource): Call destroyRenderers().
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): Enable or disable the audio
    renderer in response.
(WebCore::SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples): Added audio
    specific version.
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples): Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Deprecate some WKMutableDictionary functions
https://bugs.webkit.org/show_bug.cgi?id=125962

Reviewed by Tim Horton.

Source/WebKit2:

* Shared/API/c/WKDeprecatedFunctions.cpp:
(WKDictionaryIsMutable):
(WKDictionaryAddItem):
(WKDictionaryRemoveItem):
* Shared/API/c/WKMutableDictionary.cpp:
* Shared/API/c/WKMutableDictionary.h:

Tools:

* TestWebKitAPI/PlatformUtilities.cpp:
(TestWebKitAPI::Util::createInitializationDictionaryForInjectedBundleTest):
* TestWebKitAPI/Tests/WebKit2/DidAssociateFormControls_Bundle.cpp:
(TestWebKitAPI::didAssociateFormControls):
* TestWebKitAPI/Tests/WebKit2/WillLoad_Bundle.cpp:
(TestWebKitAPI::WillLoadTest::willLoadURLRequest):
(TestWebKitAPI::WillLoadTest::willLoadDataRequest):
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::createMouseMessageBody):
(WTR::EventSendingController::mouseMoveTo):
(WTR::EventSendingController::leapForward):
(WTR::createKeyDownMessageBody):
(WTR::EventSendingController::mouseScrollBy):
(WTR::EventSendingController::continuousMouseScrollBy):
(WTR::EventSendingController::addTouchPoint):
(WTR::EventSendingController::updateTouchPoint):
(WTR::EventSendingController::setTouchModifier):
(WTR::EventSendingController::setTouchPointRadius):
(WTR::EventSendingController::touchStart):
(WTR::EventSendingController::touchMove):
(WTR::EventSendingController::touchEnd):
(WTR::EventSendingController::touchCancel):
(WTR::EventSendingController::clearTouchPoints):
(WTR::EventSendingController::releaseTouchPoint):
(WTR::EventSendingController::cancelTouchPoint):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::done):
(WTR::InjectedBundle::setMockGeolocationPosition):
(WTR::InjectedBundle::setCustomPolicyDelegate):
(WTR::InjectedBundle::setVisibilityState):
(WTR::InjectedBundle::queueLoad):
(WTR::InjectedBundle::queueLoadHTMLString):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
(WTR::TestController::resetStateToConsistentValues):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::updateThreadedScrollingForCurrentTest):
(WTR::updateLayoutType):
(WTR::TestInvocation::invoke):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160811 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK][CMake] make libjavascriptcoregtk a public shared library again
https://bugs.webkit.org/show_bug.cgi?id=125512

Reviewed by Martin Robinson.

.:

* CMakeLists.txt: make JavaScriptCore always be a shared library for the GTK+ port.
* Source/cmake/WebKitHelpers.cmake: make -fvisibility=hidden not be applied for GTK+,
visibility of some symbols is required for threading to be initialized properly by
WebKit2 processes, and we will rely on a linker script that will be added later on,
for production builds.

Source/JavaScriptCore:

* CMakeLists.txt: use target type instead of SHARED_CORE to decide whether
JavaScriptCore is a shared library, since it's always shared for GTK+ regardless
of SHARED_CORE.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
MessageReceiverMap::addMessageReceiver should assert that destinationID is not zero
https://bugs.webkit.org/show_bug.cgi?id=125965

Reviewed by Tim Horton.

* Platform/CoreIPC/MessageReceiverMap.cpp:
(CoreIPC::MessageReceiverMap::addMessageReceiver):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Shapes] Simplify the BoxShape implementation
https://bugs.webkit.org/show_bug.cgi?id=125548

Reviewed by Andreas Kling.

Reduce BoxShape's footprint by about 2/3rds. Instead of caching the
FloatRoundedRects which represent a BoxShape's shape-padding and shape-margin
boundaries, compute them as needed.

No new tests, this is just an internal refactoring.

* rendering/shapes/BoxShape.cpp:
(WebCore::BoxShape::shapeMarginLogicalBoundingBox): Now just computes the bounding box rect.
(WebCore::BoxShape::shapePaddingLogicalBoundingBox): Ditto.
(WebCore::BoxShape::shapeMarginBounds): Removed the caching logic.
(WebCore::BoxShape::shapePaddingBounds): Ditto.
(WebCore::BoxShape::getExcludedIntervals): Use the computed margin bounds, instead of the cached one.
(WebCore::BoxShape::getIncludedIntervals): Ditto (padding bounds).
* rendering/shapes/BoxShape.h:
(WebCore::BoxShape::BoxShape): Simplified the constructor.
* rendering/shapes/Shape.cpp:
(WebCore::createBoxShape):
(WebCore::Shape::createShape):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed cmake build fix for GTK+.

Source/WebKit:

* PlatformGTK.cmake: add missing include directory.

Source/WebKit2:

* PlatformGTK.cmake: fix paths for files that were moved.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160816 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Don't waste cycles on zeroing every CascadedProperties::Property.
<https://webkit.org/b/125966>

The CascadedProperties constructor already zeroes out the whole
property array. Move the memset() to setDeferred() which is the only
other place we create a Property.

Brought to you by Instruments.app. Profile your code today!

Reviewed by Antti Koivisto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit2 View Gestures: Move WebProcess-side geometry collection into its own class
https://bugs.webkit.org/show_bug.cgi?id=125967

Reviewed by Anders Carlsson.

Move the messages dispatched by ViewGestureController that grab geometry
from the WebProcess out of the DrawingArea and into ViewGestureGeometryCollector.
This class will grow when smart magnification is implemented.

* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
* WebProcess/WebPage/DrawingArea.h:
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
Remove BeginTransientZoom() message.

* DerivedSources.make:
* UIProcess/DrawingAreaProxy.h:

* UIProcess/mac/ViewGestureController.cpp:
(WebKit::ViewGestureController::didCollectGeometryForMagnificationGesture):
(WebKit::ViewGestureController::handleMagnificationGesture):
* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureController.messages.in:
Make use of ViewGestureGeometryCollector and rename didBeginTransientZoom to didCollectGeometryForMagnificationGesture.

* WebKit2.xcodeproj/project.pbxproj:
Add new files.

* WebProcess/WebPage/ViewGestureGeometryCollector.cpp: Added.
(WebKit::ViewGestureGeometryCollector::ViewGestureGeometryCollector):
(WebKit::ViewGestureGeometryCollector::~ViewGestureGeometryCollector):
(WebKit::ViewGestureGeometryCollector::collectGeometryForMagnificationGesture):
* WebProcess/WebPage/ViewGestureGeometryCollector.h: Added.
* WebProcess/WebPage/ViewGestureGeometryCollector.messages.in: Added.
Move the code to collect the visible content rect and return it to the ViewGestureController into its own class.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
* WebProcess/WebPage/WebPage.h:
Move m_pageID to the top of WebPage's initialization list so that
it can be safely used from other members' constructors.

Add a ViewGestureGeometryCollector member and construct it.


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