diff --git a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp index c801295b120..ab9dd39f7ab 100755 --- a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp +++ b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigation.cpp @@ -68,12 +68,6 @@ nsSpatialNavigation::HandleEvent(nsIDOMEvent* aEvent) return NS_OK; } -NS_IMETHODIMP -nsSpatialNavigation::KeyDown(nsIDOMEvent* aEvent) -{ - return NS_OK; -} - NS_IMETHODIMP nsSpatialNavigation::KeyUp(nsIDOMEvent* aEvent) { @@ -82,6 +76,12 @@ nsSpatialNavigation::KeyUp(nsIDOMEvent* aEvent) NS_IMETHODIMP nsSpatialNavigation::KeyPress(nsIDOMEvent* aEvent) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsSpatialNavigation::KeyDown(nsIDOMEvent* aEvent) { nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); PRBool enabled; @@ -125,7 +125,7 @@ nsSpatialNavigation::KeyPress(nsIDOMEvent* aEvent) nsCOMPtr formControl(do_QueryInterface(targetContent)); formControlType = formControl->GetType(); - if (!mService->mIgnoreTextFields) + if (mService->mIgnoreTextFields) { if (formControlType == NS_FORM_TEXTAREA || formControlType == NS_FORM_INPUT_TEXT || @@ -219,11 +219,22 @@ nsSpatialNavigation::KeyPress(nsIDOMEvent* aEvent) // based on the selected position we decide to nav. or // not. - if (formControlType == NS_FORM_SELECT) - return NS_OK; + // ************************************************************************************ + // NS_FORM_SELECT cases: + // * if it is a select form of 'size' attr != than '1' then we do as above. + + // * if it is a select form of 'size' attr == than '1', snav can take care of it. + // if (formControlType == NS_FORM_SELECT) + // return NS_OK; + + // ************************************************************************************ + // NS_FORM_TEXTAREA cases: + + // ************************************************************************************ + // NS_FORM_INPUT_TEXT | NS_FORM_INPUT_PASSWORD | NS_FORM_INPUT_FILE cases aEvent->StopPropagation(); - aEvent->PreventDefault(); + aEvent->PreventDefault(); return Up(); } @@ -237,11 +248,22 @@ nsSpatialNavigation::KeyPress(nsIDOMEvent* aEvent) // based on the selected position we decide to nav. or // not. - if (formControlType == NS_FORM_SELECT) - return NS_OK; + // ************************************************************************************ + // NS_FORM_SELECT cases: + // * if it is a select form of 'size' attr != than '1' then we do as above. + + // * if it is a select form of 'size' attr == than '1', snav can take care of it. + // if (formControlType == NS_FORM_SELECT) + // return NS_OK; + + // ************************************************************************************ + // NS_FORM_TEXTAREA cases: + + // ************************************************************************************ + // NS_FORM_INPUT_TEXT | NS_FORM_INPUT_PASSWORD | NS_FORM_INPUT_FILE cases aEvent->StopPropagation(); // We're using this key, no one else should - aEvent->PreventDefault(); + aEvent->PreventDefault(); return Down(); } @@ -544,9 +566,13 @@ nsSpatialNavigation::handleMove(int direction) nsCOMPtr focusedContent; getFocusedContent(direction, getter_AddRefs(focusedContent)); - if (!focusedContent) - return NS_OK; - + // there are some websites which have no focusable elements, + // only text, for example. In these cases, scrolling have to be + // performed by snav. + if (!focusedContent) { + ScrollWindow(direction, getContentWindow()); + return NS_OK; + } nsPresContext* presContext = getPresContext(focusedContent); if(!presContext) return NS_ERROR_NULL_POINTER; @@ -580,7 +606,7 @@ nsSpatialNavigation::handleMove(int direction) if (!doc) return NS_ERROR_FAILURE; - nsIPresShell *presShell = doc->GetShellAt(0); +/* nsIPresShell *presShell = doc->GetShellAt(0); nsIFrame* cframe = presShell->GetPrimaryFrameFor(c); @@ -589,9 +615,10 @@ nsSpatialNavigation::handleMove(int direction) if (b) setFocusedContent(c); else - ScrollWindow(direction, getContentWindow()); + ScrollWindow(direction, getContentWindow());*/ - return NS_OK; + setFocusedContent(c); + return NS_OK; } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -733,8 +760,9 @@ nsSpatialNavigation::setFocusedContent(nsIContent* c) nsCOMPtr contentWindow; if (mService->mDisableJSWhenFocusing) contentWindow = getContentWindow(); - - DisableJSScope foopy (contentWindow); + + // We do not want to have JS disable at anytime - see bug 51075 + // DisableJSScope foopy (contentWindow); //#ifdef OLDER_LAYOUT nsPresContext* presContext = getPresContext(c); diff --git a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp index a21dd40b0e5..1ab6b5a3b1f 100755 --- a/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp +++ b/mozilla/extensions/spatialnavigation/src/nsSpatialNavigationUtils.cpp @@ -811,11 +811,10 @@ PRBool IsPartiallyVisible(nsIPresShell* shell, nsIFrame* frame) relFrameRect.y = frameOffset.y; } - float p2t; - p2t = presContext->PixelsToTwips(); + PRUint16 minPixels = PRUint16(nsPresContext::CSSPixelsToAppUnits(kMinPixels)); nsRectVisibility rectVisibility; viewManager->GetRectVisibility(containingView, relFrameRect, - NS_STATIC_CAST(PRUint16, (kMinPixels * p2t)), + minPixels, &rectVisibility); if (rectVisibility == nsRectVisibility_kVisible ||