mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1231517 - part 4, Add ZoomToFocusedInput function to nsDOMWindowUtils r=kats
This commit is contained in:
parent
5595d357f2
commit
1bb772ec45
@ -105,6 +105,7 @@
|
|||||||
#include "nsDocument.h"
|
#include "nsDocument.h"
|
||||||
#include "HTMLImageElement.h"
|
#include "HTMLImageElement.h"
|
||||||
#include "mozilla/css/ImageLoader.h"
|
#include "mozilla/css/ImageLoader.h"
|
||||||
|
#include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#undef GetClassName
|
#undef GetClassName
|
||||||
@ -2421,6 +2422,59 @@ nsDOMWindowUtils::FlushApzRepaints(bool* aOutResult)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDOMWindowUtils::ZoomToFocusedInput()
|
||||||
|
{
|
||||||
|
nsIWidget* widget = GetWidget();
|
||||||
|
if (!widget) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
// If APZ is not enabled, this function is a no-op.
|
||||||
|
if (!widget->AsyncPanZoomEnabled()) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||||
|
if (!fm) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIContent* content = fm->GetFocusedContent();
|
||||||
|
if (!content) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIPresShell* shell = APZCCallbackHelper::GetRootContentDocumentPresShellForContent(content);
|
||||||
|
if (!shell) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIScrollableFrame* rootScrollFrame = shell->GetRootScrollFrameAsScrollable();
|
||||||
|
if (!rootScrollFrame) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIDocument* document = shell->GetDocument();
|
||||||
|
if (!document) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t presShellId;
|
||||||
|
FrameMetrics::ViewID viewId;
|
||||||
|
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(document->GetDocumentElement(), &presShellId, &viewId)) {
|
||||||
|
uint32_t flags = layers::DISABLE_ZOOM_OUT;
|
||||||
|
if (!Preferences::GetBool("formhelper.autozoom")) {
|
||||||
|
flags |= layers::PAN_INTO_VIEW_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSSRect bounds = nsLayoutUtils::GetBoundingContentRect(content, rootScrollFrame);
|
||||||
|
bounds.Inflate(15.0f, 0.0f);
|
||||||
|
widget->ZoomToRect(presShellId, viewId, bounds, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement,
|
nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement,
|
||||||
const nsAString& aProperty,
|
const nsAString& aProperty,
|
||||||
|
@ -49,7 +49,7 @@ interface nsIJSRAIIHelper;
|
|||||||
interface nsIContentPermissionRequest;
|
interface nsIContentPermissionRequest;
|
||||||
interface nsIObserver;
|
interface nsIObserver;
|
||||||
|
|
||||||
[scriptable, uuid(7846c43d-e131-40a6-8417-3be2c7e11df1)]
|
[scriptable, uuid(ca6a458c-82e7-4979-886e-6d214eac6f0b)]
|
||||||
interface nsIDOMWindowUtils : nsISupports {
|
interface nsIDOMWindowUtils : nsISupports {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1458,6 +1458,11 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||||||
*/
|
*/
|
||||||
bool flushApzRepaints();
|
bool flushApzRepaints();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask APZ to pan and zoom to the focused input element.
|
||||||
|
*/
|
||||||
|
void zoomToFocusedInput();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method for testing StyleAnimationValue::ComputeDistance.
|
* Method for testing StyleAnimationValue::ComputeDistance.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user