MarkedBlocks shouldn't be put in Allocated state if they didn't produce a FreeList
https://bugs.webkit.org/show_bug.cgi?id=121236

Reviewed by Geoffrey Garen.

Right now, after a collection all MarkedBlocks are in the Marked block state. When lazy sweeping 
happens, if a block returns an empty free list after being swept, we call didConsumeFreeList(), 
which moves the block into the Allocated block state. This happens to both the block that was 
just being allocated out of (i.e. m_currentBlock) as well as any blocks who are completely full. 
We should distinguish between these two cases: m_currentBlock should transition to 
Allocated (because we were just allocating out of it) and any subsequent block that returns an 
empty free list should transition back to the Marked state. This will make the block state more 
consistent with the actual state the block is in, and it will also allow us to speed up moving 
all blocks to the Marked state during generational collection.

* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::tryAllocateHelper):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::didConsumeEmptyFreeList):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[curl] Improve multipart response handling
https://bugs.webkit.org/show_bug.cgi?id=117735

Reviewed by Brent Fulgham.

The multipart/x-mixed-replace mime type in responses are ignored
with the curl network backend. To handle such responses the
MultipartHandle is introduced which will split the content using
the boundary specified by the mime type.

There are already existing tests (http/tests/multipart).

* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* platform/network/HTTPParsers.cpp:
(WebCore::parseHTTPHeader):
* platform/network/HTTPParsers.h:
* platform/network/ResourceHandleInternal.h:
* platform/network/curl/MultipartHandle.cpp: Added.
(WebCore::MultipartHandle::extractBoundary):
(WebCore::MultipartHandle::matchForBoundary):
(WebCore::MultipartHandle::checkForBoundary):
(WebCore::MultipartHandle::parseHeadersIfPossible):
(WebCore::MultipartHandle::contentReceived):
(WebCore::MultipartHandle::processContent):
(WebCore::MultipartHandle::contentEnded):
(WebCore::MultipartHandle::didReceiveData):
(WebCore::MultipartHandle::didReceiveResponse):
* platform/network/curl/MultipartHandle.h: Added.
(WebCore::MultipartHandle::MultipartHandle):
(WebCore::MultipartHandle::~MultipartHandle):
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::writeCallback):
(WebCore::headerCallback):
(WebCore::ResourceHandleManager::downloadTimerCallback):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[curl] Use utf8 for headers in CurlDownload.
https://bugs.webkit.org/show_bug.cgi?id=120413

Patch by Tamas Czene <tczene@inf.u-szeged.hu> on 2013-09-12
Reviewed by Brent Fulgham.

* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownload::headerCallback):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reorganize Pasteboard.h to make it easier to read, and express plan for future work
https://bugs.webkit.org/show_bug.cgi?id=121234

Reviewed by Anders Carlsson.

* platform/Pasteboard.h: Move Mac/iOS-specific pasteboard names to the bottom of the
file rather than putting them up with forward declarations before the class. Removed
unneeded forward class declarations. Changed #if statements about migration to the
more modern non-layering-violation API to list platforms not yet migrated, rather than
listing platforms that have migrated (Mac). Move conditional code down below the
uncondiditional code so it's easier to see what the class is doing. Move layering-
violation code down to the bottom too, so it's easier to see the future class without
having the design mistakes mixed in. Sort platform-specific sections in alphabetical
order instead of random order. Did the destructor in a cleaner way so the #if is out
of the way after the class rather than in the class. Removed WebSmartPastePboardType,
WebURLPboardType, and WebURLsWithTitlesPboard declarations, since they are only used
inside the PasteboardMac.mm source file.

* platform/ios/PasteboardIOS.mm: Aded a FIXME comment.
* platform/mac/PasteboardMac.mm: Made the constants for pasteboard types be actual
constants, rather than global variables.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155635 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Build fix after r155635.

Rubber Stamped by Darin Adler.

* platform/Pasteboard.h: Add missing compile guards for Windows port.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155636 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] Unreviewed build fix after r155635.

Include DragData.h

* platform/gtk/PasteboardGtk.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Get rid of layering violations in PasteboardEfl.cpp
https://bugs.webkit.org/show_bug.cgi?id=121241

Patch by Christophe Dumez <ch.dumez@sisa.samsung.com> on 2013-09-12
Reviewed by Darin Adler.

Get rid of layering violations in PasteboardEfl.cpp. For now, just mimic
the Mac port to avoid divergences and leave port-specific functions
unimplemented as the EFL port does not support the pasteboard functionality
yet.

No new tests, no behavior change.

* PlatformEfl.cmake:
* editing/Editor.cpp:
(WebCore::Editor::pasteAsPlainTextWithPasteboard):
(WebCore::Editor::cut):
(WebCore::Editor::copy):
(WebCore::Editor::copyURL):
(WebCore::Editor::copyImage):
* editing/Editor.h:
* editing/efl/EditorEfl.cpp: Added.
(WebCore::Editor::writeSelectionToPasteboard):
(WebCore::Editor::writeURLToPasteboard):
(WebCore::Editor::writeImageToPasteboard):
(WebCore::Editor::readPlainTextFromPasteboard):
(WebCore::Editor::pasteWithPasteboard):
* page/DragController.cpp:
(WebCore::DragController::startDrag):
* platform/Pasteboard.h:
* platform/efl/PasteboardEfl.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155638 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove more Timeline stuff we don't use
https://bugs.webkit.org/show_bug.cgi?id=121246

Reviewed by Joseph Pecoraro.

* inspector/InspectorController.cpp:
* inspector/InspectorController.h:
* inspector/InspectorDOMDebuggerAgent.cpp:
* inspector/InspectorDOMDebuggerAgent.h:
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
* inspector/InspectorProfilerAgent.h:
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::innerAddRecordToTimeline):
* inspector/InspectorTimelineAgent.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155639 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Bitmap's WordType should be a template parameter
https://bugs.webkit.org/show_bug.cgi?id=121238

Reviewed by Darin Adler.

The code is written as if it already is. We just need to lift it out of the class.
This simplifies code that wants to load, for example, a single byte rather than an 
entire 32-bit word. 

* wtf/Bitmap.h:
(WTF::Bitmap::Bitmap):
(WTF::Bitmap::get):
(WTF::Bitmap::set):
(WTF::Bitmap::testAndSet):
(WTF::Bitmap::testAndClear):
(WTF::Bitmap::concurrentTestAndSet):
(WTF::Bitmap::concurrentTestAndClear):
(WTF::Bitmap::clear):
(WTF::Bitmap::clearAll):
(WTF::Bitmap::nextPossiblyUnset):
(WTF::Bitmap::findRunOfZeros):
(WTF::Bitmap::count):
(WTF::Bitmap::isEmpty):
(WTF::Bitmap::isFull):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
SharedBuffer::createNSData should return a RetainPtr<NSData>
https://bugs.webkit.org/show_bug.cgi?id=121237

Reviewed by Darin Adler.

Source/WebCore:

This makes memory management cleared and fixes a leak in PDFDocumentImage::createPDFDocument.
We use a RetainPtr subclass as a stopgap measure to prevent code that does [buffer->createNSData() autorelease]
from compiling and crashing due to the NSData object being overreleased.

* loader/ResourceBuffer.h:
* loader/mac/ResourceBuffer.mm:
(WebCore::ResourceBuffer::createNSData):
* platform/SharedBuffer.h:
(WebCore::SharedBuffer::NSDataRetainPtr::NSDataRetainPtr):
* platform/graphics/mac/PDFDocumentImageMac.mm:
(WebCore::PDFDocumentImage::createPDFDocument):
* platform/mac/HTMLConverter.mm:
(-[WebHTMLConverter _addAttachmentForElement:URL:needsParagraph:usePlaceholder:]):
(fileWrapperForURL):
* platform/mac/PasteboardMac.mm:
(WebCore::fileWrapper):
(WebCore::Pasteboard::read):
(WebCore::documentFragmentWithRTF):
(WebCore::fragmentFromWebArchive):
* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::setBufferForType):
* platform/mac/SharedBufferMac.mm:
(WebCore::SharedBuffer::createNSData):

Source/WebKit/mac:

Update for WebCore changes. This also fixes a leak where we'd create an NSFileWrapper from NSData but never release the data.

* WebView/WebDataSource.mm:
(-[WebDataSource data]):
* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation documentSource]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]):
* WebView/WebResource.mm:
(-[WebResource encodeWithCoder:]):
(-[WebResource data]):

Source/WebKit2:

Update for WebCore changes.

* UIProcess/API/mac/WKView.mm:
(-[WKView writeSelectionToPasteboard:types:]):
(-[WKView _setPromisedData:WebCore::withFileName:withExtension:withTitle:withURL:withVisibleURL:withArchive:WebCore::forPasteboard:]):
(-[WKView namesOfPromisedFilesDroppedAtDestination:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155641 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: Do not try to parse incomplete HTTP requests
https://bugs.webkit.org/show_bug.cgi?id=121123

Patch by Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk> on 2013-09-12
Reviewed by Darin Adler.

When working on a patch for bug #121121 I found an issue with the InspectorServer where it would try
to parse an HTTP message before receiving the full message and thus fail connecting with the
chromedevtools plugin.

What happens is that the WebSocketServerConnection receives buffers on
WebSocketServerConnection::didReceiveSocketStreamData and calls
WebSocketServerConnection::readHTTPMessage which then checks if we have a valid request by calling
HTTPRequest::parseHTTPRequestFromBuffer. If the request is valid it tries to parse the message and
clears the buffer, otherwise it continues adding data to the internal buffer until we have a valid
request.

The problem is that currently HTTPRequest::parseHTTPRequestFromBuffer considers the request as valid
before receiving the full message. To solve this we should make the method check if the request
headers end with a blank line otherwise we consider the request as invalid (see also
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html).

* UIProcess/API/gtk/tests/TestInspectorServer.cpp:
(sendIncompleteRequest):
(beforeAll):
Add GTK specific test to check if the inspector server replies to incomplete requests.
* UIProcess/InspectorServer/HTTPRequest.cpp:
(WebKit::HTTPRequest::parseHeaders):
Do not consider request valid if headers didn't end with a blank line.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155642 268f45cc-cd09-0410-ab3c-d52691b4dbfc
GPRTemporary's reuse constructor should be templatized to reduce code duplication, and the bool to denote tag or payload should be replaced with an enum
https://bugs.webkit.org/show_bug.cgi?id=121250

Reviewed by Oliver Hunt.

* dfg/DFGGPRInfo.h:
(JSC::DFG::JSValueRegs::gpr):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::GPRTemporary::GPRTemporary):
(JSC::DFG::SpeculativeJIT::compileValueToInt32):
(JSC::DFG::SpeculativeJIT::compileAdd):
(JSC::DFG::SpeculativeJIT::compileStringEquality):
(JSC::DFG::SpeculativeJIT::compileGetArgumentsLength):
(JSC::DFG::SpeculativeJIT::compileGetArrayLength):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::JSValueOperand::gpr):
(JSC::DFG::GPRTemporary::GPRTemporary):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::nonSpeculativeUInt32ToNumber):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompareNull):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeBranchNull):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompare):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::compileObjectEquality):
(JSC::DFG::SpeculativeJIT::compileLogicalNot):
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::nonSpeculativeUInt32ToNumber):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompareNull):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeBranchNull):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeBranch):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompare):
(JSC::DFG::SpeculativeJIT::compileObjectEquality):
(JSC::DFG::SpeculativeJIT::compileIntegerCompare):
(JSC::DFG::SpeculativeJIT::compileLogicalNot):
(JSC::DFG::SpeculativeJIT::compile):
* runtime/JSCJSValue.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155643 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, fix mispelling (Specualte -> Speculate) that I introduced in an
earlier patch.

* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculateInt32Operand::gpr):
(JSC::DFG::SpeculateStrictInt32Operand::gpr):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateInt32Internal):
(JSC::DFG::SpeculativeJIT::fillSpeculateInt32):
(JSC::DFG::SpeculativeJIT::fillSpeculateInt32Strict):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateInt32Internal):
(JSC::DFG::SpeculativeJIT::fillSpeculateInt32):
(JSC::DFG::SpeculativeJIT::fillSpeculateInt32Strict):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
DFG::GenerationInfo init/fill methods shouldn't duplicate a bunch of logic
https://bugs.webkit.org/show_bug.cgi?id=121253

Reviewed by Oliver Hunt.

* dfg/DFGGenerationInfo.h:
(JSC::DFG::GenerationInfo::initGPR):
(JSC::DFG::GenerationInfo::initInt32):
(JSC::DFG::GenerationInfo::initJSValue):
(JSC::DFG::GenerationInfo::initCell):
(JSC::DFG::GenerationInfo::initBoolean):
(JSC::DFG::GenerationInfo::initStorage):
(JSC::DFG::GenerationInfo::fillGPR):
(JSC::DFG::GenerationInfo::fillJSValue):
(JSC::DFG::GenerationInfo::fillCell):
(JSC::DFG::GenerationInfo::fillInt32):
(JSC::DFG::GenerationInfo::fillBoolean):
(JSC::DFG::GenerationInfo::fillStorage):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155645 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Flaky Test: plugins/mouse-events.html
https://bugs.webkit.org/show_bug.cgi?id=116665

Reviewed by Anders Carlsson.

* plugins/mouse-events-expected.txt:
* plugins/mouse-events.html:
This test used async calls for events, and then usually logged responses while waiting
for a plg.eventLoggingEnabled setter synchronously. Depending on sync/async event
order is not reliable, especially with old WebKit1 plug-in IPC code.

* platform/mac-wk2/plugins/mouse-events-expected.txt: For some unclear reason,
focus works differently in WebKit2.

* platform/gtk/plugins/mouse-events-expected.txt: Removed.
* platform/qt/plugins/mouse-events-expected.txt: Removed.
* platform/win/plugins/mouse-events-expected.txt: Removed.
These results looked similar to new cross-platform ones, hopefully custom results
won't be needed any more.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155646 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Encapsulate globals in CSSPropertyAnimation.cpp
https://bugs.webkit.org/show_bug.cgi?id=121205

Reviewed by Antti Koivisto.

Encapsulated the globals inside a newly added CSSPropertyAnimationWrapperMap. Also removed the circular
dependency from ShorthandPropertyWrapper's constructor to CSSPropertyAnimationWrapperMap::instance().
The circular dependency still exists in ensurePropertyMap but I'm going to remove it in the bug 121199.

* page/animation/CSSPropertyAnimation.cpp:
(WebCore::ShorthandPropertyWrapper::ShorthandPropertyWrapper): Takes a Vector of longhand wrappers instead of
calling wrapperForProperty in the middle of constructing the very table. This circular dependency is now
encapsulated in CSSPropertyAnimationWrapperMap::ensurePropertyMap.
(WebCore::CSSPropertyAnimationWrapperMap::instance): Added.
(WebCore::CSSPropertyAnimationWrapperMap::wrapperForProperty): Renamed from WebCore::wrapperForProperty.
(WebCore::CSSPropertyAnimationWrapperMap::wrapperForIndex): Added.
(WebCore::CSSPropertyAnimationWrapperMap::size): Added.
(WebCore::CSSPropertyAnimationWrapperMap::addPropertyWrapper): Renamed from WebCore::addPropertyWrapper. Also
cleaned up boolean logics to use early exits instead of nested ifs.
(WebCore::CSSPropertyAnimationWrapperMap::addShorthandProperties): Renamed from WebCore::addShorthandProperties.
(WebCore::CSSPropertyAnimationWrapperMap::ensurePropertyMap): Renamed from WebCore::ensurePropertyMap.
Added an alias gPropertyWrappers for m_propertyWrappers; this aliasing will be removed in the bug 121199.
(WebCore::CSSPropertyAnimation::blendProperties):
(WebCore::CSSPropertyAnimation::animationOfPropertyIsAccelerated):
(WebCore::CSSPropertyAnimation::animatableShorthandsAffectingProperty):
(WebCore::CSSPropertyAnimation::propertiesEqual):
(WebCore::CSSPropertyAnimation::getPropertyAtIndex):
(WebCore::CSSPropertyAnimation::getNumProperties):
* page/animation/CSSPropertyAnimation.h:
* rendering/style/RenderStyle.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
svg/animations/smil-leak-*.svg tests are flaky
https://bugs.webkit.org/show_bug.cgi?id=114280

Reviewed by Tim Horton.

Moved garbage collection out of the function that touches nodes to be collected,
making sure that they are definitely not on the stack.

I could not reproduce locally, so this is a speculative fix.

* svg/animations/smil-leak-dynamically-added-element-instances.svg:
* svg/animations/smil-leak-element-instances-noBaseValRef.svg:
* svg/animations/smil-leak-element-instances.svg:
* svg/animations/smil-leak-elements.svg:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore: Qt build fix. Add a return to make the compiler happy.

* dfg/DFGGPRInfo.h:
(JSC::DFG::JSValueRegs::gpr):

Source/WebCore: Qt and Windows build fix.

* page/animation/CSSPropertyAnimation.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Canvas fillText and measureText handle ideographic spaces differently
https://bugs.webkit.org/show_bug.cgi?id=108881

Fixing the test:
1. Updated paths to js-test scripts.
2. Removed "meta charcode" - we don't need to specify a charset here, and it's
"charset", not "charcode" anyway.

* fast/canvas/canvas-measureText-ideographicSpace.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt] SHOULD NEVER BE REACHED is touched WebCore::InputType::createStepRange
https://bugs.webkit.org/show_bug.cgi?id=121148

Reviewed by Kent Tamura.

Source/WebCore:

Non-steppable input types must not rendered as slider even if its webkit-apperance style
property is set to slider-vertical/horizontal.

Test: platform/qt/fast/forms/range/slider-crash-on-input.html

* platform/qt/RenderThemeQStyle.cpp:
(WebCore::RenderThemeQStyle::paintSliderTrack):

LayoutTests:

Trying to render text input as slider-vertical. Expecting to run without crash.

* platform/qt/fast/forms/range/slider-crash-on-input.html: Added.
* platform/qt/platform/qt/fast/forms/range/slider-crash-on-input-expected.txt: Added.


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