Simplify WebCredential
https://bugs.webkit.org/show_bug.cgi?id=134036

Reviewed by Andreas Kling.

* UIProcess/API/C/WKCredential.cpp:
(WKCredentialCreate):
(WKCredentialCreateWithCertificateInfo):
(WKCredentialCopyUser):
* UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
(WebKit::AuthenticationChallengeProxy::useCredential):
* UIProcess/Authentication/WebCredential.cpp:
(WebKit::WebCredential::credential):
(WebKit::WebCredential::core): Deleted.
(WebKit::WebCredential::user): Deleted.
* UIProcess/Authentication/WebCredential.h:
(WebKit::WebCredential::create): Deleted.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170114 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WK2] Re-sync didCommitLoadForMainFrame with its corresponding tile update
https://bugs.webkit.org/show_bug.cgi?id=134009

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-06-18
Reviewed by Tim Horton.

WKWebView assumed the first _didCommitLayerTree: after _didCommitLoadForMainFrame
had the state of the page being loaded.

This is not always true. Sometimes, a set of tiles can be rendering asynchronously while the next
page is loaded, and does not flush the queue until after didCommitLoadForMainFrame is executed.

Tim introduced a transactionID with each layer tree update. This patch uses that to synchronize
WKWebView with the right set of tiles.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLoadForMainFrame]):
(-[WKWebView _didCommitLayerTree:WebKit::]):
(-[WKWebView _updateVisibleContentRects]):
* UIProcess/WebPageProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
(WebKit::RemoteLayerTreeDrawingAreaProxy::nextLayerTreeTransactionID):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.messages.in:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
(WebKit::RemoteLayerTreeDrawingAreaProxy::willCommitLayerTree):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WK2] Do not add padding when magnifying replaced elements
https://bugs.webkit.org/show_bug.cgi?id=134019

Reviewed by Tim Horton.

Having margins for regular blocks make sense to improve readability. For replaced elements,
we should follow iOS's UI and display edge to edge.

* UIProcess/ios/SmartMagnificationController.mm:
(WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
-[JSContext setName:] leaks NSString
<http://webkit.org/b/134038>

Reviewed by Joseph Pecoraro.

Fixes the following static analyzer warning:

    JavaScriptCore/API/JSContext.mm:200:73: warning: Potential leak of an object
        JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[name copy]) : nullptr;
                                                                            ^

* API/JSContext.mm:
(-[JSContext setName:]): Autorelease the copy of |name|.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make ScrollingStateNodes refcounted, and other minor cleanup
https://bugs.webkit.org/show_bug.cgi?id=134040

Reviewed by Beth Dakin.

Source/WebCore:
Prepare for future scrolling frame gyrations by making
ScrollingStateNodes refcounted.

Rename ScrollingStateNode::removeChild() to removeDescendant()
since that's what it does. Also rename didRemoveNode() to willRemoveNode()
to better match the behavior.

Use 'auto' in more places.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::syncChildPositions):
* page/scrolling/ScrollingStateFixedNode.cpp:
(WebCore::ScrollingStateFixedNode::create):
(WebCore::ScrollingStateFixedNode::clone):
* page/scrolling/ScrollingStateFixedNode.h:
* page/scrolling/ScrollingStateFrameScrollingNode.cpp:
(WebCore::ScrollingStateFrameScrollingNode::create):
(WebCore::ScrollingStateFrameScrollingNode::clone):
* page/scrolling/ScrollingStateFrameScrollingNode.h:
* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::cloneAndReset):
(WebCore::ScrollingStateNode::appendChild):
(WebCore::ScrollingStateNode::removeDescendant):
(WebCore::ScrollingStateNode::willBeRemovedFromStateTree):
(WebCore::ScrollingStateNode::removeChild): Deleted.
* page/scrolling/ScrollingStateNode.h:
(WebCore::ScrollingStateNode::children):
* page/scrolling/ScrollingStateOverflowScrollingNode.cpp:
(WebCore::ScrollingStateOverflowScrollingNode::create):
(WebCore::ScrollingStateOverflowScrollingNode::clone):
* page/scrolling/ScrollingStateOverflowScrollingNode.h:
* page/scrolling/ScrollingStateStickyNode.cpp:
(WebCore::ScrollingStateStickyNode::create):
(WebCore::ScrollingStateStickyNode::clone):
* page/scrolling/ScrollingStateStickyNode.h:
* page/scrolling/ScrollingStateTree.cpp:
(WebCore::ScrollingStateTree::attachNode):
(WebCore::ScrollingStateTree::removeNode):
(WebCore::ScrollingStateTree::willRemoveNode):
(WebCore::ScrollingStateTree::didRemoveNode): Deleted.
* page/scrolling/ScrollingStateTree.h:
(WebCore::ScrollingStateTree::setRootStateNode):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::updateTreeFromStateNode):

Source/WebKit2:
* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
(WebKit::encodeNodeAndDescendants):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170118 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed build fix after r170107.

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArithMod):
Use non-template sub for armv7s.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170119 268f45cc-cd09-0410-ab3c-d52691b4dbfc
REGRESSION (r167856): Unable to log into HSBC app
https://bugs.webkit.org/show_bug.cgi?id=133991
<rdar://problem/17044839>

Reviewed by David Kilzer.

Source/WebCore:
Following <http://trac.webkit.org/changeset/167856> we disallow "navigation to any URL that is
invalid, except for JavaScript URLs, which need not be valid." A byproduct of this policy
decision is that we no longer notify the WebKit client to about a navigation if the destination
URL is invalid. And some apps, including the HSBC app for iOS, have logic to intercept URLs
as a means to pass data from their WebView-embedded web app to the WebView. We should expose a
setting called allowNavigationToInvalidURL (disabled by default on all ports and conditionally
enabled on iOS) to toggle whether WebCore allows navigation to any URL, even if its invalid,
so as to not break clients that intercept URLs and have custom logic to handle them.

Tests: fast/loader/allow-redirect-to-invalid-url-using-javascript.html
       fast/loader/allow-redirect-to-invalid-url-using-meta-refresh.html
       fast/loader/disallow-redirect-to-invalid-url-using-javascript.html
       fast/loader/disallow-redirect-to-invalid-url-using-meta-refresh.html

* loader/NavigationScheduler.cpp:
(WebCore::NavigationScheduler::shouldScheduleNavigation): Modified to only validate
the URL when the setting allowNavigationToInvalidURL is disabled.
* page/Settings.in: Added setting allowNavigationToInvalidURL (disabled by default).

Source/WebKit/mac:
Only enable the setting allowNavigationToInvalidURL for iOS app linked against WebKit/UIKit before iOS 8.

* Misc/WebKitVersionChecks.h: Added macro constant WEBKIT_FIRST_VERSION_WITH_NAVIGATION_URL_VALIDATION.
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]): Enable or disable the setting allowNavigationToInvalidURL as appropriate.

LayoutTests:
Add tests to ensure that the WebKit client will be notified to service a redirect to an invalid
URL when the setting allowNavigationToInvalidURL is enabled and will not be notified when
the setting is disabled.

* fast/loader/allow-redirect-to-invalid-url-using-javascript-expected.txt: Added.
* fast/loader/allow-redirect-to-invalid-url-using-javascript.html: Added.
* fast/loader/allow-redirect-to-invalid-url-using-meta-refresh-expected.txt: Added.
* fast/loader/allow-redirect-to-invalid-url-using-meta-refresh.html: Added.
* fast/loader/disallow-redirect-to-invalid-url-using-javascript-expected.txt: Added.
* fast/loader/disallow-redirect-to-invalid-url-using-javascript.html: Added.
* fast/loader/disallow-redirect-to-invalid-url-using-meta-refresh-expected.txt: Added.
* fast/loader/disallow-redirect-to-invalid-url-using-meta-refresh.html: Added.
* fast/loader/resources/redirect-to-invalid-url-using-javascript.html: Added.
* fast/loader/resources/redirect-to-invalid-url-using-meta-refresh.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Subtrees with :first-child and :last-child are not invalidated when siblings are added/removed
https://bugs.webkit.org/show_bug.cgi?id=133934

Reviewed by Antti Koivisto.


Source/WebCore: 
When adding/removing nodes on an element, we try to invalidate only the elements that are
affected. In the case of :first-child and :last-child, that optimizations is implemented
through two types of flags that are updated during style resolution.

The first flag is childrenAffectedByFirstChildRules (childrenAffectedByLastChildRules),
set on the parent of any element that could be affected by :first-child (:last-child).

The other part of the optimization is marking the style itself with firstChildState (lastChildState)
to further reduce invalidations.

The problem in this case happen with a subtree of element is detached. Since there is no renderer,
the computed style is resolved ad-hoc and stored directly on the element. When the element is moved,
the computed style was never cleared because the invalidation optimizations were not handling
elements without style.

Credit to Yusuke Suzuki for discovering the issue and creating test cases.

Tests: fast/css/getComputedStyle/empty-update-without-renderer.html
       fast/css/getComputedStyle/first-child-update-without-renderer.html
       fast/css/getComputedStyle/last-child-update-without-renderer.html

* dom/Element.cpp:
(WebCore::checkForEmptyStyleChange):
Clean up: pull the style directly from the function instead of expection the call sites to do that.
Refine the checks to avoid invalidation.

(WebCore::checkForSiblingStyleChanges):
Do not early return if the parent is detached, the children may still need invalidation.

When there is no renderer, assume the worst first-child/last-child and force the invalidation.

(WebCore::Element::childrenChanged):

LayoutTests: 
* fast/css/getComputedStyle/empty-update-without-renderer-expected.txt: Added.
* fast/css/getComputedStyle/empty-update-without-renderer.html: Added.
* fast/css/getComputedStyle/first-child-update-without-renderer-expected.txt: Added.
* fast/css/getComputedStyle/first-child-update-without-renderer.html: Added.
* fast/css/getComputedStyle/last-child-update-without-renderer-expected.txt: Added.
* fast/css/getComputedStyle/last-child-update-without-renderer.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
All of MiniBrowser's WKWebViews should share a configuration
https://bugs.webkit.org/show_bug.cgi?id=134017

Reviewed by Anders Carlsson.

* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController awakeFromNib]):
Share a single WKWebViewConfiguration between all of MiniBrowser's views.
This means that they'll share things like preferences, visited links, etc.
It also means that we'll properly share processes once we hit the process limit.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170122 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Simplify WebPageProxy::saveRecentSearches and WebPageProxy::loadRecentSearches
https://bugs.webkit.org/show_bug.cgi?id=134041

Reviewed by Andreas Kling.

* UIProcess/cf/WebPageProxyCF.cpp:
(WebKit::WebPageProxy::saveRecentSearches):
(WebKit::WebPageProxy::loadRecentSearches):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Work around a Windows compiler crash.

* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::createFromSelection):

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