[iOS] Web Inspector: JSContext inspection crashes in isMainThread, uninitialized WebCoreWebThreadIsLockedOrDisabled
https://bugs.webkit.org/show_bug.cgi?id=128959

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2014-02-18
Reviewed by David Kilzer.

When JavaScriptCore is used without WebCore on iOS (e.g. JSContext)
the WebCoreWebThread* functions will not be initialized. Avoid
calling the function pointer if it is uninitialized. This was
happening with remote inspection via StringImpl::createCFString
for implicit NSString / WTFString conversion which uses isMainThread.

* wtf/mac/MainThreadMac.mm:
(WTF::webThreadIsUninitializedOrLockedOrDisabled):
(WTF::isMainThread):
(WTF::canAccessThreadLocalDataForThread):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r164296.
http://trac.webkit.org/changeset/164296
https://bugs.webkit.org/show_bug.cgi?id=128989

Broke many media tests (Requested by eric_carlson on #webkit).

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/HTMLMediaElement.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164302 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Rename convertFixedAndStickyPosition() to convertPositionStyle()
https://bugs.webkit.org/show_bug.cgi?id=128987

Reviewed by NOBODY. This is addressing a post-commit review from Dean Jackson.

No new tests are necessary because there is no behavior change

* editing/EditingStyle.cpp:
(WebCore::EditingStyle::convertPositionStyle):
* editing/EditingStyle.h:
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendElement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Temporarily remove support for setting the maximumDecodedImageSize. It is causing assertions.

* Shared/WebPreferencesStore.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):



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

* UIProcess/API/Cocoa/WKProcessClassConfiguration.mm:
(-[WKProcessClassConfiguration description]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164306 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] Minibrowser: Add shortcut to open Web Inspector
https://bugs.webkit.org/show_bug.cgi?id=128813

Patch by Diego Pino García <dpino@igalia.com> on 2014-02-18
Reviewed by Anders Carlsson.

Added shortcuts Ctrl+Shift+I and F12 for toggling Web Inspector.

* MiniBrowser/gtk/BrowserWindow.c:
(toggleWebInspector):
(browser_window_init):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164307 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: shift-clicking #fff swatch results in bad rgb value
https://bugs.webkit.org/show_bug.cgi?id=128954

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2014-02-18
Reviewed by Daniel Bates.

parseInt("FF", 16) is already 255. Do not multiply the result by 255.

* UserInterface/Color.js:
(WebInspector.Color.fromString):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164308 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove unnecessary UserActionElementSet constructor, destructor
https://bugs.webkit.org/show_bug.cgi?id=128962

Reviewed by Andreas Kling.

UserActionElementSet constructor and destructor are not necessary, as is not the
static create() function that returns PassOwnPtr<UserActionElementSet>. The implicit
constructor and destructor can take care of creating and destroying the sole HashMap
member variable.

* dom/UserActionElementSet.cpp:
* dom/UserActionElementSet.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164309 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Follow-up: Add type-checked casts for StyleImage and subclasses
<http://webkit.org/b/128915>

Address some style issues based on feedback from Andreas Kling.

* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::cachedImageURL):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::~CSSImageSetValue):
(WebCore::CSSImageSetValue::hasFailedOrCanceledSubresources):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::hasFailedOrCanceledSubresources):
- Use the reference version of the type-checked casts since we
  know the pointers are not NULL.

* rendering/style/StyleImage.h:
- Use 'styleImage' instead of 'resource' in
  STYLE_IMAGE_TYPE_CASTS.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164310 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: Editing transparent color shows incorrect opacity slider
https://bugs.webkit.org/show_bug.cgi?id=128975

Reviewed by Joseph Pecoraro.

The opacity slider should show a range of colors from transparent to the full opacity of the tinted color.

* UserInterface/ColorPicker.js:
(WebInspector.ColorPicker.prototype._updateSliders):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164311 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: editing a color in the Styles sidebar using the color picker only works once for a given color
https://bugs.webkit.org/show_bug.cgi?id=128965

Reviewed by Timothy Hatcher.

Use the WebInspector.TextMarker backing the CodeMirror TextMarker object to inspect its type in
order to identify color markers that were created for a color. This fixes a regression introduced
in http://webkit.org/b/125695 when we abstracted CodeMirror TextMarker objects.

* UserInterface/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror.update):
(WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164312 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add more WKWebView SPI
https://bugs.webkit.org/show_bug.cgi?id=128994

Reviewed by Tim Horton.

* UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _unreachableURL]):
(-[WKWebView _loadAlternateHTMLString:baseURL:forUnreachableURL:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164313 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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