Factor descendant iterator assertions into a class.
https://bugs.webkit.org/show_bug.cgi?id=120422

Reviewed by Darin Adler.

Share the assertions between ChildIterator and DescendantIterator. We can use it for future const iterators too.

* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/ChildIterator.h:
(WebCore::::ChildIterator):
(WebCore::::operator):
(WebCore::=):
* dom/DescendantIterator.h:
(WebCore::::DescendantIterator):
(WebCore::::operator):
(WebCore::=):
* dom/DescendantIteratorAssertions.h: Added.
(WebCore::DescendantIteratorAssertions::DescendantIteratorAssertions):
(WebCore::DescendantIteratorAssertions::domTreeHasMutated):
(WebCore::DescendantIteratorAssertions::dropEventDispatchAssertion):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Qt] Option key combinations do not work in Input Elements.
https://bugs.webkit.org/show_bug.cgi?id=120423

Q_WS_MAC is obsolete. We should use Q_OS_MAC instead.
This caused QTBUG-32388.

Reviewed by Darin Adler.

* WebCoreSupport/EditorClientQt.cpp:
(WebCore::EditorClientQt::handleKeyboardEvent):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154752 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Grid Layout] Handle 'span' positions during layout
https://bugs.webkit.org/show_bug.cgi?id=119756

Reviewed by Andreas Kling.

From Blink r149133 by <jchaffraix@chromium.org>

Source/WebCore:

Properly handle the 'span' keyword during layout. We only had
parsing support so far but with this change we are able to
recognize these positions and act accordingly.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::resolveGridPositionsFromStyle):
(WebCore::RenderGrid::resolveGridPositionAgainstOppositePosition):
* rendering/RenderGrid.h:
* rendering/style/GridPosition.h:
(WebCore::GridPosition::shouldBeResolvedAgainstOppositePosition):

LayoutTests:

Added some new test cases to verify that we properly resolve
'span' positions.

* fast/css-grid-layout/grid-item-negative-position-resolution-expected.txt:
* fast/css-grid-layout/grid-item-negative-position-resolution.html:
* fast/css-grid-layout/grid-item-spanning-resolution-expected.txt:
* fast/css-grid-layout/grid-item-spanning-resolution.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154753 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Resolve unused parameter warning in ScriptedAnimationController.cpp.
https://bugs.webkit.org/show_bug.cgi?id=120408

Patch by Tamas Czene <tczene@inf.u-szeged.hu> on 2013-08-28
Reviewed by Darin Adler.

* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::setThrottled):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154754 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[wk2] Resolve unused parameter warnings in the WebProcess.cpp
https://bugs.webkit.org/show_bug.cgi?id=120412

Patch by Tamas Czene <tczene@inf.u-szeged.hu> on 2013-08-28
Reviewed by Darin Adler.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::startMemorySampler):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154755 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[wk2] Resolve unused parameters in WebPlatformStrategies.cpp
https://bugs.webkit.org/show_bug.cgi?id=120410

Patch by Tamas Czene <tczene@inf.u-szeged.hu> on 2013-08-28
Reviewed by Darin Adler.

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::getPluginInfo):
(WebKit::WebPlatformStrategies::transientLocalStorageNamespace):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154756 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Exclusions] Differentiate names in the simple rectangle test script
https://bugs.webkit.org/show_bug.cgi?id=105208

Patch by Niklas Nielsen <nnielsen@adobe.com> on 2013-08-28
Reviewed by Alexandru Chiculita.

Rename createRectangleTest and createRectangleTestResult to drawTestRectangle and drawExpectedRectangle respectively.

* fast/shapes/resources/simple-rectangle.js:
(drawTextRectangle):
(drawExpectedRectangle):
* fast/shapes/shape-inside/shape-inside-floats-simple-expected.html:
* fast/shapes/shape-inside/shape-inside-floats-simple.html:
* fast/shapes/shape-inside/shape-inside-multiple-blocks-dynamic-expected.html:
* fast/shapes/shape-inside/shape-inside-multiple-blocks-dynamic.html:
* fast/shapes/shape-inside/shape-inside-outside-shape-expected.html:
* fast/shapes/shape-inside/shape-inside-outside-shape.html:
* fast/shapes/shape-inside/shape-inside-recursive-layout-expected.html:
* fast/shapes/shape-inside/shape-inside-recursive-layout.html:
* fast/shapes/shape-inside/shape-inside-subsequent-blocks-expected.html:
* fast/shapes/shape-inside/shape-inside-subsequent-blocks.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154757 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Code cleanup: rename FloatIntervalSearchAdapter and remove unnecessary inlines
https://bugs.webkit.org/show_bug.cgi?id=120378

Reviewed by Darin Adler.

Rename FloatIntervalSearchAdapter to ComputeFloatOffsetAdapter. The
naming of this adapter has caused much confusion in reading the code,
as it wasn't apparent that calls to it were actually doing anything
other than searching the interval tree. The new name is a much better
description of what it actually does.

Also, rename m_lowValue and m_highValue member variables to make it
easier to read the code that uses them.

Removed the inlines based on a change by eseidel in Blink.

No new tests, no behavior change.

* rendering/RenderBlock.cpp:
(WebCore::::updateOffsetIfNeeded): Update for renames.
(WebCore::::collectIfNeeded): Ditto.
(WebCore::::getHeightRemaining): Ditto.
(WebCore::RenderBlock::logicalLeftFloatOffsetForLine): Ditto.
(WebCore::RenderBlock::logicalRightFloatOffsetForLine): Ditto.
* rendering/RenderBlock.h:
(WebCore::RenderBlock::FloatingObject::x): Remove unnecessary inline.
(WebCore::RenderBlock::FloatingObject::maxX): Ditto.
(WebCore::RenderBlock::FloatingObject::y): Ditto.
(WebCore::RenderBlock::FloatingObject::maxY): Ditto.
(WebCore::RenderBlock::FloatingObject::width): Ditto.
(WebCore::RenderBlock::FloatingObject::height): Ditto.
(WebCore::RenderBlock::ComputeFloatOffsetAdapter::ComputeFloatOffsetAdapter): Rename.
(WebCore::RenderBlock::ComputeFloatOffsetAdapter::lowValue): Rename m_lowValue.
(WebCore::RenderBlock::ComputeFloatOffsetAdapter::highValue): Rename m_highValue.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Loader is not properly determining supported MIME types
https://bugs.webkit.org/show_bug.cgi?id=120383

Reviewed by Eric Carlson.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::canShowMIMEType): Modify to ask WebView if it can
display the media type. Use new helper function to avoid converting a String
to BSTR, only to immediatly be converted from BSTR back to String.
(WebFrameLoaderClient::canShowMIMETypeAsHTML): Ditto.
* WebView.cpp:
(WebView::canShowMIMEType): Move logic to a new (similarly named) helper function.
(WebView::canShowMIMETypeAsHTML): Ditto.
* WebView.h: Add declaration for two new helper functions.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154759 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Duplicate in-band tracks when switching <source> elements
https://bugs.webkit.org/show_bug.cgi?id=120369

Patch by Brendan Long <b.long@cablelabs.com> on 2013-08-28
Reviewed by Eric Carlson.

Source/WebCore:

Test: media/track/track-in-band-duplicate-tracks-when-source-changes.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::createMediaPlayer):
Delete existing in-band tracks before creating a new media player.

LayoutTests:

* media/track/track-in-band-duplicate-tracks-when-source-changes.html: Added.
* media/track/track-in-band-duplicate-tracks-when-source-changes-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Don't keep unassociated elements in the past names map
https://bugs.webkit.org/show_bug.cgi?id=120328

Reviewed by Darin Adler.

Source/WebCore: 

Remove elements from the past names map of a form element when they are disassociated with the form to match
the behaviors of Firefox 24 and Internet Explorer 10. The specification feedback has been submitted to WHATWG
in http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-August/040586.html

Also fix a memory leak via the past names map when the elements in the map becomes an ancestor of the form
element by storing a raw pointer in the map. This is safe because the form associated elements are kept alive
by another mechanism.

Because ~FormAssociatedElement removes entries from the past names map, we could no longer store HTMLElement*
in HTMLFormElement::m_pastNamesMap as that requires casting FormAssociatedElement* to HTMLElement*, which is
not possible in ~FormAssociatedElement. We instead store pointers to FormNamedItem, new base class of
FormAssociatedElement and HTMLImageElement.

Test: fast/forms/past-names-map-should-not-contained-disassociated-elements.html

* Target.pri:
* WebCore.exp.in:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* html/FormAssociatedElement.cpp:
* html/FormAssociatedElement.h:
(WebCore::toHTMLElement):

* html/FormNamedItem.h: Added.
(WebCore::FormNamedItem::~FormNamedItem):

* html/HTMLElement.h:
(WebCore::HTMLElement::asFormNamedItem): Added. This allows the conversion from a HTMLFormControlElement,
HTMLObjectElement, HTMLImageElement to FormNamedItem in getNamedElements to update the past names map.

* html/HTMLFormControlElement.h:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::removeFormElement):
(WebCore::HTMLFormElement::removeImgElement):
(WebCore::HTMLFormElement::assertItemCanBeInPastNamesMap): Asserts that FormNamedItem added to or obtained
from the past names map is either a form associated element or an image element; the condition guarantees
that the item will be removed from the map before its element gets destructed.

(WebCore::HTMLFormElement::elementFromPastNamesMap):
(WebCore::HTMLFormElement::addToPastNamesMap):
(WebCore::HTMLFormElement::removeFromPastNamesMap): Finds and removes the obsolete item from the map in O(n).
Note that removeFromVector, which is called on m_associatedElements or m_imageElements before this function is called,
is already O(n).

(WebCore::HTMLFormElement::getNamedElements):

* html/HTMLFormElement.h:
* html/HTMLImageElement.h:
* html/HTMLObjectElement.h:

LayoutTests: 

Add a regression test. Also Updated the tests to expect the new behavior in which elements are not accessible via
their past names in a form element's name getter once they're disassociated with the form element.

* fast/forms/form-image-access-by-name-expected.txt:
* fast/forms/form-image-access-by-name.html:
* fast/forms/old-names-expected.txt:
* fast/forms/old-names.html:
* fast/forms/past-names-map-should-not-contained-disassociated-elements-expected.txt: Added.
* fast/forms/past-names-map-should-not-contained-disassociated-elements.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154761 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix a typo in the test name.

* fast/forms/past-names-map-should-not-contain-disassociated-elements-expected.txt: Copied from LayoutTests/fast/forms/past-names-map-should-not-contained-disassociated-elements-expected.txt.
* fast/forms/past-names-map-should-not-contain-disassociated-elements.html: Copied from LayoutTests/fast/forms/past-names-map-should-not-contained-disassociated-elements.html.
* fast/forms/past-names-map-should-not-contained-disassociated-elements-expected.txt: Removed.
* fast/forms/past-names-map-should-not-contained-disassociated-elements.html: Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154762 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Allow the Flash plug-in to open its preference pane
https://bugs.webkit.org/show_bug.cgi?id=120431
<rdar://problem/14857039>

Reviewed by Andreas Kling.

Forward the -[NSWorkspace openFile:] call to the UI process and allow opening
the Flash preference pane (if Flash asks for it).

* PluginProcess/PluginProcess.h:
* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::replacedNSWorkspace_openFile):
(WebKit::initializeCocoaOverrides):
(WebKit::PluginProcess::openFile):
* UIProcess/Plugins/PluginProcessProxy.h:
* UIProcess/Plugins/PluginProcessProxy.messages.in:
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::openURL):
(WebKit::shouldOpenFile):
(WebKit::PluginProcessProxy::openFile):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154763 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Provide useful error messages for WebKitErrorDomain errors
https://bugs.webkit.org/show_bug.cgi?id=120428

Reviewed by Anders Carlsson.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::cancelledError): Provide text for this error.
(WebFrameLoaderClient::blockedError): Hook up WEB_UI_STRING for this error.
(WebFrameLoaderClient::cannotShowURLError): Ditto
(WebFrameLoaderClient::interruptedForPolicyChangeError): Ditto
(WebFrameLoaderClient::cannotShowMIMETypeError): Ditto
(WebFrameLoaderClient::fileDoesNotExistError): Provide text for this error.
(WebFrameLoaderClient::pluginWillHandleLoadError): Hook up WEB_UI_STRING for this error.
(WebFrameLoaderClient::dispatchDidFailToStartPlugin): Ditto.
(WebFrameLoaderClient::createJavaAppletWidget): Ditto.
(WebFrameLoaderClient::webHistory): Remove blank line above method.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154764 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION(r154586): Past names map should only be used when named item is empty
https://bugs.webkit.org/show_bug.cgi?id=120432

Reviewed by Anders Carlsson.

Source/WebCore: 

Don't add the element from the past names map if we've found elements of the given name.

Test: fast/forms/past-names-map-should-be-used-only-when-named-item-is-empty.html

* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::getNamedElements):

LayoutTests: 

Add a regression test so that we never regress again.

* fast/forms/past-names-map-should-be-used-only-when-named-item-is-empty-expected.txt: Added.
* fast/forms/past-names-map-should-be-used-only-when-named-item-is-empty.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154765 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Document::elementSheet() should return a reference
https://bugs.webkit.org/show_bug.cgi?id=120433

Reviewed by Andreas Kling.

Since elementSheet() always retruns a valid pointer, we can simply return a reference
instead. Also rename m_elemSheet to m_elementSheet.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseInlineStyleDeclaration):
* css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::InlineCSSStyleDeclaration::parentStyleSheet):
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore::Document::recalcStyle):
(WebCore::Document::updateBaseURL):
(WebCore::Document::elementSheet):
* dom/Document.h:
* dom/StyledElement.cpp:
(WebCore::StyledElement::setInlineStyleFromString):
(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::addSubresourceAttributeURLs):
(WebCore::StyledElement::addPropertyToPresentationAttributeStyle):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
AX:Null pointer may be dereferenced.
https://bugs.webkit.org/show_bug.cgi?id=120300

Patch by Lukasz Gajowy <l.gajowy@samsung.com> on 2013-08-28
Reviewed by Chris Fleizach.

Added a check if newObj is not null and an assert in order to avoid dereferecing null pointer.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::getOrCreate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add child and descendant const iterators
https://bugs.webkit.org/show_bug.cgi?id=120430

Reviewed by Andreas Kling

This patch adds const-correct DOM tree traversal iterators. It also uses them in a few places.
        
Some const_casts have been applied where constness breaks.

* dom/ChildIterator.h:
(WebCore::::ChildConstIterator):
(WebCore::::operator):
(WebCore::=):
(WebCore::::ChildConstIteratorAdapter):
(WebCore::::begin):
(WebCore::::end):
(WebCore::elementChildren):
(WebCore::childrenOfType):
* dom/DescendantIterator.h:
(WebCore::::DescendantConstIterator):
(WebCore::::operator):
(WebCore::=):
(WebCore::::DescendantConstIteratorAdapter):
(WebCore::::begin):
(WebCore::::end):
(WebCore::elementDescendants):
(WebCore::descendantsOfType):
* dom/Node.cpp:
(WebCore::Node::numberOfScopedHTMLStyleChildren):
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::legend):
* html/HTMLFieldSetElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::finishParsingChildren):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::containsJavaApplet):
* svg/SVGElement.cpp:
(WebCore::SVGElement::title):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::collectIntersectionOrEnclosureList):
(WebCore::SVGSVGElement::checkIntersection):
(WebCore::SVGSVGElement::checkEnclosure):
(WebCore::SVGSVGElement::getElementById):
* svg/SVGSVGElement.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
MediaPlayerPrivateAVFoundationObjC is painting video frames under the video layer
https://bugs.webkit.org/show_bug.cgi?id=120170

Reviewed by Simon Fraser.

No new tests, it is only possible to test in the debugger.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame): Drive by optimization.
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext): Move logic from paint here.
(WebCore::MediaPlayerPrivateAVFoundationObjC::paint): Do nothing if we already have a video layer,
    otherwise call paint().


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154775 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Decrease number of workers used in NRWT by the Windows port.
https://bugs.webkit.org/show_bug.cgi?id=120435.

Reviewed by Brent Fulgham.

* Scripts/webkitpy/port/win.py:
(WinPort.default_child_processes):


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