Route main resource loads through the memory cache.
https://bugs.webkit.org/show_bug.cgi?id=49246

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Note that this patch doesn't actually enable caching of main resources. That will be done in a later patch.
The MainResourceLoader actually has an underlying SubresourceLoader (with the cache layer between them).
In several places, the MainResourceLoader's SubresourceLoader is treated as special.

No new tests, as this is primarily a refactor. A couple of expected results changed slightly.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::setRequest):
(WebCore::DocumentLoader::subresource):
(WebCore::DocumentLoader::addSubresourceLoader): Because the SubresourceLoader underlying the main resource
    needs special handling in certain cases, track it separately from the real SubresourceLoaders.
(WebCore::DocumentLoader::removeSubresourceLoader):
(WebCore::DocumentLoader::startLoadingMainResource):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::MainResourceLoader):
(WebCore::MainResourceLoader::receivedError):
(WebCore::MainResourceLoader::cancel):
(WebCore::MainResourceLoader::clearResource):
(WebCore):
(WebCore::MainResourceLoader::frameLoader):
(WebCore::MainResourceLoader::request):
(WebCore::MainResourceLoader::continueAfterNavigationPolicy):
(WebCore::MainResourceLoader::resourceData):
(WebCore::MainResourceLoader::redirectReceived):
(WebCore::MainResourceLoader::willSendRequest):
(WebCore::MainResourceLoader::continueAfterContentPolicy):
(WebCore::MainResourceLoader::responseReceived):
(WebCore::MainResourceLoader::dataReceived):
(WebCore::MainResourceLoader::didFinishLoading):
(WebCore::MainResourceLoader::notifyFinished):
(WebCore::MainResourceLoader::reportMemoryUsage):
(WebCore::MainResourceLoader::handleSubstituteDataLoadNow):
(WebCore::MainResourceLoader::load):
(WebCore::MainResourceLoader::setDefersLoading):
(WebCore::MainResourceLoader::defersLoading):
(WebCore::MainResourceLoader::setShouldBufferData):
(WebCore::MainResourceLoader::loader):
(WebCore::MainResourceLoader::identifier):
* loader/MainResourceLoader.h:
(MainResourceLoader):
(WebCore::MainResourceLoader::documentLoader):
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequest):
* loader/ResourceLoader.h:
(WebCore::ResourceLoader::defersLoading):
(WebCore::ResourceLoader::cancelled):
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::maybeLoadFallbackForMainResponse):
(WebCore::ApplicationCacheHost::maybeLoadFallbackForMainError):
* loader/mac/DocumentLoaderMac.cpp:
(WebCore::DocumentLoader::schedule):
(WebCore::DocumentLoader::unschedule):

LayoutTests:

* http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: The error code for loads cancelled
    by an embedder's willSendRequest() will show as standard load cancellations rather than as a content policy
    failure. This was an odd quirk of how MainResourceLoader::willSendRequest() was implemented (namely, doing a
    content policy check on ResourceRequests with empty urls).
* platform/chromium-linux/fast/replaced/border-radius-clip-content-edge-expected.png:
* platform/chromium/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: The error code for loads cancelled
    by an embedder's willSendRequest() will show as standard load cancellations rather than as a content policy
    failure. This was an odd quirk of how MainResourceLoader::willSendRequest() was implemented (namely, doing a
    content policy check on ResourceRequests with empty urls).


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137607 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Update chromium expectatins for fonts/monospace.html

* platform/chromium/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        <rdar://problem/12870065> Frequent NetworkProcess crashes due to null connection when closing tabs
        https://bugs.webkit.org/show_bug.cgi?id=104922

        Reviewed by Anders Carlsson.

        Don't zero out connection pointers when a connection closes. There doesn't appear
        to be any reason to do this.

        Tested by hitting breakpoints in all relevant objects destructors to confirm that
        this doesn't introduce leaks.

        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
        (WebKit::NetworkConnectionToWebProcess::~NetworkConnectionToWebProcess):
        (WebKit::NetworkConnectionToWebProcess::didClose):
        * NetworkProcess/NetworkResourceLoader.cpp:
        (WebKit::NetworkResourceLoader::connectionToWebProcessDidClose):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
build-webkit --chromium-android forces Make even when update-webkit used --ninja
https://bugs.webkit.org/show_bug.cgi?id=104839

Reviewed by Tony Chang.

This was recommended by Peter as part of:
https://bugs.webkit.org/show_bug.cgi?id=104434#c4
Fixing this makes build-webkit --chromium-android work for the common (ninja) case.

* Scripts/webkitdirs.pm:
(buildChromium):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] The WebKit2 bots are building and executing WebKit1 tests
https://bugs.webkit.org/show_bug.cgi?id=104690

Reviewed by Csaba Osztrogonác.

Pass --no-webkit1 option to the EFL WK2 bots when building. This
will disable WK1 API and thus, the WK1 API tests.

* BuildSlaveSupport/build.webkit.org-config/config.json:
* BuildSlaveSupport/build.webkit.org-config/master.cfg:
(CompileWebKit2Only):
(BuildAndTestFactory):
(BuildAndTestFactory.__init__):
(BuildAndTestWebKit2OnlyFactory):
Now bots using BuildAndTestWebKit2OnlyFactory (for instance only EFL) will
get --no-webkit1 as a parameter on the build-webkit script.
* Scripts/build-webkit:
Added support for -no-webkit1 for the Qt and EFL port.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove unused initiatingPage parameter from download objects
https://bugs.webkit.org/show_bug.cgi?id=104933

Reviewed by Alexey Proskuryakov.

* WebProcess/Downloads/Download.h:
(Download):
* WebProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
(WebKit::DownloadManager::convertHandleToDownload):
* WebProcess/Downloads/DownloadManager.h:
(DownloadManager):
* WebProcess/Downloads/cfnet/DownloadCFNet.cpp:
(WebKit::Download::start):
(WebKit::Download::startWithHandle):
* WebProcess/Downloads/curl/DownloadCurl.cpp:
(WebKit::Download::start):
(WebKit::Download::startWithHandle):
* WebProcess/Downloads/mac/DownloadMac.mm:
(WebKit::Download::start):
(WebKit::Download::startWithHandle):
* WebProcess/Downloads/qt/DownloadQt.cpp:
(WebKit::Download::start):
(WebKit::Download::startWithHandle):
* WebProcess/Downloads/soup/DownloadSoup.cpp:
(WebKit::Download::start):
(WebKit::Download::startWithHandle):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::startDownload):
(WebKit::WebFrame::convertHandleToDownload):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::downloadRequest):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137613 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] Add missing breaks in switch-case statements
https://bugs.webkit.org/show_bug.cgi?id=104929

Patch by Claudio Saavedra <csaavedra@igalia.com> on 2012-12-13
Reviewed by Martin Robinson.

* platform/gtk/ClipboardGtk.cpp:
(WebCore::ClipboardGtk::clearData): Add missing breaks.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137614 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Document will never be released when an Image is created inside unload event listener
https://bugs.webkit.org/show_bug.cgi?id=104830

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2012-12-13
Reviewed by Darin Adler.

When setting src attribute to an Image object inside unload event listener, ImageLoader will
mark it as load failure (by setting m_hasPendingErrorEvent to true) and the following call
to updatedHasPendingEvent will ref the element but won't be deref-ed since the Document is
being dismissed.  This was introduced in r131670.  To match pre r131670 behavior, we shouldn't
trigger error event for image loading when the page is being dismissed.

No new tests, there is no visual change.  Manually tested to verify documents are released by
using heap in Mac OS X.

* loader/ImageLoader.cpp:
(WebCore::pageIsBeingDismissed): add a helper function to test whether the page is being dismissed.
(WebCore::ImageLoader::updateFromElement): don't trigger error event if the page is being dismissed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Check whether a touchDown lands on a registered touch event handler from the compositor
https://bugs.webkit.org/show_bug.cgi?id=104863

Patch by Yusuf Ozuysal <yusufo@google.com> on 2012-12-13
Reviewed by James Robinson.

* src/WebCompositorInputHandlerImpl.cpp:
(WebKit::WebCompositorInputHandlerImpl::handleInputEventInternal):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] accessibiltiy/aria-hidden.html is failing
https://bugs.webkit.org/show_bug.cgi?id=98352

Patch by Joanmarie Diggs <jdiggs@igalia.com> on 2012-12-13
Reviewed by Martin Robinson.

The test is failing due to platform differences in the implementation of
AccessibilityUIElement::allAttributes(). This test does not require this
method as it is only looking at the AXTitle attribute.

* accessibility/aria-hidden-expected.txt: Included the actual reason for
passing/failing in the results output.
* accessibility/aria-hidden.html: Included the actual reason for passing/
failing in the results output.
* platform/gtk/TestExpectations: Unskipped the failing test.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
webkitpy: rename ResultSummary
https://bugs.webkit.org/show_bug.cgi?id=104871

Reviewed by Eric Seidel.

This patch changes the names of ResultSummary and related modules,
classes, and variables as a part of the larger clean up in bug 103824.

This change is basically a bunch of search and replaces:
- result_summary.py -> test_run_results.py
- class ResultSummary -> class TestRunResults
- "result_summary" or "rs" as a generic variable name -> "run_results",
  when it doesn't matter (or we don't know) if this refers to the
  initial pass over the tests or the retry pass.
- "result_summary" as a variable containing the results of the initial,
  complete test run -> "initial_results"
- "retry_summary" as a variable containing the results of retried
  results -> "retry_results"
- ResultSummary.results (the property) -> TestRunResults.results_by_name
- ResultSummary.failures (the property) -> TestRunResults.failures_by_name
- RunDetails.result_summary -> RunDetails.initial_results
- RunDetails.retry_summary -> RunDetails.retry_results

* Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
(LayoutTestRunner.__init__):
(LayoutTestRunner.run_tests):
(LayoutTestRunner._mark_interrupted_tests_as_skipped):
(LayoutTestRunner._interrupt_if_at_failure_limits):
(LayoutTestRunner._interrupt_if_at_failure_limits.interrupt_if_at_failure_limit):
(LayoutTestRunner._update_summary_with_result):
(LayoutTestRunner._handle_finished_test):
* Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py:
(FakePrinter.print_expected):
(LayoutTestRunnerTests.test_interrupt_if_at_failure_limits):
(LayoutTestRunnerTests.test_update_summary_with_result):
* Scripts/webkitpy/layout_tests/controllers/manager.py:
(RunDetails.__init__):
(summarize_results):
(Manager.run):
(Manager._look_for_new_crash_logs):
(Manager._tests_to_retry):
(Manager._upload_json_files):
(Manager._stats_trie):
* Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
(ManagerTest.test_look_for_new_crash_logs):
(SummarizeResultsTest):
(SummarizeResultsTest.get_run_results):
(SummarizeResultsTest.summarized_results):
* Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py:
(JSONLayoutResultsGenerator.__init__):
(JSONLayoutResultsGenerator._get_modifier_char):
(JSONLayoutResultsGenerator._insert_failure_summaries):
(JSONLayoutResultsGenerator._get_failure_summary_entry):
* Scripts/webkitpy/layout_tests/models/test_run_results.py: Renamed from Tools/Scripts/webkitpy/layout_tests/models/result_summary.py.
(TestRunResults):
(TestRunResults.__init__):
(TestRunResults.add):
* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(get_test_results):
(MainTest.test_basic):
* Scripts/webkitpy/layout_tests/views/buildbot_results.py:
(BuildBotPrinter.print_results):
(BuildBotPrinter.print_run_results):
(BuildBotPrinter._print_run_results_entry):
* Scripts/webkitpy/layout_tests/views/buildbot_results_unittest.py:
(BuildBotPrinterTests.get_run_results):
(BuildBotPrinterTests.test_print_unexpected_results.get_unexpected_results):
(BuildBotPrinterTests):
* Scripts/webkitpy/layout_tests/views/printing.py:
(Printer.print_expected):
(Printer._print_expected_results_of_type):
(Printer.print_results):
(Printer._print_timing_statistics):
(Printer._print_worker_statistics):
(Printer._print_aggregate_test_statistics):
(Printer._print_individual_test_times):
(Printer._print_directory_timings):
* Scripts/webkitpy/layout_tests/views/printing_unittest.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137621 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[chromium perf] DOM/DOMWalk.html failures
https://bugs.webkit.org/show_bug.cgi?id=104866

Reviewed by Eric Seidel.

Use PerfTestRunner.now which in turn uses window.performance.now() when it's available.

* DOM/resources/dom-perf.js:
(Interval.start):
(Interval.stop):
(BenchmarkSuite.prototype.RunSingle):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137623 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Allow plugins to be disabled by shared library filename
https://bugs.webkit.org/show_bug.cgi?id=101274

Patch by Parth Patel  <parpatel@rim.com>, Max Feil <mfeil@rim.com> on 2012-12-13
Reviewed by Antonio Gomes.

Source/WebCore:

This fix makes PluginDatabase changes general so that other ports
can use this mechanism if they wish.

Layout test not included with this patch because there
is currently no framework within LayoutTests to allow calls
from an external application via platform API code (such as the
WebView API).

* plugins/PluginDatabase.cpp:
(WebCore::PluginDatabase::fileExistsAndIsNotDisabled):
(WebCore):
(WebCore::PluginDatabase::getDeletedPlugins):
(WebCore::PluginDatabase::removeDisabledPluginFile):
(WebCore::PluginDatabase::addDisabledPluginFile):
(WebCore::PluginDatabase::getPluginPathsInDirectories):
* plugins/PluginDatabase.h:
(PluginDatabase):

Source/WebKit/blackberry:

Mechanism allows plugins to be disabled by specifying their shared library filenames.
Once disabled, a plugin's shared library should never be loaded.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::setExtraPluginDirectory):
(WebKit):
(BlackBerry::WebKit::WebPage::updateDisabledPluginFiles):
* Api/WebPage.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
.: Added manual test for canvas setFont speed.
https://bugs.webkit.org/show_bug.cgi?id=104923

Reviewed by James Robinson.

* ManualTests/canvas-font-speed.html: Added.

Source/WebCore: CanvasRenderingContext2D::setFont() is slow.
https://bugs.webkit.org/show_bug.cgi?id=104923

Reviewed by James Robinson.

This spends most of its time in the CSS parser.  As a first step,
early-out if the new value is the same as unparsed string for the current font.
See also http://code.google.com/p/chromium/issues/detail?id=164016.

Covered by existing tests in canvas/ and fast/canvas, and ManualTests/canvas-font-speed.html.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        ResourceLoader::didReceiveAuthenticationChallenge uses a wrong client
        https://bugs.webkit.org/show_bug.cgi?id=104935
        <rdar://problem/12870361>

        Reviewed by Anders Carlsson.

        * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::didReceiveAuthenticationChallenge):
        The handle is null when NetworkProcess is used. In any case, it should be correct
        to use the client carried within AuthenticationChallenge.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137631 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Heap-use-after-free in WebCore::RenderBlock::finishDelayUpdateScrollInfo
https://bugs.webkit.org/show_bug.cgi?id=103750

Reviewed by Tony Chang.

Source/WebCore:

MathML sometimes creates and destroys renderers for descendants during layout (or even to calculate
preferred logical widths), e.g. for operator stretching. RenderBlock::finishDelayUpdateScrollInfo
must therefore leave gDelayedUpdateScrollInfoSet intact as it iterates over it, so
RenderBlock::willBeDestroyed can call gDelayedUpdateScrollInfoSet->remove(this) effectively if needed.
This also prevents duplicate entries from being added to gDelayedUpdateScrollInfoSet.

Test: mathml/mo-stretch-crash.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::startDelayUpdateScrollInfo):
    - Allow gDelayedUpdateScrollInfoSet to be non-null when gDelayUpdateScrollInfo is 0 during
      RenderBlock::finishDelayUpdateScrollInfo.
(WebCore::RenderBlock::finishDelayUpdateScrollInfo):
    - Remove blocks from gDelayedUpdateScrollInfoSet one at a time, waiting for each block until it is
      about to be updated.

LayoutTests:

* mathml/mo-stretch-crash-expected.txt: Added.
* mathml/mo-stretch-crash.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] Safeguard against possible NULL-dereference
https://bugs.webkit.org/show_bug.cgi?id=104931

Patch by Claudio Saavedra <csaavedra@igalia.com> on 2012-12-13
Reviewed by Chris Fleizach.

This was spotted by Coverity. See bug 104114.

* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetIndexInParent): If parent is NULL
bail out early.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix a mis-named variable after r137621.
https://bugs.webkit.org/show_bug.cgi?id=104871

Unreviewed, build fix.

* Scripts/webkitpy/layout_tests/views/buildbot_results.py:
(BuildBotPrinter.print_results):
* Scripts/webkitpy/layout_tests/views/buildbot_results_unittest.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
IndexedDB: Improve error messages
https://bugs.webkit.org/show_bug.cgi?id=104624

Reviewed by Tony Chang.

Source/WebCore:

Add detail to error messages so that they are more helpful and can be
traced back to a specific line of code.

Updated test: transaction-error.html

* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(WebCore::IDBDatabaseBackendImpl::CreateObjectStoreOperation::perform):
(WebCore::IDBDatabaseBackendImpl::DeleteObjectStoreOperation::perform):
(WebCore::IDBDatabaseBackendImpl::VersionChangeOperation::perform):
(WebCore::IDBDatabaseBackendImpl::openConnection):
(WebCore::IDBDatabaseBackendImpl::openConnectionWithVersion):
(WebCore::IDBDatabaseBackendImpl::deleteDatabase):
(WebCore::IDBDatabaseBackendImpl::close):
* Modules/indexeddb/IDBFactoryBackendImpl.cpp:
(WebCore::IDBFactoryBackendImpl::getDatabaseNames):
(WebCore::IDBFactoryBackendImpl::deleteDatabase):
(WebCore::IDBFactoryBackendImpl::open):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
(WebCore::IDBObjectStoreBackendImpl::createIndex):
(WebCore::IDBObjectStoreBackendImpl::CreateIndexOperation::perform):
* Modules/indexeddb/IDBTransactionBackendImpl.cpp:
(WebCore::IDBTransactionBackendImpl::abort):
(WebCore::IDBTransactionBackendImpl::commit):

LayoutTests:

Updated error message and establish that non-ascii characters in index
names don't make it back to the browser properly.

* storage/indexeddb/resources/shared.js:
(unexpectedAbortCallback):
* storage/indexeddb/resources/transaction-error.js:
(testErrorFromCommit.trans.oncomplete.request.onupgradeneeded.trans.onabort):
(testErrorFromCommit.trans.oncomplete.request.onupgradeneeded):
(testErrorFromCommit.trans.oncomplete):
(testErrorFromCommit):
* storage/indexeddb/transaction-error-expected.txt:
* storage/indexeddb/transaction-error.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137635 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Download objects should keep track of their associated DownloadManager object
https://bugs.webkit.org/show_bug.cgi?id=104936

Reviewed by Andreas Kling.

This is the first step towards eliminating DownloadManager::shared.

* WebProcess/Downloads/Download.cpp:
(WebKit::Download::create):
(WebKit::Download::Download):
(WebKit::Download::didFinish):
(WebKit::Download::didFail):
(WebKit::Download::didCancel):
* WebProcess/Downloads/Download.h:
* WebProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
(WebKit::DownloadManager::convertHandleToDownload):

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