[WebKit2] Create an API for adding and removing user stylesheets from a page group
https://bugs.webkit.org/show_bug.cgi?id=98432

Reviewed by Sam Weinig.

Source/WebKit2:

This patch adds the following API to WKBrowsingContextGroup:

- (void)addUserStyleSheet:(NSString *)source baseURL:(NSURL *)baseURL whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist mainFrameOnly:(BOOL)mainFrameOnly;
- (void)removeAllUserStyleSheets;

Sheets added via this API are sent to all processes that contain a page
in the given page group. Sheets are also cached in the UI process in a
new object called UserContentContainer, which is a property of each
group's WebPageGroupData and is sent to new web processes during page
initialization.

This is less than ideal, since new pages added to a pre-existing
process / page group combination will send redundant user stylesheet
strings over the wire. To avoid this we'd have to keep track track of
the groups that currently exist in each process and only send user
content during page creation if it is the first time a process has seen
the page's group. I decided to not add this complexity for the time
being, but we might need to consider it if we find that the current
approach impacts performance for clients that heavily utilize user
content.

* Shared/API/c/WKArray.cpp:
(WKArrayCreateAdoptingValues): Add a WKArray creation function that
adopts the incoming WKTypeRefs rather than refing them.
* Shared/API/c/WKArray.h:
* Shared/API/c/WKBase.h: Move WKUserContentInjectedFrames out of
WKBundlePrivate.h so it can be used in WKPageGroup, too.
* Shared/API/c/cf/WKURLCF.cpp:
(WKURLCreateWithCFURL): Return 0 for null CFURLRefs instead of crashing
inside CFURLGetString().
* Shared/ImmutableArray.cpp:
(WebKit::ImmutableArray::ImmutableArray): Add a tag to differentiate
between the adopting and refing ctors.
* Shared/ImmutableArray.h:
(WebKit::ImmutableArray::create): Call the refing ctor.
(WebKit::ImmutableArray::adopt): Call the adopting ctor.
* Shared/UserContentContainer.cpp: Added.
(UserContentItemMessageEncoder): Create a UserMessageEncoder for
serializing UserContentContainer::Item's APIObjects.
(WebKit::UserContentItemMessageEncoder::UserContentItemMessageEncoder):
(WebKit::UserContentItemMessageEncoder::encode):
(UserContentItemMessageDecoder): Create a UserMessageEncoder for
deserializing UserContentContainer::Item's APIObjects.
(WebKit::UserContentItemMessageDecoder::UserContentItemMessageDecoder):
(WebKit::UserContentItemMessageDecoder::decode):
(WebKit::UserContentContainer::Item::Item):
(WebKit::encodeStringArray): Add a helper function for encoding
ImmutableArrays of WebStrings.
(WebKit::UserContentContainer::Item::encode): Encode the item's
properties using UserContentItemMessageEncoder.
(WebKit::decodeStringArray): Add a helper function for decoding
ImmutableArrays of WebStrings.
(WebKit::UserContentContainer::Item::decode): Decode the item's
properties using UserContentItemMessageDecoder.
(WebKit::toStringVector): Add a helper function for converting an
ImmutableArray of WebStrings to a Vector of Strings.
(WebKit::UserContentContainer::Item::whitelist): Use toStringVector().
(WebKit::UserContentContainer::Item::blacklist): Ditto.
(WebKit::UserContentContainer::encode): Encode the Vector of UserContentContainer::Items.
(WebKit::UserContentContainer::decode): Decode the Vector of UserContentContainer::Items.
* Shared/UserContentContainer.h: Added.
* Shared/WebPageGroupData.cpp:
(WebKit::WebPageGroupData::encode): Include userStyleSheets when encoding.
(WebKit::WebPageGroupData::decode): Include userStyleSheets when decoding.
* Shared/WebPageGroupData.h:
(WebPageGroupData): Add a UserContentContainer called userStyleSheets
to WebPageGroupData.
* UIProcess/API/C/WKPageGroup.cpp: Add the C SPI version of the Objective-C API.
(WKPageGroupAddUserStyleSheet):
(WKPageGroupRemoveAllUserStyleSheets):
* UIProcess/API/C/WKPageGroup.h:
* UIProcess/API/mac/WKBrowsingContextGroup.h: Add the Objective-C API.
* UIProcess/API/mac/WKBrowsingContextGroup.mm:
(createWKArray): Add a helper function that converts an NSArray of NSStrings to a WKArray of WKStrings.
(-[WKBrowsingContextGroup addUserStyleSheet:baseURL:whitelist:blacklist:mainFrameOnly:]):
Implement the Objective-C API in terms of the C SPI.
(-[WKBrowsingContextGroup removeAllUserStyleSheets]): Ditto.
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::addUserStyleSheet): Add the new sheet to the
group's WebPageGroupData, which ensures that the group's sheets are
sent to new web processes.
(WebKit::WebPageGroup::removeAllUserStyleSheets): Ditto for removal.
* UIProcess/WebPageGroup.h:
(WebKit::WebPageGroup::sendToAllProcessesInGroup): Add a helper message
that sends a message to all processes that have a page in the current
group. This is used to add new user sheets to already-initialized page
groups in the UI processes.
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: Moved
WKUserContentInjectedFrames from here to WKBase.h.
* WebProcess/WebPage/WebPageGroupProxy.cpp:
(WebKit::WebPageGroupProxy::WebPageGroupProxy): Add each sheet in the
WebPageGroupData to WebCore's page group.
(WebKit::WebPageGroupProxy::addUserStyleSheet): Add the sheet received
from the UI process to WebCore's page group.
(WebKit::WebPageGroupProxy::removeAllUserStyleSheets): Remove all
sheets from WebCore's page group.
* WebProcess/WebPage/WebPageGroupProxy.h:
* WebProcess/WebPage/WebPageGroupProxy.messages.in: Define
AddUserStyleSheet and RemoveAllUserStyleSheets, two messages sent from
the UI process to a web process's WebPageGroupProxy.

Tools:

Add three new API tests:

- Test adding a user stylesheet before a page is created. This tests
the code path where the sheet is sent to the web process as part of
the new page's WebPageCreationParameters.
- Test adding a user stylesheet after a page is created. This tests the
code patch where the sheet is sent as a separate message to all
processes containing the given page group.
- Test removing all user stylesheets.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2ObjC/UserContentTest.mm: Added.
(-[UserContentTestLoadDelegate initWithBlockToRunOnLoad:]):
(-[UserContentTestLoadDelegate browsingContextControllerDidFinishLoad:]):
(expectScriptValue):
* TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextGroupTest.mm:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130948 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, speculative build fix for Qt Win.

* css/makegrammar.pl: Rather than making a temp file, use a pipe to
pass data from gcc to the final output file.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Turn on ENABLE_MATHML for Chromium
https://bugs.webkit.org/show_bug.cgi?id=96960

Reviewed by Adam Barth.

Source/WebCore: 

Add the rendering/mathml directory to search.

* WebCore.gyp/WebCore.gyp:

Source/WebKit/chromium: 

* features.gypi:

LayoutTests: 

We're enabling MathML now partly to let the automated fuzzers go to work. Some layout tuning will also be done in the
next few days, so we expect MathML pixel tests to be changing during that time.

* platform/chromium/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130950 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add a note that this test is flaky and can trigger an ASSERT.

* platform/chromium/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130954 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, another speculative fix for Qt Win.

* DerivedSources.pri: Make the path slash marks be forward slashes to the .in file.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Pageload tests should measure memory usage
https://bugs.webkit.org/show_bug.cgi?id=93958

Reviewed by Ryosuke Niwa.

Add JS Heap and Heap memory measurement to PageLoad tests.

Source/JavaScriptCore:

* heap/HeapStatistics.cpp:
(JSC::HeapStatistics::usedJSHeap): Add new private function to expose the used JS Heap size.
(JSC):
* heap/HeapStatistics.h:
(HeapStatistics): Add new private function to expose the used JS Heap size.

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(dump): Print memory results with DRT.
* Scripts/old-run-webkit-tests:
(readFromDumpToolWithTimer): Hadle memory results.
* Scripts/webkitpy/layout_tests/port/driver.py:
(DriverOutput.__init__): Add new parameter for the results.
(Driver.__init__): Initialize the new parameter.
(Driver.run_test):
(Driver._read_first_block): Add support for the new headers.
(Driver._process_stdout_line):
(ContentBlock.__init__):
* Scripts/webkitpy/performance_tests/perftest.py:
(PageLoadingPerfTest.calculate_statistics): Move statistics calculation into a function.
(PageLoadingPerfTest.run): Handle the new memory results.
(PageLoadingPerfTest.run.in):
(PageLoadingPerfTest):
* Scripts/webkitpy/performance_tests/perftest_unittest.py: Add test for memory results of pageloadtests.
(TestPageLoadingPerfTest.MockDriver.__init__):
(TestPageLoadingPerfTest.MockDriver.run_test):
(TestPageLoadingPerfTest.test_run_with_memory_output):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, another speculative fix for Qt Win.

* DerivedSources.pri: Pass --preprocessor to the perl script.
* css/makegrammar.pl: Use --preprocessor instead of /usr/bin/gcc.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130957 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Adding myself as Committer.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Skip the color-correction tests.

Just specifying `Missing' makes the build bots sometimes report
these tests as failing.

* platform/efl/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Adapt to new image for search-cancel
https://bugs.webkit.org/show_bug.cgi?id=98954

Reviewed by Antonio Gomes.

The new image for search-cancel is bigger than the old one, so invert the scaling.

* platform/blackberry/RenderThemeBlackBerry.cpp:
(WebCore::RenderThemeBlackBerry::adjustSearchFieldCancelButtonStyle):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
When we check in image baselines, we use the -expected.png suffix
rather than the -actual.png suffix. (This is likely a typo in
http://trac.webkit.org/changeset/130940.)

* platform/chromium-win/editing/spelling/inline-spelling-markers-hidpi-actual.png: Removed.
* platform/chromium-win/editing/spelling/inline-spelling-markers-hidpi-expected.png: Copied from LayoutTests/platform/chromium-win/editing/spelling/inline-spelling-markers-hidpi-actual.png.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130961 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r130937, r130949, r130955, and
r130957.
http://trac.webkit.org/changeset/130937
http://trac.webkit.org/changeset/130949
http://trac.webkit.org/changeset/130955
http://trac.webkit.org/changeset/130957
https://bugs.webkit.org/show_bug.cgi?id=94290

Breaks Qt build

.:

* Source/cmake/WebKitMacros.cmake:

Source/WebCore:

* CMakeLists.txt:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.am:
* WebCore.gyp/WebCore.gyp:
* WebCore.gyp/scripts/action_preprocessgrammar.py: Removed.
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSGrammar.y: Renamed from Source/WebCore/css/CSSGrammar.y.in.
* css/CSSGrammar.y.includes: Removed.
* css/makegrammar.pl:

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

* platform/chromium-linux/fast/repaint/reflection-repaint-test-expected.png:
* platform/chromium-linux/fast/repaint/transform-layout-repaint-expected.png:
* platform/chromium-mac/fast/repaint/reflection-repaint-test-expected.png: Added.
* platform/chromium-mac/fast/repaint/transform-layout-repaint-expected.png: Added.
* platform/chromium-win/fast/repaint/reflection-repaint-test-expected.png:
* platform/chromium-win/fast/repaint/transform-layout-repaint-expected.png:
The flakiness dashboard was lying on this entry. After talking with Emil, the baselines are correct so
rebaselined these tests.

* platform/chromium/TestExpectations:
Marked fast/dom/gc-dom-tree-lifetime.html as timeout as marking it slow didn't remove the flakiness.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
This test can also fail with TEXT.

* platform/chromium/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130965 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Use the shareable GraphicsContext3DOpenGL* implementation.
https://bugs.webkit.org/show_bug.cgi?id=96627

Patch by Regina Chung <heejin.r.chung@samsung.com> on 2012-10-10
Reviewed by Kenneth Rohde Christiansen.

Changed EFL implementation of GraphicsContext3D(GC3D) to use GraphicsContext3DOpenGL*.
It was initially implemented in a different way, due to characteristics of Evas,
but it would be better to use the common implementation and find another way
to deal with Evas, especially because all the duplicated code.

No new tests. No functional changes.

* PlatformEfl.cmake: Removed cairo implementation of GC3D and added efl files to WebCore_SOURCES.
* platform/graphics/efl/GraphicsContext3DEfl.cpp: Modified code so GC3DOpenGL* can be used.
(WebCore::GraphicsContext3D::create):
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::platformLayer):
(WebCore::GraphicsContext3D::makeContextCurrent):
(WebCore::GraphicsContext3D::setContextLostCallback):
(WebCore::GraphicsContext3D::setErrorMessageCallback):
(WebCore::GraphicsContext3D::paintToCanvas):
(WebCore):
(WebCore::GraphicsContext3D::createGraphicsSurfaces):
(WebCore::GraphicsContext3D::releaseShaderCompiler):
(WebCore::GraphicsContext3D::getImageData):
* platform/graphics/efl/GraphicsContext3DPrivate.cpp: Removed functions implemented in GC3DOpenGL*
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore):
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::createSurface):
(WebCore::GraphicsContext3DPrivate::platformGraphicsContext3D):
(WebCore::GraphicsContext3DPrivate::makeContextCurrent):
(WebCore::GraphicsContext3DPrivate::isGLES2Compliant):
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
* platform/graphics/efl/GraphicsContext3DPrivate.h: Removed functions implemented in GC3DOpenGL*
(GraphicsContext3DPrivate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130966 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WK2][WTR] WebKitTestRunner UI process should be aware of Custom Policy Delegate
https://bugs.webkit.org/show_bug.cgi?id=95974

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-10-10
Reviewed by Kenneth Rohde Christiansen.

Tools:

Added TestController::decidePolicyForNavigationAction() function as a 'decidePolicyForNavigationAction' WKPagePolicyClient callback
for WTR UI process. WTR bundle client notifies UI process about Custom Policy Delegate via newly added message,
so that TestController is aware of whether Custom Policy Delegate as enabled and
permissive. This data is used then in TestController::decidePolicyForNavigationAction for making policy decision.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setCustomPolicyDelegate):
(WTR):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setCustomPolicyDelegate):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::initialize):
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::setCustomPolicyDelegate):
(WTR):
(WTR::TestController::decidePolicyForNavigationAction):
* WebKitTestRunner/TestController.h:
(TestController):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

Unskipped fast/loader/onload-policy-ignore-for-frame.html for WK2.

* platform/wk2/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130967 268f45cc-cd09-0410-ab3c-d52691b4dbfc
FontVerticalDataCache should allow zero as a key value
https://bugs.webkit.org/show_bug.cgi?id=98877

Reviewed by Tony Chang.

Use WTF::UnsignedWithZeroKeyHashTraits for type definition of
FontVerticalDataCache.

No new tests because there is no certain way to make
FontPlatformDataHarfBuzz::uniqueID() be zero.

* platform/graphics/FontCache.cpp:
(WebCore):
* platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp:
(WebCore::FontPlatformData::verticalData): Removed zero check of uniqueID().
(WebCore::FontPlatformData::openTypeTable): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130968 268f45cc-cd09-0410-ab3c-d52691b4dbfc
More unreviewed Chromium gardening.

* platform/chromium/TestExpectations:
Removed 11 more entries that have not failed in last 100 runs according to the flakiness dashboard.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130969 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Speculative build fix for Snow Leopard after r130948.

* TestWebKitAPI/Tests/WebKit2ObjC/UserContentTest.mm: Pull the
declaration of backgroundColorQuery out of a block to appease GCC.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130970 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add skeleton of a WebKit2 ObjC DOM SPI (not intended to be the full DOM)
https://bugs.webkit.org/show_bug.cgi?id=98955

Reviewed by Anders Carlsson.

Add a skeleton DOM implementation only exposing Node, Element and Document
for now. It is currently only available in 64-bit as it relies on the non-fragile
ABI for now.

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/mac/WKDOMDocument.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMElement.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMElement.mm: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMNode.h: Added.
* WebProcess/InjectedBundle/API/mac/WKDOMNode.mm: Added.


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