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