Incorrect TypedArray#set behavior
https://bugs.webkit.org/show_bug.cgi?id=83818

Source/JavaScriptCore: 

Reviewed by Oliver Hunt and Mark Hahnenberg.
        
This was so much fun! typedArray.set() is like a memmove on steroids, and I'm
not smart enough to figure out optimal versions for *all* of the cases. But I
did come up with optimal implementations for most of the cases, and I wrote
spec-literal code (i.e. copy via a transfer buffer) for the cases I'm not smart
enough to write optimal code for.

* runtime/JSArrayBufferView.h:
(JSC::JSArrayBufferView::hasArrayBuffer):
* runtime/JSArrayBufferViewInlines.h:
(JSC::JSArrayBufferView::buffer):
(JSC::JSArrayBufferView::existingBufferInButterfly):
(JSC::JSArrayBufferView::neuter):
(JSC::JSArrayBufferView::byteOffset):
* runtime/JSGenericTypedArrayView.h:
* runtime/JSGenericTypedArrayViewInlines.h:
(JSC::::setWithSpecificType):
(JSC::::set):
(JSC::::existingBuffer):

LayoutTests: 

Reviewed by Oliver Hunt and Mark Hahnenberg.
        
Made it possible for shouldBe() to compare typed arrays to each other and to any array-like
object.
        
Added a bunch of tests for different kinds of overlapping typedArray.set()'s.
        
For sanity, also added the reduced test case from the bug. Interestingly, though, that test
case already passed on trunk - probably by luck (we had incidentally changed the default
copy direction from one that happened to not work to one that happened to be fine, but only
for this test).

* fast/js/jsc-test-list:
* fast/js/resources/js-test-pre.js:
(isTypedArray):
(isResultCorrect):
(stringify):
(shouldBe):
* fast/js/script-tests/typed-array-copy.js: Added.
* fast/js/script-tests/typedarray-set-destination-smaller-than-source.js: Added.
* fast/js/script-tests/typedarray-set-overlapping-elements-of-same-size.js: Added.
* fast/js/script-tests/typedarray-set-same-type-memmove.js: Added.
(arraysEqual):
* fast/js/script-tests/typedarray-set-source-smaller-than-destination.js: Added.
* fast/js/typed-array-copy-expected.txt: Added.
* fast/js/typed-array-copy.html: Added.
* fast/js/typedarray-set-destination-smaller-than-source-expected.txt: Added.
* fast/js/typedarray-set-destination-smaller-than-source.html: Added.
* fast/js/typedarray-set-overlapping-elements-of-same-size-expected.txt: Added.
* fast/js/typedarray-set-overlapping-elements-of-same-size.html: Added.
* fast/js/typedarray-set-same-type-memmove-expected.txt: Added.
* fast/js/typedarray-set-same-type-memmove.html: Added.
* fast/js/typedarray-set-source-smaller-than-destination-expected.txt: Added.
* fast/js/typedarray-set-source-smaller-than-destination.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Cut down repeated code in RefPtr and RetainPtr by using copy/move-and-swap for assignment operators
https://bugs.webkit.org/show_bug.cgi?id=120223

Reviewed by Anders Carlsson.

* wtf/RefPtr.h: Switch to copy-and-swap in the assignment operators. The move ones already were done
that way.
* wtf/RetainPtr.h: Ditto, except for the move ones too.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154519 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Unreviewed build correction after r154513.

* WTF.vcxproj/build-generated-files.sh: Variable was missing '$' character.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Failure building with python3
https://bugs.webkit.org/show_bug.cgi?id=106645

Patch by Laszlo Papp <lpapp@kde.org> on 2013-08-23
Reviewed by Benjamin Poulain.

Use print functions instead of python statements to be compatible with python 3.X and 2.7 as well.
Archlinux has been using python3 and that is what causes issues while packaging QtWebKit along with Qt5.

* disassembler/udis86/itab.py:
(UdItabGenerator.genInsnTable):
* disassembler/udis86/ud_opcode.py:
(UdOpcodeTables.print_table):
* disassembler/udis86/ud_optable.py:
(UdOptableXmlParser.parseDef):
(UdOptableXmlParser.parse):
(printFn):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154521 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: Fix js minification of updated CodeMirror
https://bugs.webkit.org/show_bug.cgi?id=120231

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2013-08-23
Reviewed by Andy Estes.

Workaround a jsmin issue with "return //.test();" lines when
minifying JavaScript in production builds.

* Scripts/copy-user-interface-resources.sh:
* UserInterface/External/CodeMirror/codemirror.js:
(window.CodeMirror):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154524 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use ElementTraversal some more
https://bugs.webkit.org/show_bug.cgi?id=120226

Reviewed by Darin Adler.

More traversal with tighter typing.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::canvasHasFallbackContent):
(WebCore::siblingWithAriaRole):
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::isDataTable):
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::getFontData):
* dom/ContainerNode.cpp:
(WebCore::willRemoveChild):
* dom/ContainerNodeAlgorithms.h:
(WebCore::ChildFrameDisconnector::ChildFrameDisconnector):
(WebCore::ChildFrameDisconnector::collectFrameOwners):
(WebCore::ChildFrameDisconnector::disconnect):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::selectMediaResource):
(WebCore::HTMLMediaElement::textTrackModeChanged):
(WebCore::HTMLMediaElement::cancelPendingEventsAndCallbacks):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::parametersForPlugin):
(WebCore::HTMLObjectElement::containsJavaApplet):
* html/HTMLParamElement.h:
(WebCore::isHTMLParamElement):
(WebCore::HTMLParamElement):
* html/HTMLSourceElement.h:
(WebCore::isHTMLSourceElement):
(WebCore::HTMLSourceElement):
* svg/SVGFontFaceElement.h:
(WebCore::isSVGFontFaceElement):
(WebCore::SVGFontFaceElement):
(WebCore::toSVGFontFaceElement):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154525 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Unreviewed build correction. Need to force environment variable
to be escaped when running nmake command.

* WebCore.vcxproj/WebCoreGenerated.make:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154526 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] some track language tags are not recognized
https://bugs.webkit.org/show_bug.cgi?id=119643

Source/WebCore: 

Reviewed by Jere Noble.

No new tests, existing tests updated.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Initialize m_captionDisplayMode from settings
    if possible.
(WebCore::HTMLMediaElement::configureTextTrackGroup): Don't enable a default track when preferences
    say captions should be disabled. Don't disable an already visible track if we don't find
    a match unless preferences say captions should be disabled. m_forcedOrAutomaticSubtitleTrackLanguage ->
    m_subtitleTrackLanguage.
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): If the language of the primary
    audio track changes, only kick off a text track recalc if caption preference are set to "automatic".
* html/HTMLMediaElement.h:

* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation): Initialize m_characteristicsChanged
    and m_delayCharacteristicsChangedNotification.
(WebCore::MediaPlayerPrivateAVFoundation::setHasVideo): Call characteristicsChanged.
(WebCore::MediaPlayerPrivateAVFoundation::setHasAudio): Ditto.
(WebCore::MediaPlayerPrivateAVFoundation::setHasClosedCaptions): Ditto.
(WebCore::MediaPlayerPrivateAVFoundation::characteristicsChanged): New, allows us to coalesce 
    calls to the media player when we know several characteristics may change.
(WebCore::MediaPlayerPrivateAVFoundation::setDelayCharacteristicsChangedNotification): Enable or
    disable notification delay.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Always call languageOfPrimaryAudioTrack(),
    a track may have changed so we may have a new language.
(WebCore::MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack): Call [AVAssetTrack languageCode]
    if [AVAssetTrack extendedLanguageTag] returns NULL in case the media file has an old
    QuickTime language code.

LayoutTests: 

Reviewed by Jer Noble.

Explicitly set caption mode to "Automatic" so the track 'default' attribute works.

* media/track/text-track-cue-is-reachable.html: 
* media/track/text-track-is-reachable.html: 
* media/track/track-active-cues.html:
* media/track/track-cue-overlap-snap-to-lines-not-set.html:
* media/track/track-cue-rendering-horizontal.html:
* media/track/track-cue-rendering-vertical.html:
* media/track/track-kind.html:
* media/track/track-large-timestamp.html:
* media/track/track-mode.html:
* media/track/track-text-track-cue-list.html:
* media/track/track-webvtt-tc000-empty.html:
* media/track/track-webvtt-tc002-bom.html:
* media/track/track-webvtt-tc010-no-timings.html:
* media/track/track-webvtt-tc027-empty-cue.html:
* media/track/track-webvtt-tc028-unsupported-markup.html:
* media/track/track-word-breaking.html:
* media/video-test.js:
(setCaptionDisplayMode):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154527 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (r132545): Some PDFs generated by WebKit are blank when viewed in 
Adobe Reader
https://bugs.webkit.org/show_bug.cgi?id=120240
-and corresponding-
<rdar://problem/14634453>

Reviewed by Anders Carlsson.

Source/WebCore: 

This patch makes it so that we don’t use the infinite rect for the PDF context, 
and it adds WebCoreSystemInterface API to find out if the current content is the 
PDF context. 

* WebCore.exp.in:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::clipOut):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Source/WebKit/mac: 

Hook up new WebSystemInterface API to find out if the current context is the PDF 
context.

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKit2: 

Hook up new WebSystemInterface API to find out if the current context is the PDF 
context. 

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

WebKitLibraries: 

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceMountainLion.a:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154528 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (r150516): Media controls are messed up on right-to-left webpages
https://bugs.webkit.org/show_bug.cgi?id=120234

Reviewed by Dan Bernstein.

Source/WebCore:

Test: media/video-rtl.html

Make the media control panel explicitly direction:ltr. The captions menu and captions
display are unaffected, so rtl content will continue to appear rtl there.

* css/mediaControls.css:
(audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel):

LayoutTests:

* media/video-rtl-expected.html: Added.
* media/video-rtl.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154529 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Rebaseline after r154518.  Also fix the test to expect "0" instead of "-0".

Reviewed by Gavin Barraclough.

* fast/js/dfg-div-by-neg1-and-then-or-zero-interesting-reg-alloc-expected.txt:
* fast/js/script-tests/dfg-div-by-neg1-and-then-or-zero-interesting-reg-alloc.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Simplify some Settings access where we have a Frame in reach.
<http://webkit.org/b/120239>

Reviewed by Anders Carlsson.

In three cases where we can grab at a Frame, we can reach all the way to some Settings
without having to use pointers.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didBeginDocument):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::addToOverlapMap):
(WebCore::RenderLayerCompositor::requiresCompositingForPosition):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Build fix after r154515.

* dom/ElementTraversal.h:
(WebCore::Traversal<ElementType>::firstChild):
(WebCore::Traversal<ElementType>::lastChild):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
MediaQuery::expressions() should return a reference
<https://webkit.org/b/120215>

Reviewed by Anders Carlsson.

m_expressions is never NULL so we can just return a reference.

* css/MediaList.cpp:
(WebCore::reportMediaQueryWarningIfNeeded):
* css/MediaQuery.cpp:
(WebCore::MediaQuery::MediaQuery):
* css/MediaQuery.h:
(WebCore::MediaQuery::expressions):
* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::eval):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Unreviewed build correction.

* win/lib32/WebKitSystemInterface.lib: Update with new API for r132545.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Improve scrolling behavior in iTunes
https://bugs.webkit.org/show_bug.cgi?id=120241
<rdar://problem/14825344>

Reviewed by Sam Weinig.

When vertically scrolling a page with horizontally scrollable overflow areas,
vertical scroll gestures would be interrupted when wheel events with non-zero
X deltas were intercepted by the overflow areas.

Fix by storing a small history of wheel events deltas and using
it to determine of the scroll gesture is primarily vertical or horizontal.
When this is detected, avoid dispatching scroll events on the on the
non-dominant axis.

Currently this behavior is conditionalized to only apply in iTunes.

* page/EventHandler.cpp:
(WebCore::EventHandler::EventHandler):
(WebCore::EventHandler::recordWheelEventDelta):
(WebCore::deltaIsPredominantlyVertical):
(WebCore::EventHandler::dominantScrollGestureDirection):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::defaultWheelEventHandler):
* page/EventHandler.h:
* platform/RuntimeApplicationChecks.cpp:
(WebCore::applicationIsITunes):
* platform/RuntimeApplicationChecks.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Forgot to check in the header as well!

* win/include/WebKitSystemInterface/WebKitSystemInterface.h:



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

It didn't work with ARC like it said it would. We'll need to take a slightly different approach.

Rubber-stamped by Anders Carlsson.

* wtf/RetainPtr.h:
(WTF::RetainPtr::RetainPtr):
(WTF::RetainPtr::~RetainPtr):
(WTF::RetainPtr::operator UnspecifiedBoolType):
(WTF::::RetainPtr):
(WTF::::clear):
(WTF::=):
(WTF::adoptCF):
(WTF::adoptNS):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154537 268f45cc-cd09-0410-ab3c-d52691b4dbfc
<https://webkit.org/b/120141> Make RetainPtr work with ARC.

Have RetainPtr store the object its managing as a CFTypeRef and manage its lifetime with
CFRetain / CFRelease. This is necessary to have explicit control over the lifetime of
Objective-C objects when automatic reference counting is in use. Two helper methods are
introduced to convert between the pointer type that the RetainPtr manages and the CFTypeRef
that the pointer is stored as. For CF types and Objective-C types with ARC disabled,
these methods are simply casts. For Objective-C types under ARC they need to use the
special bridging casts to keep the compiler happy.

Reviewed by Anders Carlsson.

* wtf/RetainPtr.h:
(WTF::RetainPtr::RetainPtr): Use the helper methods to convert to and from the storage
types when necessary.
(WTF::RetainPtr::~RetainPtr): Ditto.
(WTF::RetainPtr::get): Ditto.
(WTF::RetainPtr::operator->): Ditto.
(WTF::RetainPtr::operator PtrType): Ditto.
(WTF::::RetainPtr): Ditto.
(WTF::::clear): Ditto.
(WTF::::leakRef): Ditto.
(WTF::=): Ditto.

(WTF::RetainPtr::fromStorageTypeHelper): Use crazy template magic to determine whether to use
a bridging cast or not depending on the desired return type.
(WTF::RetainPtr::fromStorageType):
(WTF::RetainPtr::toStorageType): Overloading is sufficient here.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154538 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Revert accidental change.
        
Not reviewed.

* WebProcess/com.apple.WebProcess.sb.in:



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