2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 11:12:37 +00:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2017-08-16 21:10:56 +00:00
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
/* a presentation of a document, part 2 */
|
|
|
|
|
2016-11-30 03:14:28 +00:00
|
|
|
#ifndef mozilla_PresShell_h
|
|
|
|
#define mozilla_PresShell_h
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2016-11-30 03:14:28 +00:00
|
|
|
#include "MobileViewportManager.h"
|
2012-06-19 03:26:34 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-22 13:27:34 +00:00
|
|
|
#include "mozilla/EventForwards.h"
|
2017-07-13 18:00:21 +00:00
|
|
|
#include "mozilla/layers/FocusTarget.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2018-03-29 11:15:46 +00:00
|
|
|
#include "mozilla/ServoStyleSet.h"
|
2016-01-20 21:24:28 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-11-30 03:14:28 +00:00
|
|
|
#include "nsContentUtils.h" // For AddScriptBlocker().
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsISelectionController.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsRefreshDriver.h"
|
|
|
|
#include "nsStubDocumentObserver.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "TouchManager.h"
|
2015-06-17 16:32:42 +00:00
|
|
|
#include "ZoomConstraintsClient.h"
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2016-08-03 16:00:22 +00:00
|
|
|
class nsIDocShell;
|
2012-01-10 14:19:54 +00:00
|
|
|
class nsRange;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
struct RangePaintInfo;
|
|
|
|
struct nsCallbackEventRequest;
|
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
class ReflowCountMgr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class nsPresShellEventCB;
|
|
|
|
class nsAutoCauseReflowNotifier;
|
2017-11-26 13:38:55 +00:00
|
|
|
class AutoPointerEventTargetUpdater;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
namespace mozilla {
|
2016-03-19 01:38:57 +00:00
|
|
|
|
2017-04-17 16:01:37 +00:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
2017-08-01 23:50:50 +00:00
|
|
|
class Selection;
|
2017-04-17 16:01:37 +00:00
|
|
|
} // namespace dom
|
|
|
|
|
2014-11-03 07:05:38 +00:00
|
|
|
class EventDispatchingCallback;
|
2016-03-19 01:38:57 +00:00
|
|
|
|
2016-03-25 21:49:43 +00:00
|
|
|
// A set type for tracking visible frames, for use by the visibility code in
|
|
|
|
// PresShell. The set contains nsIFrame* pointers.
|
|
|
|
typedef nsTHashtable<nsPtrHashKey<nsIFrame>> VisibleFrames;
|
|
|
|
|
2016-11-22 21:54:40 +00:00
|
|
|
// This is actually pref-controlled, but we use this value if we fail
|
2012-05-16 17:32:40 +00:00
|
|
|
// to get the pref for any reason.
|
2016-11-22 21:54:40 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-05-16 17:32:40 +00:00
|
|
|
#define PAINTLOCK_EVENT_DELAY 250
|
2016-11-22 21:54:40 +00:00
|
|
|
#else
|
|
|
|
#define PAINTLOCK_EVENT_DELAY 5
|
|
|
|
#endif
|
2012-05-16 17:32:40 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class PresShell final : public nsIPresShell,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsISelectionController,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference {
|
2018-03-07 11:13:17 +00:00
|
|
|
typedef layers::FocusTarget FocusTarget;
|
2017-07-13 18:00:21 +00:00
|
|
|
|
2011-09-09 19:50:21 +00:00
|
|
|
public:
|
|
|
|
PresShell();
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2016-08-03 16:00:22 +00:00
|
|
|
static bool AccessibleCaretEnabled(nsIDocShell* aDocShell);
|
2015-04-24 00:08:00 +00:00
|
|
|
|
2013-05-02 13:22:59 +00:00
|
|
|
void Init(nsIDocument* aDocument, nsPresContext* aPresContext,
|
2018-03-29 11:15:46 +00:00
|
|
|
nsViewManager* aViewManager, UniquePtr<ServoStyleSet> aStyleSet);
|
2018-03-07 11:13:17 +00:00
|
|
|
void Destroy() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void UpdatePreferenceStyles() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-05-08 17:52:36 +00:00
|
|
|
NS_IMETHOD GetSelectionFromScript(RawSelectionType aRawSelectionType,
|
|
|
|
dom::Selection** aSelection) override;
|
|
|
|
dom::Selection* GetSelection(RawSelectionType aRawSelectionType) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
|
|
|
|
dom::Selection* GetCurrentSelection(SelectionType aSelectionType) override;
|
|
|
|
|
|
|
|
already_AddRefed<nsISelectionController>
|
|
|
|
GetSelectionControllerForFocusedContent(
|
|
|
|
nsIContent** aFocusedContent = nullptr) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD SetDisplaySelection(int16_t aToggle) override;
|
|
|
|
NS_IMETHOD GetDisplaySelection(int16_t* aToggle) override;
|
2016-06-07 13:42:06 +00:00
|
|
|
NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,
|
|
|
|
SelectionRegion aRegion,
|
2015-03-21 16:28:04 +00:00
|
|
|
int16_t aFlags) override;
|
2016-06-07 13:42:06 +00:00
|
|
|
NS_IMETHOD RepaintSelection(RawSelectionType aRawSelectionType) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult Initialize() override;
|
|
|
|
nsresult ResizeReflow(
|
|
|
|
nscoord aWidth, nscoord aHeight, nscoord aOldWidth = 0,
|
|
|
|
nscoord aOldHeight = 0,
|
|
|
|
ResizeReflowOptions aOptions = ResizeReflowOptions::eBSizeExact) override;
|
|
|
|
nsresult ResizeReflowIgnoreOverride(
|
|
|
|
nscoord aWidth, nscoord aHeight, nscoord aOldWidth, nscoord aOldHeight,
|
|
|
|
ResizeReflowOptions aOptions = ResizeReflowOptions::eBSizeExact) override;
|
|
|
|
nsIPageSequenceFrame* GetPageSequenceFrame() const override;
|
|
|
|
nsCanvasFrame* GetCanvasFrame() const override;
|
|
|
|
|
|
|
|
void FrameNeedsReflow(
|
|
|
|
nsIFrame* aFrame, IntrinsicDirty aIntrinsicDirty, nsFrameState aBitToAdd,
|
2015-06-21 04:54:15 +00:00
|
|
|
ReflowRootHandling aRootHandling = eInferFromBitToAdd) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
void FrameNeedsToContinueReflow(nsIFrame* aFrame) override;
|
|
|
|
void CancelAllPendingReflows() override;
|
|
|
|
void DoFlushPendingNotifications(FlushType aType) override;
|
|
|
|
void DoFlushPendingNotifications(ChangesToFlush aType) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Post a callback that should be handled after reflow has finished.
|
|
|
|
*/
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult PostReflowCallback(nsIReflowCallback* aCallback) override;
|
|
|
|
void CancelReflowCallback(nsIReflowCallback* aCallback) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void ClearFrameRefs(nsIFrame* aFrame) override;
|
|
|
|
already_AddRefed<gfxContext> CreateReferenceRenderingContext() override;
|
|
|
|
nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aAdditionalScrollFlags = 0) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult ScrollToAnchor() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult ScrollContentIntoView(nsIContent* aContent, ScrollAxis aVertical,
|
2012-03-20 02:09:50 +00:00
|
|
|
ScrollAxis aHorizontal,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aFlags) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
|
2012-03-20 02:09:50 +00:00
|
|
|
ScrollAxis aVertical, ScrollAxis aHorizontal,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aFlags) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
nsRectVisibility GetRectVisibility(nsIFrame* aFrame, const nsRect& aRect,
|
2015-03-21 16:28:04 +00:00
|
|
|
nscoord aMinTwips) const override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void SetIgnoreFrameDestruction(bool aIgnore) override;
|
|
|
|
void NotifyDestroyingFrame(nsIFrame* aFrame) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult CaptureHistoryState(
|
|
|
|
nsILayoutHistoryState** aLayoutHistoryState) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void UnsuppressPainting() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-04-30 15:50:03 +00:00
|
|
|
nsresult GetAgentStyleSheets(nsTArray<RefPtr<StyleSheet>>& aSheets) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult SetAgentStyleSheets(
|
2018-04-30 15:50:03 +00:00
|
|
|
const nsTArray<RefPtr<StyleSheet>>& aSheets) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult AddOverrideStyleSheet(StyleSheet* aSheet) override;
|
|
|
|
nsresult RemoveOverrideStyleSheet(StyleSheet* aSheet) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult HandleEventWithTarget(
|
2013-10-02 03:46:04 +00:00
|
|
|
WidgetEvent* aEvent, nsIFrame* aFrame, nsIContent* aContent,
|
2017-11-26 13:54:07 +00:00
|
|
|
nsEventStatus* aStatus, bool aIsHandlingNativeEvent = false,
|
2018-03-29 16:22:59 +00:00
|
|
|
nsIContent** aTargetContent = nullptr,
|
|
|
|
nsIContent* aOverrideClickTarget = nullptr) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void NotifyCounterStylesAreDirty() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void ReconstructFrames(void) override;
|
|
|
|
void Freeze() override;
|
|
|
|
void Thaw() override;
|
|
|
|
void FireOrClearDelayedEvents(bool aFireEvents) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult RenderDocument(const nsRect& aRect, uint32_t aFlags,
|
|
|
|
nscolor aBackgroundColor,
|
|
|
|
gfxContext* aThebesContext) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
already_AddRefed<SourceSurface> RenderNode(nsINode* aNode,
|
2018-08-07 13:32:08 +00:00
|
|
|
const Maybe<CSSIntRegion>& aRegion,
|
2018-03-07 11:13:17 +00:00
|
|
|
const LayoutDeviceIntPoint aPoint,
|
|
|
|
LayoutDeviceIntRect* aScreenRect,
|
2015-07-11 16:15:19 +00:00
|
|
|
uint32_t aFlags) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
already_AddRefed<SourceSurface> RenderSelection(
|
|
|
|
dom::Selection* aSelection, const LayoutDeviceIntPoint aPoint,
|
|
|
|
LayoutDeviceIntRect* aScreenRect, uint32_t aFlags) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetRootWindow() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetFocusedDOMWindowInOurWindow()
|
|
|
|
override;
|
2017-06-06 00:12:22 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
LayerManager* GetLayerManager() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool AsyncPanZoomEnabled() override;
|
2015-06-04 20:51:10 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void SetIgnoreViewportScrolling(bool aIgnore) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult SetResolution(float aResolution) override {
|
2018-12-05 16:29:18 +00:00
|
|
|
return SetResolutionImpl(aResolution, /* aScaleToResolution = */ false,
|
|
|
|
nsGkAtoms::other);
|
2015-01-03 01:06:14 +00:00
|
|
|
}
|
2018-12-05 16:29:18 +00:00
|
|
|
nsresult SetResolutionAndScaleTo(float aResolution,
|
|
|
|
nsAtom* aOrigin) override {
|
|
|
|
return SetResolutionImpl(aResolution, /* aScaleToResolution = */ true,
|
|
|
|
aOrigin);
|
2015-01-03 01:06:14 +00:00
|
|
|
}
|
2018-03-07 11:13:17 +00:00
|
|
|
bool ScaleToResolution() const override;
|
2018-12-05 16:29:18 +00:00
|
|
|
bool IsResolutionUpdated() const override { return mResolutionUpdated; }
|
|
|
|
void SetResolutionUpdated(bool aUpdated) override {
|
|
|
|
mResolutionUpdated = aUpdated;
|
|
|
|
}
|
2018-03-07 11:13:17 +00:00
|
|
|
float GetCumulativeResolution() override;
|
|
|
|
float GetCumulativeNonRootScaleResolution() override;
|
|
|
|
void SetRestoreResolution(float aResolution,
|
|
|
|
LayoutDeviceIntSize aDisplaySize) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// nsIViewObserver interface
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
|
|
|
|
uint32_t aFlags) override;
|
2018-01-29 19:35:17 +00:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult HandleEvent(nsIFrame* aFrame,
|
|
|
|
WidgetGUIEvent* aEvent,
|
|
|
|
bool aDontRetargetEvents,
|
|
|
|
nsEventStatus* aEventStatus) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
nsEventStatus* aStatus) override;
|
|
|
|
nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
2018-04-20 16:53:16 +00:00
|
|
|
dom::Event* aEvent,
|
2018-03-07 11:13:17 +00:00
|
|
|
nsEventStatus* aStatus) override;
|
|
|
|
bool ShouldIgnoreInvalidation() override;
|
|
|
|
void WillPaint() override;
|
|
|
|
void WillPaintWindow() override;
|
|
|
|
void DidPaintWindow() override;
|
|
|
|
void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) override;
|
|
|
|
void ClearMouseCaptureOnView(nsView* aView) override;
|
|
|
|
bool IsVisible() override;
|
2018-06-25 21:42:25 +00:00
|
|
|
void SuppressDisplayport(bool aEnabled) override;
|
|
|
|
void RespectDisplayportSuppression(bool aEnabled) override;
|
|
|
|
bool IsDisplayportSuppressed() override;
|
2018-03-07 11:13:17 +00:00
|
|
|
|
|
|
|
already_AddRefed<AccessibleCaretEventHub> GetAccessibleCaretEventHub()
|
|
|
|
const override;
|
2015-04-24 00:08:00 +00:00
|
|
|
|
2011-09-09 19:50:21 +00:00
|
|
|
// caret handling
|
2018-03-07 11:13:17 +00:00
|
|
|
already_AddRefed<nsCaret> GetCaret() const override;
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD SetCaretEnabled(bool aInEnable) override;
|
|
|
|
NS_IMETHOD SetCaretReadOnly(bool aReadOnly) override;
|
|
|
|
NS_IMETHOD GetCaretEnabled(bool* aOutEnabled) override;
|
|
|
|
NS_IMETHOD SetCaretVisibilityDuringSelection(bool aVisibility) override;
|
|
|
|
NS_IMETHOD GetCaretVisible(bool* _retval) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
void SetCaret(nsCaret* aNewCaret) override;
|
|
|
|
void RestoreCaret() override;
|
2015-03-21 16:28:04 +00:00
|
|
|
|
|
|
|
NS_IMETHOD SetSelectionFlags(int16_t aInEnable) override;
|
|
|
|
NS_IMETHOD GetSelectionFlags(int16_t* aOutEnable) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// nsISelectionController
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD PhysicalMove(int16_t aDirection, int16_t aAmount,
|
|
|
|
bool aExtend) override;
|
|
|
|
NS_IMETHOD CharacterMove(bool aForward, bool aExtend) override;
|
|
|
|
NS_IMETHOD CharacterExtendForDelete() override;
|
|
|
|
NS_IMETHOD CharacterExtendForBackspace() override;
|
|
|
|
NS_IMETHOD WordMove(bool aForward, bool aExtend) override;
|
|
|
|
NS_IMETHOD WordExtendForDelete(bool aForward) override;
|
|
|
|
NS_IMETHOD LineMove(bool aForward, bool aExtend) override;
|
|
|
|
NS_IMETHOD IntraLineMove(bool aForward, bool aExtend) override;
|
Bug 1482425 - PresShell::PageMove() should use different rules to look for a container element for aExtend value r=smaug
PresShell::PageMove() climbs up to parent document when there is no scrollable
parent in current document. However, if aExtend is true, it should expand
Selection in the document itself. Therefore, it needs different rules to
look for container of expanding Selection from scrollable element to scroll.
Additionally, old rules (i.e., before the fix of bug 1369072 which caused
this regression) were also buggy. It used parent scrollable element or
root scrollable element simply. Therefore, if found scrollable element is
ancestor of selection limiter, it didn't work as expected.
This patch creates nsFrameSelection::GetFrameToPageSelect() to retrieve
per-page selection container element with the following rules:
- look for a scrollable element in selection limiter.
- if there is no scrollable element, use selection limiter.
- if there is no selection limiter, use the root frame.
So, nsFrameSelection::CommonPageMove() should take nsIFrame rather than
nsIScrollableFrame since container of per-page selection may be used in
non-scrollable contenteditable element. If it's called with non-scrollable
frame, it needs to compute the expanding range with the frame size.
Differential Revision: https://phabricator.services.mozilla.com/D8954
--HG--
extra : moz-landing-system : lando
2018-10-18 04:42:53 +00:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD PageMove(bool aForward, bool aExtend) override;
|
|
|
|
NS_IMETHOD ScrollPage(bool aForward) override;
|
|
|
|
NS_IMETHOD ScrollLine(bool aForward) override;
|
|
|
|
NS_IMETHOD ScrollCharacter(bool aRight) override;
|
|
|
|
NS_IMETHOD CompleteScroll(bool aForward) override;
|
|
|
|
NS_IMETHOD CompleteMove(bool aForward, bool aExtend) override;
|
|
|
|
NS_IMETHOD SelectAll() override;
|
2018-05-30 02:58:48 +00:00
|
|
|
NS_IMETHOD CheckVisibility(nsINode* node, int16_t startOffset,
|
|
|
|
int16_t EndOffset, bool* _retval) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult CheckVisibilityContent(nsIContent* aNode, int16_t aStartOffset,
|
|
|
|
int16_t aEndOffset, bool* aRetval) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// nsIDocumentObserver
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED
|
|
|
|
|
|
|
|
// nsIMutationObserver
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
#ifdef MOZ_REFLOW_PERF
|
2018-03-07 11:13:17 +00:00
|
|
|
void DumpReflows() override;
|
|
|
|
void CountReflows(const char* aName, nsIFrame* aFrame) override;
|
|
|
|
void PaintCount(const char* aName, gfxContext* aRenderingContext,
|
|
|
|
nsPresContext* aPresContext, nsIFrame* aFrame,
|
|
|
|
const nsPoint& aOffset, uint32_t aColor) override;
|
|
|
|
void SetPaintFrameCount(bool aOn) override;
|
|
|
|
bool IsPaintingFrameCounts() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2018-03-22 18:20:41 +00:00
|
|
|
void ListComputedStyles(FILE* out, int32_t aIndent = 0) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void ListStyleSheets(FILE* out, int32_t aIndent = 0) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
static LazyLogModule gLog;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void DisableNonTestMouseEvents(bool aDisable) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void UpdateCanvasBackground() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
|
|
|
|
nsDisplayList& aList, nsIFrame* aFrame,
|
|
|
|
const nsRect& aBounds,
|
|
|
|
nscolor aBackstopColor,
|
|
|
|
uint32_t aFlags) override;
|
2013-02-14 11:12:27 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
|
|
|
|
nsDisplayList& aList, nsIFrame* aFrame,
|
|
|
|
const nsRect& aBounds) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nscolor ComputeBackstopColor(nsView* aDisplayRoot) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult SetIsActive(bool aIsActive) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool GetIsViewportOverridden() override {
|
2015-09-01 20:47:52 +00:00
|
|
|
return (mMobileViewportManager != nullptr);
|
2015-07-21 14:51:55 +00:00
|
|
|
}
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-11-02 21:18:42 +00:00
|
|
|
RefPtr<MobileViewportManager> GetMobileViewportManager() const override {
|
|
|
|
return mMobileViewportManager;
|
|
|
|
}
|
|
|
|
|
2018-10-04 03:28:40 +00:00
|
|
|
void UpdateViewportOverridden(bool aAfterInitialization) override;
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool IsLayoutFlushObserver() override {
|
2011-09-09 19:50:21 +00:00
|
|
|
return GetPresContext()->RefreshDriver()->IsLayoutFlushObserver(this);
|
|
|
|
}
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void LoadComplete() override;
|
2013-11-25 05:00:00 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const override;
|
|
|
|
size_t SizeOfTextRuns(MallocSizeOf aMallocSizeOf) const;
|
2012-05-16 17:32:40 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
// This data is stored as a content property (nsGkAtoms::scrolling) on
|
|
|
|
// mContentToScrollTo when we have a pending ScrollIntoView.
|
|
|
|
struct ScrollIntoViewData {
|
|
|
|
ScrollAxis mContentScrollVAxis;
|
|
|
|
ScrollAxis mContentScrollHAxis;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mContentToScrollToFlags;
|
2012-05-16 17:32:40 +00:00
|
|
|
};
|
|
|
|
|
2016-03-25 21:49:43 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Approximate frame visibility tracking public API.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void ScheduleApproximateFrameVisibilityUpdateSoon() override;
|
|
|
|
void ScheduleApproximateFrameVisibilityUpdateNow() override;
|
2013-02-25 00:59:22 +00:00
|
|
|
|
2016-03-25 21:49:43 +00:00
|
|
|
void RebuildApproximateFrameVisibilityDisplayList(
|
|
|
|
const nsDisplayList& aList) override;
|
|
|
|
void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
|
|
|
|
bool aRemoveOnly = false) override;
|
2013-02-25 00:59:22 +00:00
|
|
|
|
2016-09-12 05:19:08 +00:00
|
|
|
void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame) override;
|
|
|
|
void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame) override;
|
2016-03-25 21:49:43 +00:00
|
|
|
|
|
|
|
bool AssumeAllFramesVisible() override;
|
2013-09-15 00:05:04 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool CanDispatchEvent(const WidgetGUIEvent* aEvent = nullptr) const override;
|
2016-03-21 06:20:59 +00:00
|
|
|
|
2014-08-08 16:05:40 +00:00
|
|
|
void SetNextPaintCompressed() { mNextPaintCompressed = true; }
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void NotifyStyleSheetServiceSheetAdded(StyleSheet* aSheet,
|
2017-02-17 07:56:28 +00:00
|
|
|
uint32_t aSheetType) override;
|
2018-03-07 11:13:17 +00:00
|
|
|
void NotifyStyleSheetServiceSheetRemoved(StyleSheet* aSheet,
|
2017-02-17 07:56:28 +00:00
|
|
|
uint32_t aSheetType) override;
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool HasHandledUserInput() const override { return mHasHandledUserInput; }
|
2017-11-21 22:25:09 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void FireResizeEvent() override;
|
2015-05-05 14:56:01 +00:00
|
|
|
|
2017-11-26 13:54:07 +00:00
|
|
|
static PresShell* GetShellForEventTarget(nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent);
|
2017-12-09 01:11:10 +00:00
|
|
|
static PresShell* GetShellForTouchEvent(WidgetGUIEvent* aEvent);
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
private:
|
|
|
|
~PresShell();
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void HandlePostedReflowCallbacks(bool aInterruptible);
|
2011-09-09 19:50:21 +00:00
|
|
|
void CancelPostedReflowCallbacks();
|
|
|
|
|
2015-07-23 21:53:32 +00:00
|
|
|
void ScheduleBeforeFirstPaint();
|
2011-09-09 19:50:21 +00:00
|
|
|
void UnsuppressAndInvalidate();
|
|
|
|
|
|
|
|
void WillCauseReflow() {
|
|
|
|
nsContentUtils::AddScriptBlocker();
|
|
|
|
++mChangeNestCount;
|
|
|
|
}
|
|
|
|
nsresult DidCauseReflow();
|
2016-11-30 03:14:27 +00:00
|
|
|
friend class ::nsAutoCauseReflowNotifier;
|
2017-11-26 13:38:55 +00:00
|
|
|
friend class ::AutoPointerEventTargetUpdater;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult DispatchEventToDOM(WidgetEvent* aEvent, nsEventStatus* aStatus,
|
2015-02-04 04:19:00 +00:00
|
|
|
nsPresShellEventCB* aEventCB);
|
2018-03-07 11:13:17 +00:00
|
|
|
void DispatchTouchEventToDOM(WidgetEvent* aEvent, nsEventStatus* aStatus,
|
2015-02-04 04:19:00 +00:00
|
|
|
nsPresShellEventCB* aEventCB, bool aTouchIsNew);
|
2011-12-17 00:24:11 +00:00
|
|
|
|
2011-09-09 19:50:21 +00:00
|
|
|
void WillDoReflow();
|
2013-05-14 19:24:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback handler for whether reflow happened.
|
|
|
|
*
|
|
|
|
* @param aInterruptible Whether or not reflow interruption is allowed.
|
|
|
|
*/
|
2015-11-05 04:55:16 +00:00
|
|
|
void DidDoReflow(bool aInterruptible);
|
2011-09-09 19:50:21 +00:00
|
|
|
// ProcessReflowCommands returns whether we processed all our dirty roots
|
|
|
|
// without interruptions.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool ProcessReflowCommands(bool aInterruptible);
|
2011-09-09 19:50:21 +00:00
|
|
|
// MaybeScheduleReflow checks if posting a reflow is needed, then checks if
|
|
|
|
// the last reflow was interrupted. In the interrupted case ScheduleReflow is
|
|
|
|
// called off a timer, otherwise it is called directly.
|
|
|
|
void MaybeScheduleReflow();
|
|
|
|
// Actually schedules a reflow. This should only be called by
|
|
|
|
// MaybeScheduleReflow and the reflow timer ScheduleReflowOffTimer
|
|
|
|
// sets up.
|
|
|
|
void ScheduleReflow();
|
|
|
|
|
|
|
|
// DoReflow returns whether the reflow finished without interruption
|
2018-11-27 04:30:07 +00:00
|
|
|
bool DoReflow(nsIFrame* aFrame, bool aInterruptible);
|
2011-09-09 19:50:21 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void DoVerifyReflow();
|
|
|
|
void VerifyHasDirtyRootAncestor(nsIFrame* aFrame);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Helper for ScrollContentIntoView
|
2012-05-16 17:32:40 +00:00
|
|
|
void DoScrollContentIntoView();
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2012-06-06 03:47:33 +00:00
|
|
|
/**
|
2013-05-16 15:06:03 +00:00
|
|
|
* Initialize cached font inflation preference values and do an initial
|
|
|
|
* computation to determine if font inflation is enabled.
|
2012-06-06 03:47:33 +00:00
|
|
|
*
|
|
|
|
* @see nsLayoutUtils::sFontSizeInflationEmPerLine
|
|
|
|
* @see nsLayoutUtils::sFontSizeInflationMinTwips
|
|
|
|
* @see nsLayoutUtils::sFontSizeInflationLineThreshold
|
|
|
|
*/
|
|
|
|
void SetupFontInflation();
|
|
|
|
|
2011-09-09 19:50:21 +00:00
|
|
|
struct RenderingState {
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit RenderingState(PresShell* aPresShell)
|
2015-03-06 23:07:59 +00:00
|
|
|
: mResolution(aPresShell->mResolution),
|
2012-05-16 17:32:40 +00:00
|
|
|
mRenderFlags(aPresShell->mRenderFlags) {}
|
2016-03-19 01:38:57 +00:00
|
|
|
Maybe<float> mResolution;
|
2012-05-16 17:32:40 +00:00
|
|
|
RenderFlags mRenderFlags;
|
2011-09-09 19:50:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AutoSaveRestoreRenderingState {
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit AutoSaveRestoreRenderingState(PresShell* aPresShell)
|
2011-09-09 19:50:21 +00:00
|
|
|
: mPresShell(aPresShell), mOldState(aPresShell) {}
|
|
|
|
|
|
|
|
~AutoSaveRestoreRenderingState() {
|
|
|
|
mPresShell->mRenderFlags = mOldState.mRenderFlags;
|
2015-03-06 23:07:59 +00:00
|
|
|
mPresShell->mResolution = mOldState.mResolution;
|
2011-09-09 19:50:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PresShell* mPresShell;
|
|
|
|
RenderingState mOldState;
|
|
|
|
};
|
2012-05-16 17:32:40 +00:00
|
|
|
static RenderFlags ChangeFlag(RenderFlags aFlags, bool aOnOff,
|
|
|
|
eRenderFlag aFlag) {
|
|
|
|
return aOnOff ? (aFlags | aFlag) : (aFlag & ~aFlag);
|
|
|
|
}
|
|
|
|
|
2011-09-09 19:50:21 +00:00
|
|
|
void SetRenderingState(const RenderingState& aState);
|
|
|
|
|
2016-11-30 03:14:27 +00:00
|
|
|
friend class ::nsPresShellEventCB;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mCaretEnabled;
|
2016-01-13 22:00:15 +00:00
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2018-03-29 11:15:46 +00:00
|
|
|
UniquePtr<ServoStyleSet> CloneStyleSet(ServoStyleSet* aSet);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool VerifyIncrementalReflow();
|
|
|
|
bool mInVerifyReflow;
|
2011-09-09 19:50:21 +00:00
|
|
|
void ShowEventTargetDebug();
|
|
|
|
#endif
|
|
|
|
|
2015-06-16 01:34:48 +00:00
|
|
|
void RemovePreferenceStyles();
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// methods for painting a range to an offscreen buffer
|
|
|
|
|
|
|
|
// given a display list, clip the items within the list to
|
|
|
|
// the range
|
|
|
|
nsRect ClipListToRange(nsDisplayListBuilder* aBuilder, nsDisplayList* aList,
|
2012-01-10 14:19:54 +00:00
|
|
|
nsRange* aRange);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// create a RangePaintInfo for the range aRange containing the
|
|
|
|
// display list needed to paint the range to a surface
|
2018-03-27 04:35:22 +00:00
|
|
|
UniquePtr<RangePaintInfo> CreateRangePaintInfo(nsRange* aRange,
|
2016-01-20 21:24:28 +00:00
|
|
|
nsRect& aSurfaceRect,
|
|
|
|
bool aForPrimarySelection);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Paint the items to a new surface and return it.
|
|
|
|
*
|
|
|
|
* aSelection - selection being painted, if any
|
|
|
|
* aRegion - clip region, if any
|
|
|
|
* aArea - area that the surface occupies, relative to the root frame
|
|
|
|
* aPoint - reference point, typically the mouse position
|
|
|
|
* aScreenRect - [out] set to the area of the screen the painted area should
|
|
|
|
* be displayed at
|
2015-07-11 16:15:19 +00:00
|
|
|
* aFlags - set RENDER_AUTO_SCALE to scale down large images, but it must not
|
|
|
|
* be set if a custom image was specified
|
2011-09-09 19:50:21 +00:00
|
|
|
*/
|
2015-06-17 14:00:52 +00:00
|
|
|
already_AddRefed<SourceSurface> PaintRangePaintInfo(
|
2018-03-07 11:13:17 +00:00
|
|
|
const nsTArray<UniquePtr<RangePaintInfo>>& aItems,
|
2018-08-07 13:32:08 +00:00
|
|
|
dom::Selection* aSelection, const Maybe<CSSIntRegion>& aRegion,
|
2018-03-07 11:13:17 +00:00
|
|
|
nsRect aArea, const LayoutDeviceIntPoint aPoint,
|
|
|
|
LayoutDeviceIntRect* aScreenRect, uint32_t aFlags);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Methods to handle changes to user and UA sheet lists that we get
|
|
|
|
* notified about.
|
|
|
|
*/
|
2017-02-21 02:42:27 +00:00
|
|
|
void AddUserSheet(StyleSheet* aSheet);
|
|
|
|
void AddAgentSheet(StyleSheet* aSheet);
|
|
|
|
void AddAuthorSheet(StyleSheet* aSheet);
|
2018-03-07 11:13:17 +00:00
|
|
|
void RemoveSheet(SheetType aType, StyleSheet* aSheet);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// Hide a view if it is a popup
|
2013-01-03 13:23:11 +00:00
|
|
|
void HideViewIfPopup(nsView* aView);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// Utility method to restore the root scrollframe state
|
|
|
|
void RestoreRootScrollPosition();
|
|
|
|
|
2014-08-06 05:19:27 +00:00
|
|
|
void MaybeReleaseCapturingContent();
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult HandleRetargetedEvent(WidgetEvent* aEvent, nsEventStatus* aStatus,
|
2013-10-02 03:46:04 +00:00
|
|
|
nsIContent* aTarget) {
|
2012-07-30 14:20:58 +00:00
|
|
|
PushCurrentEventInfo(nullptr, nullptr);
|
2011-09-09 19:50:21 +00:00
|
|
|
mCurrentEventContent = aTarget;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (GetCurrentEventFrame()) {
|
2015-11-10 02:49:05 +00:00
|
|
|
rv = HandleEventInternal(aEvent, aStatus, true);
|
2011-09-09 19:50:21 +00:00
|
|
|
}
|
|
|
|
PopCurrentEventInfo();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-10-22 13:27:34 +00:00
|
|
|
class DelayedEvent {
|
2011-09-09 19:50:21 +00:00
|
|
|
public:
|
2013-10-22 13:27:34 +00:00
|
|
|
virtual ~DelayedEvent() {}
|
|
|
|
virtual void Dispatch() {}
|
2017-02-03 10:16:00 +00:00
|
|
|
virtual bool IsKeyPressEvent() { return false; }
|
2011-09-09 19:50:21 +00:00
|
|
|
};
|
|
|
|
|
2013-10-22 13:27:34 +00:00
|
|
|
class DelayedInputEvent : public DelayedEvent {
|
2011-09-09 19:50:21 +00:00
|
|
|
public:
|
2018-03-07 11:13:17 +00:00
|
|
|
void Dispatch() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
protected:
|
2013-10-22 13:27:34 +00:00
|
|
|
DelayedInputEvent();
|
2018-03-07 11:13:17 +00:00
|
|
|
~DelayedInputEvent() override;
|
2013-10-18 06:10:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
WidgetInputEvent* mEvent;
|
2011-09-09 19:50:21 +00:00
|
|
|
};
|
|
|
|
|
2013-10-22 13:27:34 +00:00
|
|
|
class DelayedMouseEvent : public DelayedInputEvent {
|
2011-09-09 19:50:21 +00:00
|
|
|
public:
|
2018-03-07 11:13:17 +00:00
|
|
|
explicit DelayedMouseEvent(WidgetMouseEvent* aEvent);
|
2011-09-09 19:50:21 +00:00
|
|
|
};
|
|
|
|
|
2013-10-22 13:27:34 +00:00
|
|
|
class DelayedKeyEvent : public DelayedInputEvent {
|
2011-09-09 19:50:21 +00:00
|
|
|
public:
|
2018-03-07 11:13:17 +00:00
|
|
|
explicit DelayedKeyEvent(WidgetKeyboardEvent* aEvent);
|
|
|
|
bool IsKeyPressEvent() override;
|
2011-09-09 19:50:21 +00:00
|
|
|
};
|
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
// Check if aEvent is a mouse event and record the mouse location for later
|
|
|
|
// synth mouse moves.
|
2018-03-07 11:13:17 +00:00
|
|
|
void RecordMouseLocation(WidgetGUIEvent* aEvent);
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsSynthMouseMoveEvent final : public nsARefreshObserver {
|
2012-05-16 17:32:40 +00:00
|
|
|
public:
|
2015-04-06 15:22:00 +00:00
|
|
|
nsSynthMouseMoveEvent(PresShell* aPresShell, bool aFromScroll)
|
|
|
|
: mPresShell(aPresShell), mFromScroll(aFromScroll) {
|
2012-05-16 17:32:40 +00:00
|
|
|
NS_ASSERTION(mPresShell, "null parameter");
|
|
|
|
}
|
2014-03-21 01:16:20 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2012-05-16 17:32:40 +00:00
|
|
|
~nsSynthMouseMoveEvent() { Revoke(); }
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2014-03-21 01:16:20 +00:00
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent, override)
|
2014-03-20 06:49:25 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
void Revoke() {
|
|
|
|
if (mPresShell) {
|
|
|
|
mPresShell->GetPresContext()->RefreshDriver()->RemoveRefreshObserver(
|
2017-01-05 07:31:56 +00:00
|
|
|
this, FlushType::Display);
|
2012-07-30 14:20:58 +00:00
|
|
|
mPresShell = nullptr;
|
2012-05-16 17:32:40 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-07 11:13:17 +00:00
|
|
|
void WillRefresh(TimeStamp aTime) override {
|
2013-11-12 12:54:10 +00:00
|
|
|
if (mPresShell) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<PresShell> shell = mPresShell;
|
2015-04-06 15:22:00 +00:00
|
|
|
shell->ProcessSynthMouseMoveEvent(mFromScroll);
|
2013-11-12 12:54:10 +00:00
|
|
|
}
|
2012-05-16 17:32:40 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
private:
|
|
|
|
PresShell* mPresShell;
|
|
|
|
bool mFromScroll;
|
|
|
|
};
|
2015-04-06 15:22:00 +00:00
|
|
|
void ProcessSynthMouseMoveEvent(bool aFromScroll);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
void QueryIsActive();
|
2016-07-26 18:48:00 +00:00
|
|
|
nsresult UpdateImageLockingState();
|
2012-04-26 21:40:05 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool InZombieDocument(nsIContent* aContent);
|
2014-04-08 00:00:52 +00:00
|
|
|
already_AddRefed<nsIPresShell> GetParentPresShellForEventHandling();
|
2018-01-29 19:35:17 +00:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
RetargetEventToParent(WidgetGUIEvent* aEvent, nsEventStatus* aEventStatus);
|
2018-10-09 09:47:58 +00:00
|
|
|
|
2015-11-10 02:49:05 +00:00
|
|
|
/**
|
|
|
|
* @param aIsHandlingNativeEvent true when the caller (perhaps) handles
|
|
|
|
* an event which is caused by native
|
|
|
|
* event. Otherwise, false.
|
|
|
|
*/
|
2018-03-07 11:13:17 +00:00
|
|
|
nsresult HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus,
|
2018-03-29 16:22:59 +00:00
|
|
|
bool aIsHandlingNativeEvent,
|
|
|
|
nsIContent* aOverrideClickTarget = nullptr);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This and the next two helper methods are used to target and position the
|
|
|
|
* context menu when the keyboard shortcut is used to open it.
|
|
|
|
*
|
|
|
|
* If another menu is open, the context menu is opened relative to the
|
|
|
|
* active menuitem within the menu, or the menu itself if no item is active.
|
|
|
|
* Otherwise, if the caret is visible, the menu is opened near the caret.
|
|
|
|
* Otherwise, if a selectable list such as a listbox is focused, the
|
|
|
|
* current item within the menu is opened relative to this item.
|
|
|
|
* Otherwise, the context menu is opened at the topleft corner of the
|
|
|
|
* view.
|
|
|
|
*
|
|
|
|
* Returns true if the context menu event should fire and false if it should
|
|
|
|
* not.
|
|
|
|
*/
|
2018-03-07 11:13:17 +00:00
|
|
|
bool AdjustContextMenuKeyEvent(WidgetMouseEvent* aEvent);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2014-03-20 06:49:25 +00:00
|
|
|
//
|
2015-02-01 22:27:31 +00:00
|
|
|
bool PrepareToUseCaretPosition(nsIWidget* aEventWidget,
|
2018-03-07 11:13:17 +00:00
|
|
|
LayoutDeviceIntPoint& aTargetPt);
|
2011-09-09 19:50:21 +00:00
|
|
|
|
|
|
|
// Get the selected item and coordinates in device pixels relative to root
|
|
|
|
// document's root view for element, first ensuring the element is onscreen
|
2018-04-27 03:35:19 +00:00
|
|
|
void GetCurrentItemAndPositionForElement(dom::Element* aFocusedElement,
|
2011-09-09 19:50:21 +00:00
|
|
|
nsIContent** aTargetToUse,
|
2018-03-07 11:13:17 +00:00
|
|
|
LayoutDeviceIntPoint& aTargetPt,
|
2011-09-09 19:50:21 +00:00
|
|
|
nsIWidget* aRootWidget);
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void SynthesizeMouseMove(bool aFromScroll) override;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
PresShell* GetRootPresShell();
|
|
|
|
|
|
|
|
nscolor GetDefaultBackgroundColorToDraw();
|
|
|
|
|
2018-03-10 02:12:53 +00:00
|
|
|
DOMHighResTimeStamp GetPerformanceNowUnclamped();
|
2013-06-01 10:00:12 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
// The callback for the mPaintSuppressionTimer timer.
|
|
|
|
static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell);
|
|
|
|
|
|
|
|
// The callback for the mReflowContinueTimer timer.
|
|
|
|
static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
|
|
|
|
bool ScheduleReflowOffTimer();
|
2012-08-15 18:52:35 +00:00
|
|
|
|
|
|
|
// Widget notificiations
|
2018-03-07 11:13:17 +00:00
|
|
|
void WindowSizeMoveDone() override;
|
|
|
|
void SysColorChanged() override { mPresContext->SysColorChanged(); }
|
|
|
|
void ThemeChanged() override { mPresContext->ThemeChanged(); }
|
2018-07-04 14:31:03 +00:00
|
|
|
void BackingScaleFactorChanged() override {
|
|
|
|
mPresContext->UIResolutionChangedSync();
|
|
|
|
}
|
2018-03-07 11:13:17 +00:00
|
|
|
nsIDocument* GetPrimaryContentDocument() override;
|
2016-01-21 06:55:37 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void PausePainting() override;
|
|
|
|
void ResumePainting() override;
|
2016-01-21 06:55:37 +00:00
|
|
|
|
2016-03-25 21:49:43 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Approximate frame visibility tracking implementation.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void UpdateApproximateFrameVisibility();
|
|
|
|
void DoUpdateApproximateFrameVisibility(bool aRemoveOnly);
|
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
void ClearApproximatelyVisibleFramesList(
|
|
|
|
const Maybe<OnNonvisible>& aNonvisibleAction = Nothing());
|
2016-09-12 05:19:08 +00:00
|
|
|
static void ClearApproximateFrameVisibilityVisited(nsView* aView,
|
|
|
|
bool aClear);
|
2018-03-12 18:17:34 +00:00
|
|
|
static void MarkFramesInListApproximatelyVisible(const nsDisplayList& aList);
|
2016-03-25 21:49:43 +00:00
|
|
|
void MarkFramesInSubtreeApproximatelyVisible(nsIFrame* aFrame,
|
|
|
|
const nsRect& aRect,
|
|
|
|
bool aRemoveOnly = false);
|
2013-02-25 00:59:22 +00:00
|
|
|
|
2016-09-12 05:19:08 +00:00
|
|
|
void DecApproximateVisibleCount(
|
|
|
|
VisibleFrames& aFrames,
|
2017-02-13 17:07:40 +00:00
|
|
|
const Maybe<OnNonvisible>& aNonvisibleAction = Nothing());
|
2016-04-21 08:21:58 +00:00
|
|
|
|
2016-03-25 21:49:43 +00:00
|
|
|
nsRevocableEventPtr<nsRunnableMethod<PresShell>>
|
|
|
|
mUpdateApproximateFrameVisibilityEvent;
|
|
|
|
|
2016-07-26 18:48:00 +00:00
|
|
|
// A set of frames that were visible or could be visible soon at the time
|
|
|
|
// that we last did an approximate frame visibility update.
|
|
|
|
VisibleFrames mApproximatelyVisibleFrames;
|
2016-03-25 21:49:43 +00:00
|
|
|
|
2018-12-05 16:29:18 +00:00
|
|
|
nsresult SetResolutionImpl(float aResolution, bool aScaleToResolution,
|
|
|
|
nsAtom* aOrigin);
|
2015-01-03 01:06:14 +00:00
|
|
|
|
2018-03-29 16:22:59 +00:00
|
|
|
nsIContent* GetOverrideClickTarget(WidgetGUIEvent* aEvent, nsIFrame* aFrame);
|
2012-05-16 17:32:40 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// The reflow root under which we're currently reflowing. Null when
|
|
|
|
// not in reflow.
|
2018-03-07 11:13:17 +00:00
|
|
|
nsIFrame* mCurrentReflowRoot;
|
2012-05-16 17:32:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_REFLOW_PERF
|
2018-11-15 07:27:50 +00:00
|
|
|
UniquePtr<ReflowCountMgr> mReflowCountMgr;
|
2012-05-16 17:32:40 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-09 19:50:21 +00:00
|
|
|
// This is used for synthetic mouse events that are sent when what is under
|
|
|
|
// the mouse pointer may have changed without the mouse moving (eg scrolling,
|
|
|
|
// change to the document contents).
|
|
|
|
// It is set only on a presshell for a root document, this value represents
|
|
|
|
// the last observed location of the mouse relative to that root document. It
|
|
|
|
// is set to (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if the mouse isn't
|
|
|
|
// over our window or there is no last observed mouse location for some
|
|
|
|
// reason.
|
2018-03-07 11:13:17 +00:00
|
|
|
nsPoint mMouseLocation;
|
2016-03-10 23:25:49 +00:00
|
|
|
// This is an APZ state variable that tracks the target guid for the last
|
|
|
|
// mouse event that was processed (corresponding to mMouseLocation). This is
|
|
|
|
// needed for the synthetic mouse events.
|
2018-03-07 11:13:17 +00:00
|
|
|
layers::ScrollableLayerGuid mMouseEventTargetGuid;
|
2012-01-10 05:23:29 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
// mStyleSet owns it but we maintain a ref, may be null
|
2018-03-07 11:13:17 +00:00
|
|
|
RefPtr<StyleSheet> mPrefStyleSheet;
|
2012-05-16 17:32:40 +00:00
|
|
|
|
|
|
|
// Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
|
|
|
|
// we finish reflowing mCurrentReflowRoot.
|
|
|
|
nsTHashtable<nsPtrHashKey<nsIFrame>> mFramesToDirty;
|
|
|
|
|
2018-11-15 07:40:52 +00:00
|
|
|
nsTArray<UniquePtr<DelayedEvent>> mDelayedEvents;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-03-08 11:04:53 +00:00
|
|
|
private:
|
2011-09-09 19:50:21 +00:00
|
|
|
nsRevocableEventPtr<nsSynthMouseMoveEvent> mSynthMouseMoveEvent;
|
2018-03-07 11:13:17 +00:00
|
|
|
nsCOMPtr<nsIContent> mLastAnchorScrolledTo;
|
|
|
|
RefPtr<nsCaret> mCaret;
|
|
|
|
RefPtr<nsCaret> mOriginalCaret;
|
|
|
|
nsCallbackEventRequest* mFirstCallbackEventRequest;
|
|
|
|
nsCallbackEventRequest* mLastCallbackEventRequest;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
TouchManager mTouchManager;
|
2015-02-20 07:12:00 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<ZoomConstraintsClient> mZoomConstraintsClient;
|
|
|
|
RefPtr<MobileViewportManager> mMobileViewportManager;
|
2015-06-17 16:32:42 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
RefPtr<AccessibleCaretEventHub> mAccessibleCaretEventHub;
|
2014-06-03 07:08:54 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
// This timer controls painting suppression. Until it fires
|
|
|
|
// or all frames are constructed, we won't paint anything but
|
|
|
|
// our <body> background and scrollbars.
|
2018-03-07 11:13:17 +00:00
|
|
|
nsCOMPtr<nsITimer> mPaintSuppressionTimer;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nsCOMPtr<nsITimer> mDelayedPaintTimer;
|
2014-01-30 05:41:17 +00:00
|
|
|
|
2013-06-01 10:00:12 +00:00
|
|
|
// The `performance.now()` value when we last started to process reflows.
|
2018-03-07 11:13:17 +00:00
|
|
|
DOMHighResTimeStamp mLastReflowStart;
|
2013-06-01 10:00:12 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
TimeStamp mLoadBegin; // used to time loads
|
2013-11-05 01:03:22 +00:00
|
|
|
|
2012-05-16 17:32:40 +00:00
|
|
|
// Information needed to properly handle scrolling content into view if the
|
|
|
|
// pre-scroll reflow flush can be interrupted. mContentToScrollTo is
|
|
|
|
// non-null between the initial scroll attempt and the first time we finish
|
2012-05-16 17:32:40 +00:00
|
|
|
// processing all our dirty roots. mContentToScrollTo has a content property
|
|
|
|
// storing the details for the scroll operation, see ScrollIntoViewData above.
|
2018-03-07 11:13:17 +00:00
|
|
|
nsCOMPtr<nsIContent> mContentToScrollTo;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
nscoord mLastAnchorScrollPositionY;
|
2011-09-09 19:50:21 +00:00
|
|
|
|
2015-04-14 15:46:39 +00:00
|
|
|
// Information about live content (which still stay in DOM tree).
|
|
|
|
// Used in case we need re-dispatch event after sending pointer event,
|
|
|
|
// when target of pointer event was deleted during executing user handlers.
|
2018-03-07 11:13:17 +00:00
|
|
|
nsCOMPtr<nsIContent> mPointerEventTarget;
|
2015-04-14 15:46:39 +00:00
|
|
|
|
2018-06-25 21:42:25 +00:00
|
|
|
int32_t mActiveSuppressDisplayport;
|
|
|
|
|
2017-06-28 19:11:04 +00:00
|
|
|
// The focus sequence number of the last processed input event
|
2018-03-07 11:13:17 +00:00
|
|
|
uint64_t mAPZFocusSequenceNumber;
|
2017-06-28 19:11:04 +00:00
|
|
|
// The focus information needed for async keyboard scrolling
|
2018-03-07 11:13:17 +00:00
|
|
|
FocusTarget mAPZFocusTarget;
|
2017-06-28 19:11:04 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mDocumentLoading : 1;
|
|
|
|
bool mIgnoreFrameDestruction : 1;
|
|
|
|
bool mHaveShutDown : 1;
|
|
|
|
bool mLastRootReflowHadUnconstrainedBSize : 1;
|
|
|
|
bool mNoDelayedMouseEvents : 1;
|
|
|
|
bool mNoDelayedKeyEvents : 1;
|
2012-05-16 17:32:40 +00:00
|
|
|
|
|
|
|
// Indicates that it is safe to unlock painting once all pending reflows
|
|
|
|
// have been processed.
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mShouldUnsuppressPainting : 1;
|
2012-05-16 17:32:40 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mApproximateFrameVisibilityVisited : 1;
|
2013-02-25 00:59:22 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mNextPaintCompressed : 1;
|
2014-01-30 05:41:17 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mHasCSSBackgroundColor : 1;
|
2014-09-23 17:50:00 +00:00
|
|
|
|
2015-01-03 01:06:14 +00:00
|
|
|
// Whether content should be scaled by the resolution amount. If this is
|
|
|
|
// not set, a transform that scales by the inverse of the resolution is
|
|
|
|
// applied to rendered layers.
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mScaleToResolution : 1;
|
2015-01-03 01:06:14 +00:00
|
|
|
|
2015-01-21 01:16:04 +00:00
|
|
|
// Whether the last chrome-only escape key event is consumed.
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mIsLastChromeOnlyEscapeKeyConsumed : 1;
|
2015-01-21 01:16:04 +00:00
|
|
|
|
2015-06-18 20:42:39 +00:00
|
|
|
// Whether the widget has received a paint message yet.
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mHasReceivedPaintMessage : 1;
|
2015-06-18 20:42:39 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mIsLastKeyDownCanceled : 1;
|
2017-02-03 10:16:00 +00:00
|
|
|
|
2017-11-21 22:25:09 +00:00
|
|
|
// Whether we have ever handled a user input event
|
2018-03-07 11:13:17 +00:00
|
|
|
bool mHasHandledUserInput : 1;
|
2017-11-21 22:25:09 +00:00
|
|
|
|
2018-12-05 16:29:18 +00:00
|
|
|
// Whether the most recent change to the pres shell resolution was
|
|
|
|
// originated by the main thread.
|
|
|
|
bool mResolutionUpdated : 1;
|
|
|
|
|
2018-03-23 03:06:55 +00:00
|
|
|
// Whether we should dispatch keypress events even for non-printable keys
|
|
|
|
// for keeping backward compatibility.
|
|
|
|
bool mForceDispatchKeyPressEventsForNonPrintableKeys : 1;
|
2018-11-07 06:39:10 +00:00
|
|
|
// Whether we should set keyCode or charCode value of keypress events whose
|
|
|
|
// value is zero to the other value or not. When this is set to true, we
|
|
|
|
// should keep using legacy keyCode and charCode values (i.e., one of them
|
|
|
|
// is always 0).
|
|
|
|
bool mForceUseLegacyKeyCodeAndCharCodeValues : 1;
|
|
|
|
// Whether mForceDispatchKeyPressEventsForNonPrintableKeys and
|
|
|
|
// mForceUseLegacyKeyCodeAndCharCodeValues are initialized.
|
|
|
|
bool mInitializedWithKeyPressEventDispatchingBlacklist : 1;
|
2018-03-23 03:06:55 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
static bool sDisableNonTestMouseEvents;
|
2017-04-19 15:17:20 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
TimeStamp mLastOSWake;
|
2017-04-19 19:53:30 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
static TimeStamp sLastInputCreated;
|
|
|
|
static TimeStamp sLastInputProcessed;
|
2017-08-08 09:54:13 +00:00
|
|
|
|
2018-03-07 11:13:17 +00:00
|
|
|
static bool sProcessInteractable;
|
2011-09-09 19:50:21 +00:00
|
|
|
};
|
|
|
|
|
2016-11-30 03:14:27 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2016-11-30 03:14:28 +00:00
|
|
|
#endif // mozilla_PresShell_h
|