REGRESSION: WebProcess is terminated when all Safari windows are closed.
<rdar://problem/13990901>
<http://webkit.org/b/116766>

Reviewed by Alexey Proskuryakov.

When closing the last page, only disconnect the web process if we're using a network process.
Otherwise there might be session state in the web process getting lost.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::removeWebPage):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150691 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Move Node::isMouseFocusable() to Element.
<http://webkit.org/b/116762>

Reviewed by Anders Carlsson.

Source/WebCore:

Node::isMouseFocusable() would just return isFocusable(), which is never true for a non-Element
since Node::supportsFocus() always returns false. So move it to Element!

* dom/Node.h:
* dom/Node.cpp:
* dom/Element.h:
* dom/Element.cpp:
(WebCore::Element::isMouseFocusable):

    Moved here from Node.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::setFocusedNodeIfNeeded):
* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchMouseEvent):

    Walk up the parent chain with parentOrShadowHostElement() instead of parentOrShadowHostNode().
    Removed a misleading no-op hunk about mouse-focusable ShadowRoots, since ShadowRoots are not
    Elements and thus cannot be mouse-focusable.

* page/TouchAdjustment.cpp:
(WebCore::TouchAdjustment::nodeRespondsToTapGesture):

    Check that the Node is an Element before asking if it's mouse-focusable.

* html/HTMLAnchorElement.h:
* html/HTMLAreaElement.h:
* html/HTMLFormControlElement.h:
* html/HTMLInputElement.h:
* html/HTMLMediaElement.h:
* html/HTMLSelectElement.h:
* html/HTMLTextAreaElement.h:
* html/shadow/ClearButtonElement.h:
* html/shadow/TextControlInnerElements.h:
* svg/SVGAElement.h:
* svg/SVGStyledElement.h:

    Sprinkle OVERRIDE.

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::highlightPotentialActivation):

    Check that the potentially activated Node is an Element before asking if it's mouse-focusable.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150692 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Updated expected results after r150688.

Reviewed by Andreas Kling.

* http/tests/globalhistory/history-delegate-basic-refresh-redirect-expected.txt: Now shows
the URL that performed the client redirect, as expected.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150693 268f45cc-cd09-0410-ab3c-d52691b4dbfc
We broke (-2^31/-1)|0 in the DFG
https://bugs.webkit.org/show_bug.cgi?id=116767

Source/JavaScriptCore: 

Reviewed by Andreas Kling.
        
The bug is that we were assuming that in the -2^31 case, we already had -2^31
in the result register. This was a wrong assumption.

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileIntegerArithDivForX86):

LayoutTests: 

Reviewed by Andreas Kling.

* fast/js/dfg-div-by-neg1-and-then-or-zero-interesting-reg-alloc-expected.txt: Added.
* fast/js/dfg-div-by-neg1-and-then-or-zero-interesting-reg-alloc.html: Added.
* fast/js/dfg-div-by-zero-and-then-or-zero-interesting-reg-alloc-expected.txt: Added.
* fast/js/dfg-div-by-zero-and-then-or-zero-interesting-reg-alloc.html: Added.
* fast/js/dfg-div-neg2tothe31-by-one-and-then-or-zero-with-interesting-reg-alloc-expected.txt: Added.
* fast/js/dfg-div-neg2tothe31-by-one-and-then-or-zero-with-interesting-reg-alloc.html: Added.
* fast/js/jsc-test-list:
* fast/js/script-tests/dfg-div-by-neg1-and-then-or-zero-interesting-reg-alloc.js: Added.
(foo):
* fast/js/script-tests/dfg-div-by-zero-and-then-or-zero-interesting-reg-alloc.js: Added.
(foo):
* fast/js/script-tests/dfg-div-neg2tothe31-by-one-and-then-or-zero-with-interesting-reg-alloc.js: Added.
(foo):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150694 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unprefix Page Visibility API
https://bugs.webkit.org/show_bug.cgi?id=102340

Source/WebCore:

Reviewed by Tim Horton.

Remove prefixes from the document properties, and the visibilitychanged event.

Rename the "preview" state to "unloaded". The "unloaded" state is never
reached yet (see https://bugs.webkit.org/show_bug.cgi?id=116769).

Add some comments to places where we should update the visibility state
when going in and out of the page cache, but cannot safely do so yet.

Tested by existing Page Visibility tests.

* dom/Document.cpp:
(WebCore::Document::pageVisibilityState):
(WebCore::Document::visibilityState):
(WebCore::Document::hidden):
(WebCore::Document::dispatchVisibilityStateChangeEvent):
* dom/Document.h:
* dom/Document.idl:
* dom/EventNames.h:
* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::restore):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopLoading):
* page/Page.cpp:
(WebCore::Page::setVisibilityState):
* page/PageVisibilityState.cpp:
(WebCore::pageVisibilityStateString):
* page/PageVisibilityState.h:

Source/WebKit/efl:

Reviewed by Tim Horton.

Rename "preview" state to "unloaded" state.

* WebCoreSupport/AssertMatchingEnums.cpp:
* ewk/ewk_view.h:

Source/WebKit/mac:

Reviewed by Tim Horton.

Renaming of the "preview" state to "unloaded".

* WebView/WebView.mm:
* WebView/WebViewPrivate.h:

Source/WebKit2:

Reviewed by Tim Horton.

Renaming of the "preview" state to "unloaded".

* Shared/API/c/WKPageVisibilityTypes.h:
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toPageVisibilityState):

Tools:

Reviewed by Tim Horton.

Rename "preview" state to "unloaded" state, and adjust the tests
to test for it.

* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setPageVisibility):
* TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp:
(TestWebKitAPI::setPageVisibilityStateWithEvalContinuation):
(TestWebKitAPI::didRunStep2StateChangeHiddenToPrerender):
(TestWebKitAPI::didRunStep3StateChangePrerenderToUnloaded):
(TestWebKitAPI::didRunStep4InStateUnloaded):
* TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.html:
* TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm:
(TestWebKitAPI::PageVisibilityStateWithWindowChanges::runTest):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setPageVisibility):

LayoutTests:

Reviewed by Tim Horton.

Remove prefixes, adjust to state name changes.

* fast/events/page-visibility-iframe-delete-test.html:
* fast/events/page-visibility-iframe-move-test-expected.txt:
* fast/events/page-visibility-iframe-move-test.html:
* fast/events/page-visibility-iframe-propagation-test-expected.txt:
* fast/events/page-visibility-iframe-propagation-test.html:
* fast/events/page-visibility-null-view-expected.txt:
* fast/events/page-visibility-null-view.html:
* fast/events/page-visibility-transition-test-expected.txt:
* fast/events/page-visibility-transition-test.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Path: clean up addPathForRoundedRect()
https://bugs.webkit.org/show_bug.cgi?id=116765

Patch by Alberto Garcia <agarcia@igalia.com> on 2013-05-25
Reviewed by Andreas Kling.

Reorganize code that is a bit redundant.

No new tests, no behavior change.

* platform/graphics/Path.cpp:
(WebCore::Path::addPathForRoundedRect):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150696 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Move Node::focusDelegate() to Element.
<http://webkit.org/b/116768>

Reviewed by Anders Carlsson.

Only Element can be a focus delegate (it's currently only ever HTMLInputElement actually)
so move Node::focusDelegate() to Element. Sprinkled isElementNode() checks as needed.

* dom/Node.cpp:
* dom/Node.h:
* dom/Element.h:
* dom/Element.cpp:
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::focusDelegate):
* html/shadow/SliderThumbElement.h:
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isFocused):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintSliderThumb):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Try to fix the EFL build.

* DumpRenderTree/efl/TestRunnerEfl.cpp:
(TestRunner::setPageVisibility):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150698 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove Document::getFocusableNodes().
<http://webkit.org/b/116773>

Reviewed by Joseph Pecoraro.

Source/WebCore:

This was added in r42191 and there are no remaining clients of the API.

* dom/Document.cpp:
* dom/Document.h:
* WebCore.exp.in:

Source/WebKit/mac:

Remove the private _focusableNodes API on DOMDocument, it has no clients.

* DOM/WebDOMOperations.mm:
* DOM/WebDOMOperationsPrivate.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150699 268f45cc-cd09-0410-ab3c-d52691b4dbfc
PluginDocument::pluginNode() should be pluginElement() instead.
<http://webkit.org/b/116774>

Reviewed by Anders Carlsson.

Source/WebCore:

Make PluginDocument hand out a HTMLPlugInElement* instead of a Node*.

* dom/Document.cpp:
(WebCore::eventTargetNodeForDocument):
* html/PluginDocument.h:
* html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createDocumentStructure):
(WebCore::PluginDocument::pluginWidget):
(WebCore::PluginDocument::setPluginElement):
(WebCore::PluginDocument::detach):

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::focusedPluginViewForFrame):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150700 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Teach webkitbot and WKR how to respond to yt?
https://bugs.webkit.org/show_bug.cgi?id=116775

Reviewed by Andreas Kling.

* Scripts/webkitpy/tool/bot/irc_command.py:
(Hi): Fixed the usage string.
(Hi.execute): Made it more generic so that it works in WKR.
(YouThere): Added.
(YouThere.execute): Added.
* Scripts/webkitpy/tool/commands/newcommitbot.py:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Don't instantiate ChildNodeLists just to get a child count.
<http://webkit.org/b/116776>

Reviewed by Ryosuke Niwa.

Use ContainerNode::childNodeCount() instead of Node::childNodes()->length().

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Some build fixes for WKR and webkitbot.

* Scripts/webkitpy/tool/bot/ircbot_unittest.py:
(IRCBotTest.test_help):
* Scripts/webkitpy/tool/commands/newcommitbot.py:
(Agent):
(Agent.__init__):
(Agent.name):
(NewCommitBot):
(NewCommitBot.begin_work_queue):
(NewCommitBot.next_work_item):
* Scripts/webkitpy/tool/commands/sheriffbot.py:
(SheriffBot):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150704 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Revert an erroneous change.

* Scripts/webkitpy/tool/commands/sheriffbot.py:
(SheriffBot):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150705 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Revert another erroneous change.

* Scripts/webkitpy/tool/commands/newcommitbot.py:
(NewCommitBot.next_work_item):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150706 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Move Node::tabIndex() to Element.
<http://webkit.org/b/116772>

Reviewed by Ryosuke Niwa.

Since only Elements are keyboard-focusable, it doesn't make sense for Node to have a tabIndex().

* dom/Element.h:
* dom/Node.cpp:
* dom/Node.h:

    A Node can't have a tab index, so move tabIndex() to Element.

* page/FocusController.h:
* page/FocusController.cpp:
(WebCore::adjustedTabIndex):
(WebCore::FocusController::findElementWithExactTabIndex):
(WebCore::nextElementWithGreaterTabIndex):
(WebCore::previousElementWithLowerTabIndex):
(WebCore::FocusController::nextFocusableNode):
(WebCore::FocusController::previousFocusableNode):

    Make this code deal in Element* when doing tab index stuff. FocusController needs
    more Node->Element cleanup, but let's do that separately.

* html/HTMLAnchorElement.h:
* html/HTMLElement.h:
* html/HTMLFormControlElement.h:

    Sprinkle OVERRIDE.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150707 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Broken link to committers list on contributing web page
https://bugs.webkit.org/show_bug.cgi?id=116722

Patch by Bem Jones-Bey <bjonesbe@adobe.com> on 2013-05-25
Reviewed by Andreas Kling.

* coding/contributing.html:
Changed broken link to point to the team page instead.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150708 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Move Node::isFocusable() to Element.
<http://webkit.org/b/116777>

Reviewed by Anders Carlsson.

Nodes cannot be focusable, so move isFocusable() from Node to Element.

* dom/Node.cpp:
* dom/Node.h:
* dom/Element.h:
* dom/Element.cpp:
(WebCore::Element::isFocusable):

    Moved here from Node.

* dom/Document.cpp:
(WebCore::Document::setFocusedNode):
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRole):

    Check that the underlying node is an Element before asking if it's focusable.

* page/FrameView.cpp:
(WebCore::FrameView::scrollToAnchor):

    Renamed the 'anchorNode' variable to 'anchorElement' because reasons.

* html/HTMLAreaElement.h:
* html/HTMLFormControlElement.h:
* html/HTMLLabelElement.h:
* html/HTMLOptionElement.h:
* svg/SVGAElement.h:

    Sprinkle OVERRIDE.

* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::setMessage):

    Update a comment to refer to Element::isFocusable() instead of Node.

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