Source/WebCore: Correctly set XHR loadend attributes (loaded and total).
https://bugs.webkit.org/show_bug.cgi?id=120828

Patch by Youenn Fablet <youennf@gmail.com> on 2014-01-08
Reviewed by Alexey Proskuryakov.

Added correct initialization of lengthComputable, loaded and total attributes
to XHR ProgressEvent events (load, loadstart, loadend, abort, error and timeout).

XMLHttpRequestProgressEventThrottle and XMLHttpRequestUpload now keep persistent knowledge
of m_loaded and m_total values with this patch.

Code refactoring to handle event dispatching in case of error in a single manner.
XMLHttpRequestProgressEventThrottle::dispatchProgressEvent is renamed as dispatchThrottledProgressEvent
XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadend is replaced by dispatchProgressEvent(const AtomicString&)

Tests: http/tests/xmlhttprequest/loadstart-event-init.html
       http/tests/xmlhttprequest/onabort-progressevent-attributes.html
       http/tests/xmlhttprequest/onload-progressevent-attributes.html
       http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html
       http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::callReadyStateChangeListener): changed readystatechange event from ProgressEvent to Event (not cancellable, not bubblable) to better match the spec
(WebCore::XMLHttpRequest::createRequest):
(WebCore::XMLHttpRequest::abort): code refactoring to handle error event dispatching in a single way
(WebCore::XMLHttpRequest::networkError): code refactoring to handle error event dispatching in a single way
(WebCore::XMLHttpRequest::abortError): code refactoring to handle error event dispatching in a single way
(WebCore::XMLHttpRequest::didSendData):
(WebCore::XMLHttpRequest::didReceiveData):
(WebCore::XMLHttpRequest::dispatchErrorEvents): dispatch progress events in case of error
(WebCore::XMLHttpRequest::didTimeout): code refactoring to handle error event dispatching in a single way
* xml/XMLHttpRequest.h:
* xml/XMLHttpRequestProgressEventThrottle.cpp: before the patch, the fact that a progress event is being throttled is stored indirectly (m_loaded or m_total not equal to zero). With the patch, this information is stored in m_hasThrottledProgressEvent. The m_loaded and m_total values are no longer set back to zero after a progress event is dispatched. This allows using these values to correctly initialize other ProgressEvent events (in particular loadend, abort, timeout...)
(WebCore::XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle):
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent): always update the new m_loaded and m_total values. If progress event is not sent as part of the function call, store the fact that a progress event is being throttled through m_hasThrottledProgressEvent.
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent): used to send any ProgressEvent event that is not be throttled
(WebCore::XMLHttpRequestProgressEventThrottle::flushProgressEvent): after the call, no progress event is throttled anymore
(WebCore::XMLHttpRequestProgressEventThrottle::fired): after the call, no progress event is throttled anymore
(WebCore::XMLHttpRequestProgressEventThrottle::hasEventToDispatch):
(WebCore::XMLHttpRequestProgressEventThrottle::suspend):
* xml/XMLHttpRequestProgressEventThrottle.h: introduced m_hasThrottledProgressEvent which stores whether a progress event is being throttled and m_computableLength which is used to initialize ProgressEvent computableLength
* xml/XMLHttpRequestUpload.cpp:
(WebCore::XMLHttpRequestUpload::XMLHttpRequestUpload):
(WebCore::XMLHttpRequestUpload::dispatchProgressEvent):
* xml/XMLHttpRequestUpload.h: introduced m_loaded, m_total and m_lengthComputable, similarly to XMLHttpRequestProgressEventThrottle

LayoutTests: Correctly set XHR loadend event attributes (loaded and total).
https://bugs.webkit.org/show_bug.cgi?id=120828

Patch by Youenn Fablet <youennf@gmail.com> on 2014-01-08
Reviewed by Alexey Proskuryakov.

Tests for abort, load, loadstart and loadend ProgressEvent events for XMLHttpRequest and XMLHttpRequestUpload

* fast/xmlhttprequest/xmlhttprequest-get-expected.txt: Changed to correct event values
* http/tests/xmlhttprequest/loadstart-event-init-expected.txt: Added.
* http/tests/xmlhttprequest/loadstart-event-init.html: Added.
* http/tests/xmlhttprequest/onabort-progressevent-attributes-expected.txt: Added.
* http/tests/xmlhttprequest/onabort-progressevent-attributes.html: Added.
* http/tests/xmlhttprequest/onload-progressevent-attributes-expected.txt: Added.
* http/tests/xmlhttprequest/onload-progressevent-attributes.html: Added.
* http/tests/xmlhttprequest/upload-onabort-progressevent-attributes-expected.txt: Added.
* http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html: Added.
* http/tests/xmlhttprequest/upload-onload-progressevent-attributes-expected.txt: Added.
* http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make WK2 build when ENABLE(ASYNC_SCROLLING) is not defined
https://bugs.webkit.org/show_bug.cgi?id=126675

Reviewed by Tim Horton.

We need a stub RemoteScrollingCoordinatorTransaction outside
the #ifdef so that RemoteLayerTreeDrawingAreaProxy messages
work.

* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
(WebKit::RemoteScrollingCoordinatorTransaction::encode):
(WebKit::RemoteScrollingCoordinatorTransaction::decode):
* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: Remove InspectorClient::captureScreenshot()
https://bugs.webkit.org/show_bug.cgi?id=126616

Reviewed by Joseph Pecoraro.

No new tests, No change in behavior.

Remove leftover mothod as Page.captureScreenshot API was removed in r160202.

* inspector/InspectorClient.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Missleading style error when mixing system and non-system header include lines.
https://bugs.webkit.org/show_bug.cgi?id=126564

Patch by Gergo Balogh <geryxyz@inf.u-szeged.hu> on 2014-01-08
Reviewed by Ryosuke Niwa.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_include_line):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(OrderOfIncludesTest.test_check_alphabetical_include_order):
(OrderOfIncludesTest.test_public_primary_header):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] Add xdg.origin.url extended attribute to downloads
https://bugs.webkit.org/show_bug.cgi?id=126638

Reviewed by Carlos Garcia Campos.

This is proposed by fdo in
http://www.freedesktop.org/wiki/CommonExtendedAttributes/

Source/WebKit/gtk:

* webkit/webkitdownload.cpp:
(webkit_download_open_stream_for_uri):

Source/WebKit2:

* Shared/Downloads/soup/DownloadSoup.cpp:
(WebKit::DownloadClient::didReceiveResponse):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161536 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Clean up confusing names and calculations in image-dragging functions
https://bugs.webkit.org/show_bug.cgi?id=126661

Reviewed by Timothy Hatcher.

No new tests.

* page/DragController.cpp:
(WebCore::DragController::doImageDrag): rename variables and
simplify the calculation of the image's scaled origin.

* platform/DragImage.cpp:
(WebCore::fitDragImageToMaxSize): rename variables.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161537 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[JS] Should be able to create a promise by calling the Promise constructor as a function
https://bugs.webkit.org/show_bug.cgi?id=126561

Patch by Sam Weinig <sam@webkit.org> on 2014-01-08
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

* runtime/JSPromiseConstructor.cpp:
(JSC::JSPromiseConstructor::getCallData):
Add support for calling the Promise constructor as a function (e.g. var p = Promise(...), note
the missing "new").

LayoutTests:

* js/dom/Promise-types-expected.txt:
* js/dom/Promise-types.html:
Add test for using calling a Promise constructor as a function.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161538 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed EFL gardening. Rebaseline after r161521.

* platform/efl/css1/text_properties/letter_spacing-expected.png:
* platform/efl/css1/text_properties/letter_spacing-expected.txt:
* platform/efl/css1/text_properties/word_spacing-expected.png:
* platform/efl/css1/text_properties/word_spacing-expected.txt:
* platform/efl/fast/text/basic/013-expected.png:
* platform/efl/fast/text/basic/013-expected.txt:
* platform/efl/fast/text/text-letter-spacing-expected.txt:
* platform/efl/svg/W3C-SVG-1.1/text-spacing-01-b-expected.png:
* platform/efl/svg/W3C-SVG-1.1/text-spacing-01-b-expected.txt: Added.
* platform/efl/svg/batik/text/textLayout-expected.txt: Added.
* platform/efl/svg/custom/text-letter-spacing-expected.png: Added.
* platform/efl/svg/custom/text-letter-spacing-expected.txt: Added.
* platform/efl/svg/text/text-spacing-01-b-expected.png:
* platform/efl/svg/text/text-spacing-01-b-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Marking should be generational
https://bugs.webkit.org/show_bug.cgi?id=126552

Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

Re-marking the same objects over and over is a waste of effort. This patch implements 
the sticky mark bit algorithm (along with our already-present write barriers) to reduce 
overhead during garbage collection caused by rescanning objects.

There are now two collection modes, EdenCollection and FullCollection. EdenCollections
only visit new objects or objects that were added to the remembered set by a write barrier.
FullCollections are normal collections that visit all objects regardless of their 
generation.

In this patch EdenCollections do not do anything in CopiedSpace. This will be fixed in 
https://bugs.webkit.org/show_bug.cgi?id=126555.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::visitAggregate):
* bytecode/CodeBlock.h:
(JSC::CodeBlockSet::mark):
* dfg/DFGOperations.cpp:
* heap/CodeBlockSet.cpp:
(JSC::CodeBlockSet::add):
(JSC::CodeBlockSet::traceMarked):
(JSC::CodeBlockSet::rememberCurrentlyExecutingCodeBlocks):
* heap/CodeBlockSet.h:
* heap/CopiedBlockInlines.h:
(JSC::CopiedBlock::reportLiveBytes):
* heap/CopiedSpace.cpp:
(JSC::CopiedSpace::didStartFullCollection):
* heap/CopiedSpace.h:
(JSC::CopiedSpace::heap):
* heap/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::didAbandon):
(JSC::Heap::markRoots):
(JSC::Heap::copyBackingStores):
(JSC::Heap::addToRememberedSet):
(JSC::Heap::collectAllGarbage):
(JSC::Heap::collect):
(JSC::Heap::didAllocate):
(JSC::Heap::writeBarrier):
* heap/Heap.h:
(JSC::Heap::isInRememberedSet):
(JSC::Heap::operationInProgress):
(JSC::Heap::shouldCollect):
(JSC::Heap::isCollecting):
(JSC::Heap::isWriteBarrierEnabled):
(JSC::Heap::writeBarrier):
* heap/HeapOperation.h:
* heap/MarkStack.cpp:
(JSC::MarkStackArray::~MarkStackArray):
(JSC::MarkStackArray::clear):
(JSC::MarkStackArray::fillVector):
* heap/MarkStack.h:
* heap/MarkedAllocator.cpp:
(JSC::isListPagedOut):
(JSC::MarkedAllocator::isPagedOut):
(JSC::MarkedAllocator::tryAllocateHelper):
(JSC::MarkedAllocator::addBlock):
(JSC::MarkedAllocator::removeBlock):
(JSC::MarkedAllocator::reset):
* heap/MarkedAllocator.h:
(JSC::MarkedAllocator::MarkedAllocator):
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::clearMarks):
(JSC::MarkedBlock::clearRememberedSet):
(JSC::MarkedBlock::clearMarksWithCollectionType):
(JSC::MarkedBlock::lastChanceToFinalize):
* heap/MarkedBlock.h: Changed atomSize to 16 bytes because we have no objects smaller
than 16 bytes. This is also to pay for the additional Bitmap for the remembered set.
(JSC::MarkedBlock::didConsumeEmptyFreeList):
(JSC::MarkedBlock::setRemembered):
(JSC::MarkedBlock::clearRemembered):
(JSC::MarkedBlock::atomicClearRemembered):
(JSC::MarkedBlock::isRemembered):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::~MarkedSpace):
(JSC::MarkedSpace::resetAllocators):
(JSC::MarkedSpace::visitWeakSets):
(JSC::MarkedSpace::reapWeakSets):
(JSC::VerifyMarked::operator()):
(JSC::MarkedSpace::clearMarks):
* heap/MarkedSpace.h:
(JSC::ClearMarks::operator()):
(JSC::ClearRememberedSet::operator()):
(JSC::MarkedSpace::didAllocateInBlock):
(JSC::MarkedSpace::clearRememberedSet):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::~SlotVisitor):
(JSC::SlotVisitor::clearMarkStack):
* heap/SlotVisitor.h:
(JSC::SlotVisitor::markStack):
(JSC::SlotVisitor::sharedData):
* heap/SlotVisitorInlines.h:
(JSC::SlotVisitor::internalAppend):
(JSC::SlotVisitor::unconditionallyAppend):
(JSC::SlotVisitor::copyLater):
(JSC::SlotVisitor::reportExtraMemoryUsage):
(JSC::SlotVisitor::heap):
* jit/Repatch.cpp:
* runtime/JSGenericTypedArrayViewInlines.h:
(JSC::JSGenericTypedArrayView<Adaptor>::visitChildren):
* runtime/JSPropertyNameIterator.h:
(JSC::StructureRareData::setEnumerationCache):
* runtime/JSString.cpp:
(JSC::JSString::visitChildren):
* runtime/StructureRareDataInlines.h:
(JSC::StructureRareData::setPreviousID):
(JSC::StructureRareData::setObjectToStringValue):
* runtime/WeakMapData.cpp:
(JSC::WeakMapData::visitChildren):

Source/WTF: 

* wtf/Bitmap.h:
(WTF::WordType>::count): Added a cast that became necessary when Bitmap
is used with smaller types than int32_t.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161540 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r161532.
http://trac.webkit.org/changeset/161532
https://bugs.webkit.org/show_bug.cgi?id=126677

Caused lots of assertion failures (Requested by ap on
#webkit).

Source/WebCore:

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::callReadyStateChangeListener):
(WebCore::XMLHttpRequest::createRequest):
(WebCore::XMLHttpRequest::abort):
(WebCore::XMLHttpRequest::networkError):
(WebCore::XMLHttpRequest::abortError):
(WebCore::XMLHttpRequest::didSendData):
(WebCore::XMLHttpRequest::didReceiveData):
(WebCore::XMLHttpRequest::didTimeout):
* xml/XMLHttpRequest.h:
* xml/XMLHttpRequestProgressEventThrottle.cpp:
(WebCore::XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle):
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent):
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadEnd):
(WebCore::XMLHttpRequestProgressEventThrottle::flushProgressEvent):
(WebCore::XMLHttpRequestProgressEventThrottle::fired):
(WebCore::XMLHttpRequestProgressEventThrottle::hasEventToDispatch):
(WebCore::XMLHttpRequestProgressEventThrottle::suspend):
* xml/XMLHttpRequestProgressEventThrottle.h:
* xml/XMLHttpRequestUpload.cpp:
(WebCore::XMLHttpRequestUpload::XMLHttpRequestUpload):
(WebCore::XMLHttpRequestUpload::dispatchEventAndLoadEnd):
* xml/XMLHttpRequestUpload.h:

LayoutTests:

* fast/xmlhttprequest/xmlhttprequest-get-expected.txt:
* http/tests/xmlhttprequest/loadstart-event-init-expected.txt: Removed.
* http/tests/xmlhttprequest/loadstart-event-init.html: Removed.
* http/tests/xmlhttprequest/onabort-progressevent-attributes-expected.txt: Removed.
* http/tests/xmlhttprequest/onabort-progressevent-attributes.html: Removed.
* http/tests/xmlhttprequest/onload-progressevent-attributes-expected.txt: Removed.
* http/tests/xmlhttprequest/onload-progressevent-attributes.html: Removed.
* http/tests/xmlhttprequest/upload-onabort-progressevent-attributes-expected.txt: Removed.
* http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html: Removed.
* http/tests/xmlhttprequest/upload-onload-progressevent-attributes-expected.txt: Removed.
* http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161541 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Stub for Session API
https://bugs.webkit.org/show_bug.cgi?id=126626

Patch by Martin Hock <mhock@apple.com> on 2014-01-08
Reviewed by Sam Weinig.

* Shared/API/c/WKBase.h:
* Shared/API/c/WKSharedAPICast.h:
* Shared/APIObject.h:
* UIProcess/API/C/WKSessionRef.cpp: Added.
(WKSessionGetTypeID):
(WKSessionGetEphemeral):
* UIProcess/API/C/WKSessionRef.h: Added.
* UIProcess/API/Cocoa/WKSession.h: Added.
* UIProcess/API/Cocoa/WKSession.mm: Added.
(-[WKSession dealloc]):
(-[WKSession ephemeral]):
(-[WKSession API::]):
* UIProcess/API/Cocoa/WKSessionInternal.h: Added.
(WebKit::wrapper):
* UIProcess/APISession.cpp: Added.
(API::Session::Session):
(API::Session::create):
(API::Session::isEphemeral):
(API::Session::~Session):
* UIProcess/APISession.h: Added.
* WebKit2.xcodeproj/project.pbxproj:

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