mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1365068 - Added missing brackets & refactored some conditional statements. r=MattN
MozReview-Commit-ID: 1eOkjI06RCJ --HG-- extra : rebase_source : 18068d1483d9127c06b858ce917f53dc41f4c58f
This commit is contained in:
parent
7235e8b878
commit
969046c009
@ -112,8 +112,9 @@ var Prefs = {
|
||||
get expireDays() { this.ensureInitialized(); return this._expireDays; },
|
||||
|
||||
ensureInitialized() {
|
||||
if (this.initialized)
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
@ -234,15 +235,21 @@ function validateSearchData(aData, aDataType) {
|
||||
|
||||
function makeQueryPredicates(aQueryData, delimiter = " AND ") {
|
||||
return Object.keys(aQueryData).map(function(field) {
|
||||
if (field == "firstUsedStart") {
|
||||
return "firstUsed >= :" + field;
|
||||
} else if (field == "firstUsedEnd") {
|
||||
return "firstUsed <= :" + field;
|
||||
} else if (field == "lastUsedStart") {
|
||||
return "lastUsed >= :" + field;
|
||||
} else if (field == "lastUsedEnd") {
|
||||
return "lastUsed <= :" + field;
|
||||
switch (field) {
|
||||
case "firstUsedStart": {
|
||||
return "firstUsed >= :" + field;
|
||||
}
|
||||
case "firstUsedEnd": {
|
||||
return "firstUsed <= :" + field;
|
||||
}
|
||||
case "lastUsedStart": {
|
||||
return "lastUsed >= :" + field;
|
||||
}
|
||||
case "lastUsedEnd": {
|
||||
return "lastUsed <= :" + field;
|
||||
}
|
||||
}
|
||||
|
||||
return field + " = :" + field;
|
||||
}).join(delimiter);
|
||||
}
|
||||
@ -352,8 +359,9 @@ function generateGUID() {
|
||||
let bytes = 0;
|
||||
for (let i = 1; bytes < 12 ; i += 2) {
|
||||
// Skip dashes
|
||||
if (uuid[i] == "-")
|
||||
if (uuid[i] == "-") {
|
||||
i++;
|
||||
}
|
||||
let hexVal = parseInt(uuid[i] + uuid[i + 1], 16);
|
||||
raw += String.fromCharCode(hexVal);
|
||||
bytes++;
|
||||
@ -396,8 +404,9 @@ var dbStmts = new Map();
|
||||
* Creates a statement, wraps it, and then does parameter replacement
|
||||
*/
|
||||
function dbCreateAsyncStatement(aQuery, aParams, aBindingArrays) {
|
||||
if (!aQuery)
|
||||
if (!aQuery) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let stmt = dbStmts.get(aQuery);
|
||||
if (!stmt) {
|
||||
@ -633,10 +642,12 @@ function updateFormHistoryWrite(aChanges, aCallbacks) {
|
||||
case "remove":
|
||||
log("Remove from form history " + change);
|
||||
let delStmt = makeMoveToDeletedStatement(change.guid, now, change, bindingArrays);
|
||||
if (delStmt && stmts.indexOf(delStmt) == -1)
|
||||
if (delStmt && stmts.indexOf(delStmt) == -1) {
|
||||
stmts.push(delStmt);
|
||||
if ("timeDeleted" in change)
|
||||
}
|
||||
if ("timeDeleted" in change) {
|
||||
delete change.timeDeleted;
|
||||
}
|
||||
stmt = makeRemoveStatement(change, bindingArrays);
|
||||
notifications.push([ "formhistory-remove", change.guid ]);
|
||||
break;
|
||||
@ -773,7 +784,9 @@ this.FormHistory = {
|
||||
|
||||
search: function formHistorySearch(aSelectTerms, aSearchData, aCallbacks) {
|
||||
// if no terms selected, select everything
|
||||
aSelectTerms = (aSelectTerms) ? aSelectTerms : validFields;
|
||||
if (!aSelectTerms) {
|
||||
aSelectTerms = validFields;
|
||||
}
|
||||
validateSearchData(aSearchData, "Search");
|
||||
|
||||
let stmt = makeSearchStatement(aSearchData, aSelectTerms);
|
||||
@ -844,12 +857,13 @@ this.FormHistory = {
|
||||
let searchFailed = false;
|
||||
|
||||
function validIdentifier(change) {
|
||||
// The identifier is only valid if one of either the guid or the (fieldname/value) are set
|
||||
// The identifier is only valid if one of either the guid or the (fieldname/value) are set (so an X-OR)
|
||||
return Boolean(change.guid) != Boolean(change.fieldname && change.value);
|
||||
}
|
||||
|
||||
if (!("length" in aChanges))
|
||||
if (!("length" in aChanges)) {
|
||||
aChanges = [aChanges];
|
||||
}
|
||||
|
||||
let isRemoveOperation = aChanges.every(change => change && change.op && change.op == "remove");
|
||||
if (!Prefs.enabled && !isRemoveOperation) {
|
||||
@ -1026,8 +1040,9 @@ this.FormHistory = {
|
||||
|
||||
// Chicken and egg problem: Need the statement to escape the params we
|
||||
// pass to the function that gives us the statement. So, fix it up now.
|
||||
if (searchString.length >= 1)
|
||||
if (searchString.length >= 1) {
|
||||
stmt.params.valuePrefix = stmt.escapeStringForLIKE(searchString, "/") + "%";
|
||||
}
|
||||
if (searchString.length > 1) {
|
||||
let searchTokenCount = Math.min(searchTokens.length, MAX_SEARCH_TOKENS);
|
||||
for (let i = 0; i < searchTokenCount; i++) {
|
||||
|
@ -45,8 +45,9 @@ FormHistoryStartup.prototype = {
|
||||
pendingQuery: null,
|
||||
|
||||
init() {
|
||||
if (this.inited)
|
||||
if (this.inited) {
|
||||
return;
|
||||
}
|
||||
this.inited = true;
|
||||
|
||||
Services.prefs.addObserver("browser.formfill.", this, true);
|
||||
|
@ -40,11 +40,13 @@ var satchelFormListener = {
|
||||
ccNumber = ccNumber.replace(/[\-\s]/g, "");
|
||||
|
||||
let len = ccNumber.length;
|
||||
if (len != 9 && len != 15 && len != 16)
|
||||
if (len != 9 && len != 15 && len != 16) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!/^\d+$/.test(ccNumber))
|
||||
if (!/^\d+$/.test(ccNumber)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let total = 0;
|
||||
for (let i = 0; i < len; i++) {
|
||||
@ -52,8 +54,9 @@ var satchelFormListener = {
|
||||
if (i % 2 == 1) {
|
||||
// Double it, add digits together if > 10
|
||||
ch *= 2;
|
||||
if (ch > 9)
|
||||
if (ch > 9) {
|
||||
ch -= 9;
|
||||
}
|
||||
}
|
||||
total += ch;
|
||||
}
|
||||
@ -61,8 +64,9 @@ var satchelFormListener = {
|
||||
},
|
||||
|
||||
log(message) {
|
||||
if (!this.debug)
|
||||
if (!this.debug) {
|
||||
return;
|
||||
}
|
||||
dump("satchelFormListener: " + message + "\n");
|
||||
Services.console.logStringMessage("satchelFormListener: " + message);
|
||||
},
|
||||
@ -85,41 +89,44 @@ var satchelFormListener = {
|
||||
|
||||
notify(form, domWin, actionURI, cancelSubmit) {
|
||||
try {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
|
||||
if (PrivateBrowsingUtils.isContentWindowPrivate(domWin))
|
||||
if (!this.enabled || PrivateBrowsingUtils.isContentWindowPrivate(domWin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.log("Form submit observer notified.");
|
||||
|
||||
if (form.hasAttribute("autocomplete") &&
|
||||
form.getAttribute("autocomplete").toLowerCase() == "off")
|
||||
form.getAttribute("autocomplete").toLowerCase() == "off") {
|
||||
return;
|
||||
}
|
||||
|
||||
let entries = [];
|
||||
for (let i = 0; i < form.elements.length; i++) {
|
||||
let input = form.elements[i];
|
||||
if (!(input instanceof Ci.nsIDOMHTMLInputElement))
|
||||
if (!(input instanceof Ci.nsIDOMHTMLInputElement)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only use inputs that hold text values (not including type="password")
|
||||
if (!input.mozIsTextField(true))
|
||||
if (!input.mozIsTextField(true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Bug 394612: If Login Manager marked this input, don't save it.
|
||||
// The login manager will deal with remembering it.
|
||||
|
||||
// Don't save values when autocomplete=off is present.
|
||||
if (input.hasAttribute("autocomplete") &&
|
||||
input.getAttribute("autocomplete").toLowerCase() == "off")
|
||||
input.getAttribute("autocomplete").toLowerCase() == "off") {
|
||||
continue;
|
||||
}
|
||||
|
||||
let value = input.value.trim();
|
||||
|
||||
// Don't save empty or unchanged values.
|
||||
if (!value || value == input.defaultValue.trim())
|
||||
if (!value || value == input.defaultValue.trim()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't save credit card numbers.
|
||||
if (this.isValidCCNumber(value)) {
|
||||
@ -128,8 +135,9 @@ var satchelFormListener = {
|
||||
}
|
||||
|
||||
let name = input.name || input.id;
|
||||
if (!name)
|
||||
if (!name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name == "searchbar-history") {
|
||||
this.log('addEntry for input name "' + name + '" is denied')
|
||||
|
@ -53,13 +53,11 @@ function FormHistoryClient({ formField, inputName }) {
|
||||
this.mm = topDocShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIContentFrameMessageManager);
|
||||
} else {
|
||||
if (inputName == this.SEARCHBAR_ID) {
|
||||
if (formField) {
|
||||
throw new Error("FormHistoryClient constructed with both a " +
|
||||
"formField and an inputName. This is not " +
|
||||
"supported, and only empty results will be " +
|
||||
"returned.");
|
||||
}
|
||||
if (inputName == this.SEARCHBAR_ID && formField) {
|
||||
throw new Error("FormHistoryClient constructed with both a " +
|
||||
"formField and an inputName. This is not " +
|
||||
"supported, and only empty results will be " +
|
||||
"returned.");
|
||||
}
|
||||
this.mm = Services.cpmm;
|
||||
}
|
||||
@ -210,38 +208,39 @@ FormAutoComplete.prototype = {
|
||||
|
||||
observe(subject, topic, data) {
|
||||
let self = this._self;
|
||||
if (topic == "nsPref:changed") {
|
||||
let prefName = data;
|
||||
self.log("got change to " + prefName + " preference");
|
||||
|
||||
switch (prefName) {
|
||||
case "agedWeight":
|
||||
self._agedWeight = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "debug":
|
||||
self._debug = self._prefBranch.getBoolPref(prefName);
|
||||
break;
|
||||
case "enable":
|
||||
self._enabled = self._prefBranch.getBoolPref(prefName);
|
||||
break;
|
||||
case "maxTimeGroupings":
|
||||
self._maxTimeGroupings = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "timeGroupingSize":
|
||||
self._timeGroupingSize = self._prefBranch.getIntPref(prefName) * 1000 * 1000;
|
||||
break;
|
||||
case "bucketSize":
|
||||
self._bucketSize = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "boundaryWeight":
|
||||
self._boundaryWeight = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "prefixWeight":
|
||||
self._prefixWeight = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
default:
|
||||
self.log("Oops! Pref not handled, change ignored.");
|
||||
}
|
||||
if (topic == "nsPref:changed") {
|
||||
let prefName = data;
|
||||
self.log("got change to " + prefName + " preference");
|
||||
|
||||
switch (prefName) {
|
||||
case "agedWeight":
|
||||
self._agedWeight = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "debug":
|
||||
self._debug = self._prefBranch.getBoolPref(prefName);
|
||||
break;
|
||||
case "enable":
|
||||
self._enabled = self._prefBranch.getBoolPref(prefName);
|
||||
break;
|
||||
case "maxTimeGroupings":
|
||||
self._maxTimeGroupings = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "timeGroupingSize":
|
||||
self._timeGroupingSize = self._prefBranch.getIntPref(prefName) * 1000 * 1000;
|
||||
break;
|
||||
case "bucketSize":
|
||||
self._bucketSize = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "boundaryWeight":
|
||||
self._boundaryWeight = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
case "prefixWeight":
|
||||
self._prefixWeight = self._prefBranch.getIntPref(prefName);
|
||||
break;
|
||||
default:
|
||||
self.log("Oops! Pref not handled, change ignored.");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -259,8 +258,9 @@ FormAutoComplete.prototype = {
|
||||
* window
|
||||
*/
|
||||
log(message) {
|
||||
if (!this._debug)
|
||||
if (!this._debug) {
|
||||
return;
|
||||
}
|
||||
dump("FormAutoComplete: " + message + "\n");
|
||||
Services.console.logStringMessage("FormAutoComplete: " + message);
|
||||
},
|
||||
@ -378,8 +378,9 @@ FormAutoComplete.prototype = {
|
||||
let entry = entries[i];
|
||||
// Remove results that do not contain the token
|
||||
// XXX bug 394604 -- .toLowerCase can be wrong for some intl chars
|
||||
if (searchTokens.some(tok => entry.textLowerCase.indexOf(tok) < 0))
|
||||
if (searchTokens.some(tok => entry.textLowerCase.indexOf(tok) < 0)) {
|
||||
continue;
|
||||
}
|
||||
this._calculateScore(entry, searchString, searchTokens);
|
||||
this.log("Reusing autocomplete entry '" + entry.text +
|
||||
"' (" + entry.frecency + " / " + entry.totalScore + ")");
|
||||
@ -553,8 +554,9 @@ FormAutoCompleteResult.prototype = {
|
||||
fieldName: null,
|
||||
|
||||
_checkIndexBounds(index) {
|
||||
if (index < 0 || index >= this.entries.length)
|
||||
if (index < 0 || index >= this.entries.length) {
|
||||
throw Components.Exception("Index out of range.", Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
}
|
||||
},
|
||||
|
||||
// Allow autoCompleteSearch to get at the JS object so it can
|
||||
@ -567,13 +569,15 @@ FormAutoCompleteResult.prototype = {
|
||||
searchString: "",
|
||||
errorDescription: "",
|
||||
get defaultIndex() {
|
||||
if (this.entries.length == 0)
|
||||
if (this.entries.length == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
get searchResult() {
|
||||
if (this.entries.length == 0)
|
||||
if (this.entries.length == 0) {
|
||||
return Ci.nsIAutoCompleteResult.RESULT_NOMATCH;
|
||||
}
|
||||
return Ci.nsIAutoCompleteResult.RESULT_SUCCESS;
|
||||
},
|
||||
get matchCount() {
|
||||
|
@ -300,8 +300,9 @@ nsFormFillController::MarkAsLoginManagerField(nsIDOMHTMLInputElement *aInput)
|
||||
}
|
||||
}
|
||||
|
||||
if (!mLoginManager)
|
||||
if (!mLoginManager) {
|
||||
mLoginManager = do_GetService("@mozilla.org/login-manager;1");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -367,10 +368,11 @@ nsFormFillController::GetController(nsIAutoCompleteController **aController)
|
||||
NS_IMETHODIMP
|
||||
nsFormFillController::GetPopupOpen(bool *aPopupOpen)
|
||||
{
|
||||
if (mFocusedPopup)
|
||||
if (mFocusedPopup) {
|
||||
mFocusedPopup->GetPopupOpen(aPopupOpen);
|
||||
else
|
||||
} else {
|
||||
*aPopupOpen = false;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -399,8 +401,9 @@ nsFormFillController::SetPopupOpen(bool aPopupOpen)
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mFocusedInput);
|
||||
mFocusedPopup->OpenAutocompletePopup(this, element);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
mFocusedPopup->ClosePopup();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -900,37 +903,43 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent)
|
||||
mController->HandleText(&unused) : NS_OK;
|
||||
}
|
||||
if (type.EqualsLiteral("blur")) {
|
||||
if (mFocusedInput)
|
||||
if (mFocusedInput) {
|
||||
StopControllingInput();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
if (type.EqualsLiteral("compositionstart")) {
|
||||
NS_ASSERTION(mController, "should have a controller!");
|
||||
if (mController && mFocusedInput)
|
||||
if (mController && mFocusedInput) {
|
||||
mController->HandleStartComposition();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
if (type.EqualsLiteral("compositionend")) {
|
||||
NS_ASSERTION(mController, "should have a controller!");
|
||||
if (mController && mFocusedInput)
|
||||
if (mController && mFocusedInput) {
|
||||
mController->HandleEndComposition();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
if (type.EqualsLiteral("contextmenu")) {
|
||||
if (mFocusedPopup)
|
||||
if (mFocusedPopup) {
|
||||
mFocusedPopup->ClosePopup();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
if (type.EqualsLiteral("pagehide")) {
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(
|
||||
aEvent->InternalDOMEvent()->GetTarget());
|
||||
if (!doc)
|
||||
if (!doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mFocusedInput) {
|
||||
if (doc == mFocusedInputNode->OwnerDoc())
|
||||
if (doc == mFocusedInputNode->OwnerDoc()) {
|
||||
StopControllingInput();
|
||||
}
|
||||
}
|
||||
|
||||
RemoveForDocument(doc);
|
||||
@ -971,17 +980,20 @@ void
|
||||
nsFormFillController::MaybeStartControllingInput(nsIDOMHTMLInputElement* aInput)
|
||||
{
|
||||
nsCOMPtr<nsINode> inputNode = do_QueryInterface(aInput);
|
||||
if (!inputNode)
|
||||
if (!inputNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aInput);
|
||||
if (!formControl || !formControl->IsSingleLineTextControl(false))
|
||||
if (!formControl || !formControl->IsSingleLineTextControl(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool isReadOnly = false;
|
||||
aInput->GetReadOnly(&isReadOnly);
|
||||
if (isReadOnly)
|
||||
if (isReadOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool autocomplete = nsContentUtils::IsAutocompleteEnabled(aInput);
|
||||
|
||||
@ -1047,12 +1059,14 @@ nsresult
|
||||
nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(mController, "should have a controller!");
|
||||
if (!mFocusedInput || !mController)
|
||||
if (!mFocusedInput || !mController) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
|
||||
if (!keyEvent)
|
||||
if (!keyEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
bool cancel = false;
|
||||
bool unused = false;
|
||||
@ -1089,8 +1103,9 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
|
||||
keyEvent->GetCtrlKey(&isCtrl);
|
||||
keyEvent->GetAltKey(&isAlt);
|
||||
keyEvent->GetMetaKey(&isMeta);
|
||||
if (isCtrl || isAlt || isMeta)
|
||||
if (isCtrl || isAlt || isMeta) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
MOZ_FALLTHROUGH;
|
||||
case nsIDOMKeyEvent::DOM_VK_UP:
|
||||
@ -1159,13 +1174,15 @@ nsresult
|
||||
nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aEvent));
|
||||
if (!mouseEvent)
|
||||
if (!mouseEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> targetInput = do_QueryInterface(
|
||||
aEvent->InternalDOMEvent()->GetTarget());
|
||||
if (!targetInput)
|
||||
if (!targetInput) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int16_t button;
|
||||
mouseEvent->GetButton(&button);
|
||||
@ -1178,8 +1195,9 @@ nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (button != 0)
|
||||
if (button != 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return ShowPopup();
|
||||
}
|
||||
@ -1195,8 +1213,9 @@ nsFormFillController::ShowPopup()
|
||||
|
||||
nsCOMPtr<nsIAutoCompleteInput> input;
|
||||
mController->GetInput(getter_AddRefs(input));
|
||||
if (!input)
|
||||
if (!input) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
input->GetTextValue(value);
|
||||
@ -1221,13 +1240,15 @@ nsFormFillController::ShowPopup()
|
||||
void
|
||||
nsFormFillController::AddWindowListeners(nsPIDOMWindowOuter* aWindow)
|
||||
{
|
||||
if (!aWindow)
|
||||
if (!aWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventTarget* target = aWindow->GetChromeEventHandler();
|
||||
|
||||
if (!target)
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
target->AddEventListener(NS_LITERAL_STRING("focus"), this,
|
||||
true, false);
|
||||
@ -1254,8 +1275,9 @@ nsFormFillController::AddWindowListeners(nsPIDOMWindowOuter* aWindow)
|
||||
void
|
||||
nsFormFillController::RemoveWindowListeners(nsPIDOMWindowOuter* aWindow)
|
||||
{
|
||||
if (!aWindow)
|
||||
if (!aWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
StopControllingInput();
|
||||
|
||||
@ -1264,8 +1286,9 @@ nsFormFillController::RemoveWindowListeners(nsPIDOMWindowOuter* aWindow)
|
||||
|
||||
EventTarget* target = aWindow->GetChromeEventHandler();
|
||||
|
||||
if (!target)
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("focus"), this, true);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("blur"), this, true);
|
||||
@ -1293,8 +1316,9 @@ nsFormFillController::StartControllingInput(nsIDOMHTMLInputElement *aInput)
|
||||
// Find the currently focused docShell
|
||||
nsCOMPtr<nsIDocShell> docShell = GetDocShellForInput(aInput);
|
||||
int32_t index = GetIndexOfDocShell(docShell);
|
||||
if (index < 0)
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache the popup for the focused docShell
|
||||
mFocusedPopup = mPopups.SafeElementAt(index);
|
||||
@ -1333,8 +1357,9 @@ nsFormFillController::StopControllingInput()
|
||||
// focus by clicking another autocomplete textbox
|
||||
nsCOMPtr<nsIAutoCompleteInput> input;
|
||||
mController->GetInput(getter_AddRefs(input));
|
||||
if (input == this)
|
||||
if (input == this) {
|
||||
mController->SetInput(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (mFocusedInputNode) {
|
||||
@ -1387,14 +1412,16 @@ nsFormFillController::GetWindowForDocShell(nsIDocShell *aDocShell)
|
||||
int32_t
|
||||
nsFormFillController::GetIndexOfDocShell(nsIDocShell *aDocShell)
|
||||
{
|
||||
if (!aDocShell)
|
||||
if (!aDocShell) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Loop through our cached docShells looking for the given docShell
|
||||
uint32_t count = mDocShells.Length();
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
if (mDocShells[i] == aDocShell)
|
||||
if (mDocShells[i] == aDocShell) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively check the parent docShell of this one
|
||||
|
Loading…
Reference in New Issue
Block a user