зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1547416, bug 1547418) for causing conflicts. a=backout
Backed out changeset 91ac1bb728ef (bug 1547418) Backed out changeset d89587999df1 (bug 1547416)
This commit is contained in:
Родитель
f0ef51bfaf
Коммит
b378f30b76
|
@ -211,15 +211,15 @@ bool nsCoreUtils::IsAncestorOf(nsINode *aPossibleAncestorNode,
|
|||
|
||||
nsresult nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame, nsRange *aRange,
|
||||
uint32_t aScrollType) {
|
||||
ScrollAxis vertical, horizontal;
|
||||
nsIPresShell::ScrollAxis vertical, horizontal;
|
||||
ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
|
||||
|
||||
return ScrollSubstringTo(aFrame, aRange, vertical, horizontal);
|
||||
}
|
||||
|
||||
nsresult nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame, nsRange *aRange,
|
||||
ScrollAxis aVertical,
|
||||
ScrollAxis aHorizontal) {
|
||||
nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal) {
|
||||
if (!aFrame || !aRange) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -262,9 +262,9 @@ void nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame,
|
|||
scrollableFrame->ScrollTo(scrollPoint, ScrollMode::Instant);
|
||||
}
|
||||
|
||||
void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType,
|
||||
ScrollAxis *aVertical,
|
||||
ScrollAxis *aHorizontal) {
|
||||
void nsCoreUtils::ConvertScrollTypeToPercents(
|
||||
uint32_t aScrollType, nsIPresShell::ScrollAxis *aVertical,
|
||||
nsIPresShell::ScrollAxis *aHorizontal) {
|
||||
WhereToScroll whereY, whereX;
|
||||
WhenToScroll whenY, whenX;
|
||||
switch (aScrollType) {
|
||||
|
@ -310,8 +310,8 @@ void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType,
|
|||
whereX = kScrollMinimum;
|
||||
whenX = WhenToScroll::IfNotFullyVisible;
|
||||
}
|
||||
*aVertical = ScrollAxis(whereY, whenY);
|
||||
*aHorizontal = ScrollAxis(whereX, whenX);
|
||||
*aVertical = nsIPresShell::ScrollAxis(whereY, whenY);
|
||||
*aHorizontal = nsIPresShell::ScrollAxis(whereX, whenX);
|
||||
}
|
||||
|
||||
nsIntPoint nsCoreUtils::GetScreenCoordsForWindow(nsINode *aNode) {
|
||||
|
@ -507,7 +507,7 @@ bool nsCoreUtils::IsColumnHidden(nsTreeColumn *aColumn) {
|
|||
|
||||
void nsCoreUtils::ScrollTo(PresShell *aPresShell, nsIContent *aContent,
|
||||
uint32_t aScrollType) {
|
||||
ScrollAxis vertical, horizontal;
|
||||
nsIPresShell::ScrollAxis vertical, horizontal;
|
||||
ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
|
||||
aPresShell->ScrollContentIntoView(aContent, vertical, horizontal,
|
||||
ScrollFlags::ScrollOverflowHidden);
|
||||
|
|
|
@ -157,8 +157,8 @@ class nsCoreUtils {
|
|||
* and when.
|
||||
*/
|
||||
static nsresult ScrollSubstringTo(nsIFrame *aFrame, nsRange *aRange,
|
||||
mozilla::ScrollAxis aVertical,
|
||||
mozilla::ScrollAxis aHorizontal);
|
||||
nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal);
|
||||
|
||||
/**
|
||||
* Scrolls the given frame to the point, used for implememntation of
|
||||
|
@ -175,9 +175,9 @@ class nsCoreUtils {
|
|||
* Converts scroll type constant defined in nsIAccessibleScrollType to
|
||||
* vertical and horizontal parameters.
|
||||
*/
|
||||
static void ConvertScrollTypeToPercents(uint32_t aScrollType,
|
||||
mozilla::ScrollAxis *aVertical,
|
||||
mozilla::ScrollAxis *aHorizontal);
|
||||
static void ConvertScrollTypeToPercents(
|
||||
uint32_t aScrollType, nsIPresShell::ScrollAxis *aVertical,
|
||||
nsIPresShell::ScrollAxis *aHorizontal);
|
||||
|
||||
/**
|
||||
* Returns coordinates in device pixels relative screen for the top level
|
||||
|
|
|
@ -1844,7 +1844,8 @@ void Accessible::DispatchClickEvent(nsIContent* aContent,
|
|||
RefPtr<PresShell> presShell = mDoc->PresShellPtr();
|
||||
|
||||
// Scroll into view.
|
||||
presShell->ScrollContentIntoView(aContent, ScrollAxis(), ScrollAxis(),
|
||||
presShell->ScrollContentIntoView(aContent, nsIPresShell::ScrollAxis(),
|
||||
nsIPresShell::ScrollAxis(),
|
||||
ScrollFlags::ScrollOverflowHidden);
|
||||
|
||||
AutoWeakFrame frame = aContent->GetPrimaryFrame();
|
||||
|
|
|
@ -1277,7 +1277,7 @@ nsresult HyperTextAccessible::SetSelectionRange(int32_t aStartPos,
|
|||
|
||||
// Make sure it is visible
|
||||
domSel->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
|
||||
ScrollAxis(), ScrollAxis(),
|
||||
nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis(),
|
||||
dom::Selection::SCROLL_FOR_CARET_MOVE |
|
||||
dom::Selection::SCROLL_OVERFLOW_HIDDEN);
|
||||
|
||||
|
@ -1646,7 +1646,8 @@ void HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
|
|||
int16_t vPercent = offsetPointY * 100 / size.height;
|
||||
|
||||
nsresult rv = nsCoreUtils::ScrollSubstringTo(
|
||||
frame, range, ScrollAxis(vPercent), ScrollAxis(hPercent));
|
||||
frame, range, nsIPresShell::ScrollAxis(vPercent),
|
||||
nsIPresShell::ScrollAxis(hPercent));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
initialScrolled = true;
|
||||
|
|
|
@ -3676,7 +3676,7 @@ Element* Document::GetCurrentScript() {
|
|||
void Document::ReleaseCapture() const {
|
||||
// only release the capture if the caller can access it. This prevents a
|
||||
// page from stopping a scrollbar grab for example.
|
||||
nsCOMPtr<nsINode> node = PresShell::GetCapturingContent();
|
||||
nsCOMPtr<nsINode> node = nsIPresShell::GetCapturingContent();
|
||||
if (node && nsContentUtils::CanCallerAccess(node)) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
|
|
|
@ -783,8 +783,10 @@ void Element::ScrollIntoView(const ScrollIntoViewOptions& aOptions) {
|
|||
}
|
||||
|
||||
presShell->ScrollContentIntoView(
|
||||
this, ScrollAxis(whereToScrollVertically, WhenToScroll::Always),
|
||||
ScrollAxis(whereToScrollHorizontally, WhenToScroll::Always), scrollFlags);
|
||||
this,
|
||||
nsIPresShell::ScrollAxis(whereToScrollVertically, WhenToScroll::Always),
|
||||
nsIPresShell::ScrollAxis(whereToScrollHorizontally, WhenToScroll::Always),
|
||||
scrollFlags);
|
||||
}
|
||||
|
||||
void Element::Scroll(const CSSIntPoint& aScroll,
|
||||
|
|
|
@ -1175,7 +1175,7 @@ class Element : public FragmentOrElement {
|
|||
// If there is already an active capture, ignore this request. This would
|
||||
// occur if a splitter, frame resizer, etc had already captured and we don't
|
||||
// want to override those.
|
||||
if (!PresShell::GetCapturingContent()) {
|
||||
if (!nsIPresShell::GetCapturingContent()) {
|
||||
PresShell::SetCapturingContent(
|
||||
this, CaptureFlags::PreventDragStart |
|
||||
(aRetargetToElement ? CaptureFlags::RetargetToElement
|
||||
|
@ -1192,7 +1192,7 @@ class Element : public FragmentOrElement {
|
|||
}
|
||||
|
||||
void ReleaseCapture() {
|
||||
if (PresShell::GetCapturingContent() == this) {
|
||||
if (nsIPresShell::GetCapturingContent() == this) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ class nsAutoScrollTimer final : public nsITimerCallback, public nsINamed {
|
|||
// stopped by the selection if the prescontext is destroyed.
|
||||
mPresContext = aPresContext;
|
||||
|
||||
mContent = PresShell::GetCapturingContent();
|
||||
mContent = nsIPresShell::GetCapturingContent();
|
||||
|
||||
if (!mTimer) {
|
||||
mTimer = NS_NewTimer(
|
||||
|
@ -1877,8 +1877,8 @@ nsresult Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint) {
|
|||
bool didScroll;
|
||||
while (true) {
|
||||
didScroll = presShell->ScrollFrameRectIntoView(
|
||||
aFrame, nsRect(aPoint, nsSize(0, 0)), ScrollAxis(), ScrollAxis(),
|
||||
ScrollFlags::IgnoreMarginAndPadding);
|
||||
aFrame, nsRect(aPoint, nsSize(0, 0)), nsIPresShell::ScrollAxis(),
|
||||
nsIPresShell::ScrollAxis(), ScrollFlags::IgnoreMarginAndPadding);
|
||||
if (!weakFrame || !weakRootFrame) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3006,10 +3006,9 @@ Selection::ScrollSelectionIntoViewEvent::Run() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Selection::PostScrollSelectionIntoViewEvent(SelectionRegion aRegion,
|
||||
int32_t aFlags,
|
||||
ScrollAxis aVertical,
|
||||
ScrollAxis aHorizontal) {
|
||||
nsresult Selection::PostScrollSelectionIntoViewEvent(
|
||||
SelectionRegion aRegion, int32_t aFlags, nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal) {
|
||||
// If we've already posted an event, revoke it and place a new one at the
|
||||
// end of the queue to make sure that any new pending reflow events are
|
||||
// processed before we scroll. This will insure that we scroll to the
|
||||
|
@ -3030,15 +3029,16 @@ void Selection::ScrollIntoView(int16_t aRegion, bool aIsSynchronous,
|
|||
WhereToScroll aVPercent, WhereToScroll aHPercent,
|
||||
ErrorResult& aRv) {
|
||||
int32_t flags = aIsSynchronous ? Selection::SCROLL_SYNCHRONOUS : 0;
|
||||
nsresult rv = ScrollIntoView(aRegion, ScrollAxis(aVPercent),
|
||||
ScrollAxis(aHPercent), flags);
|
||||
nsresult rv = ScrollIntoView(aRegion, nsIPresShell::ScrollAxis(aVPercent),
|
||||
nsIPresShell::ScrollAxis(aHPercent), flags);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult Selection::ScrollIntoView(SelectionRegion aRegion,
|
||||
ScrollAxis aVertical, ScrollAxis aHorizontal,
|
||||
nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal,
|
||||
int32_t aFlags) {
|
||||
if (!mFrameSelection) {
|
||||
return NS_OK;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "mozilla/AccessibleCaretEventHub.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/PresShell.h" // For ScrollAxis
|
||||
#include "mozilla/RangeBoundary.h"
|
||||
#include "mozilla/SelectionChangeEventDispatcher.h"
|
||||
#include "mozilla/TextRange.h"
|
||||
|
@ -136,10 +136,9 @@ class Selection final : public nsSupportsWeakReference,
|
|||
nsIFrame* GetSelectionEndPointGeometry(SelectionRegion aRegion,
|
||||
nsRect* aRect);
|
||||
|
||||
nsresult PostScrollSelectionIntoViewEvent(SelectionRegion aRegion,
|
||||
int32_t aFlags,
|
||||
ScrollAxis aVertical,
|
||||
ScrollAxis aHorizontal);
|
||||
nsresult PostScrollSelectionIntoViewEvent(
|
||||
SelectionRegion aRegion, int32_t aFlags,
|
||||
nsIPresShell::ScrollAxis aVertical, nsIPresShell::ScrollAxis aHorizontal);
|
||||
enum {
|
||||
SCROLL_SYNCHRONOUS = 1 << 1,
|
||||
SCROLL_FIRST_ANCESTOR_ONLY = 1 << 2,
|
||||
|
@ -153,10 +152,11 @@ class Selection final : public nsSupportsWeakReference,
|
|||
// Otherwise, if SCROLL_DO_FLUSH is also in aFlags, then this method will
|
||||
// flush layout and you MUST hold a strong ref on 'this' for the duration
|
||||
// of this call. This might destroy arbitrary layout objects.
|
||||
nsresult ScrollIntoView(SelectionRegion aRegion,
|
||||
ScrollAxis aVertical = ScrollAxis(),
|
||||
ScrollAxis aHorizontal = ScrollAxis(),
|
||||
int32_t aFlags = 0);
|
||||
nsresult ScrollIntoView(
|
||||
SelectionRegion aRegion,
|
||||
nsIPresShell::ScrollAxis aVertical = nsIPresShell::ScrollAxis(),
|
||||
nsIPresShell::ScrollAxis aHorizontal = nsIPresShell::ScrollAxis(),
|
||||
int32_t aFlags = 0);
|
||||
nsresult SubtractRange(RangeData* aRange, nsRange* aSubtract,
|
||||
nsTArray<RangeData>* aOutput);
|
||||
/**
|
||||
|
@ -664,7 +664,8 @@ class Selection final : public nsSupportsWeakReference,
|
|||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
ScrollSelectionIntoViewEvent(Selection* aSelection, SelectionRegion aRegion,
|
||||
ScrollAxis aVertical, ScrollAxis aHorizontal,
|
||||
nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal,
|
||||
int32_t aFlags)
|
||||
: Runnable("dom::Selection::ScrollSelectionIntoViewEvent"),
|
||||
mSelection(aSelection),
|
||||
|
@ -679,8 +680,8 @@ class Selection final : public nsSupportsWeakReference,
|
|||
private:
|
||||
Selection* mSelection;
|
||||
SelectionRegion mRegion;
|
||||
ScrollAxis mVerticalScroll;
|
||||
ScrollAxis mHorizontalScroll;
|
||||
nsIPresShell::ScrollAxis mVerticalScroll;
|
||||
nsIPresShell::ScrollAxis mHorizontalScroll;
|
||||
int32_t mFlags;
|
||||
};
|
||||
|
||||
|
|
|
@ -2516,8 +2516,9 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
|
|||
// main-thread side knows to scroll the content into view before we get
|
||||
// the bounding content rect and ask APZ to adjust the visual viewport.
|
||||
presShell->ScrollContentIntoView(
|
||||
content, ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
content,
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
ScrollFlags::ScrollOverflowHidden);
|
||||
|
||||
CSSRect bounds =
|
||||
|
|
|
@ -2135,8 +2135,10 @@ void nsFocusManager::ScrollIntoView(PresShell* aPresShell, nsIContent* aContent,
|
|||
scrollFlags |= ScrollFlags::IgnoreMarginAndPadding;
|
||||
}
|
||||
aPresShell->ScrollContentIntoView(
|
||||
aContent, ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible), scrollFlags);
|
||||
aContent,
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
scrollFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6336,7 +6336,7 @@ void nsGlobalWindowOuter::EnterModalState() {
|
|||
// Usually the activeESM check above does that, but there are cases when
|
||||
// we don't have activeESM, or it is for different document.
|
||||
Document* topDoc = topWin->GetExtantDoc();
|
||||
nsIContent* capturingContent = PresShell::GetCapturingContent();
|
||||
nsIContent* capturingContent = nsIPresShell::GetCapturingContent();
|
||||
if (capturingContent && topDoc &&
|
||||
nsContentUtils::ContentIsCrossDocDescendantOf(capturingContent, topDoc)) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
|
|
|
@ -3004,7 +3004,8 @@ nsresult ContentEventHandler::OnSelectionEvent(WidgetSelectionEvent* aEvent) {
|
|||
}
|
||||
|
||||
mSelection->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
|
||||
ScrollAxis(), ScrollAxis(), 0);
|
||||
nsIPresShell::ScrollAxis(),
|
||||
nsIPresShell::ScrollAxis(), 0);
|
||||
aEvent->mSucceeded = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1757,7 +1757,7 @@ void EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// If non-native code is capturing the mouse don't start a drag.
|
||||
if (PresShell::IsMouseCapturePreventingDrag()) {
|
||||
if (nsIPresShell::IsMouseCapturePreventingDrag()) {
|
||||
StopTrackingDragGesture();
|
||||
return;
|
||||
}
|
||||
|
@ -3035,7 +3035,7 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
// mousemove/mouseup events will continue to be dispatched to this element
|
||||
// and therefore forwarded to the child.
|
||||
if (aEvent->HasBeenPostedToRemoteProcess() &&
|
||||
!PresShell::GetCapturingContent()) {
|
||||
!nsIPresShell::GetCapturingContent()) {
|
||||
if (nsIContent* content =
|
||||
mCurrentTarget ? mCurrentTarget->GetContent() : nullptr) {
|
||||
PresShell::SetCapturingContent(content, CaptureFlags::None);
|
||||
|
@ -6290,7 +6290,7 @@ AutoHandlingUserInputStatePusher::~AutoHandlingUserInputStatePusher() {
|
|||
}
|
||||
EventStateManager::StopHandlingUserInput(mMessage);
|
||||
if (mMessage == eMouseDown) {
|
||||
PresShell::AllowMouseCapture(false);
|
||||
nsIPresShell::AllowMouseCapture(false);
|
||||
}
|
||||
if (NeedsToResetFocusManagerMouseButtonHandlingState()) {
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
|
|
|
@ -3428,7 +3428,7 @@ void HTMLInputElement::StartRangeThumbDrag(WidgetGUIEvent* aEvent) {
|
|||
void HTMLInputElement::FinishRangeThumbDrag(WidgetGUIEvent* aEvent) {
|
||||
MOZ_ASSERT(mIsDraggingRange);
|
||||
|
||||
if (PresShell::GetCapturingContent() == this) {
|
||||
if (nsIPresShell::GetCapturingContent() == this) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
if (aEvent) {
|
||||
|
@ -3443,7 +3443,7 @@ void HTMLInputElement::CancelRangeThumbDrag(bool aIsForUserEvent) {
|
|||
MOZ_ASSERT(mIsDraggingRange);
|
||||
|
||||
mIsDraggingRange = false;
|
||||
if (PresShell::GetCapturingContent() == this) {
|
||||
if (nsIPresShell::GetCapturingContent() == this) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
if (aIsForUserEvent) {
|
||||
|
@ -3512,7 +3512,7 @@ void HTMLInputElement::StartNumberControlSpinnerSpin() {
|
|||
|
||||
void HTMLInputElement::StopNumberControlSpinnerSpin(SpinnerStopState aState) {
|
||||
if (mNumberControlSpinnerIsSpinning) {
|
||||
if (PresShell::GetCapturingContent() == this) {
|
||||
if (nsIPresShell::GetCapturingContent() == this) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
|
||||
|
@ -4183,7 +4183,7 @@ void HTMLInputElement::PostHandleEventForRangeThumb(
|
|||
if (mIsDraggingRange) {
|
||||
break;
|
||||
}
|
||||
if (PresShell::GetCapturingContent()) {
|
||||
if (nsIPresShell::GetCapturingContent()) {
|
||||
break; // don't start drag if someone else is already capturing
|
||||
}
|
||||
WidgetInputEvent* inputEvent = aVisitor.mEvent->AsInputEvent();
|
||||
|
@ -4212,7 +4212,7 @@ void HTMLInputElement::PostHandleEventForRangeThumb(
|
|||
if (!mIsDraggingRange) {
|
||||
break;
|
||||
}
|
||||
if (PresShell::GetCapturingContent() != this) {
|
||||
if (nsIPresShell::GetCapturingContent() != this) {
|
||||
// Someone else grabbed capture.
|
||||
CancelRangeThumbDrag();
|
||||
break;
|
||||
|
|
|
@ -1809,7 +1809,7 @@ static NPCocoaEventType CocoaEventTypeForEvent(const WidgetGUIEvent& anEvent,
|
|||
// We don't know via information on events from the widget code whether or
|
||||
// not we're dragging. The widget code just generates mouse move events
|
||||
// from native drag events. If anybody is capturing, this is a drag event.
|
||||
if (PresShell::GetCapturingContent()) {
|
||||
if (nsIPresShell::GetCapturingContent()) {
|
||||
return NPCocoaEventMouseDragged;
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,9 @@ using namespace mozilla::layout;
|
|||
using PaintFrameFlags = nsLayoutUtils::PaintFrameFlags;
|
||||
typedef ScrollableLayerGuid::ViewID ViewID;
|
||||
|
||||
PresShell::CapturingContentInfo PresShell::sCapturingContentInfo;
|
||||
CapturingContentInfo nsIPresShell::gCaptureInfo = {
|
||||
false /* mAllowed */, false /* mPointerLock */,
|
||||
false /* mRetargetToElement */, false /* mPreventDrag */};
|
||||
|
||||
// RangePaintInfo is used to paint ranges to offscreen buffers
|
||||
struct RangePaintInfo {
|
||||
|
@ -2440,8 +2442,7 @@ void PresShell::MaybeReleaseCapturingContent() {
|
|||
if (frameSelection) {
|
||||
frameSelection->SetDragState(false);
|
||||
}
|
||||
if (sCapturingContentInfo.mContent &&
|
||||
sCapturingContentInfo.mContent->OwnerDoc() == mDocument) {
|
||||
if (gCaptureInfo.mContent && gCaptureInfo.mContent->OwnerDoc() == mDocument) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
}
|
||||
|
@ -3314,8 +3315,10 @@ static nscoord ComputeWhereToScroll(WhereToScroll aWhereToScroll,
|
|||
*/
|
||||
static void ScrollToShowRect(nsIPresShell* aPresShell,
|
||||
nsIScrollableFrame* aFrameAsScrollable,
|
||||
const nsRect& aRect, ScrollAxis aVertical,
|
||||
ScrollAxis aHorizontal, ScrollFlags aScrollFlags) {
|
||||
const nsRect& aRect,
|
||||
nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal,
|
||||
ScrollFlags aScrollFlags) {
|
||||
nsPoint scrollPt = aFrameAsScrollable->GetVisualViewportOffset();
|
||||
nsRect visibleRect(scrollPt, aFrameAsScrollable->GetVisualViewportSize());
|
||||
|
||||
|
@ -3396,8 +3399,8 @@ static void ScrollToShowRect(nsIPresShell* aPresShell,
|
|||
}
|
||||
|
||||
nsresult PresShell::ScrollContentIntoView(nsIContent* aContent,
|
||||
ScrollAxis aVertical,
|
||||
ScrollAxis aHorizontal,
|
||||
nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal,
|
||||
ScrollFlags aScrollFlags) {
|
||||
NS_ENSURE_TRUE(aContent, NS_ERROR_NULL_POINTER);
|
||||
RefPtr<Document> composedDoc = aContent->GetComposedDoc();
|
||||
|
@ -3514,8 +3517,8 @@ void PresShell::DoScrollContentIntoView() {
|
|||
|
||||
bool nsIPresShell::ScrollFrameRectIntoView(nsIFrame* aFrame,
|
||||
const nsRect& aRect,
|
||||
ScrollAxis aVertical,
|
||||
ScrollAxis aHorizontal,
|
||||
nsIPresShell::ScrollAxis aVertical,
|
||||
nsIPresShell::ScrollAxis aHorizontal,
|
||||
ScrollFlags aScrollFlags) {
|
||||
bool didScroll = false;
|
||||
// This function needs to work even if rect has a width or height of 0.
|
||||
|
@ -3709,11 +3712,11 @@ void nsIPresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent) {
|
|||
}
|
||||
|
||||
void PresShell::ClearMouseCaptureOnView(nsView* aView) {
|
||||
if (sCapturingContentInfo.mContent) {
|
||||
if (gCaptureInfo.mContent) {
|
||||
if (aView) {
|
||||
// if a view was specified, ensure that the captured content is within
|
||||
// this view.
|
||||
nsIFrame* frame = sCapturingContentInfo.mContent->GetPrimaryFrame();
|
||||
nsIFrame* frame = gCaptureInfo.mContent->GetPrimaryFrame();
|
||||
if (frame) {
|
||||
nsView* view = frame->GetClosestView();
|
||||
// if there is no view, capturing won't be handled any more, so
|
||||
|
@ -3721,10 +3724,10 @@ void PresShell::ClearMouseCaptureOnView(nsView* aView) {
|
|||
if (view) {
|
||||
do {
|
||||
if (view == aView) {
|
||||
sCapturingContentInfo.mContent = nullptr;
|
||||
gCaptureInfo.mContent = nullptr;
|
||||
// the view containing the captured content likely disappeared so
|
||||
// disable capture for now.
|
||||
sCapturingContentInfo.mAllowed = false;
|
||||
gCaptureInfo.mAllowed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3736,38 +3739,38 @@ void PresShell::ClearMouseCaptureOnView(nsView* aView) {
|
|||
}
|
||||
}
|
||||
|
||||
sCapturingContentInfo.mContent = nullptr;
|
||||
gCaptureInfo.mContent = nullptr;
|
||||
}
|
||||
|
||||
// disable mouse capture until the next mousedown as a dialog has opened
|
||||
// or a drag has started. Otherwise, someone could start capture during
|
||||
// the modal dialog or drag.
|
||||
sCapturingContentInfo.mAllowed = false;
|
||||
gCaptureInfo.mAllowed = false;
|
||||
}
|
||||
|
||||
void PresShell::ClearMouseCapture(nsIFrame* aFrame) {
|
||||
if (!sCapturingContentInfo.mContent) {
|
||||
sCapturingContentInfo.mAllowed = false;
|
||||
void nsIPresShell::ClearMouseCapture(nsIFrame* aFrame) {
|
||||
if (!gCaptureInfo.mContent) {
|
||||
gCaptureInfo.mAllowed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// null frame argument means clear the capture
|
||||
if (!aFrame) {
|
||||
sCapturingContentInfo.mContent = nullptr;
|
||||
sCapturingContentInfo.mAllowed = false;
|
||||
gCaptureInfo.mContent = nullptr;
|
||||
gCaptureInfo.mAllowed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
nsIFrame* capturingFrame = sCapturingContentInfo.mContent->GetPrimaryFrame();
|
||||
nsIFrame* capturingFrame = gCaptureInfo.mContent->GetPrimaryFrame();
|
||||
if (!capturingFrame) {
|
||||
sCapturingContentInfo.mContent = nullptr;
|
||||
sCapturingContentInfo.mAllowed = false;
|
||||
gCaptureInfo.mContent = nullptr;
|
||||
gCaptureInfo.mAllowed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::IsAncestorFrameCrossDoc(aFrame, capturingFrame)) {
|
||||
sCapturingContentInfo.mContent = nullptr;
|
||||
sCapturingContentInfo.mAllowed = false;
|
||||
gCaptureInfo.mContent = nullptr;
|
||||
gCaptureInfo.mAllowed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6132,28 +6135,27 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
|
|||
void PresShell::SetCapturingContent(nsIContent* aContent, CaptureFlags aFlags) {
|
||||
// If capture was set for pointer lock, don't unlock unless we are coming
|
||||
// out of pointer lock explicitly.
|
||||
if (!aContent && sCapturingContentInfo.mPointerLock &&
|
||||
if (!aContent && gCaptureInfo.mPointerLock &&
|
||||
!(aFlags & CaptureFlags::PointerLock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sCapturingContentInfo.mContent = nullptr;
|
||||
gCaptureInfo.mContent = nullptr;
|
||||
|
||||
// only set capturing content if allowed or the
|
||||
// CaptureFlags::IgnoreAllowedState or CaptureFlags::PointerLock are used.
|
||||
if ((aFlags & CaptureFlags::IgnoreAllowedState) ||
|
||||
sCapturingContentInfo.mAllowed || (aFlags & CaptureFlags::PointerLock)) {
|
||||
if ((aFlags & CaptureFlags::IgnoreAllowedState) || gCaptureInfo.mAllowed ||
|
||||
(aFlags & CaptureFlags::PointerLock)) {
|
||||
if (aContent) {
|
||||
sCapturingContentInfo.mContent = aContent;
|
||||
gCaptureInfo.mContent = aContent;
|
||||
}
|
||||
// CaptureFlags::PointerLock is the same as
|
||||
// CaptureFlags::RetargetToElement & CaptureFlags::IgnoreAllowedState.
|
||||
sCapturingContentInfo.mRetargetToElement =
|
||||
gCaptureInfo.mRetargetToElement =
|
||||
!!(aFlags & CaptureFlags::RetargetToElement) ||
|
||||
!!(aFlags & CaptureFlags::PointerLock);
|
||||
sCapturingContentInfo.mPreventDrag =
|
||||
!!(aFlags & CaptureFlags::PreventDragStart);
|
||||
sCapturingContentInfo.mPointerLock = !!(aFlags & CaptureFlags::PointerLock);
|
||||
gCaptureInfo.mPreventDrag = !!(aFlags & CaptureFlags::PreventDragStart);
|
||||
gCaptureInfo.mPointerLock = !!(aFlags & CaptureFlags::PointerLock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6674,7 +6676,7 @@ nsresult PresShell::EventHandler::HandleEventUsingCoordinates(
|
|||
// capture retargeting is being used, no frame was found or the frame's
|
||||
// content is not a descendant of the capturing content.
|
||||
if (capturingContent && !pointerCapturingContent &&
|
||||
(PresShell::sCapturingContentInfo.mRetargetToElement ||
|
||||
(gCaptureInfo.mRetargetToElement ||
|
||||
!eventTargetData.mFrame->GetContent() ||
|
||||
!nsContentUtils::ContentIsCrossDocDescendantOf(
|
||||
eventTargetData.mFrame->GetContent(), capturingContent))) {
|
||||
|
@ -7013,7 +7015,7 @@ nsIContent* PresShell::EventHandler::GetCapturingContentFor(
|
|||
return (aGUIEvent->mClass == ePointerEventClass ||
|
||||
aGUIEvent->mClass == eWheelEventClass ||
|
||||
aGUIEvent->HasMouseEventMessage())
|
||||
? PresShell::GetCapturingContent()
|
||||
? nsIPresShell::GetCapturingContent()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
|
@ -7378,7 +7380,7 @@ PresShell::EventHandler::ComputeRootFrameToHandleEventWithCapturingContent(
|
|||
return aRootFrameToHandleEvent;
|
||||
}
|
||||
|
||||
if (PresShell::sCapturingContentInfo.mRetargetToElement) {
|
||||
if (gCaptureInfo.mRetargetToElement) {
|
||||
*aIsCaptureRetargeted = true;
|
||||
return aRootFrameToHandleEvent;
|
||||
}
|
||||
|
@ -7847,7 +7849,7 @@ bool PresShell::EventHandler::PrepareToDispatchEvent(
|
|||
GetPresContext() &&
|
||||
GetPresContext()->EventStateManager() ==
|
||||
EventStateManager::GetActiveEventStateManager();
|
||||
PresShell::AllowMouseCapture(allowCapture);
|
||||
nsIPresShell::AllowMouseCapture(allowCapture);
|
||||
*aIsUserInteraction = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -7924,7 +7926,7 @@ void PresShell::EventHandler::FinalizeHandlingEvent(WidgetEvent* aEvent) {
|
|||
PresShell::ReleaseCapturingContent();
|
||||
return;
|
||||
case eMouseMove:
|
||||
PresShell::AllowMouseCapture(false);
|
||||
nsIPresShell::AllowMouseCapture(false);
|
||||
return;
|
||||
case eDrag:
|
||||
case eDragEnd:
|
||||
|
@ -8263,7 +8265,7 @@ void PresShell::EventHandler::DispatchTouchEventToDOM(
|
|||
}
|
||||
|
||||
Document* doc = content->OwnerDoc();
|
||||
nsIContent* capturingContent = PresShell::GetCapturingContent();
|
||||
nsIContent* capturingContent = nsIPresShell::GetCapturingContent();
|
||||
if (capturingContent) {
|
||||
if (capturingContent->OwnerDoc() != doc) {
|
||||
// Wrong document, don't dispatch anything.
|
||||
|
@ -8511,13 +8513,15 @@ bool PresShell::EventHandler::PrepareToUseCaretPosition(
|
|||
// problem. The only difference in the result is that if your cursor is in
|
||||
// an edit box below the current view, you'll get the edit box aligned with
|
||||
// the top of the window. This is arguably better behavior anyway.
|
||||
rv =
|
||||
MOZ_KnownLive(mPresShell)
|
||||
->ScrollContentIntoView(
|
||||
content, ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
ScrollFlags::ScrollOverflowHidden |
|
||||
ScrollFlags::IgnoreMarginAndPadding);
|
||||
rv = MOZ_KnownLive(mPresShell)
|
||||
->ScrollContentIntoView(
|
||||
content,
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum,
|
||||
WhenToScroll::IfNotVisible),
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum,
|
||||
WhenToScroll::IfNotVisible),
|
||||
ScrollFlags::ScrollOverflowHidden |
|
||||
ScrollFlags::IgnoreMarginAndPadding);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
frame = content->GetPrimaryFrame();
|
||||
NS_WARNING_ASSERTION(frame, "No frame for focused content?");
|
||||
|
|
|
@ -73,34 +73,6 @@ class PresShell final : public nsIPresShell,
|
|||
|
||||
static bool AccessibleCaretEnabled(nsIDocShell* aDocShell);
|
||||
|
||||
/**
|
||||
* Return the active content currently capturing the mouse if any.
|
||||
*/
|
||||
static nsIContent* GetCapturingContent() {
|
||||
return sCapturingContentInfo.mContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow or disallow mouse capturing.
|
||||
*/
|
||||
static void AllowMouseCapture(bool aAllowed) {
|
||||
sCapturingContentInfo.mAllowed = aAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is an active mouse capture that wants to prevent
|
||||
* drags.
|
||||
*/
|
||||
static bool IsMouseCapturePreventingDrag() {
|
||||
return sCapturingContentInfo.mPreventDrag && sCapturingContentInfo.mContent;
|
||||
}
|
||||
|
||||
static void ClearMouseCaptureOnView(nsView* aView);
|
||||
|
||||
// If a frame in the subtree rooted at aFrame is capturing the mouse then
|
||||
// clears that capture.
|
||||
static void ClearMouseCapture(nsIFrame* aFrame);
|
||||
|
||||
void Init(Document*, nsPresContext*, nsViewManager*);
|
||||
void Destroy() override;
|
||||
|
||||
|
@ -266,6 +238,7 @@ class PresShell final : public nsIPresShell,
|
|||
*/
|
||||
void ScheduleViewManagerFlush(PaintType aType = PaintType::Default);
|
||||
|
||||
void ClearMouseCaptureOnView(nsView* aView) override;
|
||||
bool IsVisible() override;
|
||||
void SuppressDisplayport(bool aEnabled) override;
|
||||
void RespectDisplayportSuppression(bool aEnabled) override;
|
||||
|
@ -1577,8 +1550,6 @@ class PresShell final : public nsIPresShell,
|
|||
// details for the scroll operation, see ScrollIntoViewData above.
|
||||
nsCOMPtr<nsIContent> mContentToScrollTo;
|
||||
|
||||
TimeStamp mLastOSWake;
|
||||
|
||||
// The focus sequence number of the last processed input event
|
||||
uint64_t mAPZFocusSequenceNumber;
|
||||
// The focus information needed for async keyboard scrolling
|
||||
|
@ -1626,24 +1597,10 @@ class PresShell final : public nsIPresShell,
|
|||
// Whether mForceUseLegacyNonPrimaryDispatch is initialised.
|
||||
bool mInitializedWithClickEventDispatchingBlacklist : 1;
|
||||
|
||||
struct CapturingContentInfo final {
|
||||
CapturingContentInfo()
|
||||
: mAllowed(false),
|
||||
mPointerLock(false),
|
||||
mRetargetToElement(false),
|
||||
mPreventDrag(false) {}
|
||||
|
||||
// capture should only be allowed during a mousedown event
|
||||
StaticRefPtr<nsIContent> mContent;
|
||||
bool mAllowed;
|
||||
bool mPointerLock;
|
||||
bool mRetargetToElement;
|
||||
bool mPreventDrag;
|
||||
};
|
||||
static CapturingContentInfo sCapturingContentInfo;
|
||||
|
||||
static bool sDisableNonTestMouseEvents;
|
||||
|
||||
TimeStamp mLastOSWake;
|
||||
|
||||
static bool sProcessInteractable;
|
||||
};
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ enum class ReflowRootHandling {
|
|||
|
||||
// WhereToScroll should be 0 ~ 100 or -1. When it's in 0 ~ 100, it means
|
||||
// percentage of scrollTop/scrollLeft in scrollHeight/scrollWidth.
|
||||
// See the comment for constructor of ScrollAxis for the detail.
|
||||
// See ComputeWhereToScroll() for the detail.
|
||||
typedef int16_t WhereToScroll;
|
||||
static const WhereToScroll kScrollToTop = 0;
|
||||
static const WhereToScroll kScrollToLeft = 0;
|
||||
|
@ -86,62 +86,12 @@ static const WhereToScroll kScrollToBottom = 100;
|
|||
static const WhereToScroll kScrollToRight = 100;
|
||||
static const WhereToScroll kScrollMinimum = -1;
|
||||
|
||||
// See the comment for constructor of ScrollAxis for the detail.
|
||||
enum class WhenToScroll : uint8_t {
|
||||
Always,
|
||||
IfNotVisible,
|
||||
IfNotFullyVisible,
|
||||
};
|
||||
|
||||
struct ScrollAxis final {
|
||||
/**
|
||||
* aWhere:
|
||||
* Either a percentage or a special value. PresShell defines:
|
||||
* * (Default) kScrollMinimum = -1: The visible area is scrolled the
|
||||
* minimum amount to show as much as possible of the frame. This won't
|
||||
* hide any initially visible part of the frame.
|
||||
* * kScrollToTop = 0: The frame's upper edge is aligned with the top edge
|
||||
* of the visible area.
|
||||
* * kScrollToBottom = 100: The frame's bottom edge is aligned with the
|
||||
* bottom edge of the visible area.
|
||||
* * kScrollToLeft = 0: The frame's left edge is aligned with the left edge
|
||||
* of the visible area.
|
||||
* * kScrollToRight = 100: The frame's right edge is aligned* with the right
|
||||
* edge of the visible area.
|
||||
* * kScrollToCenter = 50: The frame is centered along the axis the
|
||||
* ScrollAxis is used for.
|
||||
*
|
||||
* Other values are treated as a percentage, and the point*"percent"
|
||||
* down the frame is placed at the point "percent" down the visible area.
|
||||
*
|
||||
* aWhen:
|
||||
* * (Default) WhenToScroll::IfNotFullyVisible: Move the frame only if it is
|
||||
* not fully visible (including if it's not visible at all). Note that
|
||||
* in this case if the frame is too large to fit in view, it will only
|
||||
* be scrolled if more of it can fit than is already in view.
|
||||
* * WhenToScroll::IfNotVisible: Move the frame only if none of it is
|
||||
* visible.
|
||||
* * WhenToScroll::Always: Move the frame regardless of its current
|
||||
* visibility.
|
||||
*
|
||||
* aOnlyIfPerceivedScrollableDirection:
|
||||
* If the direction is not a perceived scrollable direction (i.e. no
|
||||
* scrollbar showing and less than one device pixel of scrollable
|
||||
* distance), don't scroll. Defaults to false.
|
||||
*/
|
||||
explicit ScrollAxis(WhereToScroll aWhere = kScrollMinimum,
|
||||
WhenToScroll aWhen = WhenToScroll::IfNotFullyVisible,
|
||||
bool aOnlyIfPerceivedScrollableDirection = false)
|
||||
: mWhereToScroll(aWhere),
|
||||
mWhenToScroll(aWhen),
|
||||
mOnlyIfPerceivedScrollableDirection(
|
||||
aOnlyIfPerceivedScrollableDirection) {}
|
||||
|
||||
WhereToScroll mWhereToScroll;
|
||||
WhenToScroll mWhenToScroll;
|
||||
bool mOnlyIfPerceivedScrollableDirection : 1;
|
||||
};
|
||||
|
||||
enum class ScrollFlags {
|
||||
None = 0,
|
||||
ScrollFirstAncestorOnly = 1 << 0,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/ScrollTypes.h"
|
||||
#include "mozilla/ServoStyleSet.h"
|
||||
#include "mozilla/ServoStyleConsts.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
|
@ -127,6 +128,15 @@ class SourceSurface;
|
|||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
struct CapturingContentInfo final {
|
||||
// capture should only be allowed during a mousedown event
|
||||
bool mAllowed;
|
||||
bool mPointerLock;
|
||||
bool mRetargetToElement;
|
||||
bool mPreventDrag;
|
||||
mozilla::StaticRefPtr<nsIContent> mContent;
|
||||
};
|
||||
|
||||
// b7b89561-4f03-44b3-9afa-b47e7f313ffb
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ \
|
||||
|
@ -609,6 +619,53 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||
*/
|
||||
already_AddRefed<gfxContext> CreateReferenceRenderingContext();
|
||||
|
||||
typedef struct ScrollAxis {
|
||||
mozilla::WhereToScroll mWhereToScroll;
|
||||
mozilla::WhenToScroll mWhenToScroll;
|
||||
bool mOnlyIfPerceivedScrollableDirection : 1;
|
||||
/**
|
||||
* aWhere:
|
||||
* Either a percentage or a special value. nsIPresShell defines:
|
||||
* * (Default) SCROLL_MINIMUM = -1: The visible area is scrolled the
|
||||
* minimum amount to show as much as possible of the frame. This won't
|
||||
* hide any initially visible part of the frame.
|
||||
* * SCROLL_TOP = 0: The frame's upper edge is aligned with the top edge
|
||||
* of the visible area.
|
||||
* * SCROLL_BOTTOM = 100: The frame's bottom edge is aligned with the
|
||||
* bottom edge of the visible area.
|
||||
* * SCROLL_LEFT = 0: The frame's left edge is aligned with the left edge
|
||||
* of the visible area.
|
||||
* * SCROLL_RIGHT = 100: The frame's right edge is aligned* with the right
|
||||
* edge of the visible area.
|
||||
* * SCROLL_CENTER = 50: The frame is centered along the axis the
|
||||
* ScrollAxis is used for.
|
||||
*
|
||||
* Other values are treated as a percentage, and the point*"percent"
|
||||
* down the frame is placed at the point "percent" down the visible area.
|
||||
*
|
||||
* aWhen:
|
||||
* * (Default) SCROLL_IF_NOT_FULLY_VISIBLE: Move the frame only if it is
|
||||
* not fully visible (including if it's not visible at all). Note that
|
||||
* in this case if the frame is too large to fit in view, it will only
|
||||
* be scrolled if more of it can fit than is already in view.
|
||||
* * SCROLL_IF_NOT_VISIBLE: Move the frame only if none of it is visible.
|
||||
* * SCROLL_ALWAYS: Move the frame regardless of its current visibility.
|
||||
*
|
||||
* aOnlyIfPerceivedScrollableDirection:
|
||||
* If the direction is not a perceived scrollable direction (i.e. no
|
||||
* scrollbar showing and less than one device pixel of scrollable
|
||||
* distance), don't scroll. Defaults to false.
|
||||
*/
|
||||
explicit ScrollAxis(
|
||||
mozilla::WhereToScroll aWhere = mozilla::kScrollMinimum,
|
||||
mozilla::WhenToScroll aWhen = mozilla::WhenToScroll::IfNotFullyVisible,
|
||||
bool aOnlyIfPerceivedScrollableDirection = false)
|
||||
: mWhereToScroll(aWhere),
|
||||
mWhenToScroll(aWhen),
|
||||
mOnlyIfPerceivedScrollableDirection(
|
||||
aOnlyIfPerceivedScrollableDirection) {}
|
||||
} ScrollAxis;
|
||||
|
||||
/**
|
||||
* Scrolls the view of the document so that the given area of a frame
|
||||
* is visible, if possible. Layout is not flushed before scrolling.
|
||||
|
@ -633,8 +690,7 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||
* @return true if any scrolling happened, false if no scrolling happened
|
||||
*/
|
||||
bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
|
||||
mozilla::ScrollAxis aVertical,
|
||||
mozilla::ScrollAxis aHorizontal,
|
||||
ScrollAxis aVertical, ScrollAxis aHorizontal,
|
||||
mozilla::ScrollFlags aScrollFlags);
|
||||
|
||||
/**
|
||||
|
@ -1047,6 +1103,29 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||
|
||||
bool IsActive() { return mIsActive; }
|
||||
|
||||
// mouse capturing
|
||||
static CapturingContentInfo gCaptureInfo;
|
||||
|
||||
/**
|
||||
* Return the active content currently capturing the mouse if any.
|
||||
*/
|
||||
static nsIContent* GetCapturingContent() { return gCaptureInfo.mContent; }
|
||||
|
||||
/**
|
||||
* Allow or disallow mouse capturing.
|
||||
*/
|
||||
static void AllowMouseCapture(bool aAllowed) {
|
||||
gCaptureInfo.mAllowed = aAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is an active mouse capture that wants to prevent
|
||||
* drags.
|
||||
*/
|
||||
static bool IsMouseCapturePreventingDrag() {
|
||||
return gCaptureInfo.mPreventDrag && gCaptureInfo.mContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep track of how many times this presshell has been rendered to
|
||||
* a window.
|
||||
|
@ -1167,6 +1246,7 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||
*/
|
||||
virtual void DidPaintWindow() = 0;
|
||||
|
||||
virtual void ClearMouseCaptureOnView(nsView* aView) = 0;
|
||||
virtual bool IsVisible() = 0;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void DispatchSynthMouseMove(mozilla::WidgetGUIEvent* aEvent);
|
||||
|
@ -1328,6 +1408,10 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||
bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver);
|
||||
bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver);
|
||||
|
||||
// If a frame in the subtree rooted at aFrame is capturing the mouse then
|
||||
// clears that capture.
|
||||
static void ClearMouseCapture(nsIFrame* aFrame);
|
||||
|
||||
void SetVisualViewportSize(nscoord aWidth, nscoord aHeight);
|
||||
void ResetVisualViewportSize();
|
||||
bool IsVisualViewportSizeSet() { return mVisualViewportSizeSet; }
|
||||
|
@ -1477,8 +1561,8 @@ class nsIPresShell : public nsStubDocumentObserver {
|
|||
// This data is stored as a content property (nsGkAtoms::scrolling) on
|
||||
// mContentToScrollTo when we have a pending ScrollIntoView.
|
||||
struct ScrollIntoViewData {
|
||||
mozilla::ScrollAxis mContentScrollVAxis;
|
||||
mozilla::ScrollAxis mContentScrollHAxis;
|
||||
ScrollAxis mContentScrollVAxis;
|
||||
ScrollAxis mContentScrollHAxis;
|
||||
mozilla::ScrollFlags mContentToScrollToFlags;
|
||||
};
|
||||
|
||||
|
|
|
@ -824,7 +824,7 @@ void nsListControlFrame::CaptureMouseEvents(bool aGrabMouseEvents) {
|
|||
if (aGrabMouseEvents) {
|
||||
PresShell::SetCapturingContent(mContent, CaptureFlags::IgnoreAllowedState);
|
||||
} else {
|
||||
nsIContent* capturingContent = PresShell::GetCapturingContent();
|
||||
nsIContent* capturingContent = nsIPresShell::GetCapturingContent();
|
||||
|
||||
bool dropDownIsHidden = false;
|
||||
if (IsInDropDownMode()) {
|
||||
|
@ -1606,7 +1606,7 @@ nsresult nsListControlFrame::GetIndexFromDOMEvent(dom::Event* aMouseEvent,
|
|||
int32_t& aCurIndex) {
|
||||
if (IgnoreMouseEventForSelection(aMouseEvent)) return NS_ERROR_FAILURE;
|
||||
|
||||
if (PresShell::GetCapturingContent() != mContent) {
|
||||
if (nsIPresShell::GetCapturingContent() != mContent) {
|
||||
// If we're not capturing, then ignore movement in the border
|
||||
nsPoint pt =
|
||||
nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(aMouseEvent, this);
|
||||
|
@ -1813,8 +1813,8 @@ void nsListControlFrame::ScrollToFrame(dom::HTMLOptionElement& aOptElement) {
|
|||
nsIFrame* childFrame = aOptElement.GetPrimaryFrame();
|
||||
if (childFrame) {
|
||||
PresShell()->ScrollFrameRectIntoView(
|
||||
childFrame, nsRect(nsPoint(0, 0), childFrame->GetSize()), ScrollAxis(),
|
||||
ScrollAxis(),
|
||||
childFrame, nsRect(nsPoint(0, 0), childFrame->GetSize()),
|
||||
nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis(),
|
||||
ScrollFlags::ScrollOverflowHidden |
|
||||
ScrollFlags::ScrollFirstAncestorOnly |
|
||||
ScrollFlags::IgnoreMarginAndPadding);
|
||||
|
|
|
@ -2134,7 +2134,7 @@ void nsIFrame::OnVisibilityChange(Visibility aNewVisibility,
|
|||
|
||||
static nsIFrame* GetActiveSelectionFrame(nsPresContext* aPresContext,
|
||||
nsIFrame* aFrame) {
|
||||
nsIContent* capturingContent = PresShell::GetCapturingContent();
|
||||
nsIContent* capturingContent = nsIPresShell::GetCapturingContent();
|
||||
if (capturingContent) {
|
||||
nsIFrame* activeFrame = aPresContext->GetPrimaryFrameFor(capturingContent);
|
||||
return activeFrame ? activeFrame : aFrame;
|
||||
|
@ -4268,7 +4268,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext, WidgetGUIEvent* aEvent,
|
|||
// the mouse on the nearest scrollable frame. If there isn't a scrollable
|
||||
// frame, or something else is already capturing the mouse, there's no
|
||||
// reason to capture.
|
||||
if (!PresShell::GetCapturingContent()) {
|
||||
if (!nsIPresShell::GetCapturingContent()) {
|
||||
nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetNearestScrollableFrame(
|
||||
this, nsLayoutUtils::SCROLLABLE_SAME_DOC |
|
||||
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
|
||||
|
@ -4673,7 +4673,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext,
|
|||
|
||||
nsIFrame* activeFrame = GetActiveSelectionFrame(aPresContext, this);
|
||||
|
||||
nsCOMPtr<nsIContent> captureContent = PresShell::GetCapturingContent();
|
||||
nsCOMPtr<nsIContent> captureContent = nsIPresShell::GetCapturingContent();
|
||||
|
||||
// We can unconditionally stop capturing because
|
||||
// we should never be capturing when the mouse button is up
|
||||
|
|
|
@ -446,7 +446,7 @@ nsresult nsFrameSelection::ConstrainFrameAndPointToAnchorSubtree(
|
|||
if (anchorRoot == contentRoot) {
|
||||
// If the aFrame's content isn't the capturing content, it should be
|
||||
// a descendant. At this time, we can return simply.
|
||||
nsIContent* capturedContent = PresShell::GetCapturingContent();
|
||||
nsIContent* capturedContent = nsIPresShell::GetCapturingContent();
|
||||
if (capturedContent != content) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -702,7 +702,8 @@ nsresult nsFrameSelection::MoveCaret(nsDirection aDirection,
|
|||
sel->Collapse(node, offset);
|
||||
}
|
||||
sel->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
|
||||
ScrollAxis(), ScrollAxis(), scrollFlags);
|
||||
nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis(),
|
||||
scrollFlags);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -831,8 +832,8 @@ nsresult nsFrameSelection::MoveCaret(nsDirection aDirection,
|
|||
}
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mDomSelections[index]->ScrollIntoView(
|
||||
nsISelectionController::SELECTION_FOCUS_REGION, ScrollAxis(),
|
||||
ScrollAxis(), scrollFlags);
|
||||
nsISelectionController::SELECTION_FOCUS_REGION,
|
||||
nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis(), scrollFlags);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1388,7 +1389,7 @@ nsresult nsFrameSelection::ScrollSelectionIntoView(SelectionType aSelectionType,
|
|||
|
||||
if (!mDomSelections[index]) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
ScrollAxis verticalScroll = ScrollAxis();
|
||||
nsIPresShell::ScrollAxis verticalScroll = nsIPresShell::ScrollAxis();
|
||||
int32_t flags = Selection::SCROLL_DO_FLUSH;
|
||||
if (aFlags & nsISelectionController::SCROLL_SYNCHRONOUS) {
|
||||
flags |= Selection::SCROLL_SYNCHRONOUS;
|
||||
|
@ -1399,8 +1400,8 @@ nsresult nsFrameSelection::ScrollSelectionIntoView(SelectionType aSelectionType,
|
|||
flags |= Selection::SCROLL_OVERFLOW_HIDDEN;
|
||||
}
|
||||
if (aFlags & nsISelectionController::SCROLL_CENTER_VERTICALLY) {
|
||||
verticalScroll =
|
||||
ScrollAxis(kScrollToCenter, WhenToScroll::IfNotFullyVisible);
|
||||
verticalScroll = nsIPresShell::ScrollAxis(kScrollToCenter,
|
||||
WhenToScroll::IfNotFullyVisible);
|
||||
}
|
||||
if (aFlags & nsISelectionController::SCROLL_FOR_CARET_MOVE) {
|
||||
flags |= Selection::SCROLL_FOR_CARET_MOVE;
|
||||
|
@ -1409,7 +1410,8 @@ nsresult nsFrameSelection::ScrollSelectionIntoView(SelectionType aSelectionType,
|
|||
// After ScrollSelectionIntoView(), the pending notifications might be
|
||||
// flushed and PresShell/PresContext/Frames may be dead. See bug 418470.
|
||||
RefPtr<Selection> sel = mDomSelections[index];
|
||||
return sel->ScrollIntoView(aRegion, verticalScroll, ScrollAxis(), flags);
|
||||
return sel->ScrollIntoView(aRegion, verticalScroll,
|
||||
nsIPresShell::ScrollAxis(), flags);
|
||||
}
|
||||
|
||||
nsresult nsFrameSelection::RepaintSelection(SelectionType aSelectionType) {
|
||||
|
|
|
@ -1187,7 +1187,7 @@ void nsHTMLFramesetFrame::StartMouseDrag(nsPresContext* aPresContext,
|
|||
void nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
|
||||
WidgetGUIEvent* aEvent) {
|
||||
// if the capture ended, reset the drag state
|
||||
if (PresShell::GetCapturingContent() != GetContent()) {
|
||||
if (nsIPresShell::GetCapturingContent() != GetContent()) {
|
||||
mDragger = nullptr;
|
||||
gDragInProgress = false;
|
||||
return;
|
||||
|
|
|
@ -2231,7 +2231,7 @@ nsresult nsImageFrame::GetContentForEvent(WidgetEvent* aEvent,
|
|||
// XXX We need to make this special check for area element's capturing the
|
||||
// mouse due to bug 135040. Remove it once that's fixed.
|
||||
nsIContent* capturingContent = aEvent->HasMouseEventMessage()
|
||||
? PresShell::GetCapturingContent()
|
||||
? nsIPresShell::GetCapturingContent()
|
||||
: nullptr;
|
||||
if (capturingContent && capturingContent->GetPrimaryFrame() == this) {
|
||||
*aContent = capturingContent;
|
||||
|
|
|
@ -1514,7 +1514,7 @@ nsresult nsPluginFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// These two calls to PresShell::SetCapturingContent() (on mouse-down
|
||||
// These two calls to nsIPresShell::SetCapturingContext() (on mouse-down
|
||||
// and mouse-up) are needed to make the routing of mouse events while
|
||||
// dragging conform to standard OS X practice, and to the Cocoa NPAPI spec.
|
||||
// See bug 525078 and bug 909678.
|
||||
|
|
|
@ -212,6 +212,7 @@ whitelist-types = [
|
|||
".*ThreadSafe.*Holder",
|
||||
"AnonymousContent",
|
||||
"AudioContext",
|
||||
"CapturingContentInfo",
|
||||
"DefaultDelete",
|
||||
"DOMIntersectionObserverEntry",
|
||||
"Element",
|
||||
|
@ -355,8 +356,6 @@ opaque-types = [
|
|||
"mozilla::HashSet",
|
||||
"mozilla::Pair",
|
||||
"mozilla::Pair_Base",
|
||||
"mozilla::ScrollAxis", # <- For some reason the alignment of this is 4
|
||||
# for clang.
|
||||
"mozilla::SeenPtrs",
|
||||
"mozilla::SupportsWeakPtr",
|
||||
"mozilla::Tuple",
|
||||
|
@ -370,6 +369,8 @@ opaque-types = [
|
|||
"nsBaseHashtable", "nsRefPtrHashtable", "nsDataHashtable", "nsClassHashtable", # <- Ditto
|
||||
"nsInterfaceHashtable", # <- Ditto
|
||||
"mozilla::dom::Document_SelectorCache", # <- Inherits from nsExpirationTracker<.., 4>
|
||||
"nsIPresShell_ScrollAxis", # <- For some reason the alignment of this is 4
|
||||
# for clang.
|
||||
"nsPIDOMWindow", # <- Takes the vtable from a template parameter, and we can't
|
||||
# generate it conditionally.
|
||||
"JS::Rooted",
|
||||
|
|
|
@ -77,7 +77,7 @@ void nsDeckFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|||
void nsDeckFrame::ShowBox(nsIFrame* aBox) { Animate(aBox, true); }
|
||||
|
||||
void nsDeckFrame::HideBox(nsIFrame* aBox) {
|
||||
mozilla::PresShell::ClearMouseCapture(aBox);
|
||||
nsIPresShell::ClearMouseCapture(aBox);
|
||||
Animate(aBox, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -1814,7 +1814,7 @@ void nsMenuPopupFrame::EnsureMenuItemIsVisible(nsMenuFrame* aMenuItem) {
|
|||
if (aMenuItem) {
|
||||
aMenuItem->PresShell()->ScrollFrameRectIntoView(
|
||||
aMenuItem, nsRect(nsPoint(0, 0), aMenuItem->GetRect().Size()),
|
||||
ScrollAxis(), ScrollAxis(),
|
||||
nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis(),
|
||||
ScrollFlags::ScrollOverflowHidden |
|
||||
ScrollFlags::ScrollFirstAncestorOnly |
|
||||
ScrollFlags::IgnoreMarginAndPadding);
|
||||
|
|
|
@ -1151,7 +1151,7 @@ void nsSliderFrame::DragThumb(bool aGrabMouseEvents) {
|
|||
}
|
||||
|
||||
bool nsSliderFrame::isDraggingThumb() const {
|
||||
return PresShell::GetCapturingContent() == GetContent();
|
||||
return (nsIPresShell::GetCapturingContent() == GetContent());
|
||||
}
|
||||
|
||||
void nsSliderFrame::AddListener() {
|
||||
|
|
|
@ -387,8 +387,9 @@ nsFormFillController::SetPopupOpen(bool aPopupOpen) {
|
|||
RefPtr<PresShell> presShell = docShell->GetPresShell();
|
||||
NS_ENSURE_STATE(presShell);
|
||||
presShell->ScrollContentIntoView(
|
||||
content, ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
content,
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
nsIPresShell::ScrollAxis(kScrollMinimum, WhenToScroll::IfNotVisible),
|
||||
ScrollFlags::ScrollOverflowHidden |
|
||||
ScrollFlags::IgnoreMarginAndPadding);
|
||||
// mFocusedPopup can be destroyed after ScrollContentIntoView, see bug
|
||||
|
|
|
@ -57,8 +57,8 @@ nsView::nsView(nsViewManager* aViewManager, nsViewVisibility aVisibility)
|
|||
}
|
||||
|
||||
void nsView::DropMouseGrabbing() {
|
||||
if (mViewManager->GetPresShell()) {
|
||||
PresShell::ClearMouseCaptureOnView(this);
|
||||
if (PresShell* presShell = mViewManager->GetPresShell()) {
|
||||
presShell->ClearMouseCaptureOnView(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ nsBaseDragService::InvokeDragSession(
|
|||
// capture. However, this gets in the way of determining drag
|
||||
// feedback for things like trees because the event coordinates
|
||||
// are in the wrong coord system, so turn off mouse capture.
|
||||
PresShell::ClearMouseCapture(nullptr);
|
||||
nsIPresShell::ClearMouseCapture(nullptr);
|
||||
|
||||
uint32_t length = 0;
|
||||
mozilla::Unused << aTransferableArray->GetLength(&length);
|
||||
|
|
Загрузка…
Ссылка в новой задаче