Add common base for element iterators
https://bugs.webkit.org/show_bug.cgi?id=120557

Reviewed by Andreas Kling.

Add ElementIterator and use it as the base for child and descendant iterators. The only difference is the definition of operator++.
        
Also renamed DescendantIteratorAssertions to ElementIteratorAssertions.

* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/ChildIterator.h:
(WebCore::::ChildIterator):
(WebCore::::operator):
(WebCore::::ChildConstIterator):
(WebCore::::begin):
(WebCore::::end):
* dom/DescendantIterator.h:
(WebCore::::DescendantIterator):
(WebCore::::operator):
(WebCore::::DescendantConstIterator):
* dom/DescendantIteratorAssertions.h: Removed.
* dom/ElementIterator.h: Added.
(WebCore::::ElementIterator):
(WebCore::::traverseNext):
(WebCore::::traversePrevious):
(WebCore::::traverseNextSibling):
(WebCore::::traversePreviousSibling):
(WebCore::::operator):
(WebCore::=):
(WebCore::::ElementConstIterator):
* dom/ElementIteratorAssertions.h: Copied from Source/WebCore/dom/DescendantIteratorAssertions.h.
(WebCore::ElementIteratorAssertions::ElementIteratorAssertions):
(WebCore::ElementIteratorAssertions::domTreeHasMutated):
(WebCore::ElementIteratorAssertions::dropEventDispatchAssertion):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Don't do document style recalc unless there's a RenderView.
<https://webkit.org/b/120558>

Reviewed by Antti Koivisto.

There's no sense in computing style for a Document that has no RenderView.
Checking this before continuing also lets us know that there's a Frame & FrameView
present, simplifying some things later on.

* dom/Document.cpp:
(WebCore::Document::recalcStyle):
* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154927 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Rename ChildIterator -> ElementChildIterator, DescendantIterator -> ElementDescendantIterator
https://bugs.webkit.org/show_bug.cgi?id=120561

Reviewed by Andreas Kling.

New names are more descriptive and consistent. They also put related iterator files close by in file lists.
The types are always used with auto so longer names don't make them any clumsier to use.

For simplicity included all Element iterator types from ElementIterator.h so it is the only file that has
to be included by the clients.

* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* accessibility/AccessibilityNodeObject.cpp:
* accessibility/AccessibilityRenderObject.cpp:
* accessibility/AccessibilityTable.cpp:
* css/CSSFontFaceSource.cpp:
* dom/ChildIterator.h: Removed.
* dom/DescendantIterator.h: Removed.
* dom/Document.cpp:
* dom/ElementChildIterator.h: Copied from Source/WebCore/dom/ChildIterator.h.
(WebCore::::ElementChildIterator):
(WebCore::::operator):
(WebCore::::ElementChildConstIterator):
(WebCore::::ElementChildIteratorAdapter):
(WebCore::::begin):
(WebCore::::end):
(WebCore::::ElementChildConstIteratorAdapter):
(WebCore::elementChildren):
(WebCore::childrenOfType):
* dom/ElementDescendantIterator.h: Copied from Source/WebCore/dom/DescendantIterator.h.
(WebCore::::ElementDescendantIterator):
(WebCore::::operator):
(WebCore::::ElementDescendantConstIterator):
(WebCore::::ElementDescendantIteratorAdapter):
(WebCore::::begin):
(WebCore::::end):
(WebCore::::ElementDescendantConstIteratorAdapter):
(WebCore::elementDescendants):
(WebCore::descendantsOfType):
* dom/ElementIterator.h:
* dom/Node.cpp:
* dom/TreeScope.cpp:
* editing/ApplyStyleCommand.cpp:
* editing/markup.cpp:
* html/HTMLAppletElement.cpp:
* html/HTMLFieldSetElement.cpp:
* html/HTMLLabelElement.cpp:
* html/HTMLMapElement.cpp:
* html/HTMLMediaElement.cpp:
* html/HTMLObjectElement.cpp:
* loader/PlaceholderDocument.cpp:
* rendering/FilterEffectRenderer.cpp:
* style/StyleResolveTree.cpp:
* svg/SVGElement.cpp:
* svg/SVGSVGElement.cpp:
* svg/animation/SMILTimeContainer.cpp:
* svg/graphics/SVGImage.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154928 268f45cc-cd09-0410-ab3c-d52691b4dbfc
PostAttachCallbackDisabler should take a ContainerNode&.
<https://webkit.org/b/120560>

Reviewed by Antti Koivisto.

Let PostAttachCallbackDisabler take a reference and remove an ugly assertion.

* dom/ContainerNode.h:
(WebCore::PostAttachCallbackDisabler::PostAttachCallbackDisabler):
(WebCore::PostAttachCallbackDisabler::~PostAttachCallbackDisabler):
* dom/Document.cpp:
(WebCore::Document::recalcStyle):
* style/StyleResolveTree.cpp:
(WebCore::Style::attachRenderTree):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove unused variable in LayerTreeHost
https://bugs.webkit.org/show_bug.cgi?id=118950

Patch by Jae Hyun Park <jae.park@company100.net> on 2013-08-31
Reviewed by Anders Carlsson.

m_waitingForUIProcess has been renamed to m_isWaitingForRenderer as of
r152183, and it is a private variable in CoordinatedLayerTreeHost. Thus,
we don't need m_waitingForUIProcess in LayerTreeHost.

* WebProcess/WebPage/LayerTreeHost.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
InlineBox::renderer() and pals should return references.
<https://webkit.org/b/120562>

Reviewed by Antti Koivisto.

Make InlineBox::renderer() and its friends return references instead of pointers.
Every box always has a renderer, so this clears up any ambiguity, and a number of
weird assertions in SVG code.

Made InlineBox::m_renderer private so subclasses have to go through renderer().
The next step will be to replace renderer() with tightly-typed accessors where
applicable (e.g InlineTextBox's renderer is always a RenderText.)

Also added reference versions of these RenderObject casts:

    - toRenderBox()
    - toRenderBlock()
    - toRenderInline()
    - toRenderSVGInlineText()


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
XMLSerializer-attribute-namespace-prefix-conflicts can't produce reliable results
https://bugs.webkit.org/show_bug.cgi?id=120490

Reviewed by Ryosuke Niwa.

Source/WebCore:

Retain the key of the namespaces map by using AtomicString as key instead of AtomicStringImpl*.

* editing/MarkupAccumulator.h:

LayoutTests:

Unskip these previously failing tests.

* TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix typo in r154931 that caused assertions in continuation tests.

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paint):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154933 268f45cc-cd09-0410-ab3c-d52691b4dbfc
warning: unused parameter point and area in EwkView.cpp:1390
https://bugs.webkit.org/show_bug.cgi?id=120545

Patch by Santosh Mahto <santosh.ma@samsung.com> on 2013-08-31
Reviewed by Darin Adler.

* UIProcess/API/efl/EwkView.cpp:
(EwkView::didFindZoomableArea): Added UNUSED_PARAM.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
CodeBlock refactoring broke profile dumping
https://bugs.webkit.org/show_bug.cgi?id=120551

Reviewed by Michael Saboff.
        
Fix the bug, and did a big clean-up of how Executable returns CodeBlocks. A lot
of the problems we have with code like CodeBlock::baselineVersion() is that we
were trying *way too hard* to side-step the fact that Executable can't return a
CodeBlock*. Previously it could only return CodeBlock&, so if it didn't have a
CodeBlock yet, you were screwed. And if you didn't know, or weren't sure, if it
did have a CodeBlock, you were really going to have a bad time. Also it really
bugs me that the methods were called generatedBytecode(). In all other contexts
if you ask for a CodeBlock, then method to call is codeBlock(). So I made all
of those changes.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::baselineVersion):
(JSC::ProgramCodeBlock::replacement):
(JSC::EvalCodeBlock::replacement):
(JSC::FunctionCodeBlock::replacement):
(JSC::CodeBlock::globalObjectFor):
* bytecode/CodeOrigin.cpp:
(JSC::InlineCallFrame::hash):
* dfg/DFGOperations.cpp:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
* jit/JITCode.h:
(JSC::JITCode::isExecutableScript):
(JSC::JITCode::isLowerTier):
* jit/JITStubs.cpp:
(JSC::lazyLinkFor):
(JSC::DEFINE_STUB_FUNCTION):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::traceFunctionPrologue):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
(JSC::LLInt::setUpCall):
* runtime/ArrayPrototype.cpp:
(JSC::isNumericCompareFunction):
* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::arityCheckFor):
* runtime/Executable.cpp:
(JSC::ScriptExecutable::installCode):
* runtime/Executable.h:
(JSC::EvalExecutable::codeBlock):
(JSC::ProgramExecutable::codeBlock):
(JSC::FunctionExecutable::eitherCodeBlock):
(JSC::FunctionExecutable::codeBlockForCall):
(JSC::FunctionExecutable::codeBlockForConstruct):
(JSC::FunctionExecutable::codeBlockFor):
* runtime/FunctionExecutableDump.cpp:
(JSC::FunctionExecutableDump::dump):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154935 268f45cc-cd09-0410-ab3c-d52691b4dbfc
warning: unused parameter ‘renderingMode'  in ImageBufferCairo.cpp:94
https://bugs.webkit.org/show_bug.cgi?id=120543

Patch by Santosh Mahto <santosh.ma@samsung.com> on 2013-08-31
Reviewed by Darin Adler.

Fixing warning by adding ASSERT_UNUSED.

* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::ImageBuffer):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make more use of toRenderFoo(RenderObject&) cast helpers.
<https://webkit.org/b/120565>

Reviewed by Darin Adler.

To make amends for putting ugly toRenderFoo(&renderer) casts everywhere,
here's a patch that switches a bunch of code over to using reference-based casts.

I removed pointer-based casts altogether for these renderers:

    - RenderBR
    - RenderCombineText
    - RenderListMarker
    - RenderVideo
    - RenderView


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
EditCommand constructors should take Document&.
<https://webkit.org/b/120566>

Reviewed by Darin Adler.

Let EditCommand's and all subclass constructors take Document& instead of Document*.
EditCommand::document() now returns a Document&.

Added Editor::document() which returns Editor::frame().document() after asserting
that it's non-null, to make passing a Document& from Editor functions easier.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154938 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Refactor URL and image writing so layer-violating parts are in Editor, not Pasteboard (Mac-only at first)
https://bugs.webkit.org/show_bug.cgi?id=120573

Reviewed by Andreas Kling.

* editing/Editor.cpp:
(WebCore::Editor::copy): Use writeImageToPasteboard instead of Pasteboard::writeImage on Mac.
(WebCore::Editor::copyURL): Use writeURLToPasteboard instead of Pasteboard::writeURL on Mac.
(WebCore::innerNonSharedElement): Added. Used in copyImage.
(WebCore::Editor::copyImage): Use innerNonSharedElement instead of innerNonSharedNode.
Use writeImageToPasteboard instead of Pasteboard::writeImage on Mac.

* editing/Editor.h: Add new functions, writeURLToPasteboard and writeImageToPasteboard,
both Mac-only for now.

* editing/mac/EditorMac.mm:
(WebCore::Editor::pasteWithPasteboard): Removed unneeded "m_frame.editor()" round trip that
was left behind in this function.
(WebCore::getImage): Added. Helper used by writeImageToPasteboard.
(WebCore::Editor::writeURLToPasteboard): Added. Sets up PasteboardURL and then calls
Pasteboard::write with it.
(WebCore::Editor::writeImageToPasteboard): Added. Sets up PasteboardImage and then calls
Pasteboard::write with it.
* page/DragController.cpp:
(WebCore::DragController::startDrag): Use Editor::writeURLToPasteboard instead of
Pasteboard::writeURL on Mac.

* platform/Pasteboard.h: Added PasteboardURL and PasteboardImage structures.
Declare write functions for PasteboardWebContent, PasteboardURL, and PasteboardImage.
Guard writeURL and writeImage with !PLATFORM(MAC).

* platform/mac/PasteboardMac.mm:
(WebCore::writeURLForTypes): Changed this to take a PasteboardURL.
(WebCore::Pasteboard::write): Renamed writeURL and writeImage to this. Refactor both
to take PasteboardURL and PasteboardImage arguments.
(WebCore::fileWrapper): Renamed from fileWrapperForImage since the fact that this is
for an image is now clear from its argument, a PasteboardImage.
(WebCore::writeFileWrapperAsRTFDAttachment): Changed this function to use early return.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154939 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add element ancestor iterator
https://bugs.webkit.org/show_bug.cgi?id=120563

Reviewed by Andreas Kling.

This patch adds ancestor iterators. They iterate over elements parent chain up to the root.
        
To iterate over Element ancestors:
        
auto ancestors = elementAncestors(this);
for (auto it = ancestors.begin(), end = ancestors.end(); it != end; ++it) {
    Element& element = *it;
    ...

To iterate over Element ancestors including the current element:
        
auto lineage = elementLineage(this);
for (auto it = lineage.begin(), end = lineage.end(); it != end; ++it) {
    Element& element = *it;
    ...
            
To iterate over ancestors of a specific Element subclass:

auto htmlAncestors = ancestorsOfType<HTMLElement>(this);
for (auto it = htmlAncestors.begin(), end = htmlAncestors.end(); it != end; ++it) {
    HTMLElement& htmlElement = *it;
    ...
            
To iterate over ancestors of a specific Element subclass including the current element:

auto htmlLineage = lineageOfType<HTMLElement>(this);
for (auto it = htmlLineage.begin(), end = htmlLineage.end(); it != end; ++it) {
    HTMLElement& htmlElement = *it;
    ...
            
The patch also uses the new types in a few places.

* WebCore.xcodeproj/project.pbxproj:
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::mouseButtonListener):
(WebCore::AccessibilityNodeObject::labelForElement):
* dom/ElementAncestorIterator.h: Added.
(WebCore::::ElementAncestorIterator):
(WebCore::::operator):
(WebCore::::ElementAncestorConstIterator):
(WebCore::::ElementAncestorIteratorAdapter):
(WebCore::::begin):
(WebCore::::end):
(WebCore::::ElementAncestorConstIteratorAdapter):
(WebCore::elementLineage):
(WebCore::elementAncestors):
(WebCore::ancestorsOfType):
* dom/ElementIterator.h:
(WebCore::findElementAncestorOfType):
(WebCore::::traverseAncestor):
(WebCore::=):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged):
* html/HTMLFieldSetElement.h:
(WebCore::isHTMLFieldSetElement):
(WebCore::HTMLFieldSetElement):
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::findContaining):
* html/HTMLFrameSetElement.h:
(WebCore::HTMLFrameSetElement):
* html/HTMLInputElement.h:
(WebCore::isHTMLInputElement):
(WebCore::toHTMLInputElement):
* html/HTMLLegendElement.cpp:
(WebCore::HTMLLegendElement::associatedControl):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fixed typo in media/video-volume-slider.html
https://bugs.webkit.org/show_bug.cgi?id=120578

Unreviewed.


* media/video-volume-slider.html: Fixed typo.
* platform/gtk/media/video-volume-slider-expected.png:
* platform/gtk/media/video-volume-slider-expected.txt:
* platform/mac/media/video-volume-slider-expected.png:
* platform/mac/media/video-volume-slider-expected.txt: New
baselines.


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