Move IndexedDB module, LevelDB code to std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=128964

Reviewed by Andreas Kling.

Replace uses of OwnPtr and PassOwnPtr in the IndexedDB module and LevelDB platform code with std::unique_ptr.

* Modules/indexeddb/IDBCursorBackend.h:
* Modules/indexeddb/IDBDatabaseBackend.cpp:
(WebCore::IDBDatabaseBackend::IDBDatabaseBackend):
(WebCore::IDBDatabaseBackend::transactionFinishedAndAbortFired):
(WebCore::IDBDatabaseBackend::processPendingCalls):
(WebCore::IDBDatabaseBackend::processPendingOpenCalls):
(WebCore::IDBDatabaseBackend::openConnection):
(WebCore::IDBDatabaseBackend::runIntVersionChangeTransaction):
(WebCore::IDBDatabaseBackend::deleteDatabase):
(WebCore::IDBDatabaseBackend::close):
* Modules/indexeddb/IDBDatabaseBackend.h:
(WebCore::IDBDatabaseBackend::hasPendingSecondHalfOpen):
(WebCore::IDBDatabaseBackend::setPendingSecondHalfOpen):
* Modules/indexeddb/IDBPendingDeleteCall.h:
(WebCore::IDBPendingDeleteCall::IDBPendingDeleteCall):
* Modules/indexeddb/IDBPendingOpenCall.h:
(WebCore::IDBPendingOpenCall::IDBPendingOpenCall):
* Modules/indexeddb/IDBTransactionBackendOperations.cpp:
(WebCore::IDBDatabaseBackend::VersionChangeOperation::perform):
* Modules/indexeddb/IDBTransactionCoordinator.cpp:
* Modules/indexeddb/IDBTransactionCoordinator.h:
* Modules/indexeddb/leveldb/IDBBackingStoreCursorLevelDB.h:
* Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
(WebCore::setUpMetadata):
(WebCore::DefaultLevelDBFactory::openLevelDB):
(WebCore::IDBBackingStoreLevelDB::IDBBackingStoreLevelDB):
(WebCore::IDBBackingStoreLevelDB::~IDBBackingStoreLevelDB):
(WebCore::IDBBackingStoreLevelDB::open):
(WebCore::IDBBackingStoreLevelDB::openInMemory):
(WebCore::IDBBackingStoreLevelDB::create):
(WebCore::IDBBackingStoreLevelDB::getDatabaseNames):
(WebCore::deleteRange):
(WebCore::IDBBackingStoreLevelDB::deleteDatabase):
(WebCore::IDBBackingStoreLevelDB::getObjectStores):
(WebCore::IDBBackingStoreLevelDB::getKeyGeneratorCurrentNumber):
(WebCore::IDBBackingStoreLevelDB::getIndexes):
(WebCore::findGreatestKeyLessThanOrEqual):
(WebCore::IDBBackingStoreLevelDB::findKeyInIndex):
* Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h:
* platform/leveldb/LevelDBDatabase.cpp:
(WebCore::LevelDBDatabase::~LevelDBDatabase):
(WebCore::LevelDBDatabase::open):
(WebCore::LevelDBDatabase::openInMemory):
(WebCore::IteratorImpl::IteratorImpl):
(WebCore::LevelDBDatabase::createIterator):
* platform/leveldb/LevelDBDatabase.h:
* platform/leveldb/LevelDBTransaction.cpp:
(WebCore::LevelDBTransaction::commit):
(WebCore::LevelDBTransaction::createIterator):
(WebCore::LevelDBTransaction::TransactionIterator::TransactionIterator):
(WebCore::LevelDBTransaction::TransactionIterator::refreshTreeIterator):
(WebCore::LevelDBWriteOnlyTransaction::LevelDBWriteOnlyTransaction):
* platform/leveldb/LevelDBTransaction.h:
* platform/leveldb/LevelDBWriteBatch.cpp:
(WebCore::LevelDBWriteBatch::LevelDBWriteBatch):
* platform/leveldb/LevelDBWriteBatch.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add SPI for getting the original URL from a WKNavigationAction
https://bugs.webkit.org/show_bug.cgi?id=128997

Reviewed by Tim Horton.

* UIProcess/API/Cocoa/WKNavigationActionInternal.h:
* UIProcess/API/Cocoa/WKNavigationActionPrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h.
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
setSelectionRange should set selection without validation
https://bugs.webkit.org/show_bug.cgi?id=128949

Reviewed by Enrica Casucci.

Source/WebCore: 

Since positionForIndex in HTMLTextFormControlElement always returns a candidate Position, we don't have to
validate selection in setSelectionRange.

Also fixed various bugs uncovered by this change.

This patch also fixes fast/forms/input-select-webkit-user-select-none.html, which used to assert wrong outcome
so that WebKit's behavior matches that of Chrome and Firefox.

Test: fast/forms/input-select-webkit-user-select-none.html

* dom/Position.h:
(WebCore::positionInParentBeforeNode): This function had a bug that when node is a child of the shadow root
it would return a null Position. Allow a position anchored inside a shadow root.
(WebCore::positionInParentAfterNode): Ditto.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::moveWithoutValidationTo): Renamed from moveTo and avoided selection validation.
* editing/FrameSelection.h:

* editing/htmlediting.cpp:
(WebCore::updatePositionForNodeRemoval): Fixed the bug that this function doesn't update positions before
or after children even if the shadow host of the anchor node is getting removed. Move the position before
the shadow host to be removed in both situations.

* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setSelectionRange): moveTo is renamed to moveWithoutValidationTo.
(WebCore::HTMLTextFormControlElement::selectionChanged): Check if the cached selection offsets are different
in lieu of FrameSelection::isRange() since they're equivalent here.
(WebCore::positionForIndex): Return the position inside or after the last br when there is one to match
the canonicalization algorithm we have. It's probably harmless to return the last position in the inner text
element anyways since most of our codebase supports that but this would avoid having to rebaseline dozens
of tests and reduces the risk of this patch.

LayoutTests: 

Fixed input-select-webkit-user-select-none.html which was erroneously asserting selectionStart and selectionEnd
of a text field to be zero when it has -webkit-user-select: none. This doesn't not match behaviors of Chrome
and Firefox. They both retain the programatically set selection offsets since such style should not bleed into
the shadow DOM of the text field in the first place.

New behavior matches the latest Firefox and Chrome although we still have the bug that user cannot select text
inside such a text field.

Also modernized LayoutTests/editing/selection/5497643.html to make the expected results more readable and made
the test more robust against changes in the node index of textarea element.

* editing/selection/5497643-expected.txt: See above.
* editing/selection/5497643.html:
* fast/forms/input-select-webkit-user-select-none-expected.txt: See above.
* fast/forms/input-select-webkit-user-select-none.html:
* editing/deleting/delete-ligature-001-expected.txt: Progression in the editing delegate callbacks dumps.
Now we set selection directly into the text node inside the inner text element.
* platform/mac/platform/mac/editing/spelling/autocorrection-at-beginning-of-word-1-expected.txt: Ditto.
* platform/mac/platform/mac/editing/spelling/autocorrection-at-beginning-of-word-2-expected.txt: Ditto.
* platform/mac-mountainlion/platform/mac/editing/spelling/autocorrection-at-beginning-of-word-1-expected.txt:
Removed.
* platform/mac-mountainlion/platform/mac/editing/spelling/autocorrection-at-beginning-of-word-2-expected.txt:
Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] All WebKit clients should encrypt WebCrypto keys automatically
https://bugs.webkit.org/show_bug.cgi?id=128938

Reviewed by Dan Bernstein.

Don't pass ACLs on iOS. Key will be added to app's default Keychain access group.

Also, don't pass kSecAttrIsPermanent, which is irrelevant for password items, and
caused error -50 in DumpRenderTree for me when passed.

Added fallback to _NSGetProgname for account name, to account for tools such as
Mac DumpRenderTree that don't have bundle identifiers.

* crypto/mac/SerializedCryptoKeyWrapMac.mm:
(WebCore::masterKeyAccountNameForCurrentApplication):
(WebCore::createAndStoreMasterKey):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164317 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Do not cache media time until media engine returns a non-zero value
https://bugs.webkit.org/show_bug.cgi?id=128976

Reviewed by Jer Noble.

No new tests, covered by existing tests.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::refreshCachedTime): Don't mark the cached time as valid
    until it is non-zero.
(WebCore::HTMLMediaElement::currentTime): Return 0 if m_cachedTime is invalid.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164318 268f45cc-cd09-0410-ab3c-d52691b4dbfc
FrameSelection::textWasReplaced and setSelectedRange shouldn't trigger synchronous layout
https://bugs.webkit.org/show_bug.cgi?id=128951

Reviewed by Antti Koivisto.

Cleanup.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::textWasReplaced): Don't call updateLayout. It's totally unnecessarily.
(WebCore::FrameSelection::setSelectedRange): Ditto. Also removed the code to set affinity only when
range is collapsed since VisibleSelection::validate already does this.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164319 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Merge notifyComponentsOnChangedSelection into respondToSelectionChange
https://bugs.webkit.org/show_bug.cgi?id=128993

Reviewed by Andreas Kling.

Merged notifyComponentsOnChangedSelection into respondToSelectionChange since notifyComponentsOnChangedSelection
was only added in iOS codebase in response to the code added for continuous spellchecking and alternative text controller
in respondToChangedSelection but they should have been called inside setIgnoreCompositionSelectionChange.

So merge these two functions and make respondToChangedSelection behave like setIgnoreCompositionSelectionChange.

* editing/Editor.cpp:
(WebCore::Editor::setIgnoreCompositionSelectionChange):
(WebCore::Editor::respondToChangedSelection):
* editing/Editor.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
AX: Searching for "immediate descendants only" can return unexpected results.
https://bugs.webkit.org/show_bug.cgi?id=128986

Reviewed by Chris Fleizach.

Source/WebCore:

Missed an application of the immediateDescendantsOnly flag during the initial implementation. We
need to make sure we don't decend into the startObject first if it is provided. This fix causes
the outer loop to 'skip' the first iteration so only siblings of the startObject are considered.

No new tests, updated existing search-predicate-immediate-descendants-only.html test to cover this case.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::findMatchingObjects):

LayoutTests:

Updated test and expectations to make sure the results match traditional "children" results when appropriate.

* platform/mac/accessibility/search-predicate-immediate-descendants-only-expected.txt:
* platform/mac/accessibility/search-predicate-immediate-descendants-only.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
iOS build fix after r164319.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::setSelectedRange):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Crash when merging ruby bases that contain floats

https://bugs.webkit.org/show_bug.cgi?id=127515
<rdar://problem/15896562>

Source/WebCore:

This crash occurs when we remove a ruby text object and decide to merge
two adjacent ruby base objects. The right ruby base's children were
being merged into the left ruby base, but the right ruby base's floats
were not being moved to the left base. This could cause us not to
descend into all nodes containing a FloatingObject in
RenderBlockFlow::markAllDescendantsWithFloatsForLayout(), because we
assume that if a block does not have a particular float in its float
list, none of its descendants will, either.

Reviewed by David Hyatt.

Test: fast/ruby/ruby-base-merge-block-children-crash-2.html

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::moveFloatsTo):
Code split out of moveAllChildrenIncludingFloatsTo().
(WebCore::RenderBlockFlow::moveAllChildrenIncludingFloatsTo):
Call moveFloatsTo().

* rendering/RenderBlockFlow.h:
Add declaration of moveFloatsTo().

* rendering/RenderRubyBase.cpp:
(WebCore::RenderRubyBase::mergeChildrenWithBase):
Move children and floats to the new base.

* rendering/RenderRubyBase.h:
Declare mergeChildrenWithBase().

* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::removeChild):
Call mergeChildrenWithBase().

LayoutTests:

Reviewed by David Hyatt.

* fast/ruby/ruby-base-merge-block-children-crash-2.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Bottom/right sticky positioning don't correctly handle scroll containers with padding
https://bugs.webkit.org/show_bug.cgi?id=119280

Patch by Viatcheslav Ostapenko <sl.ostapenko@samsung.com> on 2014-02-18
Reviewed by Simon Fraser.

Source/WebCore:

Take padding into account during calculation of overflow constraining rect for sticky
positioning.

Test: fast/css/sticky/sticky-bottom-overflow-padding.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::stickyPositionOffset):

LayoutTests:

Check that sticky elements positioned correcly in overflow with padding.

* fast/css/sticky/sticky-bottom-overflow-padding-expected.html: Added.
* fast/css/sticky/sticky-bottom-overflow-padding.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164324 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add SPI for allowing HTTPS certificates
https://bugs.webkit.org/show_bug.cgi?id=129002

Reviewed by Dan Bernstein.

* UIProcess/API/Cocoa/WKProcessClass.mm:
(-[WKProcessClass _setAllowsSpecificHTTPSCertificate:forHost:]):
* UIProcess/API/Cocoa/WKProcessClassInternal.h:
* UIProcess/API/Cocoa/WKProcessClassPrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessClassInternal.h.
* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164325 268f45cc-cd09-0410-ab3c-d52691b4dbfc
FTL unwind parsing should handle ARM64
https://bugs.webkit.org/show_bug.cgi?id=128984

Reviewed by Oliver Hunt.
        
This makes unwind parsing handle ARM64 and it makes all clients of unwind info capable of
dealing with that architecture.
        
The big difference is that ARM64 has callee-save double registers. This is conceptually easy
to handle, but out code for dealing with callee-saves spoke of "GPRReg". We've been in this
situation before: code that needs to deal with either a GPRReg or a FPRReg. In the past we'd
hacked around the problem, but this time I decided to do a full frontal assault. This patch
adds a Reg class, which is a box for either GPRReg or FPRReg along with tools for iterating
over all possible registers. Then, I threaded this through SaveRestore, RegisterSet,
RegisterAtOffset, and UnwindInfo. With the help of Reg, it was easy to refactor the code to
handle FPRs in addition to GPRs.

* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* ftl/FTLOSRExitCompiler.cpp:
(JSC::FTL::compileStub):
* ftl/FTLRegisterAtOffset.cpp:
(JSC::FTL::RegisterAtOffset::dump):
* ftl/FTLRegisterAtOffset.h:
(JSC::FTL::RegisterAtOffset::RegisterAtOffset):
(JSC::FTL::RegisterAtOffset::operator!):
(JSC::FTL::RegisterAtOffset::reg):
(JSC::FTL::RegisterAtOffset::operator==):
(JSC::FTL::RegisterAtOffset::operator<):
(JSC::FTL::RegisterAtOffset::getReg):
* ftl/FTLSaveRestore.cpp:
(JSC::FTL::offsetOfReg):
* ftl/FTLSaveRestore.h:
* ftl/FTLUnwindInfo.cpp:
(JSC::FTL::UnwindInfo::parse):
(JSC::FTL::UnwindInfo::find):
(JSC::FTL::UnwindInfo::indexOf):
* ftl/FTLUnwindInfo.h:
* jit/Reg.cpp: Added.
(JSC::Reg::dump):
* jit/Reg.h: Added.
(JSC::Reg::Reg):
(JSC::Reg::fromIndex):
(JSC::Reg::first):
(JSC::Reg::last):
(JSC::Reg::next):
(JSC::Reg::index):
(JSC::Reg::isSet):
(JSC::Reg::operator!):
(JSC::Reg::isGPR):
(JSC::Reg::isFPR):
(JSC::Reg::gpr):
(JSC::Reg::fpr):
(JSC::Reg::operator==):
(JSC::Reg::operator!=):
(JSC::Reg::operator<):
(JSC::Reg::operator>):
(JSC::Reg::operator<=):
(JSC::Reg::operator>=):
(JSC::Reg::hash):
(JSC::Reg::invalid):
* jit/RegisterSet.h:
(JSC::RegisterSet::set):
(JSC::RegisterSet::clear):
(JSC::RegisterSet::get):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add -[WKWebView reload]
https://bugs.webkit.org/show_bug.cgi?id=129005

Reviewed by Tim Horton.

* UIProcess/API/Cocoa/WKWebView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView reload]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make reload SPI for now
https://bugs.webkit.org/show_bug.cgi?id=129007

Reviewed by Simon Fraser.

* UIProcess/API/Cocoa/WKWebView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _reload]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164328 268f45cc-cd09-0410-ab3c-d52691b4dbfc
TextFieldInputType::handleBeforeTextInsertedEvent shouldn't use plainText
https://bugs.webkit.org/show_bug.cgi?id=128953

Reviewed by Alexey Proskuryakov.

Don't use FrameSelection's toNormalizedRange and plainText. Instead, use the cached selection start and selection
end to extract the selected text. The caches are updated inside FrameSelection::setSelection whenever selection
is inside a text form control via HTMLTextFormControlElement::selectionChanged.

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):


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