Add ElementTraversal::next/previousSibling
https://bugs.webkit.org/show_bug.cgi?id=119681

Reviewed by Andreas Kling.

Add nextSibling/previousSibling/lastWithin to ElementTraversal namespace.
        
- Use them to replace internal use of Element::next/previousElementSibling DOM API for traversal.
- Replace some Node::nextSibling() usage with ElementTraversal::nextSibling() for tighter code.
- Replace ElementTraversal::nextSkippingChildren where it is used to traverse over immediate children only.

* css/SelectorChecker.cpp:
(WebCore::isFirstChildElement):
(WebCore::isLastChildElement):
(WebCore::isFirstOfType):
(WebCore::isLastOfType):
(WebCore::countElementsBefore):
(WebCore::countElementsOfTypeBefore):
(WebCore::countElementsAfter):
(WebCore::countElementsOfTypeAfter):
* dom/Element.cpp:
(WebCore::Element::lastElementChild):
(WebCore::Element::previousElementSibling):
(WebCore::Element::nextElementSibling):
* dom/Element.h:
* dom/ElementTraversal.h:
(WebCore::ElementTraversal::lastElementWithinTemplate):
(WebCore::ElementTraversal::lastWithin):
(WebCore::ElementTraversal::traverseNextSiblingElementTemplate):
(WebCore::ElementTraversal::nextSibling):
(WebCore::ElementTraversal::traversePreviousSiblingElementTemplate):
(WebCore::ElementTraversal::previousSibling):
* editing/ApplyStyleCommand.cpp:
(WebCore::isSpanWithoutAttributesOrUnstyledStyleSpan):
(WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::breakOutOfEmptyListItem):
* editing/IndentOutdentCommand.cpp:
(WebCore::IndentOutdentCommand::tryIndentingAsListItem):
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::mergeWithNeighboringLists):
* editing/markup.cpp:
(WebCore::createContextualFragment):
* html/HTMLCollection.cpp:
(WebCore::firstMatchingChildElement):
(WebCore::nextMatchingSiblingElement):
(WebCore::HTMLCollection::traverseNextElement):
(WebCore::HTMLCollection::traverseForwardToOffset):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::childrenChanged):
(WebCore::HTMLFieldSetElement::legend):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::finishParsingChildren):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::containsJavaApplet):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
* style/StyleResolveTree.cpp:
(WebCore::Style::resolveTree):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::title):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153942 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Win] TestWebKitAPI fails to link.
https://bugs.webkit.org/show_bug.cgi?id=119619

Patch by peavo@outlook.com <peavo@outlook.com> on 2013-08-12
Reviewed by Brent Fulgham.

* WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: Export needed symbol.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Curl] Crash when starting second download.
https://bugs.webkit.org/show_bug.cgi?id=119620

Patch by peavo@outlook.com <peavo@outlook.com> on 2013-08-12
Reviewed by Brent Fulgham.

When a second download is started, a crash sometimes occurs in Curl.
This happens because the Curl easy handle is deleted and removed from the Curl multi handle twice.
This is solved by adding an array to keep track of active downloads to avoid double deletion.

* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownloadManager::CurlDownloadManager): Removed active download count member.
(WebCore::CurlDownloadManager::getActiveDownloadCount): Use active download array to return active download count.
(WebCore::CurlDownloadManager::updateHandleList): Remove Curl handles before adding, in case Curl reuses handles.
(WebCore::CurlDownloadManager::addToCurl): Add Curl handle to active download array.
(WebCore::CurlDownloadManager::removeFromCurl): Check if Curl handle is in active download array to avoid double deletion.
(WebCore::CurlDownloadManager::downloadThread): Removed active download count member.
* platform/network/curl/CurlDownload.h: Added array of active downloads member, and removed download count member.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153944 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Revert r153912 because it broke some track tests.

Rubber-stamped by Antti Koivisto.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged):
(WebCore::MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153945 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Curl] Cookie is not set when url string is unicode.
https://bugs.webkit.org/show_bug.cgi?id=119545

Patch by peavo@outlook.com <peavo@outlook.com> on 2013-08-12
Reviewed by Brent Fulgham.

When the method setCookiesFromDOM is called with an unicode url parameter, the cookie is not correctly set.
We need to convert the cookie string to 8 bit, before passing it to the Curl api function.

* platform/network/curl/CookieJarCurl.cpp:
(WebCore::setCookiesFromDOM): Convert cookie string to 8 bit, if needed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153946 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] Don't load GAIL when using GTK 3.2 or greater
https://bugs.webkit.org/show_bug.cgi?id=72735

Patch by Anton Obzhirov <a.obzhirov@samsung.com> on 2013-08-12
Reviewed by Carlos Garcia Campos.

Source/WebKit/gtk:

* tests/testatk.c:
(initializeTestingFramework):
(main):

Source/WebKit2:

* UIProcess/API/gtk/tests/AccessibilityTestServer.cpp:
(main):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153947 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Shadows don't support viewport units
https://bugs.webkit.org/show_bug.cgi?id=119649

Reviewed by Darin Adler.

Source/WebCore:

We don't yet support viewport units in shadows, so
fail parsing if we see one. The bug to fix this
completely is: https://webkit.org/b/119650

Test: fast/css/shadow-viewport-units.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseShadow): Fail if we get one of
vh, vw, vmin, vmax.

LayoutTests:

Test that exercises a viewport unit in text-shadow to make sure we don't parse it.

* fast/css/shadow-viewport-units-expected.txt: Added.
* fast/css/shadow-viewport-units.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153948 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt] [WebKit2] Remove duplicate RAM Size calculation and reuse WTF::ramSize()
https://bugs.webkit.org/show_bug.cgi?id=119663

Patch by Arunprasad Rajkumar <arurajku@cisco.com> on 2013-08-12
Reviewed by Sam Weinig.

* WebProcess/qt/WebProcessQt.cpp:
(WebKit::WebProcess::platformSetCacheModel):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] isMainThread implementation with USE(WEB_THREAD)
https://bugs.webkit.org/show_bug.cgi?id=119644

Reviewed by Benjamin Poulain.

On iOS isMainThread() means that the current thread is either the
MainThread or WebThread and the current thread has the WebThreadLock.

* wtf/ios/WebCoreThread.cpp: Added.
* wtf/ios/WebCoreThread.h: Added.
* wtf/mac/MainThreadMac.mm:
(WTF::isMainThread):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153950 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Broken build with build-webkit --no-webgl
https://bugs.webkit.org/show_bug.cgi?id=119272

Patch by Ragner Magalhaes <ranger.n@samsung.com> on 2013-08-12
Reviewed by Alexandru Chiculita.

CSS_SHADERS requires WEBGL enabled.
Add error message to dependency failure.

* wtf/FeatureDefines.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
dataLog dumpers for WebCore's basic geometry types
https://bugs.webkit.org/show_bug.cgi?id=119636

Reviewed by Filip Pizlo.

* platform/graphics/FloatPoint.cpp:
(WebCore::FloatPoint::dump):
* platform/graphics/FloatPoint.h:
* platform/graphics/FloatRect.cpp:
(WebCore::FloatRect::dump):
* platform/graphics/FloatRect.h:
* platform/graphics/FloatSize.cpp:
(WebCore::FloatSize::dump):
* platform/graphics/FloatSize.h:
* platform/graphics/IntPoint.h:
(WebCore::IntPoint::dump):
* platform/graphics/IntRect.cpp:
(WebCore::IntRect::dump):
* platform/graphics/IntRect.h:
* platform/graphics/IntSize.h:
(WebCore::IntSize::dump):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153952 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Multiple CSP tests complain about undefined strings in echo-object-data.pl and echo-script-src.pl
https://bugs.webkit.org/show_bug.cgi?id=119692

Reviewed by Darin Adler.

* http/tests/security/contentSecurityPolicy/resources/echo-object-data.pl:
* http/tests/security/contentSecurityPolicy/resources/echo-script-src.pl:
Check whether optional CGI parameters are provided.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove glu's libtest rule from checker.py
https://bugs.webkit.org/show_bug.cgi?id=119674

Reviewed by Darin Adler.

* Scripts/webkitpy/style/checker.py: It is no longer used after r148032.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153954 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Define DOM_KEY_LOCATION_* constants on KeyboardEvent
https://bugs.webkit.org/show_bug.cgi?id=119341

Reviewed by Ryosuke Niwa.

Source/WebCore:

Add support for the DOM_KEY_LOCATION_* constants on KeyboardEvent as per
the specification:
http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent

Those constants are already supported by IE10, Firefox 22 and since
recently Blink.

Note that the following constants are not supported / exposed yet:
DOM_KEY_LOCATION_MOBILE and DOM_KEY_LOCATION_JOYSTICK.

Test: fast/events/keyboardevent-location-constants.html

* dom/KeyboardEvent.cpp:
(WebCore::keyLocationCode):
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/KeyboardEvent.h:
* dom/KeyboardEvent.idl:

LayoutTests:

Make use of the new DOM_KEY_LOCATION_* constants in the KeyboardEvent
test cases instead of hardcoding their values.

* fast/events/constructors/keyboard-event-constructor-expected.txt:
* fast/events/constructors/keyboard-event-constructor.html:
* fast/events/js-keyboard-event-creation-expected.txt:
* fast/events/js-keyboard-event-creation.html:
* fast/events/keyboardevent-location-constants-expected.txt: Added.
* fast/events/keyboardevent-location-constants.html: Added.
* fast/events/keydown-leftright-keys-expected.txt:
* fast/events/keydown-leftright-keys.html:
* fast/events/keydown-numpad-keys-expected.txt:
* fast/events/script-tests/keydown-numpad-keys.js:
(testKeyEventWithLocation):
* platform/efl/fast/events/js-keyboard-event-creation-expected.txt:
* platform/gtk/fast/events/js-keyboard-event-creation-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove didNewFirstVisuallyNonEmptyLayout from WebKit2
https://bugs.webkit.org/show_bug.cgi?id=119658

Reviewed by Darin Adler.

Source/WebKit2: 

Removing this function entirely will change some functionality in the Nightlies, 
but we think that is an acceptable difference for the Nightlies. If is does cause 
a problem though, we can roll out this patch and deprecate the function instead.

* UIProcess/API/C/WKPage.h:
* UIProcess/WebLoaderClient.cpp:
* UIProcess/WebLoaderClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::initializeLoaderClient):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidLayout):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::initializeInjectedBundleLoaderClient):

Tools: 

* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController awakeFromNib]):
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::InjectedBundlePage):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
The LayoutMilestones didLayout callback should only fire for the main frame
https://bugs.webkit.org/show_bug.cgi?id=119457

Reviewed by Sam Weinig.

Source/WebCore: 

This patch makes it so that FrameLoader::didLayout(LayoutMilestones) is only ever 
called for the main frame. Technically this will change existing API for 
didFirstVisuallyNonEmptyLayoutInFrame and didFirstLayoutInFrame. Clients used to 
be able to register for those callbacks for any frame they wanted, however, now 
they will only ever get the callback when it applies to the main frame. We think 
that this is acceptable since we don’t know of any clients that ever used those 
APIs for a non-main frame. This change also makes nothing but sense for the 
didLayout(LayoutMilestones) callback, since that is a Page-level concept, so it 
should only fire for the main frame.

Only call didLayout for the main frame.
* dom/Document.cpp:
(WebCore::Document::setVisualUpdatesAllowed):

Assert that this is the main frame.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didLayout):

Only call didLayout for the main frame.
* page/FrameView.cpp:
(WebCore::FrameView::performPostLayoutTasks):

Tools: 

Now that the didLayout callback only fires for the main frame, we want to make 
sure it will fire even when all of the content is in a subframe.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/LayoutMilestonesWithAllContentInFrame.cpp: Added.
(TestWebKitAPI::didLayout):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/all-content-in-one-iframe.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use const AtomicStringImpl* in DocumentOrderedMap
https://bugs.webkit.org/show_bug.cgi?id=119700

Reviewed by Benjamin Poulain.

Use const AtomicStringImpl* in DocumentOrderedMap. It caught at least one bug that HTMLNameCollection'
subclasses' nodeMatches were taking const AtomicString& instead of AtomicStringImpl*. This was forcing
DocumentOrderedMap::getElementByWindowNamedItem and DocumentOrderedMap::getElementByDocumentNamedItem
to create temporary AtomicStrings.

* dom/DocumentOrderedMap.cpp:
(WebCore::keyMatchesId):
(WebCore::keyMatchesName):
(WebCore::keyMatchesMapName):
(WebCore::keyMatchesLowercasedMapName):
(WebCore::keyMatchesLabelForAttribute):
(WebCore::keyMatchesWindowNamedItem):
(WebCore::keyMatchesDocumentNamedItem):
(WebCore::DocumentOrderedMap::add):
(WebCore::DocumentOrderedMap::remove):
(WebCore::DocumentOrderedMap::get):
(WebCore::DocumentOrderedMap::getElementById):
(WebCore::DocumentOrderedMap::getElementByName):
(WebCore::DocumentOrderedMap::getElementByMapName):
(WebCore::DocumentOrderedMap::getElementByLowercasedMapName):
(WebCore::DocumentOrderedMap::getElementByLabelForAttribute):
(WebCore::DocumentOrderedMap::getElementByWindowNamedItem):
(WebCore::DocumentOrderedMap::getElementByDocumentNamedItem):
(WebCore::DocumentOrderedMap::getAllElementsById):
* dom/DocumentOrderedMap.h:
(WebCore::DocumentOrderedMap::containsSingle):
(WebCore::DocumentOrderedMap::contains):
(WebCore::DocumentOrderedMap::containsMultiple):
* html/HTMLNameCollection.cpp:
(WebCore::WindowNameCollection::nodeMatches):
(WebCore::DocumentNameCollection::nodeMatches):
* html/HTMLNameCollection.h:
(WebCore::WindowNameCollection::nodeMatches):
(WebCore::DocumentNameCollection::nodeMatches):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Layout Test fast/overflow/scrollbar-click-retains-focus.html is failing on Apple Mac WK1 and GTK.
https://bugs.webkit.org/show_bug.cgi?id=104104

Add back test expectation for Mac since it's still failing on ML WK1 bots.

* platform/mac/TestExpectations:
* platform/mac-wk2/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[cairo] memory corruption with putImageData and accelerated canvas.
https://bugs.webkit.org/show_bug.cgi?id=118621

Reviewed by Martin Robinson.

When we have an accelerated imageBuffer, and we putByteArray with a
non zero destPoint, we create temporary surface of sourceSize. Then,
we write to image data with an offset. This results in an out of bound
write.

In order to avoid that, we use a 0 offset when writing data.

In addition, we also create image with the minimal needed size in
getImageData, and also use a 0 offset. This decrease data transfer
between cpu and gpu

Instead of the map/unmap mechanism, perform an explicit surface copy
when needed. This change also removes an unneeded glReadPixels at the
start of putByteArray

Add two parameters to copyRectFromOneSurfaceToAnother: destination
offset, and cairo drawing operator.

No new tests. Accelerated canvas is not enabled for testing yet.

* platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::copyRectFromOneSurfaceToAnother):
* platform/graphics/cairo/CairoUtilities.h:
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::copySurfaceToImageAndAdjustRect):
(WebCore::getImageData):
(WebCore::ImageBuffer::putByteArray):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153961 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Stop making unnecessary copy of CodeBlock Identifier Vector
https://bugs.webkit.org/show_bug.cgi?id=119702

Reviewed by Michael Saboff.

Make CodeBlock simply use a separate Vector for additional Identifiers
and use the UnlinkedCodeBlock for the initial set of identifiers.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::printGetByIdOp):
(JSC::dumpStructure):
(JSC::dumpChain):
(JSC::CodeBlock::printGetByIdCacheStatus):
(JSC::CodeBlock::printPutByIdOp):
(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::shrinkToFit):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::numberOfIdentifiers):
(JSC::CodeBlock::numberOfAdditionalIdentifiers):
(JSC::CodeBlock::addAdditionalIdentifier):
(JSC::CodeBlock::identifier):
* dfg/DFGDesiredIdentifiers.cpp:
(JSC::DFG::DesiredIdentifiers::reallyAdd):
* jit/JIT.h:
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_get_arguments_length):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_by_id):
(JSC::JIT::compileGetByIdHotPath):
(JSC::JIT::emitSlow_op_get_by_id):
(JSC::JIT::compileGetByIdSlowCase):
(JSC::JIT::emitSlow_op_put_by_id):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_by_id):
(JSC::JIT::compileGetByIdHotPath):
(JSC::JIT::compileGetByIdSlowCase):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):

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