matchingShorthandsForLonghand builds map using a giant function
https://bugs.webkit.org/show_bug.cgi?id=121029

Reviewed by Anders Carlsson.

There is no need to use a map for this; a switch statement is fine.
Also, these structures are simple enough that we can build them
every time; we don't need to keep them in globals.

* css/CSSParser.cpp:
(WebCore::CSSParser::addProperty): Got rid of non-helpful local in
CSS_VARIABLES code. Updated for change in return value of the
matchingShorthandsForLonghand.
(WebCore::CSSParser::parseShorthand): Updated for change in return
type of propertiesForInitialization.

* css/CSSProperty.cpp:
(WebCore::StylePropertyMetadata::shorthandID): Updated for change in
return value of matchingShorthandsForLonghand.

* css/StylePropertyShorthand.cpp:
(WebCore::backgroundShorthand): Got rid of local variable, constructing
the StylePropertyShorthand every time.
(WebCore::backgroundPositionShorthand): Ditto.
(WebCore::backgroundRepeatShorthand): Ditto.
(WebCore::borderShorthand): Ditto.
(WebCore::borderAbridgedShorthand): Ditto.
(WebCore::borderBottomShorthand): Ditto.
(WebCore::borderColorShorthand): Ditto.
(WebCore::borderImageShorthand): Ditto.
(WebCore::borderLeftShorthand): Ditto.
(WebCore::borderRadiusShorthand): Ditto.
(WebCore::webkitBorderRadiusShorthand): Ditto.
(WebCore::borderRightShorthand): Ditto.
(WebCore::borderSpacingShorthand): Ditto.
(WebCore::borderStyleShorthand): Ditto.
(WebCore::borderTopShorthand): Ditto.
(WebCore::borderWidthShorthand): Ditto.
(WebCore::listStyleShorthand): Ditto.
(WebCore::fontShorthand): Ditto.
(WebCore::marginShorthand): Ditto. Ditto.
(WebCore::markerShorthand): Ditto.
(WebCore::outlineShorthand): Ditto.
(WebCore::overflowShorthand): Ditto.
(WebCore::paddingShorthand): Ditto.
(WebCore::transitionShorthand): Ditto.
(WebCore::webkitAnimationShorthand): Ditto.
(WebCore::webkitAnimationShorthandForParsing): Ditto.
(WebCore::webkitBorderAfterShorthand): Ditto.
(WebCore::webkitBorderBeforeShorthand): Ditto.
(WebCore::webkitBorderEndShorthand): Ditto.
(WebCore::webkitBorderStartShorthand): Ditto.
(WebCore::webkitColumnsShorthand): Ditto.
(WebCore::webkitColumnRuleShorthand): Ditto.
(WebCore::webkitFlexFlowShorthand): Ditto.
(WebCore::webkitFlexShorthand): Ditto.
(WebCore::webkitMarginCollapseShorthand): Ditto.
(WebCore::webkitGridColumnShorthand): Ditto.
(WebCore::webkitGridRowShorthand): Ditto.
(WebCore::webkitMarqueeShorthand): Ditto.
(WebCore::webkitMaskShorthand): Ditto.
(WebCore::webkitMaskPositionShorthand): Ditto.
(WebCore::webkitMaskRepeatShorthand): Ditto.
(WebCore::webkitTextDecorationShorthand): Ditto.
(WebCore::webkitTextEmphasisShorthand): Ditto.
(WebCore::webkitTextStrokeShorthand): Ditto.
(WebCore::webkitTransitionShorthand): Ditto.
(WebCore::webkitTransformOriginShorthand): Ditto.
(WebCore::widthShorthand): Ditto.
(WebCore::heightShorthand): Ditto.
(WebCore::shorthandForProperty): Ditto.
(WebCore::makeVector): Added. Helper function for the cases in the
switch inside matchingShorthandsForLonghand.
(WebCore::matchingShorthandsForLonghand): Rewrote this to use a switch
instead of a map.
(WebCore::indexOfShorthandForLonghand): Tightened up the coding style a bit.

* css/StylePropertyShorthand.h: Changed type of StylePropertyShorthand's
propertiesForInitialization to be an array of shorthands rather than an
array of pointers to shorthands. Changed return types of the shorthand
functions to return a shorthand object rather than a reference. Did the same
for the other functions.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155352 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed build fix.

* GNUmakefile.list.am: Typo - left-over \ from a copy/paste, most likely.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Shapes] Heap-buffer-overflow in WebCore::ShapeInterval<float>::subtractShapeIntervals
https://bugs.webkit.org/show_bug.cgi?id=120802

Reviewed by Darin Adler.

Source/WebCore:

Revised the implementation of subtractShapeIntervals() to isloate and check the
places where it dereferences ShapeInterval vector iterators.

Test: fast/shapes/shape-inside/shape-inside-subtract-intervals-crash.html

* rendering/shapes/ShapeInterval.h:
(WebCore::ShapeInterval::subtractShapeIntervals):

LayoutTests:

Added a test case that crashed a bounds-checking runtime prior to this fix.

* fast/shapes/shape-inside/shape-inside-subtract-intervals-crash-expected.html: Added.
* fast/shapes/shape-inside/shape-inside-subtract-intervals-crash.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Tighten up EventQueue classes a bit, less indirection and memory allocation
https://bugs.webkit.org/show_bug.cgi?id=121016

Reviewed by Andreas Kling.

* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession): Updated since event queue is now
a member rather than an OwnPtr.
(WebCore::MediaKeySession::close): Ditto.
(WebCore::MediaKeySession::keyRequestTimerFired): Ditto.
(WebCore::MediaKeySession::addKeyTimerFired): Ditto.
* Modules/encryptedmedia/MediaKeySession.h: Ditto.

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::closeConnection): Updated since ScriptExecutionContext's
eventQueue function now returns a reference rather than a pointer. Also, the
cancelEvent function takes a reference instead of a pointer.
(WebCore::IDBDatabase::enqueueEvent): Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::abort): Ditto.
(WebCore::IDBRequest::enqueueEvent): Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::enqueueEvent): Ditto.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::MediaSource): Updated since event queue is now a
member rather than an OwnPtr. Also use initialization instead of assignment
to set up source buffers.
(WebCore::MediaSource::hasPendingActivity): Ditto.
(WebCore::MediaSource::stop): Ditto.
(WebCore::MediaSource::scheduleEvent): Ditto.
* Modules/mediasource/MediaSource.h: Ditto.

* Modules/mediasource/SourceBufferList.cpp:
(WebCore::SourceBufferList::SourceBufferList): Take references instead of
pointers.
(WebCore::SourceBufferList::length): Changed type to unsigned instead of
unsigned long. This is an IDL "unsigned long", which corresponds to "unsigned"
in our C++ DOM implementation.
(WebCore::SourceBufferList::createAndFireEvent): Updated since event queue is
now a reference.
(WebCore::SourceBufferList::scriptExecutionContext): Updated since script
execution context is now a reference.
* Modules/mediasource/SourceBufferList.h: Ditto.

* dom/Document.cpp:
(WebCore::Document::Document): Updated since event queue is now a member rather
than a RefPtr.
(WebCore::Document::detach): Ditto.
(WebCore::Document::enqueueWindowEvent): Ditto.
(WebCore::Document::enqueueDocumentEvent): Ditto.
* dom/Document.h: Ditto.

* dom/DocumentEventQueue.cpp: Renamed DocumentEventQueueTimer to just Timer and
made it a class member of DocumentEventQueue. Also changed it to use references
instead of pointers and removed unneeded ScriptExecutionContext argument.
(WebCore::DocumentEventQueue::DocumentEventQueue): Updated to take a document
reference instead of a script execution context pointer.
(WebCore::DocumentEventQueue::enqueueEvent): Wrote the assertions in a clearer
style and do the assertions even when the queue is closed.
(WebCore::DocumentEventQueue::enqueueOrDispatchScrollEvent): Removed the unneeded
ScrollEventTargetType argument, since the policy is specific to the document node.
Made the argument a reference instead of a PassRefPtr, and rewrote the function
to be more straightforward and readable.
(WebCore::DocumentEventQueue::cancelEvent): Use the return value recently added to
the remove function to avoid the need for use of iterators and a find/remove pair.
(WebCore::DocumentEventQueue::pendingEventTimerFired): Rewrote this to use the
recently added ListHashSet takeFirst function. Also protect the document instead
of protecting just this object during the dispatch. Can't really protect the
event queue since it's no longer separately reference counted.
(WebCore::DocumentEventQueue::dispatchEvent): Changed this to take a reference and
added a FIXME about some curious code in here that needs a "why" comment.
* dom/DocumentEventQueue.h: Removed many unneeded includes, some unneeded forward
declarations, marked the class final, made it no longer derive from RefCounted,
removed ScrollEventTargetType and create, and did the other changes mentioned above.

* dom/EventQueue.h: Got rid of many uneeded includes, changed the argument type
of cancelEvent to Event& and rewrote the comment for close.

* dom/GenericEventQueue.cpp:
(WebCore::GenericEventQueue::GenericEventQueue): Updated to take a reference.
(WebCore::GenericEventQueue::enqueueEvent): Ditto.
(WebCore::GenericEventQueue::timerFired): Ditto.
* dom/GenericEventQueue.h: Changed this class to no longer derive from EventQueue
since there was no value coming from that polymorphism. Removed all the virtual
keywords from the class. Switched from pointers to references. Removed the unused
cancelEvent function. Removed the create function since this is always used as a
data member, not a pointer on the heap.

* dom/ScriptExecutionContext.h: Changed the return type of eventQueue to a reference.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Updated since event queue is now a
member rather than an OwnPtr.
(WebCore::HTMLMediaElement::~HTMLMediaElement): Ditto.
(WebCore::HTMLMediaElement::scheduleEvent): Ditto.
(WebCore::HTMLMediaElement::updateActiveTextTrackCues): Ditto.
(WebCore::HTMLMediaElement::cancelPendingEventsAndCallbacks): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerKeyAdded): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerKeyError): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerKeyMessage): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerKeyNeeded): Ditto.
(WebCore::HTMLMediaElement::stop): Ditto.
(WebCore::HTMLMediaElement::hasPendingActivity): Ditto.
* html/HTMLMediaElement.h: Ditto.

* page/EventHandler.cpp:
(WebCore::EventHandler::sendScrollEvent): Updated to remove the now-uneeded
ScrollEventTargetType argument, and also to use references instead of pointers.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo): Ditto.
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::scrollTo): Ditto.

* workers/WorkerEventQueue.cpp:
(WebCore::WorkerEventQueue::WorkerEventQueue): Updated to work with references
instead of pointers.
(WebCore::WorkerEventQueue::enqueueEvent): Ditto.
(WebCore::WorkerEventQueue::cancelEvent): Use the take function instead of a
get/remove pair, to eliminate double hashing.
* workers/WorkerEventQueue.h: Removed unneeded includes, forward declarations,
the create function, and the private removeEvent function. Marked class final.

* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope): Updated since eventQueue is
now a data member.
(WebCore::WorkerGlobalScope::eventQueue): Ditto.
* workers/WorkerGlobalScope.h: Made m_eventQueue a queue instead of a pointer
to a queue. Also made the eventQueue function private and final.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155356 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Begin moving off of TypeTraits.h
https://bugs.webkit.org/show_bug.cgi?id=121006

Reviewed by Darin Adler.

Source/JavaScriptCore:

Convert uses of WTF type traits to STL type traits.

* heap/PassWeak.h:
* runtime/JSCell.h:
(JSC::jsCast):
(JSC::jsDynamicCast):
* runtime/WriteBarrier.h:
(JSC::validateCell):

Source/WebKit2:

Convert uses of WTF type traits to STL type traits.

* Platform/CoreIPC/ArgumentCoder.h:
* Platform/CoreIPC/ArgumentCoders.h:
* Platform/CoreIPC/ArgumentDecoder.h:
* Platform/CoreIPC/ArgumentEncoder.h:
* Platform/CoreIPC/Arguments.h:
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toImpl):

Source/WTF:

The C++11 has its own type traits implementation that is more complete and handles corner cases better
since it ties into the compiler. Begin switching uses of WTF type traits to STL type traits.

* wtf/CheckedArithmetic.h:
* wtf/HashTraits.h:
* wtf/NeverDestroyed.h:
* wtf/OwnPtr.h:
* wtf/PassOwnPtr.h:
(WTF::adoptPtr):
* wtf/RetainPtr.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Preparing WebCore to receive Nix Port
https://bugs.webkit.org/show_bug.cgi?id=118326

Reviewed by Eric Carlson.

Only adding the compilation directives that are Nix specific, in the
existent WebCore files

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::defaultObjectContentType):
* platform/Cursor.h:
* platform/DragData.h:
* platform/DragImage.h:
* platform/FileSystem.h:
* platform/RunLoop.h:
* platform/Widget.h:
* platform/audio/FFTFrame.h:
* platform/audio/HRTFElevation.cpp:
* platform/cairo/WidgetBackingStore.h:
* platform/graphics/ANGLEWebKitBridge.h:
* platform/graphics/FontPlatformData.h:
* platform/graphics/GraphicsContext3D.cpp:
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/OpenGLESShims.h:
* platform/graphics/OpenGLShims.cpp:
(WebCore::getProcAddress):
* platform/graphics/OpenGLShims.h:
* platform/graphics/PlatformLayer.h:
* platform/graphics/cairo/GLContext.cpp:
(WebCore::GLContext::createContextForWindow):
* platform/graphics/cairo/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
* platform/graphics/opengl/Extensions3DOpenGL.cpp:
(WebCore::Extensions3DOpenGL::createVertexArrayOES):
(WebCore::Extensions3DOpenGL::deleteVertexArrayOES):
(WebCore::Extensions3DOpenGL::isVertexArrayOES):
(WebCore::Extensions3DOpenGL::bindVertexArrayOES):
(WebCore::Extensions3DOpenGL::supportsExtension):
* platform/graphics/opengl/Extensions3DOpenGL.h:
* platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
* platform/graphics/opengl/Extensions3DOpenGLES.h:
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::reshape):
* platform/graphics/texmap/TextureMapper.h:
* plugins/PluginPackage.cpp:
* plugins/PluginView.cpp:
(WebCore::PluginView::PluginView):
* plugins/PluginView.h:
* plugins/PluginViewNone.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Nix upstreaming - Adding stubs and Nix specific platform files
https://bugs.webkit.org/show_bug.cgi?id=118358

Reviewed by Benjamin Poulain.

Basically adding all files that have "Nix" in their names and
are related to WebCore module.

Source/WebCore:

No new tests. They will be uploaded on another patch during the
upstreaming process.

* css/mediaControlsNix.css: Added.
* css/mediaControlsNixFullscreen.css: Added.
* page/nix/EventHandlerNix.cpp: Added.
* platform/graphics/egl/GLContextFromCurrentEGL.cpp: Added.
* platform/graphics/egl/GLContextFromCurrentEGL.h: Added.
* platform/graphics/gstreamer/PlatformVideoWindowNix.cpp: Added.
* platform/graphics/nix/IconNix.cpp: Added.
* platform/graphics/nix/ImageNix.cpp: Added.
* platform/nix/CursorNix.cpp: Added.
* platform/nix/DragDataNix.cpp: Added.
* platform/nix/DragImageNix.cpp: Added.
* platform/nix/GamepadsNix.cpp: Added.
* platform/nix/LanguageNix.cpp: Added.
* platform/nix/LocalizedStringsNix.cpp: Added.
* platform/nix/NixKeyboardUtilities.cpp: Added.
* platform/nix/NixKeyboardUtilities.h: Added.
* platform/nix/PasteboardNix.cpp: Added.
* platform/nix/PlatformKeyboardEventNix.cpp: Added.
* platform/nix/PlatformScreenNix.cpp: Added.
* platform/nix/SoundNix.cpp: Added.
* platform/nix/WidgetNix.cpp: Added.
* platform/text/nix/TextBreakIteratorInternalICUNix.cpp: Added.

Source/WTF:

* wtf/nix/FeatureDefinesNix.h: Added.
* wtf/nix/PlatformNix.h: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155360 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WK2] Assertion failure in WebCore::Page::checkSubframeCountConsistency when going back
https://bugs.webkit.org/show_bug.cgi?id=119781

Reviewed by Alexey Proskuryakov.

Source/WebCore:

We should pair restoring a cached frame and adding it to FrameTree so that
actual added frame count in FrameTree keeps same with restored frame count.
Otherwise assert failure occurs in Page::CheckSubframeCountConsistency.
We have added cached frames to FrameTree ahead and then restored them by tree travelsal.
But this way doesn't guarantee subframecount of Page and the number of child of FrameTree are equal.
In addition, we still make sure that adding a cached frame to FrameTree should happen
before opening it. Because FrameTree might be used while restoring a cached page.

Test: fast/history/go-back-to-iframe-with-plugin.html

* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::restore):
(WebCore::CachedFrame::open):

LayoutTests:

To verify this fix, we need to use the CachedPage in WK2 debug mode.
And the test page should have at least one iframe with plugin.

* fast/history/go-back-to-iframe-with-plugin-expected.txt: Added.
* fast/history/go-back-to-iframe-with-plugin.html: Added.
* fast/history/resources/subframe-with-plugin.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
MediaStream API: Moving Add/Remove track from WebMediaStreamCenterClient to WebMediaStream
https://bugs.webkit.org/show_bug.cgi?id=120872

Reviewed by Jer Noble.

Merge https://chromium.googlesource.com/chromium/blink/+/7d740fd27c1f345b59c846df01c3adce53c18e6e
Simple cleanup that makes the API cleaner.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::removeTrack):
(WebCore::MediaStream::addRemoteTrack):
(WebCore::MediaStream::removeRemoteTrack):
* platform/mediastream/MediaStreamCenter.cpp:
* platform/mediastream/MediaStreamCenter.h:
* platform/mediastream/MediaStreamDescriptor.h:
(WebCore::MediaStreamDescriptor::removeAudioComponent):
(WebCore::MediaStreamDescriptor::addRemoteTrack):
(WebCore::MediaStreamDescriptor::removeRemoteTrack):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155362 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, fix build.

* Modules/encryptedmedia/MediaKeySession.h:



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