2017-10-27 20:33:53 +03: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 15:12:37 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2017-08-17 00:10:56 +03:00
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-09-09 23:50:21 +04:00
|
|
|
|
|
|
|
/* a presentation of a document, part 2 */
|
|
|
|
|
2016-11-30 06:14:28 +03:00
|
|
|
#ifndef mozilla_PresShell_h
|
|
|
|
#define mozilla_PresShell_h
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-04-25 08:02:20 +03:00
|
|
|
#include "mozilla/PresShellForwards.h"
|
|
|
|
|
2019-05-01 05:28:59 +03:00
|
|
|
#include <stdio.h> // for FILE definition
|
|
|
|
#include "FrameMetrics.h"
|
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
#include "TouchManager.h"
|
|
|
|
#include "Units.h"
|
Bug 1600545 - Remove useless inclusions of header files generated from IDL files in accessible/, browser/, caps/, chrome/, devtools/, docshell/, editor/, extensions/, gfx/, hal/, image/, intl/, ipc/, js/, layout/, and media/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55443
--HG--
extra : moz-landing-system : lando
2019-12-06 12:16:44 +03:00
|
|
|
#include "Visibility.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "gfxPoint.h"
|
|
|
|
#include "mozilla/ArenaObjectID.h"
|
2012-06-19 07:26:34 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-22 17:27:34 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "mozilla/FlushType.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2019-03-26 02:17:20 +03:00
|
|
|
#include "mozilla/ScrollTypes.h"
|
2018-03-29 14:15:46 +03:00
|
|
|
#include "mozilla/ServoStyleSet.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "mozilla/ServoStyleConsts.h"
|
2019-03-04 09:11:41 +03:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
2016-01-21 00:24:28 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "mozilla/WeakPtr.h"
|
|
|
|
#include "mozilla/dom/HTMLDocumentBinding.h"
|
|
|
|
#include "mozilla/layers/FocusTarget.h"
|
2019-11-01 07:33:48 +03:00
|
|
|
#include "mozilla/layout/LayoutTelemetryTools.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "nsChangeHint.h"
|
|
|
|
#include "nsClassHashtable.h"
|
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsCoord.h"
|
2019-12-19 01:49:07 +03:00
|
|
|
#include "nsDOMNavigationTiming.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "nsFrameManager.h"
|
|
|
|
#include "nsFrameState.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsIContent.h"
|
2016-11-30 06:14:28 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsISelectionController.h"
|
|
|
|
#include "nsIWidget.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "nsQueryFrame.h"
|
|
|
|
#include "nsMargin.h"
|
|
|
|
#include "nsPresArena.h"
|
2016-11-30 06:14:28 +03:00
|
|
|
#include "nsPresContext.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
2016-11-30 06:14:28 +03:00
|
|
|
#include "nsRefreshDriver.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "nsRegionFwd.h"
|
|
|
|
#include "nsStringFwd.h"
|
2016-11-30 06:14:28 +03:00
|
|
|
#include "nsStubDocumentObserver.h"
|
2019-05-01 05:28:59 +03:00
|
|
|
#include "nsTHashtable.h"
|
2016-11-30 06:14:28 +03:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsWeakReference.h"
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:28:59 +03:00
|
|
|
class AutoPointerEventTargetUpdater;
|
|
|
|
class AutoWeakFrame;
|
|
|
|
class gfxContext;
|
|
|
|
class MobileViewportManager;
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
class nsAccessibilityService;
|
|
|
|
#endif
|
|
|
|
class nsARefreshObserver;
|
|
|
|
class nsAutoCauseReflowNotifier;
|
|
|
|
class nsCanvasFrame;
|
|
|
|
class nsCaret;
|
|
|
|
class nsCSSFrameConstructor;
|
|
|
|
class nsDisplayList;
|
|
|
|
class nsDisplayListBuilder;
|
|
|
|
class nsDocShell;
|
|
|
|
class nsFrameSelection;
|
2016-08-03 19:00:22 +03:00
|
|
|
class nsIDocShell;
|
2019-05-01 05:28:59 +03:00
|
|
|
class nsIFrame;
|
|
|
|
class nsILayoutHistoryState;
|
|
|
|
class nsINode;
|
2019-05-22 15:01:33 +03:00
|
|
|
class nsPageSequenceFrame;
|
2019-05-01 05:28:59 +03:00
|
|
|
class nsIReflowCallback;
|
|
|
|
class nsIScrollableFrame;
|
|
|
|
class nsITimer;
|
|
|
|
class nsPIDOMWindowOuter;
|
|
|
|
class nsAPostRefreshObserver;
|
|
|
|
class nsPresShellEventCB;
|
2012-01-10 18:19:54 +04:00
|
|
|
class nsRange;
|
2019-05-01 05:28:59 +03:00
|
|
|
class nsRefreshDriver;
|
|
|
|
class nsRegion;
|
|
|
|
class nsView;
|
|
|
|
class nsViewManager;
|
|
|
|
class nsWindowSizes;
|
2011-09-09 23:50:21 +04:00
|
|
|
struct RangePaintInfo;
|
2019-05-01 05:28:59 +03:00
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
class ReflowCountMgr;
|
|
|
|
#endif
|
|
|
|
class WeakFrame;
|
2019-12-19 01:57:48 +03:00
|
|
|
class ZoomConstraintsClient;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:28:59 +03:00
|
|
|
template <class E>
|
|
|
|
class nsCOMArray;
|
|
|
|
|
|
|
|
struct nsCallbackEventRequest;
|
|
|
|
struct nsPoint;
|
|
|
|
struct nsRect;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2014-06-20 14:32:49 +04:00
|
|
|
namespace mozilla {
|
2019-05-01 05:28:59 +03:00
|
|
|
class AccessibleCaretEventHub;
|
|
|
|
class EventStates;
|
|
|
|
class GeckoMVMContext;
|
|
|
|
class OverflowChangedTracker;
|
|
|
|
class StyleSheet;
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
namespace a11y {
|
|
|
|
class DocAccessible;
|
|
|
|
} // namespace a11y
|
|
|
|
#endif
|
2016-03-19 04:38:57 +03:00
|
|
|
|
2017-04-17 19:01:37 +03:00
|
|
|
namespace dom {
|
2019-05-01 05:28:59 +03:00
|
|
|
class Document;
|
2017-04-17 19:01:37 +03:00
|
|
|
class Element;
|
2019-05-01 05:28:59 +03:00
|
|
|
class Event;
|
|
|
|
class HTMLSlotElement;
|
2017-08-02 02:50:50 +03:00
|
|
|
class Selection;
|
2017-04-17 19:01:37 +03:00
|
|
|
} // namespace dom
|
|
|
|
|
2019-05-01 05:28:59 +03:00
|
|
|
namespace gfx {
|
|
|
|
class SourceSurface;
|
|
|
|
} // namespace gfx
|
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
class LayerManager;
|
|
|
|
} // namespace layers
|
|
|
|
|
|
|
|
namespace layout {
|
|
|
|
class ScrollAnchorContainer;
|
|
|
|
} // namespace layout
|
2016-03-19 04:38:57 +03:00
|
|
|
|
2019-04-30 03:56:14 +03:00
|
|
|
// 039d8ffc-fa55-42d7-a53a-388cb129b052
|
|
|
|
#define NS_PRESSHELL_IID \
|
|
|
|
{ \
|
|
|
|
0x039d8ffc, 0xfa55, 0x42d7, { \
|
|
|
|
0xa5, 0x3a, 0x38, 0x8c, 0xb1, 0x29, 0xb0, 0x52 \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2019-05-01 05:28:59 +03:00
|
|
|
#undef NOISY_INTERRUPTIBLE_REFLOW
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Presentation shell. Presentation shells are the controlling point for
|
|
|
|
* managing the presentation of a document. The presentation shell holds a
|
|
|
|
* live reference to the document, the presentation context, the style
|
|
|
|
* manager, the style set and the root frame.
|
|
|
|
*
|
|
|
|
* When this object is Release'd, it will release the document, the
|
|
|
|
* presentation context, the style manager, the style set and the root frame.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PresShell final : public nsStubDocumentObserver,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsISelectionController,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference {
|
2019-05-01 05:28:25 +03:00
|
|
|
typedef dom::Document Document;
|
2019-04-03 10:02:00 +03:00
|
|
|
typedef dom::Element Element;
|
2019-05-01 05:28:25 +03:00
|
|
|
typedef gfx::SourceSurface SourceSurface;
|
|
|
|
typedef layers::FocusTarget FocusTarget;
|
|
|
|
typedef layers::FrameMetrics FrameMetrics;
|
|
|
|
typedef layers::LayerManager LayerManager;
|
2017-07-13 21:00:21 +03:00
|
|
|
|
2019-04-25 08:02:20 +03: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;
|
|
|
|
|
2011-09-09 23:50:21 +04:00
|
|
|
public:
|
2019-12-11 15:18:00 +03:00
|
|
|
explicit PresShell(Document* aDocument);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2019-04-30 03:56:14 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRESSHELL_IID)
|
|
|
|
|
2016-08-03 19:00:22 +03:00
|
|
|
static bool AccessibleCaretEnabled(nsIDocShell* aDocShell);
|
2015-04-24 03:08:00 +03:00
|
|
|
|
2019-04-30 03:26:57 +03:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2019-04-30 10:53:20 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
/**
|
|
|
|
* Return the document accessible for this PresShell if there is one.
|
|
|
|
*/
|
|
|
|
a11y::DocAccessible* GetDocAccessible() const { return mDocAccessible; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the document accessible for this PresShell.
|
|
|
|
*/
|
|
|
|
void SetDocAccessible(a11y::DocAccessible* aDocAccessible) {
|
|
|
|
mDocAccessible = aDocAccessible;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if accessibility is active.
|
|
|
|
*/
|
|
|
|
static bool IsAccessibilityActive();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return accessibility service if accessibility is active.
|
|
|
|
*/
|
|
|
|
static nsAccessibilityService* GetAccessibilityService();
|
|
|
|
#endif // #ifdef ACCESSIBILITY
|
|
|
|
|
2019-12-11 15:18:00 +03:00
|
|
|
void Init(nsPresContext*, nsViewManager*);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* All callers are responsible for calling |Destroy| after calling
|
|
|
|
* |EndObservingDocument|. It needs to be separate only because form
|
|
|
|
* controls incorrectly store their data in the frames rather than the
|
|
|
|
* content model and printing calls |EndObservingDocument| multiple
|
|
|
|
* times to make form controls behave nicely when printed.
|
|
|
|
*/
|
|
|
|
void Destroy();
|
2018-03-07 14:13:17 +03:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
bool IsDestroying() { return mIsDestroying; }
|
2018-03-07 14:13:17 +03:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* All frames owned by the shell are allocated from an arena. They
|
|
|
|
* are also recycled using free lists. Separate free lists are
|
|
|
|
* maintained for each frame type (aID), which must always correspond
|
|
|
|
* to the same aSize value. AllocateFrame is infallible and will abort
|
|
|
|
* on out-of-memory.
|
|
|
|
*/
|
|
|
|
void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) {
|
2019-07-02 05:46:09 +03:00
|
|
|
#define FRAME_ID(classname, ...) \
|
|
|
|
static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
|
|
|
|
size_t(eArenaObjectID_##classname), \
|
|
|
|
"");
|
|
|
|
#define ABSTRACT_FRAME_ID(classname) \
|
|
|
|
static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
|
|
|
|
size_t(eArenaObjectID_##classname), \
|
|
|
|
"");
|
|
|
|
#include "mozilla/FrameIdList.h"
|
|
|
|
#undef FRAME_ID
|
|
|
|
#undef ABSTRACT_FRAME_ID
|
|
|
|
return AllocateByObjectID(ArenaObjectID(size_t(aID)), aSize);
|
2019-05-01 05:27:53 +03:00
|
|
|
}
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr) {
|
2019-07-02 05:46:09 +03:00
|
|
|
return FreeByObjectID(ArenaObjectID(size_t(aID)), aPtr);
|
2019-05-01 05:27:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void* AllocateByObjectID(ArenaObjectID aID, size_t aSize) {
|
2019-07-02 05:46:09 +03:00
|
|
|
void* result = mFrameArena.Allocate(aID, aSize);
|
2019-05-01 05:27:53 +03:00
|
|
|
RecordAlloc(result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeByObjectID(ArenaObjectID aID, void* aPtr) {
|
|
|
|
RecordFree(aPtr);
|
|
|
|
if (!mIsDestroying) {
|
2019-07-02 05:46:09 +03:00
|
|
|
mFrameArena.Free(aID, aPtr);
|
2019-05-01 05:27:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Document* GetDocument() const { return mDocument; }
|
|
|
|
|
|
|
|
nsPresContext* GetPresContext() const { return mPresContext; }
|
|
|
|
|
|
|
|
nsViewManager* GetViewManager() const { return mViewManager; }
|
|
|
|
|
|
|
|
nsRefreshDriver* GetRefreshDriver() const;
|
|
|
|
|
|
|
|
nsCSSFrameConstructor* FrameConstructor() const {
|
|
|
|
return mFrameConstructor.get();
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* FrameSelection will return the Frame based selection API.
|
|
|
|
* You cannot go back and forth anymore with QI between nsIDOM sel and
|
|
|
|
* nsIFrame sel.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsFrameSelection> FrameSelection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ConstFrameSelection returns an object which methods are safe to use for
|
|
|
|
* example in nsIFrame code.
|
|
|
|
*/
|
|
|
|
const nsFrameSelection* ConstFrameSelection() const { return mSelection; }
|
|
|
|
|
|
|
|
// Start receiving notifications from our document. If called after Destroy,
|
|
|
|
// this will be ignored.
|
|
|
|
void BeginObservingDocument();
|
|
|
|
|
|
|
|
// Stop receiving notifications from our document. If called after Destroy,
|
|
|
|
// this will be ignored.
|
|
|
|
void EndObservingDocument();
|
|
|
|
|
|
|
|
bool IsObservingDocument() const { return mIsObservingDocument; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return whether Initialize() was previously called.
|
|
|
|
*/
|
|
|
|
bool DidInitialize() const { return mDidInitialize; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform initialization. Constructs the frame for the root content
|
|
|
|
* object and then enqueues a reflow of the frame model.
|
|
|
|
*
|
|
|
|
* Callers of this method must hold a reference to this shell that
|
|
|
|
* is guaranteed to survive through arbitrary script execution.
|
|
|
|
* Calling Initialize can execute arbitrary script.
|
|
|
|
*/
|
|
|
|
nsresult Initialize();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow the frame model into a new width and height. The
|
|
|
|
* coordinates for aWidth and aHeight must be in standard nscoord's.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
Bug 1583534 - Further simplify PresShell::ResizeReflow. r=botond
In particular, not let ResizeReflow take the old and new size. Most of the
callers pass dummy values anyway.
Instead, use the old size of the layout viewport. This ensures we fire resize
events only if the layout viewport actually changes.
This is important because the first resize of the mobile viewport manager
after a navigation has an "old size" of 0x0, even though the layout viewport
is initialized on presshell initialization to the right size.
Thus, we fire resize events unnecessarily in that case, which is the root cause
for bug 1528052.
To do this, we need to shuffle a bit of code in nsDocumentViewer that deals with
delayed resizes, to set the visible area _and_ invalidate layout, rather than
setting the visible area and _then_ relying on doing a resize reflow.
Further cleanup is possible, though not required for my android resizing fix, so
will do separately.
Differential Revision: https://phabricator.services.mozilla.com/D46944
--HG--
extra : moz-landing-system : lando
2019-09-25 22:12:44 +03:00
|
|
|
ResizeReflow(nscoord aWidth, nscoord aHeight,
|
|
|
|
ResizeReflowOptions = ResizeReflowOptions::NoOption);
|
2019-10-06 21:29:55 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult ResizeReflowIgnoreOverride(nscoord aWidth,
|
|
|
|
nscoord aHeight,
|
|
|
|
ResizeReflowOptions);
|
2019-05-01 05:27:53 +03:00
|
|
|
|
2019-09-13 03:21:04 +03:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* This is what ResizeReflowIgnoreOverride does when not shrink-wrapping (that
|
|
|
|
* is, when ResizeReflowOptions::BSizeLimit is not specified).
|
|
|
|
*/
|
Bug 1583534 - Further simplify PresShell::ResizeReflow. r=botond
In particular, not let ResizeReflow take the old and new size. Most of the
callers pass dummy values anyway.
Instead, use the old size of the layout viewport. This ensures we fire resize
events only if the layout viewport actually changes.
This is important because the first resize of the mobile viewport manager
after a navigation has an "old size" of 0x0, even though the layout viewport
is initialized on presshell initialization to the right size.
Thus, we fire resize events unnecessarily in that case, which is the root cause
for bug 1528052.
To do this, we need to shuffle a bit of code in nsDocumentViewer that deals with
delayed resizes, to set the visible area _and_ invalidate layout, rather than
setting the visible area and _then_ relying on doing a resize reflow.
Further cleanup is possible, though not required for my android resizing fix, so
will do separately.
Differential Revision: https://phabricator.services.mozilla.com/D46944
--HG--
extra : moz-landing-system : lando
2019-09-25 22:12:44 +03:00
|
|
|
void SimpleResizeReflow(nscoord aWidth, nscoord aHeight, ResizeReflowOptions);
|
2019-09-13 03:21:04 +03:00
|
|
|
|
|
|
|
public:
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
2019-05-28 16:31:59 +03:00
|
|
|
* Returns true if this document has a potentially zoomable viewport,
|
|
|
|
* allowing for its layout and visual viewports to diverge.
|
2019-05-01 05:27:53 +03:00
|
|
|
*/
|
2019-05-28 16:31:59 +03:00
|
|
|
bool GetIsViewportOverridden() const {
|
|
|
|
return (mMobileViewportManager != nullptr);
|
|
|
|
}
|
2019-05-01 05:27:53 +03:00
|
|
|
|
|
|
|
/**
|
2019-05-28 16:31:59 +03:00
|
|
|
* Note that the assumptions that determine whether we have a potentially
|
|
|
|
* zoomable viewport may have changed.
|
2019-05-01 05:27:53 +03:00
|
|
|
*/
|
|
|
|
void UpdateViewportOverridden(bool aAfterInitialization);
|
|
|
|
|
2019-05-28 16:31:59 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this document uses mobile viewport sizing (including
|
|
|
|
* processing of <meta name="viewport"> tags).
|
|
|
|
*
|
|
|
|
* Note that having a MobileViewportManager does not necessarily mean using
|
|
|
|
* mobile viewport sizing, as with desktop zooming we can have a
|
|
|
|
* MobileViewportManager on desktop, but we only want to do mobile viewport
|
|
|
|
* sizing on mobile. (TODO: Rename MobileViewportManager to reflect its more
|
|
|
|
* general role.)
|
|
|
|
*/
|
|
|
|
bool UsesMobileViewportSizing() const;
|
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Get the MobileViewportManager used to manage the document's mobile
|
|
|
|
* viewport. Will return null in situations where we don't have a mobile
|
|
|
|
* viewport, and for documents that are not the root content document.
|
|
|
|
*/
|
|
|
|
RefPtr<MobileViewportManager> GetMobileViewportManager() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the presshell expects layout flush.
|
|
|
|
*/
|
|
|
|
bool IsLayoutFlushObserver() {
|
|
|
|
return GetPresContext()->RefreshDriver()->IsLayoutFlushObserver(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when document load completes.
|
|
|
|
*/
|
|
|
|
void LoadComplete();
|
|
|
|
/**
|
|
|
|
* This calls through to the frame manager to get the root frame.
|
|
|
|
*/
|
|
|
|
nsIFrame* GetRootFrame() const { return mFrameManager->GetRootFrame(); }
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get root scroll frame from FrameManager()->GetRootFrame().
|
|
|
|
*/
|
|
|
|
nsIFrame* GetRootScrollFrame() const;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The same as GetRootScrollFrame, but returns an nsIScrollableFrame
|
|
|
|
*/
|
|
|
|
nsIScrollableFrame* GetRootScrollFrameAsScrollable() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current focused content or DOM selection that should be the
|
|
|
|
* target for scrolling.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIContent> GetContentForScrolling() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the DOM selection that should be the target for scrolling, if there
|
|
|
|
* is no focused content.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIContent> GetSelectedContentForScrolling() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets nearest scrollable frame from the specified content node. The frame
|
|
|
|
* is scrollable with overflow:scroll or overflow:auto in some direction when
|
|
|
|
* aDirection is eEither. Otherwise, this returns a nearest frame that is
|
|
|
|
* scrollable in the specified direction.
|
|
|
|
*/
|
|
|
|
nsIScrollableFrame* GetScrollableFrameToScrollForContent(
|
|
|
|
nsIContent* aContent, ScrollableDirection aDirection);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets nearest scrollable frame from current focused content or DOM
|
|
|
|
* selection if there is no focused content. The frame is scrollable with
|
|
|
|
* overflow:scroll or overflow:auto in some direction when aDirection is
|
|
|
|
* eEither. Otherwise, this returns a nearest frame that is scrollable in
|
|
|
|
* the specified direction.
|
|
|
|
*/
|
|
|
|
nsIScrollableFrame* GetScrollableFrameToScroll(
|
|
|
|
ScrollableDirection aDirection);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets nearest ancestor scrollable frame from aFrame. The frame is
|
|
|
|
* scrollable with overflow:scroll or overflow:auto in some direction when
|
|
|
|
* aDirection is eEither. Otherwise, this returns a nearest frame that is
|
|
|
|
* scrollable in the specified direction.
|
|
|
|
*/
|
|
|
|
nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame,
|
|
|
|
ScrollableDirection aDirection);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the page sequence frame associated with the frame hierarchy.
|
|
|
|
* Returns nullptr if not a paginated view.
|
|
|
|
*/
|
2019-05-22 15:01:33 +03:00
|
|
|
nsPageSequenceFrame* GetPageSequenceFrame() const;
|
2019-01-26 08:27:09 +03:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Returns the canvas frame associated with the frame hierarchy.
|
|
|
|
* Returns nullptr if is XUL document.
|
|
|
|
*/
|
|
|
|
nsCanvasFrame* GetCanvasFrame() const;
|
|
|
|
|
|
|
|
void PostPendingScrollAnchorSelection(
|
|
|
|
layout::ScrollAnchorContainer* aContainer);
|
|
|
|
void FlushPendingScrollAnchorSelections();
|
|
|
|
void PostPendingScrollAnchorAdjustment(
|
|
|
|
layout::ScrollAnchorContainer* aContainer);
|
|
|
|
|
|
|
|
void CancelAllPendingReflows();
|
|
|
|
|
|
|
|
void NotifyCounterStylesAreDirty();
|
|
|
|
|
|
|
|
bool FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy the frames for aElement, and reconstruct them asynchronously if
|
|
|
|
* needed.
|
|
|
|
*
|
|
|
|
* Note that this may destroy frames for an ancestor instead.
|
|
|
|
*/
|
|
|
|
void DestroyFramesForAndRestyle(Element* aElement);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles all the layout stuff needed when the slot assignment for an element
|
|
|
|
* is about to change.
|
|
|
|
*
|
|
|
|
* Only called when the slot attribute of the element changes, the rest of
|
|
|
|
* the changes should be handled in ShadowRoot.
|
|
|
|
*/
|
|
|
|
void SlotAssignmentWillChange(Element& aElement,
|
|
|
|
dom::HTMLSlotElement* aOldSlot,
|
|
|
|
dom::HTMLSlotElement* aNewSlot);
|
|
|
|
|
|
|
|
void PostRecreateFramesFor(Element*);
|
|
|
|
void RestyleForAnimation(Element*, RestyleHint);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if it is safe to flush all pending notifications.
|
|
|
|
*/
|
|
|
|
bool IsSafeToFlush() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Informs the document's FontFaceSet that the refresh driver ticked,
|
|
|
|
* flushing style and layout.
|
|
|
|
*/
|
|
|
|
void NotifyFontFaceSetOnRefresh();
|
|
|
|
|
|
|
|
// Removes ourself from the list of layout / style / and resize refresh driver
|
|
|
|
// observers.
|
|
|
|
//
|
|
|
|
// Right now this is only used for documents in the BFCache, so if you want to
|
|
|
|
// use this for anything else you need to ensure we don't end up in those
|
|
|
|
// lists after calling this, but before calling StartObservingRefreshDriver
|
|
|
|
// again.
|
|
|
|
//
|
|
|
|
// That is handled by the mDocument->GetBFCacheEntry checks in
|
|
|
|
// DoObserve*Flushes functions, though that could conceivably become a boolean
|
|
|
|
// member in the shell if needed.
|
|
|
|
//
|
|
|
|
// Callers are responsible of manually calling StartObservingRefreshDriver
|
|
|
|
// again.
|
|
|
|
void StopObservingRefreshDriver();
|
|
|
|
void StartObservingRefreshDriver();
|
|
|
|
|
|
|
|
bool ObservingStyleFlushes() const { return mObservingStyleFlushes; }
|
|
|
|
bool ObservingLayoutFlushes() const { return mObservingLayoutFlushes; }
|
|
|
|
|
|
|
|
void ObserveStyleFlushes() {
|
|
|
|
if (!ObservingStyleFlushes()) {
|
|
|
|
DoObserveStyleFlushes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callbacks will be called even if reflow itself fails for
|
|
|
|
* some reason.
|
|
|
|
*/
|
|
|
|
nsresult PostReflowCallback(nsIReflowCallback* aCallback);
|
|
|
|
void CancelReflowCallback(nsIReflowCallback* aCallback);
|
|
|
|
|
|
|
|
void ScheduleBeforeFirstPaint();
|
|
|
|
void UnsuppressAndInvalidate();
|
|
|
|
|
|
|
|
void ClearFrameRefs(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a reference rendering context. This is a context that should not
|
|
|
|
* be rendered to, but is suitable for measuring text and performing
|
|
|
|
* other non-rendering operations. Guaranteed to return non-null.
|
|
|
|
*/
|
|
|
|
already_AddRefed<gfxContext> CreateReferenceRenderingContext();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scrolls the view of the document so that the given area of a frame
|
|
|
|
* is visible, if possible. Layout is not flushed before scrolling.
|
|
|
|
*
|
|
|
|
* @param aRect relative to aFrame
|
|
|
|
* @param aVertical see ScrollContentIntoView and ScrollAxis
|
|
|
|
* @param aHorizontal see ScrollContentIntoView and ScrollAxis
|
|
|
|
* @param aScrollFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
|
|
|
|
* nearest scrollable ancestor is scrolled, otherwise all
|
|
|
|
* scrollable ancestors may be scrolled if necessary
|
|
|
|
* if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction
|
|
|
|
* even if overflow:hidden is specified in that direction; otherwise
|
|
|
|
* we will not scroll in that direction when overflow:hidden is
|
|
|
|
* set for that direction
|
|
|
|
* If SCROLL_NO_PARENT_FRAMES is set then we only scroll
|
|
|
|
* nodes in this document, not in any parent documents which
|
|
|
|
* contain this document in a iframe or the like.
|
|
|
|
* If SCROLL_IGNORE_SCROLL_MARGIN_AND_PADDING is set we ignore scroll-margin
|
|
|
|
* value specified for |aFrame| and scroll-padding value for the scroll
|
|
|
|
* container. This option is typically used to locate poped-up frames into
|
|
|
|
* view.
|
|
|
|
* @return true if any scrolling happened, false if no scrolling happened
|
|
|
|
*/
|
2019-05-06 16:57:46 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-05-01 05:27:53 +03:00
|
|
|
bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
|
|
|
|
ScrollAxis aVertical, ScrollAxis aHorizontal,
|
|
|
|
ScrollFlags aScrollFlags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Suppress notification of the frame manager that frames are
|
|
|
|
* being destroyed.
|
|
|
|
*/
|
|
|
|
void SetIgnoreFrameDestruction(bool aIgnore);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Get the AccessibleCaretEventHub, if it exists. AddRefs it.
|
|
|
|
*/
|
|
|
|
already_AddRefed<AccessibleCaretEventHub> GetAccessibleCaretEventHub() const;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Get the caret, if it exists. AddRefs it.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsCaret> GetCaret() const;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Set the current caret to a new caret. To undo this, call RestoreCaret.
|
|
|
|
*/
|
|
|
|
void SetCaret(nsCaret* aNewCaret);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore the caret to the original caret that this pres shell was created
|
|
|
|
* with.
|
|
|
|
*/
|
|
|
|
void RestoreCaret();
|
|
|
|
|
|
|
|
dom::Selection* GetCurrentSelection(SelectionType aSelectionType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a selection controller for the focused content in the DOM window
|
|
|
|
* for mDocument.
|
|
|
|
*
|
|
|
|
* @param aFocusedContent If there is focused content in the DOM window,
|
|
|
|
* the focused content will be returned. This may
|
|
|
|
* be nullptr if it's not necessary.
|
|
|
|
* @return A selection controller for focused content.
|
|
|
|
* E.g., if an <input> element has focus, returns
|
|
|
|
* the independent selection controller of it.
|
|
|
|
* If the DOM window does not have focused content
|
|
|
|
* (similar to Document.activeElement), returns
|
|
|
|
* nullptr.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsISelectionController>
|
|
|
|
GetSelectionControllerForFocusedContent(
|
|
|
|
nsIContent** aFocusedContent = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface to dispatch events via the presshell
|
|
|
|
* @note The caller must have a strong reference to the PresShell.
|
|
|
|
*/
|
2019-05-06 16:15:05 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-05-01 05:27:53 +03:00
|
|
|
nsresult HandleEventWithTarget(WidgetEvent* aEvent, nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
bool aIsHandlingNativeEvent = false,
|
|
|
|
nsIContent** aTargetContent = nullptr,
|
|
|
|
nsIContent* aOverrideClickTarget = nullptr) {
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
MOZ_ASSERT(aEvent);
|
|
|
|
EventHandler eventHandler(*this);
|
|
|
|
return eventHandler.HandleEventWithTarget(
|
|
|
|
aEvent, aFrame, aContent, aEventStatus, aIsHandlingNativeEvent,
|
|
|
|
aTargetContent, aOverrideClickTarget);
|
|
|
|
}
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Dispatch event to content only (NOT full processing)
|
|
|
|
*/
|
2019-05-09 23:21:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-05-01 05:27:53 +03:00
|
|
|
nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
nsEventStatus* aStatus);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch event to content only (NOT full processing)
|
|
|
|
*/
|
2019-05-09 23:21:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-05-01 05:27:53 +03:00
|
|
|
nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
|
|
|
dom::Event* aEvent, nsEventStatus* aStatus);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return whether or not the event is valid to be dispatched
|
|
|
|
*/
|
|
|
|
bool CanDispatchEvent(const WidgetGUIEvent* aEvent = nullptr) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current target event frame from the PresShell
|
|
|
|
*/
|
|
|
|
nsIFrame* GetCurrentEventFrame();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current target event frame from the PresShell
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIContent> GetEventTargetContent(WidgetEvent* aEvent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get and set the history state for the current document
|
|
|
|
*/
|
|
|
|
nsresult CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Determine if reflow is currently locked
|
|
|
|
* returns true if reflow is locked, false otherwise
|
|
|
|
*/
|
|
|
|
bool IsReflowLocked() const { return mIsReflowing; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to find out if painting is suppressed for this presshell. If it is
|
|
|
|
* suppressd, we don't allow the painting of any layer but the background, and
|
|
|
|
* we don't recur into our children.
|
|
|
|
*/
|
|
|
|
bool IsPaintingSuppressed() const { return mPaintingSuppressed; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause painting by freezing the refresh driver of this and all parent
|
|
|
|
* presentations. This may not have the desired effect if this pres shell
|
|
|
|
* has its own refresh driver.
|
|
|
|
*/
|
|
|
|
void PausePainting();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resume painting by thawing the refresh driver of this and all parent
|
|
|
|
* presentations. This may not have the desired effect if this pres shell
|
|
|
|
* has its own refresh driver.
|
|
|
|
*/
|
|
|
|
void ResumePainting();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unsuppress painting.
|
|
|
|
*/
|
|
|
|
void UnsuppressPainting();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an override style sheet for this presentation
|
|
|
|
*/
|
|
|
|
nsresult AddOverrideStyleSheet(StyleSheet* aSheet);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an override style sheet
|
|
|
|
*/
|
|
|
|
nsresult RemoveOverrideStyleSheet(StyleSheet* aSheet);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reconstruct frames for all elements in the document
|
|
|
|
*/
|
2019-12-11 15:18:00 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void ReconstructFrames();
|
2019-05-01 05:27:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See if reflow verification is enabled. To enable reflow verification add
|
|
|
|
* "verifyreflow:1" to your MOZ_LOG environment variable (any non-zero
|
|
|
|
* debug level will work). Or, call SetVerifyReflowEnable with true.
|
|
|
|
*/
|
|
|
|
static bool GetVerifyReflowEnable();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the verify-reflow enable flag.
|
|
|
|
*/
|
|
|
|
static void SetVerifyReflowEnable(bool aEnabled);
|
|
|
|
|
|
|
|
nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
void DumpReflows();
|
|
|
|
void CountReflows(const char* aName, nsIFrame* aFrame);
|
|
|
|
void PaintCount(const char* aName, gfxContext* aRenderingContext,
|
|
|
|
nsPresContext* aPresContext, nsIFrame* aFrame,
|
|
|
|
const nsPoint& aOffset, uint32_t aColor);
|
|
|
|
void SetPaintFrameCount(bool aOn);
|
|
|
|
bool IsPaintingFrameCounts();
|
|
|
|
#endif // #ifdef MOZ_REFLOW_PERF
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Debugging hooks
|
|
|
|
void ListComputedStyles(FILE* out, int32_t aIndent = 0);
|
|
|
|
|
|
|
|
void ListStyleSheets(FILE* out, int32_t aIndent = 0);
|
|
|
|
#endif // #ifdef DEBUG
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop all active elements (plugins and the caret) in this presentation and
|
|
|
|
* in the presentations of subdocuments. Resets painting to a suppressed
|
|
|
|
* state.
|
|
|
|
* XXX this should include image animations
|
|
|
|
*/
|
|
|
|
void Freeze();
|
|
|
|
bool IsFrozen() { return mFrozen; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restarts active elements (plugins) in this presentation and in the
|
|
|
|
* presentations of subdocuments, then do a full invalidate of the content
|
|
|
|
* area.
|
|
|
|
*/
|
|
|
|
void Thaw();
|
|
|
|
|
|
|
|
void FireOrClearDelayedEvents(bool aFireEvents);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When this shell is disconnected from its containing docshell, we
|
|
|
|
* lose our container pointer. However, we'd still like to be able to target
|
|
|
|
* user events at the docshell's parent. This pointer allows us to do that.
|
|
|
|
* It should not be used for any other purpose.
|
|
|
|
*/
|
|
|
|
void SetForwardingContainer(const WeakPtr<nsDocShell>& aContainer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the document into an arbitrary gfxContext
|
|
|
|
* Designed for getting a picture of a document or a piece of a document
|
|
|
|
* Note that callers will generally want to call FlushPendingNotifications
|
|
|
|
* to get an up-to-date view of the document
|
|
|
|
* @param aRect is the region to capture into the offscreen buffer, in the
|
|
|
|
* root frame's coordinate system (if aIgnoreViewportScrolling is false)
|
|
|
|
* or in the root scrolled frame's coordinate system
|
|
|
|
* (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
|
|
|
|
* @param aFlags see below;
|
|
|
|
* set RenderDocumentFlags::IsUntrusted if the contents may be passed to
|
|
|
|
* malicious agents. E.g. we might choose not to paint the contents of
|
|
|
|
* sensitive widgets such as the file name in a file upload widget, and we
|
|
|
|
* might choose not to paint themes.
|
|
|
|
* set RenderDocumentFlags::IgnoreViewportScrolling to ignore clipping and
|
|
|
|
* scrollbar painting due to scrolling in the viewport
|
|
|
|
* set RenderDocumentFlags::DrawCaret to draw the caret if one would be
|
|
|
|
* visible (by default the caret is never drawn)
|
|
|
|
* set RenderDocumentFlags::UseWidgetLayers to force rendering to go
|
|
|
|
* through the layer manager for the window. This may be unexpectedly slow
|
|
|
|
* (if the layer manager must read back data from the GPU) or low-quality
|
|
|
|
* (if the layer manager reads back pixel data and scales it
|
|
|
|
* instead of rendering using the appropriate scaling). It may also
|
|
|
|
* slow everything down if the area rendered does not correspond to the
|
|
|
|
* normal visible area of the window.
|
|
|
|
* set RenderDocumentFlags::AsyncDecodeImages to avoid having images
|
|
|
|
* synchronously decoded during rendering.
|
|
|
|
* (by default images decode synchronously with RenderDocument)
|
|
|
|
* set RenderDocumentFlags::DocumentRelative to render the document as if
|
|
|
|
* there has been no scrolling and interpret |aRect| relative to the document
|
|
|
|
* instead of the CSS viewport. Only considered if
|
|
|
|
* RenderDocumentFlags::IgnoreViewportScrolling is set or the document is in
|
|
|
|
* ignore viewport scrolling mode
|
|
|
|
* (PresShell::SetIgnoreViewportScrolling/IgnoringViewportScrolling).
|
|
|
|
* @param aBackgroundColor a background color to render onto
|
|
|
|
* @param aRenderedContext the gfxContext to render to. We render so that
|
|
|
|
* one CSS pixel in the source document is rendered to one unit in the current
|
|
|
|
* transform.
|
|
|
|
*/
|
2019-04-25 08:04:23 +03:00
|
|
|
nsresult RenderDocument(const nsRect& aRect, RenderDocumentFlags aFlags,
|
2018-03-07 14:13:17 +03:00
|
|
|
nscolor aBackgroundColor,
|
2019-05-01 05:27:53 +03:00
|
|
|
gfxContext* aRenderedContext);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Renders a node aNode to a surface and returns it. The aRegion may be used
|
|
|
|
* to clip the rendering. This region is measured in CSS pixels from the
|
|
|
|
* edge of the presshell area. The aPoint, aScreenRect and aFlags arguments
|
|
|
|
* function in a similar manner as RenderSelection.
|
|
|
|
*/
|
2019-05-01 05:28:59 +03:00
|
|
|
already_AddRefed<SourceSurface> RenderNode(nsINode* aNode,
|
|
|
|
const Maybe<CSSIntRegion>& aRegion,
|
|
|
|
const LayoutDeviceIntPoint aPoint,
|
|
|
|
LayoutDeviceIntRect* aScreenRect,
|
|
|
|
RenderImageFlags aFlags);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Renders a selection to a surface and returns it. This method is primarily
|
|
|
|
* intended to create the drag feedback when dragging a selection.
|
|
|
|
*
|
|
|
|
* aScreenRect will be filled in with the bounding rectangle of the
|
|
|
|
* selection area on screen.
|
|
|
|
*
|
|
|
|
* If the area of the selection is large and the RenderImageFlags::AutoScale
|
|
|
|
* is set, the image will be scaled down. The argument aPoint is used in this
|
|
|
|
* case as a reference point when determining the new screen rectangle after
|
|
|
|
* scaling. Typically, this will be the mouse position, so that the screen
|
|
|
|
* rectangle is positioned such that the mouse is over the same point in the
|
|
|
|
* scaled image as in the original. When scaling does not occur, the mouse
|
|
|
|
* point isn't used because the position can be determined from the displayed
|
|
|
|
* frames.
|
|
|
|
*/
|
2019-05-01 05:28:59 +03:00
|
|
|
already_AddRefed<SourceSurface> RenderSelection(
|
2018-03-07 14:13:17 +03:00
|
|
|
dom::Selection* aSelection, const LayoutDeviceIntPoint aPoint,
|
2019-05-01 05:27:53 +03:00
|
|
|
LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
void AddAutoWeakFrame(AutoWeakFrame* aWeakFrame);
|
|
|
|
void AddWeakFrame(WeakFrame* aWeakFrame);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
void RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame);
|
|
|
|
void RemoveWeakFrame(WeakFrame* aWeakFrame);
|
2017-06-06 03:12:22 +03:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Stop or restart non synthetic test mouse event handling on *all*
|
|
|
|
* presShells.
|
|
|
|
*
|
|
|
|
* @param aDisable If true, disable all non synthetic test mouse
|
|
|
|
* events on all presShells. Otherwise, enable them.
|
|
|
|
*/
|
|
|
|
void DisableNonTestMouseEvents(bool aDisable);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Record the background color of the most recently drawn canvas. This color
|
|
|
|
* is composited on top of the user's default background color and then used
|
|
|
|
* to draw the background color of the canvas. See PresShell::Paint,
|
|
|
|
* PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
|
|
|
|
* bug 488242, bug 476557 and other bugs mentioned there.
|
|
|
|
*/
|
|
|
|
void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; }
|
|
|
|
nscolor GetCanvasBackground() { return mCanvasBackgroundColor; }
|
2015-06-04 23:51:10 +03:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Use the current frame tree (if it exists) to update the background
|
|
|
|
* color of the most recently drawn canvas.
|
|
|
|
*/
|
|
|
|
void UpdateCanvasBackground();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a solid color item to the bottom of aList with frame aFrame and
|
|
|
|
* bounds aBounds representing the dark grey background behind the page of a
|
|
|
|
* print preview presentation.
|
|
|
|
*/
|
2019-06-06 20:54:13 +03:00
|
|
|
void AddPrintPreviewBackgroundItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aList, nsIFrame* aFrame,
|
2019-05-01 05:27:53 +03:00
|
|
|
const nsRect& aBounds);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the backstop color for the view: transparent if in a transparent
|
|
|
|
* widget, otherwise the PresContext default background color. This color is
|
|
|
|
* only visible if the contents of the view as a whole are translucent.
|
|
|
|
*/
|
|
|
|
nscolor ComputeBackstopColor(nsView* aDisplayRoot);
|
|
|
|
|
|
|
|
void ObserveNativeAnonMutationsForPrint(bool aObserve) {
|
|
|
|
mObservesMutationsForPrint = aObserve;
|
|
|
|
}
|
|
|
|
bool ObservesNativeAnonMutationsForPrint() {
|
|
|
|
return mObservesMutationsForPrint;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult SetIsActive(bool aIsActive);
|
|
|
|
|
|
|
|
bool IsActive() { return mIsActive; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Keep track of how many times this presshell has been rendered to
|
|
|
|
* a window.
|
|
|
|
*/
|
|
|
|
uint64_t GetPaintCount() { return mPaintCount; }
|
|
|
|
void IncrementPaintCount() { ++mPaintCount; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the root DOM window of this presShell.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetRootWindow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This returns the focused DOM window under our top level window.
|
|
|
|
* I.e., when we are deactive, this returns the *last* focused DOM window.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetFocusedDOMWindowInOurWindow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the focused content under this window.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIContent> GetFocusedContentInOurWindow() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the layer manager for the widget of the root view, if it has
|
|
|
|
* one.
|
|
|
|
*/
|
|
|
|
LayerManager* GetLayerManager();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true iff there is a widget rendering this presShell and that
|
|
|
|
* widget is APZ-enabled.
|
|
|
|
*/
|
|
|
|
bool AsyncPanZoomEnabled();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Track whether we're ignoring viewport scrolling for the purposes
|
|
|
|
* of painting. If we are ignoring, then layers aren't clipped to
|
|
|
|
* the CSS viewport and scrollbars aren't drawn.
|
|
|
|
*/
|
|
|
|
bool IgnoringViewportScrolling() const {
|
2019-05-01 05:28:25 +03:00
|
|
|
return !!(mRenderingStateFlags &
|
|
|
|
RenderingStateFlags::IgnoringViewportScrolling);
|
2019-05-01 05:27:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
float GetResolution() const { return mResolution.valueOr(1.0); }
|
|
|
|
float GetCumulativeResolution();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessors for a flag that tracks whether the most recent change to
|
|
|
|
* the pres shell's resolution was originated by the main thread.
|
|
|
|
*/
|
|
|
|
bool IsResolutionUpdated() const { return mResolutionUpdated; }
|
|
|
|
void SetResolutionUpdated(bool aUpdated) { mResolutionUpdated = aUpdated; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the resolution has ever been changed by APZ.
|
|
|
|
*/
|
|
|
|
bool IsResolutionUpdatedByApz() const { return mResolutionUpdatedByApz; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the cumulative scale resolution from this document up to
|
|
|
|
* but not including the root document.
|
|
|
|
*/
|
|
|
|
float GetCumulativeNonRootScaleResolution();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used by session restore code to restore a resolution before the first
|
|
|
|
* paint.
|
|
|
|
*/
|
|
|
|
void SetRestoreResolution(float aResolution,
|
|
|
|
LayoutDeviceIntSize aDisplaySize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether we are in a DrawWindow() call that used the
|
|
|
|
* DRAWWINDOW_DO_NOT_FLUSH flag.
|
|
|
|
*/
|
|
|
|
bool InDrawWindowNotFlushing() const {
|
2019-05-01 05:28:25 +03:00
|
|
|
return !!(mRenderingStateFlags &
|
|
|
|
RenderingStateFlags::DrawWindowNotFlushing);
|
2019-05-01 05:27:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the isFirstPaint flag.
|
|
|
|
*/
|
|
|
|
void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the isFirstPaint flag.
|
|
|
|
*/
|
|
|
|
bool GetIsFirstPaint() const { return mIsFirstPaint; }
|
|
|
|
|
|
|
|
uint32_t GetPresShellId() { return mPresShellId; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch a mouse move event based on the most recent mouse position if
|
|
|
|
* this PresShell is visible. This is used when the contents of the page
|
|
|
|
* moved (aFromScroll is false) or scrolled (aFromScroll is true).
|
|
|
|
*/
|
|
|
|
void SynthesizeMouseMove(bool aFromScroll);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult HandleEvent(nsIFrame* aFrame, WidgetGUIEvent* aEvent,
|
|
|
|
bool aDontRetargetEvents, nsEventStatus* aEventStatus);
|
|
|
|
bool ShouldIgnoreInvalidation();
|
|
|
|
/**
|
|
|
|
* Notify that we're going to call Paint with PaintFlags::PaintComposite.
|
|
|
|
* Fires on the presshell for the painted widget.
|
|
|
|
* This is issued at a time when it's safe to modify widget geometry.
|
|
|
|
*/
|
2019-05-06 16:01:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void WillPaintWindow();
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Notify that we called Paint with PaintFlags::PaintComposite.
|
|
|
|
* Fires on the presshell for the painted widget.
|
|
|
|
* This is issued at a time when it's safe to modify widget geometry.
|
|
|
|
*/
|
2019-05-06 16:01:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void DidPaintWindow();
|
2019-05-01 05:27:53 +03:00
|
|
|
|
2019-05-10 14:15:30 +03:00
|
|
|
bool IsVisible() const;
|
2019-05-10 14:15:43 +03:00
|
|
|
bool IsUnderHiddenEmbedderElement() const {
|
|
|
|
return mUnderHiddenEmbedderElement;
|
|
|
|
}
|
|
|
|
void SetIsUnderHiddenEmbedderElement(bool aUnderHiddenEmbedderElement);
|
2019-05-01 05:27:53 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void DispatchSynthMouseMove(WidgetGUIEvent* aEvent);
|
|
|
|
|
|
|
|
/* Temporarily ignore the Displayport for better paint performance. We
|
|
|
|
* trigger a repaint once suppression is disabled. Without that
|
|
|
|
* the displayport may get left at the suppressed size for an extended
|
|
|
|
* period of time and result in unnecessary checkerboarding (see bug
|
|
|
|
* 1255054). */
|
|
|
|
void SuppressDisplayport(bool aEnabled);
|
|
|
|
|
|
|
|
/* Whether or not displayport suppression should be turned on. Note that
|
|
|
|
* this only affects the return value of |IsDisplayportSuppressed()|, and
|
|
|
|
* doesn't change the value of the internal counter.
|
|
|
|
*/
|
|
|
|
void RespectDisplayportSuppression(bool aEnabled);
|
|
|
|
|
|
|
|
/* Whether or not the displayport is currently suppressed. */
|
|
|
|
bool IsDisplayportSuppressed();
|
|
|
|
|
|
|
|
void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Methods that retrieve the cached font inflation preferences.
|
|
|
|
*/
|
|
|
|
uint32_t FontSizeInflationEmPerLine() const {
|
|
|
|
return mFontSizeInflationEmPerLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t FontSizeInflationMinTwips() const {
|
|
|
|
return mFontSizeInflationMinTwips;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t FontSizeInflationLineThreshold() const {
|
|
|
|
return mFontSizeInflationLineThreshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FontSizeInflationForceEnabled() const {
|
|
|
|
return mFontSizeInflationForceEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FontSizeInflationDisabledInMasterProcess() const {
|
|
|
|
return mFontSizeInflationDisabledInMasterProcess;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FontSizeInflationEnabled() const { return mFontSizeInflationEnabled; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recomputes whether font-size inflation is enabled.
|
|
|
|
*/
|
|
|
|
void RecomputeFontSizeInflationEnabled();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the most recent interruptible reflow was interrupted.
|
|
|
|
*/
|
|
|
|
bool IsReflowInterrupted() const { return mWasLastReflowInterrupted; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the the interruptible reflows have to be suppressed.
|
|
|
|
* This may happen only if if the most recent reflow was interrupted.
|
|
|
|
*/
|
|
|
|
bool SuppressInterruptibleReflows() const {
|
|
|
|
return mWasLastReflowInterrupted;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Approximate frame visibility tracking public API.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule an update of the list of approximately visible frames "soon".
|
|
|
|
* This lets the refresh driver know that we want a visibility update in the
|
|
|
|
* near future. The refresh driver applies its own heuristics and throttling
|
|
|
|
* to decide when to actually perform the visibility update.
|
|
|
|
*/
|
|
|
|
void ScheduleApproximateFrameVisibilityUpdateSoon();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule an update of the list of approximately visible frames "now". The
|
|
|
|
* update runs asynchronously, but it will be posted to the event loop
|
|
|
|
* immediately. Prefer the "soon" variation of this method when possible, as
|
|
|
|
* this variation ignores the refresh driver's heuristics.
|
|
|
|
*/
|
|
|
|
void ScheduleApproximateFrameVisibilityUpdateNow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears the current list of approximately visible frames on this pres shell
|
|
|
|
* and replaces it with frames that are in the display list @aList.
|
|
|
|
*/
|
|
|
|
void RebuildApproximateFrameVisibilityDisplayList(const nsDisplayList& aList);
|
|
|
|
void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
|
|
|
|
bool aRemoveOnly = false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures @aFrame is in the list of approximately visible frames.
|
|
|
|
*/
|
|
|
|
void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/// Removes @aFrame from the list of approximately visible frames if present.
|
|
|
|
void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/// Whether we should assume all frames are visible.
|
|
|
|
bool AssumeAllFramesVisible();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the document's style set's rule processor for the
|
|
|
|
* specified level of the cascade is shared by multiple style sets.
|
|
|
|
*
|
|
|
|
* @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
|
|
|
|
*/
|
|
|
|
nsresult HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
|
|
|
|
bool* aRetVal);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the document has ever handled user input
|
|
|
|
*/
|
|
|
|
bool HasHandledUserInput() const { return mHasHandledUserInput; }
|
|
|
|
|
2019-12-11 15:17:17 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void FireResizeEvent();
|
2019-05-01 05:27:53 +03:00
|
|
|
|
|
|
|
void NativeAnonymousContentRemoved(nsIContent* aAnonContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See HTMLDocument.setKeyPressEventModel() in HTMLDocument.webidl for the
|
|
|
|
* detail.
|
|
|
|
*/
|
|
|
|
void SetKeyPressEventModel(uint16_t aKeyPressEventModel) {
|
|
|
|
mForceUseLegacyKeyCodeAndCharCodeValues |=
|
|
|
|
aKeyPressEventModel ==
|
2019-05-31 04:37:26 +03:00
|
|
|
dom::Document_Binding::KEYPRESS_EVENT_MODEL_SPLIT;
|
2019-05-01 05:27:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AddRefreshObserver(nsARefreshObserver* aObserver, FlushType aFlushType);
|
|
|
|
bool RemoveRefreshObserver(nsARefreshObserver* aObserver,
|
|
|
|
FlushType aFlushType);
|
|
|
|
|
|
|
|
bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver);
|
|
|
|
bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver);
|
|
|
|
|
|
|
|
// Represents an update to the visual scroll offset that will be sent to APZ.
|
|
|
|
// The update type is used to determine priority compared to other scroll
|
|
|
|
// updates.
|
|
|
|
struct VisualScrollUpdate {
|
|
|
|
nsPoint mVisualScrollOffset;
|
|
|
|
FrameMetrics::ScrollOffsetUpdateType mUpdateType;
|
|
|
|
bool mAcknowledged = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Ask APZ in the next transaction to scroll to the given visual viewport
|
|
|
|
// offset (relative to the document).
|
2019-05-07 06:04:06 +03:00
|
|
|
// This is intended to be used when desired in cases where the browser
|
|
|
|
// internally triggers scrolling; scrolling triggered explicitly by web
|
|
|
|
// content (such as via window.scrollTo() should scroll the layout viewport
|
|
|
|
// only).
|
2019-05-01 05:27:53 +03:00
|
|
|
// If scrolling "far away", i.e. not just within the existing layout
|
|
|
|
// viewport, it's recommended to use both nsIScrollableFrame.ScrollTo*()
|
|
|
|
// (via window.scrollTo if calling from JS) *and* this function; otherwise,
|
2019-05-07 06:04:06 +03:00
|
|
|
// temporary checkerboarding may result. If doing this:
|
|
|
|
// * Be sure to call ScrollTo*() first, as a subsequent layout scroll
|
|
|
|
// in the same transaction will cancel the pending visual scroll.
|
|
|
|
// * Keep in mind that ScrollTo*() can tear down the pres shell and
|
|
|
|
// frame tree. Depending on how the pres shell is obtained for the
|
|
|
|
// subsequent ScrollToVisual() call, AutoWeakFrame or similar may
|
|
|
|
// need to be used.
|
2019-05-01 05:27:53 +03:00
|
|
|
// Please request APZ review if adding a new call site.
|
|
|
|
void ScrollToVisual(const nsPoint& aVisualViewportOffset,
|
|
|
|
FrameMetrics::ScrollOffsetUpdateType aUpdateType,
|
|
|
|
ScrollMode aMode);
|
|
|
|
void AcknowledgePendingVisualScrollUpdate();
|
|
|
|
void ClearPendingVisualScrollUpdate();
|
|
|
|
const Maybe<VisualScrollUpdate>& GetPendingVisualScrollUpdate() const {
|
|
|
|
return mPendingVisualScrollUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint GetLayoutViewportOffset() const;
|
|
|
|
nsSize GetLayoutViewportSize() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Documents belonging to an invisible DocShell must not be painted ever.
|
|
|
|
*/
|
|
|
|
bool IsNeverPainting() { return mIsNeverPainting; }
|
|
|
|
|
|
|
|
void SetNeverPainting(bool aNeverPainting) {
|
|
|
|
mIsNeverPainting = aNeverPainting;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if a reflow event has been scheduled, or is going to be scheduled
|
|
|
|
* to run in the future.
|
|
|
|
*/
|
|
|
|
bool HasPendingReflow() const {
|
|
|
|
return mObservingLayoutFlushes || mReflowContinueTimer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyncWindowProperties(nsView* aView);
|
|
|
|
|
|
|
|
Document* GetPrimaryContentDocument();
|
|
|
|
|
|
|
|
struct MOZ_RAII AutoAssertNoFlush {
|
|
|
|
explicit AutoAssertNoFlush(PresShell& aPresShell)
|
|
|
|
: mPresShell(aPresShell), mOldForbidden(mPresShell.mForbiddenToFlush) {
|
|
|
|
mPresShell.mForbiddenToFlush = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoAssertNoFlush() { mPresShell.mForbiddenToFlush = mOldForbidden; }
|
|
|
|
|
|
|
|
PresShell& mPresShell;
|
|
|
|
const bool mOldForbidden;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHOD GetSelectionFromScript(RawSelectionType aRawSelectionType,
|
|
|
|
dom::Selection** aSelection) override;
|
|
|
|
dom::Selection* GetSelection(RawSelectionType aRawSelectionType) override;
|
|
|
|
|
|
|
|
NS_IMETHOD SetDisplaySelection(int16_t aToggle) override;
|
|
|
|
NS_IMETHOD GetDisplaySelection(int16_t* aToggle) override;
|
|
|
|
NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,
|
|
|
|
SelectionRegion aRegion,
|
|
|
|
int16_t aFlags) override;
|
|
|
|
NS_IMETHOD RepaintSelection(RawSelectionType aRawSelectionType) override;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-04-25 08:04:23 +03:00
|
|
|
/**
|
|
|
|
* Set a "resolution" for the document, which if not 1.0 will
|
|
|
|
* allocate more or fewer pixels for rescalable content by a factor
|
|
|
|
* of |resolution| in both dimensions. Return NS_OK iff the
|
|
|
|
* resolution bounds are sane, and the resolution of this was
|
|
|
|
* actually updated.
|
|
|
|
*
|
|
|
|
* Also increase the scale of the content by the same amount
|
|
|
|
* (that's the "AndScaleTo" part).
|
|
|
|
*
|
|
|
|
* The resolution defaults to 1.0.
|
|
|
|
*
|
|
|
|
* |aOrigin| specifies who originated the resolution change. For changes
|
|
|
|
* sent by APZ, pass ResolutionChangeOrigin::Apz. For changes sent by
|
|
|
|
* the main thread, use pass ResolutionChangeOrigin::MainThread (similar
|
|
|
|
* to the |aOrigin| parameter of nsIScrollableFrame::ScrollToCSSPixels()).
|
|
|
|
*/
|
2018-12-30 05:16:42 +03:00
|
|
|
nsresult SetResolutionAndScaleTo(float aResolution,
|
2019-04-25 08:04:23 +03:00
|
|
|
ResolutionChangeOrigin aOrigin);
|
|
|
|
|
2019-03-29 18:12:47 +03:00
|
|
|
// Widget notificiations
|
2019-05-01 21:52:59 +03:00
|
|
|
void WindowSizeMoveDone();
|
|
|
|
void SysColorChanged() { mPresContext->SysColorChanged(); }
|
|
|
|
void ThemeChanged() { mPresContext->ThemeChanged(); }
|
|
|
|
void BackingScaleFactorChanged() { mPresContext->UIResolutionChangedSync(); }
|
2019-03-29 18:12:47 +03:00
|
|
|
|
2019-05-06 16:25:35 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-03-07 14:13:17 +03:00
|
|
|
void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
|
2019-04-25 08:04:23 +03:00
|
|
|
PaintFlags aFlags);
|
|
|
|
|
2019-04-13 15:39:03 +03:00
|
|
|
/**
|
2019-04-25 08:04:23 +03:00
|
|
|
* Notify that we're going to call Paint with PaintFlags::PaintLayers
|
2019-04-13 15:39:03 +03:00
|
|
|
* on the pres shell for a widget (which might not be this one, since
|
|
|
|
* WillPaint is called on all presshells in the same toplevel window as the
|
|
|
|
* painted widget). This is issued at a time when it's safe to modify
|
|
|
|
* widget geometry.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT void WillPaint();
|
2019-04-25 08:04:23 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that the refresh driver is running, and schedules a view
|
|
|
|
* manager flush on the next tick.
|
|
|
|
*
|
|
|
|
* @param aType PaintType::DelayedCompress : Schedule a paint to be executed
|
|
|
|
* after a delay, and put FrameLayerBuilder in 'compressed' mode that avoids
|
|
|
|
* short cut optimizations.
|
|
|
|
*/
|
|
|
|
void ScheduleViewManagerFlush(PaintType aType = PaintType::Default);
|
|
|
|
|
2011-09-09 23:50:21 +04:00
|
|
|
// caret handling
|
2015-03-21 19:28:04 +03: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;
|
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Should the images have borders etc. Actual visual effects are determined
|
|
|
|
* by the frames. Visual effects may not effect layout, only display.
|
|
|
|
* Takes effect on next repaint, does not force a repaint itself.
|
|
|
|
*
|
|
|
|
* @param aInEnable if true, visual selection effects are enabled
|
|
|
|
* if false visual selection effects are disabled
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetSelectionFlags(int16_t aInEnable) override;
|
|
|
|
NS_IMETHOD GetSelectionFlags(int16_t* aOutEnable) override;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Gets the current state of non text selection effects
|
|
|
|
* @return current state of non text selection,
|
|
|
|
* as set by SetDisplayNonTextSelection
|
|
|
|
*/
|
|
|
|
int16_t GetSelectionFlags() const { return mSelectionFlags; }
|
2019-04-03 15:40:26 +03:00
|
|
|
|
2011-09-09 23:50:21 +04:00
|
|
|
// nsISelectionController
|
|
|
|
|
2015-03-21 19:28:04 +03: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 07:42:53 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2015-03-21 19:28:04 +03: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 05:58:48 +03:00
|
|
|
NS_IMETHOD CheckVisibility(nsINode* node, int16_t startOffset,
|
|
|
|
int16_t EndOffset, bool* _retval) override;
|
2018-03-07 14:13:17 +03:00
|
|
|
nsresult CheckVisibilityContent(nsIContent* aNode, int16_t aStartOffset,
|
|
|
|
int16_t aEndOffset, bool* aRetval) override;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-04-17 22:29:59 +03:00
|
|
|
// Notifies that the state of the document has changed.
|
|
|
|
void DocumentStatesChanged(EventStates);
|
|
|
|
|
2011-09-09 23:50:21 +04:00
|
|
|
// nsIDocumentObserver
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
// Inline methods defined in PresShellInlines.h
|
|
|
|
inline void EnsureStyleFlush();
|
|
|
|
inline void SetNeedStyleFlush();
|
|
|
|
inline void SetNeedLayoutFlush();
|
|
|
|
inline void SetNeedThrottledAnimationFlush();
|
|
|
|
inline ServoStyleSet* StyleSet() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether we might need a flush for the given flush type. If this
|
|
|
|
* function returns false, we definitely don't need to flush.
|
|
|
|
*
|
|
|
|
* @param aFlushType The flush type to check. This must be
|
|
|
|
* >= FlushType::Style. This also returns true if a throttled
|
|
|
|
* animation flush is required.
|
|
|
|
*/
|
|
|
|
bool NeedFlush(FlushType aType) const {
|
|
|
|
// We check mInFlush to handle re-entrant calls to FlushPendingNotifications
|
|
|
|
// by reporting that we always need a flush in that case. Otherwise,
|
|
|
|
// we could end up missing needed flushes, since we clear the mNeedXXXFlush
|
|
|
|
// flags at the top of FlushPendingNotifications.
|
|
|
|
MOZ_ASSERT(aType >= FlushType::Style);
|
|
|
|
return mNeedStyleFlush ||
|
|
|
|
(mNeedLayoutFlush && aType >= FlushType::InterruptibleLayout) ||
|
|
|
|
aType >= FlushType::Display || mNeedThrottledAnimationFlush ||
|
|
|
|
mInFlush;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if we might need to flush layout, even if we haven't scheduled
|
|
|
|
* one yet (as opposed to HasPendingReflow, which returns true if a flush is
|
|
|
|
* scheduled or will soon be scheduled).
|
|
|
|
*/
|
|
|
|
bool NeedLayoutFlush() const { return mNeedLayoutFlush; }
|
|
|
|
|
|
|
|
bool NeedStyleFlush() const { return mNeedStyleFlush; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush pending notifications of the type specified. This method
|
|
|
|
* will not affect the content model; it'll just affect style and
|
|
|
|
* frames. Callers that actually want up-to-date presentation (other
|
|
|
|
* than the document itself) should probably be calling
|
|
|
|
* Document::FlushPendingNotifications.
|
|
|
|
*
|
|
|
|
* This method can execute script, which can destroy this presshell object
|
|
|
|
* unless someone is holding a reference to it on the stack. The presshell
|
|
|
|
* itself will ensure it lives up until the method returns, but callers who
|
|
|
|
* plan to use the presshell after this call should hold a strong ref
|
|
|
|
* themselves!
|
|
|
|
*
|
|
|
|
* @param aType the type of notifications to flush
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void FlushPendingNotifications(FlushType aType) {
|
|
|
|
if (!NeedFlush(aType)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoFlushPendingNotifications(aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void FlushPendingNotifications(ChangesToFlush aType) {
|
|
|
|
if (!NeedFlush(aType.mFlushType)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoFlushPendingNotifications(aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tell the pres shell that a frame needs to be marked dirty and needs
|
|
|
|
* Reflow. It's OK if this is an ancestor of the frame needing reflow as
|
|
|
|
* long as the ancestor chain between them doesn't cross a reflow root.
|
|
|
|
*
|
|
|
|
* The bit to add should be NS_FRAME_IS_DIRTY, NS_FRAME_HAS_DIRTY_CHILDREN
|
|
|
|
* or nsFrameState(0); passing 0 means that dirty bits won't be set on the
|
|
|
|
* frame or its ancestors/descendants, but that intrinsic widths will still
|
|
|
|
* be marked dirty. Passing aIntrinsicDirty = eResize and aBitToAdd = 0
|
|
|
|
* would result in no work being done, so don't do that.
|
|
|
|
*/
|
|
|
|
void FrameNeedsReflow(
|
|
|
|
nsIFrame* aFrame, IntrinsicDirty aIntrinsicDirty, nsFrameState aBitToAdd,
|
|
|
|
ReflowRootHandling aRootHandling = ReflowRootHandling::InferFromBitToAdd);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls FrameNeedsReflow on all fixed position children of the root frame.
|
|
|
|
*/
|
|
|
|
void MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty);
|
|
|
|
|
|
|
|
// This function handles all the work after VisualViewportSize is set
|
|
|
|
// or reset.
|
|
|
|
void CompleteChangeToVisualViewportSize();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The return value indicates whether the offset actually changed.
|
|
|
|
*/
|
|
|
|
bool SetVisualViewportOffset(const nsPoint& aScrollOffset,
|
|
|
|
const nsPoint& aPrevLayoutScrollPos);
|
|
|
|
|
|
|
|
nsPoint GetVisualViewportOffset() const {
|
|
|
|
return mVisualViewportOffset.valueOr(nsPoint());
|
|
|
|
}
|
|
|
|
bool IsVisualViewportOffsetSet() const {
|
|
|
|
return mVisualViewportOffset.isSome();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetVisualViewportSize(nscoord aWidth, nscoord aHeight);
|
|
|
|
void ResetVisualViewportSize();
|
|
|
|
bool IsVisualViewportSizeSet() { return mVisualViewportSizeSet; }
|
|
|
|
nsSize GetVisualViewportSize() {
|
|
|
|
NS_ASSERTION(mVisualViewportSizeSet,
|
|
|
|
"asking for visual viewport size when its not set?");
|
|
|
|
return mVisualViewportSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint GetVisualViewportOffsetRelativeToLayoutViewport() const;
|
|
|
|
|
2019-11-22 00:36:59 +03:00
|
|
|
// Returns state of the dynamic toolbar.
|
|
|
|
DynamicToolbarState GetDynamicToolbarState() const {
|
|
|
|
if (!mPresContext) {
|
|
|
|
return DynamicToolbarState::None;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mPresContext->GetDynamicToolbarState();
|
|
|
|
}
|
|
|
|
// Returns the visual viewport size during the dynamic toolbar is being
|
|
|
|
// shown/hidden.
|
|
|
|
nsSize GetVisualViewportSizeUpdatedByDynamicToolbar() const;
|
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
/* Enable/disable author style level. Disabling author style disables the
|
|
|
|
* entire author level of the cascade, including the HTML preshint level.
|
|
|
|
*/
|
|
|
|
// XXX these could easily be inlined, but there is a circular #include
|
|
|
|
// problem with nsStyleSet.
|
|
|
|
void SetAuthorStyleDisabled(bool aDisabled);
|
|
|
|
bool GetAuthorStyleDisabled() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the style set somehow to take into account changed prefs which
|
|
|
|
* affect document styling.
|
|
|
|
*/
|
|
|
|
void UpdatePreferenceStyles();
|
|
|
|
|
|
|
|
// aSheetType is one of the nsIStyleSheetService *_SHEET constants.
|
|
|
|
void NotifyStyleSheetServiceSheetAdded(StyleSheet* aSheet,
|
|
|
|
uint32_t aSheetType);
|
|
|
|
void NotifyStyleSheetServiceSheetRemoved(StyleSheet* aSheet,
|
|
|
|
uint32_t aSheetType);
|
|
|
|
|
|
|
|
// DoReflow returns whether the reflow finished without interruption
|
|
|
|
// If aFrame is not the root frame, the caller must pass a non-null
|
|
|
|
// aOverflowTracker.
|
|
|
|
bool DoReflow(nsIFrame* aFrame, bool aInterruptible,
|
|
|
|
OverflowChangedTracker* aOverflowTracker);
|
|
|
|
|
2019-04-25 08:04:23 +03:00
|
|
|
/**
|
|
|
|
* Add a solid color item to the bottom of aList with frame aFrame and bounds
|
|
|
|
* aBounds. Checks first if this needs to be done by checking if aFrame is a
|
|
|
|
* canvas frame (if the AddCanvasBackgroundColorFlags::ForceDraw is passed
|
|
|
|
* then this check is skipped). aBackstopColor is composed behind the
|
|
|
|
* background color of the canvas, it is transparent by default.
|
|
|
|
*
|
|
|
|
* We attempt to make the background color part of the scrolled canvas (to
|
|
|
|
* reduce transparent layers), and if async scrolling is enabled (and the
|
|
|
|
* background is opaque) then we add a second, unscrolled item to handle the
|
|
|
|
* checkerboarding case.
|
|
|
|
*
|
|
|
|
* AddCanvasBackgroundColorFlags::AddSubDocument should be specified when
|
|
|
|
* calling this for a subdocument, and LayoutUseContainersForRootFrame might
|
|
|
|
* cause the whole list to be scrolled. In that case the second unscrolled
|
|
|
|
* item will be elided.
|
|
|
|
*
|
|
|
|
* AddCanvasBackgroundColorFlags::AppendUnscrolledOnly only attempts to add
|
|
|
|
* the unscrolled item, so that we can add it manually after
|
|
|
|
* LayoutUseContainersForRootFrame has built the scrolling ContainerLayer.
|
|
|
|
*/
|
2019-04-03 15:40:26 +03:00
|
|
|
void AddCanvasBackgroundColorItem(
|
2019-06-06 20:54:13 +03:00
|
|
|
nsDisplayListBuilder* aBuilder, nsDisplayList* aList, nsIFrame* aFrame,
|
2019-04-03 15:40:26 +03:00
|
|
|
const nsRect& aBounds, nscolor aBackstopColor = NS_RGBA(0, 0, 0, 0),
|
2019-04-25 08:04:23 +03:00
|
|
|
AddCanvasBackgroundColorFlags aFlags =
|
|
|
|
AddCanvasBackgroundColorFlags::None);
|
2013-02-14 15:12:27 +04:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
size_t SizeOfTextRuns(MallocSizeOf aMallocSizeOf) const;
|
2012-05-16 21:32:40 +04:00
|
|
|
|
2014-08-08 20:05:40 +04:00
|
|
|
void SetNextPaintCompressed() { mNextPaintCompressed = true; }
|
|
|
|
|
2017-11-26 16:54:07 +03:00
|
|
|
static PresShell* GetShellForEventTarget(nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent);
|
2017-12-09 04:11:10 +03:00
|
|
|
static PresShell* GetShellForTouchEvent(WidgetGUIEvent* aEvent);
|
|
|
|
|
2019-04-23 04:27:47 +03:00
|
|
|
/**
|
|
|
|
* Informs the pres shell that the document is now at the anchor with
|
|
|
|
* the given name. If |aScroll| is true, scrolls the view of the
|
|
|
|
* document so that the anchor with the specified name is displayed at
|
|
|
|
* the top of the window. If |aAnchorName| is empty, then this informs
|
|
|
|
* the pres shell that there is no current target, and |aScroll| must
|
2019-04-25 08:04:15 +03:00
|
|
|
* be false. If |aAdditionalScrollFlags| is ScrollFlags::ScrollSmoothAuto
|
2019-04-23 04:27:47 +03:00
|
|
|
* and |aScroll| is true, the scrolling may be performed with an animation.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
2019-04-25 08:04:15 +03:00
|
|
|
ScrollFlags aAdditionalScrollFlags = ScrollFlags::None);
|
2019-04-23 04:27:47 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells the presshell to scroll again to the last anchor scrolled to by
|
|
|
|
* GoToAnchor, if any. This scroll only happens if the scroll
|
2019-07-20 18:02:35 +03:00
|
|
|
* position has not changed since the last GoToAnchor (modulo scroll anchoring
|
|
|
|
* adjustments). This is called by nsDocumentViewer::LoadComplete. This clears
|
|
|
|
* the last anchor scrolled to by GoToAnchor (we don't want to keep it alive
|
|
|
|
* if it's removed from the DOM), so don't call this more than once.
|
2019-04-23 04:27:47 +03:00
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult ScrollToAnchor();
|
|
|
|
|
2019-07-20 18:02:35 +03:00
|
|
|
/**
|
|
|
|
* When scroll anchoring adjusts positions in the root frame during page load,
|
|
|
|
* it may move our scroll position in the root frame.
|
|
|
|
*
|
|
|
|
* While that's generally desirable, when scrolling to an anchor via an id-ref
|
|
|
|
* we have a more direct target. If the id-ref points to something that cannot
|
|
|
|
* be selected as a scroll anchor container (like an image or an inline), we
|
|
|
|
* may select a node following it as a scroll anchor, and if then stuff is
|
|
|
|
* inserted on top, we may end up moving the id-ref element offscreen to the
|
|
|
|
* top inadvertently.
|
|
|
|
*
|
|
|
|
* On page load, the document viewer will call ScrollToAnchor(), and will only
|
|
|
|
* scroll to the anchor again if the scroll position is not changed. We don't
|
|
|
|
* want scroll anchoring adjustments to prevent this, so account for them.
|
|
|
|
*/
|
|
|
|
void RootScrollFrameAdjusted(nscoord aYAdjustment) {
|
|
|
|
if (mLastAnchorScrolledTo) {
|
|
|
|
mLastAnchorScrollPositionY += aYAdjustment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-23 04:34:24 +03:00
|
|
|
/**
|
|
|
|
* Scrolls the view of the document so that the primary frame of the content
|
|
|
|
* is displayed in the window. Layout is flushed before scrolling.
|
|
|
|
*
|
|
|
|
* @param aContent The content object of which primary frame should be
|
|
|
|
* scrolled into view.
|
|
|
|
* @param aVertical How to align the frame vertically and when to do so.
|
|
|
|
* This is a ScrollAxis of Where and When.
|
|
|
|
* @param aHorizontal How to align the frame horizontally and when to do so.
|
|
|
|
* This is a ScrollAxis of Where and When.
|
2019-04-25 08:04:15 +03:00
|
|
|
* @param aScrollFlags If ScrollFlags::ScrollFirstAncestorOnly is set,
|
|
|
|
* only the nearest scrollable ancestor is scrolled,
|
|
|
|
* otherwise all scrollable ancestors may be scrolled
|
|
|
|
* if necessary. If ScrollFlags::ScrollOverflowHidden
|
|
|
|
* is set then we may scroll in a direction even if
|
|
|
|
* overflow:hidden is specified in that direction;
|
|
|
|
* otherwise we will not scroll in that direction when
|
|
|
|
* overflow:hidden is set for that direction. If
|
|
|
|
* ScrollFlags::ScrollNoParentFrames is set then we
|
|
|
|
* only scroll nodes in this document, not in any
|
|
|
|
* parent documents which contain this document in a
|
|
|
|
* iframe or the like. If ScrollFlags::ScrollSmooth
|
|
|
|
* is set and CSSOM-VIEW scroll-behavior is enabled,
|
|
|
|
* we will scroll smoothly using
|
|
|
|
* nsIScrollableFrame::ScrollMode::SMOOTH_MSD;
|
|
|
|
* otherwise, nsIScrollableFrame::ScrollMode::INSTANT
|
|
|
|
* will be used. If ScrollFlags::ScrollSmoothAuto is
|
|
|
|
* set, the CSSOM-View scroll-behavior attribute is
|
|
|
|
* set to 'smooth' on the scroll frame, and CSSOM-VIEW
|
|
|
|
* scroll-behavior is enabled, we will scroll smoothly
|
|
|
|
* using nsIScrollableFrame::ScrollMode::SMOOTH_MSD;
|
|
|
|
* otherwise, nsIScrollableFrame::ScrollMode::INSTANT
|
|
|
|
* will be used.
|
2019-04-23 04:34:24 +03:00
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult ScrollContentIntoView(nsIContent* aContent, ScrollAxis aVertical,
|
2019-04-25 08:04:15 +03:00
|
|
|
ScrollAxis aHorizontal,
|
|
|
|
ScrollFlags aScrollFlags);
|
2019-04-23 04:34:24 +03:00
|
|
|
|
2019-04-25 08:02:20 +03:00
|
|
|
/**
|
|
|
|
* When capturing content is set, it traps all mouse events and retargets
|
|
|
|
* them at this content node. If capturing is not allowed
|
|
|
|
* (gCaptureInfo.mAllowed is false), then capturing is not set. However, if
|
|
|
|
* the CaptureFlags::IgnoreAllowedState is set, the allowed state is ignored
|
|
|
|
* and capturing is set regardless. To disable capture, pass null for the
|
|
|
|
* value of aContent.
|
|
|
|
*
|
|
|
|
* If CaptureFlags::RetargetedToElement is set, all mouse events are
|
|
|
|
* targeted at aContent only. Otherwise, mouse events are targeted at
|
|
|
|
* aContent or its descendants. That is, descendants of aContent receive
|
|
|
|
* mouse events as they normally would, but mouse events outside of aContent
|
|
|
|
* are retargeted to aContent.
|
|
|
|
*
|
|
|
|
* If CaptureFlags::PreventDragStart is set then drags are prevented from
|
|
|
|
* starting while this capture is active.
|
|
|
|
*
|
|
|
|
* If CaptureFlags::PointerLock is set, similar to
|
|
|
|
* CaptureFlags::RetargetToElement, then events are targeted at aContent,
|
|
|
|
* but capturing is held more strongly (i.e., calls to SetCapturingContent()
|
|
|
|
* won't unlock unless CaptureFlags::PointerLock is set again).
|
|
|
|
*/
|
|
|
|
static void SetCapturingContent(nsIContent* aContent, CaptureFlags aFlags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias for SetCapturingContent(nullptr, CaptureFlags::None) for making
|
|
|
|
* callers what they do clearer.
|
|
|
|
*/
|
|
|
|
static void ReleaseCapturingContent() {
|
|
|
|
PresShell::SetCapturingContent(nullptr, CaptureFlags::None);
|
|
|
|
}
|
|
|
|
|
2019-04-26 08:14:00 +03:00
|
|
|
// Called at the end of nsLayoutUtils::PaintFrame().
|
|
|
|
// This is used to clear any pending visual scroll updates that have been
|
|
|
|
// acknowledged, to make sure they don't stick around for the next paint.
|
|
|
|
void EndPaint();
|
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
/**
|
|
|
|
* Tell the presshell that the given frame's reflow was interrupted. This
|
|
|
|
* will mark as having dirty children a path from the given frame (inclusive)
|
|
|
|
* to the nearest ancestor with a dirty subtree, or to the reflow root
|
|
|
|
* currently being reflowed if no such ancestor exists (inclusive). This is
|
|
|
|
* to be done immediately after reflow of the current reflow root completes.
|
|
|
|
* This method must only be called during reflow, and the frame it's being
|
|
|
|
* called on must be in the process of being reflowed when it's called. This
|
|
|
|
* method doesn't mark any intrinsic widths dirty and doesn't add any bits
|
|
|
|
* other than NS_FRAME_HAS_DIRTY_CHILDREN.
|
|
|
|
*/
|
|
|
|
void FrameNeedsToContinueReflow(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification sent by a frame informing the pres shell that it is about to
|
|
|
|
* be destroyed.
|
|
|
|
* This allows any outstanding references to the frame to be cleaned up
|
|
|
|
*/
|
|
|
|
void NotifyDestroyingFrame(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
|
|
|
|
#endif
|
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
private:
|
|
|
|
~PresShell();
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
/**
|
|
|
|
* Refresh observer management.
|
|
|
|
*/
|
|
|
|
void DoObserveStyleFlushes();
|
|
|
|
void DoObserveLayoutFlushes();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does the actual work of figuring out the current state of font size
|
|
|
|
* inflation.
|
|
|
|
*/
|
|
|
|
bool DetermineFontSizeInflationState();
|
|
|
|
|
|
|
|
void RecordAlloc(void* aPtr) {
|
|
|
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mAllocatedPointers.Contains(aPtr));
|
|
|
|
mAllocatedPointers.PutEntry(aPtr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void RecordFree(void* aPtr) {
|
|
|
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mAllocatedPointers.Contains(aPtr));
|
|
|
|
mAllocatedPointers.RemoveEntry(aPtr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
|
|
|
|
void PopCurrentEventInfo();
|
|
|
|
nsIContent* GetCurrentEventContent();
|
|
|
|
|
|
|
|
friend class ::nsRefreshDriver;
|
|
|
|
friend class ::nsAutoCauseReflowNotifier;
|
|
|
|
|
|
|
|
void WillCauseReflow();
|
|
|
|
void DidCauseReflow();
|
|
|
|
|
|
|
|
void CancelPostedReflowCallbacks();
|
|
|
|
void FlushPendingScrollAnchorAdjustments();
|
|
|
|
|
|
|
|
void SetPendingVisualScrollUpdate(
|
|
|
|
const nsPoint& aVisualViewportOffset,
|
|
|
|
FrameMetrics::ScrollOffsetUpdateType aUpdateType);
|
|
|
|
|
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
UniquePtr<ReflowCountMgr> mReflowCountMgr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void WillDoReflow();
|
|
|
|
|
|
|
|
// This data is stored as a content property (nsGkAtoms::scrolling) on
|
|
|
|
// mContentToScrollTo when we have a pending ScrollIntoView.
|
|
|
|
struct ScrollIntoViewData {
|
|
|
|
ScrollAxis mContentScrollVAxis;
|
|
|
|
ScrollAxis mContentScrollHAxis;
|
|
|
|
ScrollFlags mContentToScrollToFlags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static LazyLogModule gLog;
|
|
|
|
|
|
|
|
DOMHighResTimeStamp GetPerformanceNowUnclamped();
|
|
|
|
|
|
|
|
// The callback for the mReflowContinueTimer timer.
|
|
|
|
static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
|
|
|
|
bool ScheduleReflowOffTimer();
|
|
|
|
// 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();
|
|
|
|
|
2017-11-26 16:38:55 +03:00
|
|
|
friend class ::AutoPointerEventTargetUpdater;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-04-13 15:40:48 +03:00
|
|
|
// ProcessReflowCommands returns whether we processed all our dirty roots
|
|
|
|
// without interruptions.
|
|
|
|
MOZ_CAN_RUN_SCRIPT bool ProcessReflowCommands(bool aInterruptible);
|
|
|
|
|
2019-04-13 15:42:02 +03:00
|
|
|
/**
|
|
|
|
* Callback handler for whether reflow happened.
|
|
|
|
*
|
|
|
|
* @param aInterruptible Whether or not reflow interruption is allowed.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT void DidDoReflow(bool aInterruptible);
|
|
|
|
|
2019-04-13 15:42:38 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void HandlePostedReflowCallbacks(bool aInterruptible);
|
|
|
|
|
2019-04-23 04:34:26 +03:00
|
|
|
/**
|
|
|
|
* Helper for ScrollContentIntoView()
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT void DoScrollContentIntoView();
|
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
/**
|
|
|
|
* Methods to handle changes to user and UA sheet lists that we get
|
|
|
|
* notified about.
|
|
|
|
*/
|
|
|
|
void AddUserSheet(StyleSheet*);
|
|
|
|
void AddAgentSheet(StyleSheet*);
|
|
|
|
void AddAuthorSheet(StyleSheet*);
|
|
|
|
void RemoveSheet(StyleOrigin, StyleSheet*);
|
|
|
|
void RemovePreferenceStyles();
|
|
|
|
|
2012-06-06 07:47:33 +04:00
|
|
|
/**
|
2013-05-16 19:06:03 +04:00
|
|
|
* Initialize cached font inflation preference values and do an initial
|
|
|
|
* computation to determine if font inflation is enabled.
|
2012-06-06 07:47:33 +04:00
|
|
|
*
|
|
|
|
* @see nsLayoutUtils::sFontSizeInflationEmPerLine
|
|
|
|
* @see nsLayoutUtils::sFontSizeInflationMinTwips
|
|
|
|
* @see nsLayoutUtils::sFontSizeInflationLineThreshold
|
|
|
|
*/
|
|
|
|
void SetupFontInflation();
|
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
/**
|
|
|
|
* Implementation methods for FlushPendingNotifications.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT void DoFlushPendingNotifications(FlushType aType);
|
|
|
|
MOZ_CAN_RUN_SCRIPT void DoFlushPendingNotifications(ChangesToFlush aType);
|
|
|
|
|
2011-09-09 23:50:21 +04:00
|
|
|
struct RenderingState {
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit RenderingState(PresShell* aPresShell)
|
2015-03-07 02:07:59 +03:00
|
|
|
: mResolution(aPresShell->mResolution),
|
2019-05-01 05:28:25 +03:00
|
|
|
mRenderingStateFlags(aPresShell->mRenderingStateFlags) {}
|
2016-03-19 04:38:57 +03:00
|
|
|
Maybe<float> mResolution;
|
2019-05-01 05:28:25 +03:00
|
|
|
RenderingStateFlags mRenderingStateFlags;
|
2011-09-09 23:50:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AutoSaveRestoreRenderingState {
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit AutoSaveRestoreRenderingState(PresShell* aPresShell)
|
2011-09-09 23:50:21 +04:00
|
|
|
: mPresShell(aPresShell), mOldState(aPresShell) {}
|
|
|
|
|
|
|
|
~AutoSaveRestoreRenderingState() {
|
2019-05-01 05:28:25 +03:00
|
|
|
mPresShell->mRenderingStateFlags = mOldState.mRenderingStateFlags;
|
2015-03-07 02:07:59 +03:00
|
|
|
mPresShell->mResolution = mOldState.mResolution;
|
2011-09-09 23:50:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PresShell* mPresShell;
|
|
|
|
RenderingState mOldState;
|
|
|
|
};
|
|
|
|
void SetRenderingState(const RenderingState& aState);
|
|
|
|
|
2016-11-30 06:14:27 +03:00
|
|
|
friend class ::nsPresShellEventCB;
|
2011-09-09 23:50:21 +04: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 18:19:54 +04:00
|
|
|
nsRange* aRange);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
|
|
|
// create a RangePaintInfo for the range aRange containing the
|
|
|
|
// display list needed to paint the range to a surface
|
2018-03-27 07:35:22 +03:00
|
|
|
UniquePtr<RangePaintInfo> CreateRangePaintInfo(nsRange* aRange,
|
2016-01-21 00:24:28 +03:00
|
|
|
nsRect& aSurfaceRect,
|
|
|
|
bool aForPrimarySelection);
|
2011-09-09 23:50:21 +04: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
|
2019-04-25 08:04:23 +03:00
|
|
|
* aFlags - set RenderImageFlags::AutoScale to scale down large images, but
|
|
|
|
* it must not be set if a custom image was specified
|
2011-09-09 23:50:21 +04:00
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<SourceSurface> PaintRangePaintInfo(
|
2018-03-07 14:13:17 +03:00
|
|
|
const nsTArray<UniquePtr<RangePaintInfo>>& aItems,
|
2018-08-07 16:32:08 +03:00
|
|
|
dom::Selection* aSelection, const Maybe<CSSIntRegion>& aRegion,
|
2018-03-07 14:13:17 +03:00
|
|
|
nsRect aArea, const LayoutDeviceIntPoint aPoint,
|
2019-04-25 08:04:23 +03:00
|
|
|
LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
|
|
|
// Hide a view if it is a popup
|
2013-01-03 17:23:11 +04:00
|
|
|
void HideViewIfPopup(nsView* aView);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
|
|
|
// Utility method to restore the root scrollframe state
|
|
|
|
void RestoreRootScrollPosition();
|
|
|
|
|
2014-08-06 09:19:27 +04:00
|
|
|
void MaybeReleaseCapturingContent();
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2013-10-22 17:27:34 +04:00
|
|
|
class DelayedEvent {
|
2011-09-09 23:50:21 +04:00
|
|
|
public:
|
2013-10-22 17:27:34 +04:00
|
|
|
virtual ~DelayedEvent() {}
|
|
|
|
virtual void Dispatch() {}
|
2017-02-03 13:16:00 +03:00
|
|
|
virtual bool IsKeyPressEvent() { return false; }
|
2011-09-09 23:50:21 +04:00
|
|
|
};
|
|
|
|
|
2013-10-22 17:27:34 +04:00
|
|
|
class DelayedInputEvent : public DelayedEvent {
|
2011-09-09 23:50:21 +04:00
|
|
|
public:
|
2018-03-07 14:13:17 +03:00
|
|
|
void Dispatch() override;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
|
|
|
protected:
|
2013-10-22 17:27:34 +04:00
|
|
|
DelayedInputEvent();
|
2018-03-07 14:13:17 +03:00
|
|
|
~DelayedInputEvent() override;
|
2013-10-18 10:10:21 +04:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
WidgetInputEvent* mEvent;
|
2011-09-09 23:50:21 +04:00
|
|
|
};
|
|
|
|
|
2013-10-22 17:27:34 +04:00
|
|
|
class DelayedMouseEvent : public DelayedInputEvent {
|
2011-09-09 23:50:21 +04:00
|
|
|
public:
|
2018-03-07 14:13:17 +03:00
|
|
|
explicit DelayedMouseEvent(WidgetMouseEvent* aEvent);
|
2011-09-09 23:50:21 +04:00
|
|
|
};
|
|
|
|
|
2013-10-22 17:27:34 +04:00
|
|
|
class DelayedKeyEvent : public DelayedInputEvent {
|
2011-09-09 23:50:21 +04:00
|
|
|
public:
|
2018-03-07 14:13:17 +03:00
|
|
|
explicit DelayedKeyEvent(WidgetKeyboardEvent* aEvent);
|
|
|
|
bool IsKeyPressEvent() override;
|
2011-09-09 23:50:21 +04:00
|
|
|
};
|
|
|
|
|
2012-05-16 21:32:40 +04:00
|
|
|
// Check if aEvent is a mouse event and record the mouse location for later
|
|
|
|
// synth mouse moves.
|
2018-03-07 14:13:17 +03:00
|
|
|
void RecordMouseLocation(WidgetGUIEvent* aEvent);
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsSynthMouseMoveEvent final : public nsARefreshObserver {
|
2012-05-16 21:32:40 +04:00
|
|
|
public:
|
2015-04-06 18:22:00 +03:00
|
|
|
nsSynthMouseMoveEvent(PresShell* aPresShell, bool aFromScroll)
|
|
|
|
: mPresShell(aPresShell), mFromScroll(aFromScroll) {
|
2012-05-16 21:32:40 +04:00
|
|
|
NS_ASSERTION(mPresShell, "null parameter");
|
|
|
|
}
|
2014-03-21 05:16:20 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2012-05-16 21:32:40 +04:00
|
|
|
~nsSynthMouseMoveEvent() { Revoke(); }
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2014-03-21 05:16:20 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent, override)
|
2014-03-20 10:49:25 +04:00
|
|
|
|
2012-05-16 21:32:40 +04:00
|
|
|
void Revoke() {
|
|
|
|
if (mPresShell) {
|
|
|
|
mPresShell->GetPresContext()->RefreshDriver()->RemoveRefreshObserver(
|
2017-01-05 10:31:56 +03:00
|
|
|
this, FlushType::Display);
|
2012-07-30 18:20:58 +04:00
|
|
|
mPresShell = nullptr;
|
2012-05-16 21:32:40 +04:00
|
|
|
}
|
|
|
|
}
|
2019-03-11 17:58:04 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-03-07 14:13:17 +03:00
|
|
|
void WillRefresh(TimeStamp aTime) override {
|
2013-11-12 16:54:10 +04:00
|
|
|
if (mPresShell) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PresShell> shell = mPresShell;
|
2015-04-06 18:22:00 +03:00
|
|
|
shell->ProcessSynthMouseMoveEvent(mFromScroll);
|
2013-11-12 16:54:10 +04:00
|
|
|
}
|
2012-05-16 21:32:40 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-05-16 21:32:40 +04:00
|
|
|
private:
|
|
|
|
PresShell* mPresShell;
|
|
|
|
bool mFromScroll;
|
|
|
|
};
|
2019-03-11 17:58:04 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void ProcessSynthMouseMoveEvent(bool aFromScroll);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2012-05-16 21:32:40 +04:00
|
|
|
void QueryIsActive();
|
2016-07-26 21:48:00 +03:00
|
|
|
nsresult UpdateImageLockingState();
|
2012-04-27 01:40:05 +04:00
|
|
|
|
2019-04-13 04:03:13 +03:00
|
|
|
already_AddRefed<PresShell> GetParentPresShellForEventHandling();
|
2018-10-09 12:47:58 +03:00
|
|
|
|
2015-11-10 05:49:05 +03:00
|
|
|
/**
|
2019-05-01 05:27:53 +03:00
|
|
|
* EventHandler is implementation of PresShell::HandleEvent().
|
2015-11-10 05:49:05 +03:00
|
|
|
*/
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
class MOZ_STACK_CLASS EventHandler final {
|
|
|
|
public:
|
|
|
|
EventHandler() = delete;
|
|
|
|
EventHandler(const EventHandler& aOther) = delete;
|
2019-03-04 09:12:22 +03:00
|
|
|
explicit EventHandler(PresShell& aPresShell)
|
|
|
|
: mPresShell(aPresShell), mCurrentEventInfoSetter(nullptr) {}
|
2019-02-12 07:10:33 +03:00
|
|
|
explicit EventHandler(RefPtr<PresShell>&& aPresShell)
|
2019-03-04 09:12:22 +03:00
|
|
|
: mPresShell(aPresShell.forget()), mCurrentEventInfoSetter(nullptr) {}
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* HandleEvent() may dispatch aGUIEvent. This may redirect the event to
|
|
|
|
* another PresShell, or the event may be handled by other classes like
|
Bug 1466208 - part 44: Rename PresShell::EventHandler::HandleEventInternal() to HandleEventWithCurrentEventInfo() r=smaug
In my understanding, `PresShell::EventHandler::HandleEvent()` may redirect
the event to another class or PresShell first. Otherwise, it computes
event target and sets current event info of mPresShell to it. Then, calls
`HandleEventInternal()` to dispatch the event. Then, `HandleEventInternal()`
may handle the event before dispatch, and/or prepare to dispatch, then,
finally dispatches the event and finalize the state of mPresShell and the
event. Therefore, `HandleEventInternal()` actually handles the event, but
the word, "internal" is not explicitly explain its different points from
`HandleEvent()`. Therefore, I think that `HandleEventWithCurrentEventInfo()`
is better name since `HandleEvent()` considers the current event info.
Differential Revision: https://phabricator.services.mozilla.com/D22462
--HG--
extra : moz-landing-system : lando
2019-03-12 07:25:13 +03:00
|
|
|
* AccessibleCaretEventHub, or discarded. Otherwise, this sets current
|
|
|
|
* event info of mPresShell and calls HandleEventWithCurrentEventInfo()
|
|
|
|
* to dispatch the event into the DOM tree.
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
*
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. If PresShell
|
|
|
|
* has root frame, it should be set.
|
|
|
|
* Otherwise, a frame which contains the
|
|
|
|
* PresShell should be set instead. I.e.,
|
|
|
|
* in the latter case, the frame is in
|
|
|
|
* a parent document.
|
2019-03-26 13:02:06 +03:00
|
|
|
* @param aGUIEvent Event to be handled. Must be a trusted
|
|
|
|
* event.
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
* @param aDontRetargetEvents true if this shouldn't redirect the
|
|
|
|
* event to different PresShell.
|
|
|
|
* false if this can redirect the event to
|
|
|
|
* different PresShell.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aGUIEvent.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-03-13 13:32:36 +03:00
|
|
|
nsresult HandleEvent(nsIFrame* aFrameForPresShell,
|
|
|
|
WidgetGUIEvent* aGUIEvent, bool aDontRetargetEvents,
|
|
|
|
nsEventStatus* aEventStatus);
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* HandleEventWithTarget() tries to dispatch aEvent on aContent after
|
|
|
|
* setting current event target content to aNewEventContent and current
|
|
|
|
* event frame to aNewEventFrame temporarily. Note that this supports
|
|
|
|
* WidgetEvent, not WidgetGUIEvent. So, you can dispatch a simple event
|
|
|
|
* with this.
|
|
|
|
*
|
2019-03-26 13:02:06 +03:00
|
|
|
* @param aEvent Event to be dispatched. Must be a
|
|
|
|
* trusted event.
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
* @param aNewEventFrame Temporal new event frame.
|
|
|
|
* @param aNewEventContent Temporal new event content.
|
|
|
|
* @param aEventStatus [in/out] EventStuatus of aEvent.
|
|
|
|
* @param aIsHandlingNativeEvent true if aEvent represents a native
|
|
|
|
* event.
|
|
|
|
* @param aTargetContent This is used only when aEvent is a
|
|
|
|
* pointer event. If
|
|
|
|
* PresShell::mPointerEventTarget is
|
|
|
|
* changed during dispatching aEvent,
|
|
|
|
* this is set to the new target.
|
|
|
|
* @param aOverrideClickTarget Override click event target.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult HandleEventWithTarget(WidgetEvent* aEvent,
|
|
|
|
nsIFrame* aNewEventFrame,
|
|
|
|
nsIContent* aNewEventContent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
bool aIsHandlingNativeEvent,
|
|
|
|
nsIContent** aTargetContent,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2019-03-04 09:11:41 +03:00
|
|
|
/**
|
|
|
|
* OnPresShellDestroy() is called when every PresShell instance is being
|
|
|
|
* destroyed.
|
|
|
|
*/
|
2019-03-29 18:11:22 +03:00
|
|
|
static inline void OnPresShellDestroy(Document* aDocument);
|
2019-03-04 09:11:41 +03:00
|
|
|
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
private:
|
|
|
|
static bool InZombieDocument(nsIContent* aContent);
|
2019-04-16 10:25:10 +03:00
|
|
|
static nsIFrame* GetNearestFrameContainingPresShell(PresShell* aPresShell);
|
2020-01-09 15:09:18 +03:00
|
|
|
static nsIPrincipal* GetDocumentPrincipalToCompareWithBlacklist(
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
PresShell& aPresShell);
|
|
|
|
|
2019-03-02 03:03:01 +03:00
|
|
|
/**
|
|
|
|
* HandleEventUsingCoordinates() handles aGUIEvent whose
|
|
|
|
* IsUsingCoordinates() returns true with the following helper methods.
|
|
|
|
*
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. See
|
|
|
|
* explanation of HandleEvent() for the
|
|
|
|
* details.
|
2019-03-02 03:03:01 +03:00
|
|
|
* @param aGUIEvent The handling event. Make sure that
|
|
|
|
* its IsUsingCoordinates() returns true.
|
|
|
|
* @param aEventStatus The status of aGUIEvent.
|
|
|
|
* @param aDontRetargetEvents true if we've already retarget document.
|
|
|
|
* Otherwise, false.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult HandleEventUsingCoordinates(nsIFrame* aFrameForPresShell,
|
|
|
|
WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
bool aDontRetargetEvents);
|
|
|
|
|
2019-02-13 02:23:27 +03:00
|
|
|
/**
|
|
|
|
* EventTargetData struct stores a set of a PresShell (event handler),
|
|
|
|
* a frame (to handle the event) and a content (event target for the frame).
|
|
|
|
*/
|
|
|
|
struct MOZ_STACK_CLASS EventTargetData final {
|
|
|
|
EventTargetData() = delete;
|
|
|
|
EventTargetData(const EventTargetData& aOther) = delete;
|
2019-12-19 20:08:41 +03:00
|
|
|
explicit EventTargetData(nsIFrame* aFrameToHandleEvent) {
|
|
|
|
SetFrameAndComputePresShell(aFrameToHandleEvent);
|
2019-02-13 02:23:27 +03:00
|
|
|
}
|
2019-12-19 20:08:41 +03:00
|
|
|
|
2019-02-13 02:23:27 +03:00
|
|
|
void SetFrameAndComputePresShell(nsIFrame* aFrameToHandleEvent);
|
|
|
|
void SetFrameAndComputePresShellAndContent(nsIFrame* aFrameToHandleEvent,
|
|
|
|
WidgetGUIEvent* aGUIEvent);
|
|
|
|
void SetContentForEventFromFrame(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
|
|
|
nsPresContext* GetPresContext() const {
|
|
|
|
return mPresShell ? mPresShell->GetPresContext() : nullptr;
|
|
|
|
};
|
|
|
|
EventStateManager* GetEventStateManager() const {
|
|
|
|
nsPresContext* presContext = GetPresContext();
|
|
|
|
return presContext ? presContext->EventStateManager() : nullptr;
|
|
|
|
}
|
|
|
|
Document* GetDocument() const {
|
|
|
|
return mPresShell ? mPresShell->GetDocument() : nullptr;
|
|
|
|
}
|
|
|
|
nsIContent* GetFrameContent() const;
|
|
|
|
|
2019-02-15 05:06:31 +03:00
|
|
|
/**
|
|
|
|
* MaybeRetargetToActiveDocument() tries retarget aGUIEvent into
|
|
|
|
* active document if there is. Note that this does not support to
|
|
|
|
* retarget mContent. Make sure it is nullptr before calling this.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @return true if retargetted.
|
|
|
|
*/
|
|
|
|
bool MaybeRetargetToActiveDocument(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-02-18 07:33:06 +03:00
|
|
|
/**
|
|
|
|
* ComputeElementFromFrame() computes mContent for aGUIEvent. If
|
|
|
|
* mContent is set by this method, mContent is always nullptr or an
|
|
|
|
* Element.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @return true if caller can keep handling the event.
|
|
|
|
* Otherwise, false.
|
|
|
|
* Note that even if this returns true, mContent
|
|
|
|
* may be nullptr.
|
|
|
|
*/
|
|
|
|
bool ComputeElementFromFrame(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-03-02 03:02:10 +03:00
|
|
|
/**
|
|
|
|
* UpdateTouchEventTarget() updates mFrame, mPresShell and mContent if
|
|
|
|
* aGUIEvent is a touch event and there is new proper target.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent The handled event. If it's not a touch event,
|
|
|
|
* this method does nothing.
|
|
|
|
*/
|
|
|
|
void UpdateTouchEventTarget(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-02-13 02:23:27 +03:00
|
|
|
RefPtr<PresShell> mPresShell;
|
2019-12-19 20:08:41 +03:00
|
|
|
nsIFrame* mFrame = nullptr;
|
2019-02-13 02:23:27 +03:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
2019-03-01 04:58:02 +03:00
|
|
|
nsCOMPtr<nsIContent> mOverrideClickTarget;
|
2019-02-13 02:23:27 +03:00
|
|
|
};
|
|
|
|
|
Bug 1506508 - Make PresShell::EventHandler::HandleEvent() flush any dirty region before deciding to event target of eMouseDown and eMouseUp r=smaug
When preceding mouse event is handled, that may cause changing style of the
target. Therefore, when an eMouseDown or eMouseUp event is handled, handlers
require the latest layout. Currently, nsViewManager::DispatchEvent() tries
to guarantee that with calling nsIPresShell::FlushPendingNotifications()
with FlushType::Layout. However, this just flushes the pending layout in
the PresShell associated with the nsViewManager instance. I.e., if the
target is in a child PresShell, its layout hasn't been flushed.
This patch makes PresShell::EventHandler::HandleEvent() flush pending
notifications at first of handling events using coordinates (only when
eMouseDown or eMouseUp, though). Then, when it realizes that the event
should be handled in a child PresShell, makes it flush its pending
notifications and then, recompute event target with the latest layout if
the layout is actually changed.
Differential Revision: https://phabricator.services.mozilla.com/D13720
--HG--
extra : moz-landing-system : lando
2019-02-12 02:25:45 +03:00
|
|
|
/**
|
|
|
|
* MaybeFlushPendingNotifications() maybe flush pending notifications if
|
|
|
|
* aGUIEvent should be handled with the latest layout.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @return true if this actually flushes pending
|
|
|
|
* layout and that has caused changing the
|
|
|
|
* layout.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
bool MaybeFlushPendingNotifications(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetFrameToHandleNonTouchEvent() returns a frame to handle the event.
|
|
|
|
* This may flush pending layout if the target is in child PresShell.
|
|
|
|
*
|
|
|
|
* @param aRootFrameToHandleEvent The root frame to handle the event.
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @return The frame which should handle the
|
|
|
|
* event. nullptr if the caller should
|
|
|
|
* stop handling the event.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsIFrame* GetFrameToHandleNonTouchEvent(nsIFrame* aRootFrameToHandleEvent,
|
|
|
|
WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-02-27 16:59:30 +03:00
|
|
|
/**
|
|
|
|
* ComputeEventTargetFrameAndPresShellAtEventPoint() computes event
|
|
|
|
* target frame at the event point of aGUIEvent and set it to
|
|
|
|
* aEventTargetData.
|
|
|
|
*
|
|
|
|
* @param aRootFrameToHandleEvent The root frame to handle aGUIEvent.
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @param aEventTargetData [out] Its frame and PresShell will
|
|
|
|
* be set.
|
|
|
|
* @return true if the caller can handle the
|
|
|
|
* event. Otherwise, false.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
bool ComputeEventTargetFrameAndPresShellAtEventPoint(
|
|
|
|
nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
|
|
|
|
EventTargetData* aEventTargetData);
|
|
|
|
|
2019-03-01 05:02:31 +03:00
|
|
|
/**
|
|
|
|
* DispatchPrecedingPointerEvent() dispatches preceding pointer event for
|
|
|
|
* aGUIEvent if Pointer Events is enabled.
|
|
|
|
*
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. See
|
|
|
|
* explanation of HandleEvent() for the
|
|
|
|
* details.
|
2019-03-01 05:02:31 +03:00
|
|
|
* @param aGUIEvent The handled event.
|
|
|
|
* @param aPointerCapturingContent The content which is capturing pointer
|
|
|
|
* events if there is. Otherwise, nullptr.
|
|
|
|
* @param aDontRetargetEvents Set aDontRetargetEvents of
|
|
|
|
* HandleEvent() which called this method.
|
|
|
|
* @param aEventTargetData [in/out] Event target data of
|
|
|
|
* aGUIEvent. If pointer event listeners
|
|
|
|
* change the DOM tree or reframe the
|
|
|
|
* target, updated by this method.
|
|
|
|
* @param aEventStatus [in/out] The event status of aGUIEvent.
|
|
|
|
* @return true if the caller can handle the
|
|
|
|
* event. Otherwise, false.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
bool DispatchPrecedingPointerEvent(nsIFrame* aFrameForPresShell,
|
|
|
|
WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsIContent* aPointerCapturingContent,
|
|
|
|
bool aDontRetargetEvents,
|
|
|
|
EventTargetData* aEventTargetData,
|
|
|
|
nsEventStatus* aEventStatus);
|
|
|
|
|
2019-02-02 05:20:28 +03:00
|
|
|
/**
|
|
|
|
* MaybeDiscardEvent() checks whether it's safe to handle aGUIEvent right
|
|
|
|
* now. If it's not safe, this may notify somebody of discarding event if
|
|
|
|
* necessary.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent Handling event.
|
|
|
|
* @return true if it's not safe to handle the event.
|
|
|
|
*/
|
|
|
|
bool MaybeDiscardEvent(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-01-30 10:17:43 +03:00
|
|
|
/**
|
|
|
|
* GetCapturingContentFor() returns capturing content for aGUIEvent.
|
|
|
|
* If aGUIEvent is not related to capturing, this returns nullptr.
|
|
|
|
*/
|
|
|
|
static nsIContent* GetCapturingContentFor(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-01-31 05:24:51 +03:00
|
|
|
/**
|
|
|
|
* GetRetargetEventDocument() returns a document if aGUIEvent should be
|
|
|
|
* handled in another document.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent Handling event.
|
|
|
|
* @param aRetargetEventDocument Document which should handle aGUIEvent.
|
|
|
|
* @return true if caller can keep handling
|
|
|
|
* aGUIEvent.
|
|
|
|
*/
|
|
|
|
bool GetRetargetEventDocument(WidgetGUIEvent* aGUIEvent,
|
|
|
|
Document** aRetargetEventDocument);
|
|
|
|
|
2019-02-01 05:15:54 +03:00
|
|
|
/**
|
|
|
|
* GetFrameForHandlingEventWith() returns a frame which should be used as
|
2019-03-13 13:32:36 +03:00
|
|
|
* aFrameForPresShell of HandleEvent(). See @return for the details.
|
2019-02-01 05:15:54 +03:00
|
|
|
*
|
|
|
|
* @param aGUIEvent Handling event.
|
|
|
|
* @param aRetargetDocument Document which aGUIEvent should be
|
|
|
|
* fired on. Typically, should be result
|
|
|
|
* of GetRetargetEventDocument().
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. See
|
|
|
|
* explanation of HandleEvent() for the
|
|
|
|
* details.
|
2019-02-01 05:15:54 +03:00
|
|
|
* @return nullptr if caller should stop handling
|
|
|
|
* the event.
|
|
|
|
* aFrameForPresShell if caller should
|
|
|
|
* keep handling the event by itself.
|
|
|
|
* Otherwise, caller should handle it with
|
|
|
|
* another PresShell which is result of
|
|
|
|
* nsIFrame::PresContext()->GetPresShell().
|
|
|
|
*/
|
|
|
|
nsIFrame* GetFrameForHandlingEventWith(WidgetGUIEvent* aGUIEvent,
|
|
|
|
Document* aRetargetDocument,
|
|
|
|
nsIFrame* aFrameForPresShell);
|
|
|
|
|
2019-02-02 05:20:25 +03:00
|
|
|
/**
|
|
|
|
* MaybeHandleEventWithAnotherPresShell() may handle aGUIEvent with another
|
|
|
|
* PresShell.
|
|
|
|
*
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. See
|
|
|
|
* explanation of HandleEvent() for the
|
|
|
|
* details.
|
2019-02-02 05:20:25 +03:00
|
|
|
* @param aGUIEvent Handling event.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aGUIEvent.
|
|
|
|
* @param aRv [out] Returns error if this gets an
|
|
|
|
* error handling the event.
|
|
|
|
* @return false if caller needs to keep handling
|
|
|
|
* the event by itself.
|
|
|
|
* true if caller shouldn't keep handling
|
|
|
|
* the event. Note that when no PresShell
|
|
|
|
* can handle the event, this returns true.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
bool MaybeHandleEventWithAnotherPresShell(nsIFrame* aFrameForPresShell,
|
|
|
|
WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
nsresult* aRv);
|
|
|
|
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult RetargetEventToParent(WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
|
|
|
|
2019-01-29 13:30:35 +03:00
|
|
|
/**
|
|
|
|
* MaybeHandleEventWithAccessibleCaret() may handle aGUIEvent with
|
|
|
|
* AccessibleCaretEventHub if it's necessary.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent Event may be handled by AccessibleCaretEventHub.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aGUIEvent.
|
|
|
|
* @return true if AccessibleCaretEventHub handled the
|
|
|
|
* event and caller shouldn't keep handling it.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2020-01-17 02:01:09 +03:00
|
|
|
bool MaybeHandleEventWithAccessibleCaret(WidgetGUIEvent* aGUIEvent,
|
2019-01-29 13:30:35 +03:00
|
|
|
nsEventStatus* aEventStatus);
|
|
|
|
|
2019-02-07 04:49:31 +03:00
|
|
|
/**
|
|
|
|
* MaybeDiscardOrDelayKeyboardEvent() may discared or put aGUIEvent into
|
|
|
|
* the delayed event queue if it's a keyboard event and if we should do so.
|
|
|
|
* If aGUIEvent is not a keyboard event, this does nothing.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @return true if this method discard the event or
|
|
|
|
* put it into the delayed event queue.
|
|
|
|
*/
|
|
|
|
bool MaybeDiscardOrDelayKeyboardEvent(WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-02-12 07:12:20 +03:00
|
|
|
/**
|
|
|
|
* MaybeDiscardOrDelayMouseEvent() may discard or put aGUIEvent into the
|
|
|
|
* delayed event queue if it's a mouse event and if we should do so.
|
|
|
|
* If aGUIEvent is not a mouse event, this does nothing.
|
|
|
|
* If there is suppressed event listener like debugger of devtools, this
|
|
|
|
* notifies it of the event after discard or put it into the delayed
|
|
|
|
* event queue.
|
|
|
|
*
|
|
|
|
* @param aFrameToHandleEvent The frame to handle aGUIEvent.
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @return true if this method discard the event
|
|
|
|
* or put it into the delayed event queue.
|
|
|
|
*/
|
|
|
|
bool MaybeDiscardOrDelayMouseEvent(nsIFrame* aFrameToHandleEvent,
|
|
|
|
WidgetGUIEvent* aGUIEvent);
|
|
|
|
|
2019-02-08 08:05:45 +03:00
|
|
|
/**
|
|
|
|
* MaybeFlushThrottledStyles() tries to flush pending animation. If it's
|
|
|
|
* flushed and then aFrameForPresShell is destroyed, returns new frame
|
|
|
|
* which contains mPresShell.
|
|
|
|
*
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. See
|
|
|
|
* explanation of HandleEvent() for the
|
|
|
|
* details. This can be nullptr.
|
2019-02-08 08:05:45 +03:00
|
|
|
* @return Maybe new frame for mPresShell.
|
|
|
|
* If aFrameForPresShell is not nullptr
|
|
|
|
* and hasn't been destroyed, returns
|
|
|
|
* aFrameForPresShell as-is.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsIFrame* MaybeFlushThrottledStyles(nsIFrame* aFrameForPresShell);
|
|
|
|
|
2019-02-08 10:11:01 +03:00
|
|
|
/**
|
|
|
|
* ComputeRootFrameToHandleEvent() returns root frame to handle the event.
|
|
|
|
* For example, if there is a popup, this returns the popup frame.
|
|
|
|
* If there is capturing content and it's in a scrolled frame, returns
|
|
|
|
* the scrolled frame.
|
|
|
|
*
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. See
|
|
|
|
* explanation of HandleEvent() for
|
|
|
|
* the details.
|
2019-02-08 10:11:01 +03:00
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @param aCapturingContent Capturing content if there is.
|
|
|
|
* nullptr, otherwise.
|
|
|
|
* @param aIsCapturingContentIgnored [out] true if aCapturingContent
|
|
|
|
* is not nullptr but it should be
|
|
|
|
* ignored to handle the event.
|
|
|
|
* @param aIsCaptureRetargeted [out] true if aCapturingContent
|
|
|
|
* is not nullptr but it's
|
|
|
|
* retargeted.
|
|
|
|
* @return Root frame to handle the event.
|
|
|
|
*/
|
|
|
|
nsIFrame* ComputeRootFrameToHandleEvent(nsIFrame* aFrameForPresShell,
|
|
|
|
WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsIContent* aCapturingContent,
|
|
|
|
bool* aIsCapturingContentIgnored,
|
|
|
|
bool* aIsCaptureRetargeted);
|
|
|
|
|
2019-02-09 02:10:13 +03:00
|
|
|
/**
|
|
|
|
* ComputeRootFrameToHandleEventWithPopup() returns popup frame if there
|
|
|
|
* is a popup and we should handle the event in it. Otherwise, returns
|
|
|
|
* aRootFrameToHandleEvent.
|
|
|
|
*
|
|
|
|
* @param aRootFrameToHandleEvent Candidate root frame to handle
|
|
|
|
* the event.
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @param aCapturingContent Capturing content if there is.
|
|
|
|
* nullptr, otherwise.
|
|
|
|
* @param aIsCapturingContentIgnored [out] true if aCapturingContent
|
|
|
|
* is not nullptr but it should be
|
|
|
|
* ignored to handle the event.
|
|
|
|
* @return A popup frame if there is a
|
|
|
|
* popup and we should handle the
|
|
|
|
* event in it. Otherwise,
|
|
|
|
* aRootFrameToHandleEvent.
|
|
|
|
* I.e., never returns nullptr.
|
|
|
|
*/
|
|
|
|
nsIFrame* ComputeRootFrameToHandleEventWithPopup(
|
|
|
|
nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsIContent* aCapturingContent, bool* aIsCapturingContentIgnored);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ComputeRootFrameToHandleEventWithCapturingContent() returns root frame
|
|
|
|
* to handle event for the capturing content, or aRootFrameToHandleEvent
|
|
|
|
* if it should be ignored.
|
|
|
|
*
|
|
|
|
* @param aRootFrameToHandleEvent Candidate root frame to handle
|
|
|
|
* the event.
|
|
|
|
* @param aCapturingContent Capturing content. nullptr is
|
|
|
|
* not allowed.
|
|
|
|
* @param aIsCapturingContentIgnored [out] true if aCapturingContent
|
|
|
|
* is not nullptr but it should be
|
|
|
|
* ignored to handle the event.
|
|
|
|
* @param aIsCaptureRetargeted [out] true if aCapturingContent
|
|
|
|
* is not nullptr but it's
|
|
|
|
* retargeted.
|
|
|
|
* @return A popup frame if there is a
|
|
|
|
* popup and we should handle the
|
|
|
|
* event in it. Otherwise,
|
|
|
|
* aRootFrameToHandleEvent.
|
|
|
|
* I.e., never returns nullptr.
|
|
|
|
*/
|
|
|
|
nsIFrame* ComputeRootFrameToHandleEventWithCapturingContent(
|
|
|
|
nsIFrame* aRootFrameToHandleEvent, nsIContent* aCapturingContent,
|
|
|
|
bool* aIsCapturingContentIgnored, bool* aIsCaptureRetargeted);
|
|
|
|
|
2019-02-12 07:10:33 +03:00
|
|
|
/**
|
|
|
|
* HandleEventWithPointerCapturingContentWithoutItsFrame() handles
|
|
|
|
* aGUIEvent with aPointerCapturingContent when it does not have primary
|
|
|
|
* frame.
|
|
|
|
*
|
2019-03-13 13:32:36 +03:00
|
|
|
* @param aFrameForPresShell The frame for PresShell. See
|
|
|
|
* explanation of HandleEvent() for the
|
|
|
|
* details.
|
2019-02-12 07:10:33 +03:00
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @param aPointerCapturingContent Current pointer capturing content.
|
|
|
|
* Must not be nullptr.
|
|
|
|
* @param aEventStatus [in/out] The event status of aGUIEvent.
|
|
|
|
* @return Basically, result of
|
|
|
|
* HandeEventWithTraget().
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult HandleEventWithPointerCapturingContentWithoutItsFrame(
|
|
|
|
nsIFrame* aFrameForPresShell, WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsIContent* aPointerCapturingContent, nsEventStatus* aEventStatus);
|
|
|
|
|
2019-03-06 09:03:31 +03:00
|
|
|
/**
|
|
|
|
* HandleEventAtFocusedContent() handles aGUIEvent at focused content.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent The handling event which should be handled at
|
|
|
|
* focused content.
|
|
|
|
* @param aEventStatus [in/out] The event status of aGUIEvent.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult HandleEventAtFocusedContent(WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
|
|
|
|
2019-03-04 09:11:41 +03:00
|
|
|
/**
|
|
|
|
* ComputeFocusedEventTargetElement() returns event target element for
|
|
|
|
* aGUIEvent which should be handled with focused content.
|
|
|
|
* This may set/unset sLastKeyDownEventTarget if necessary.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent The handling event.
|
|
|
|
* @return The element which should be the event
|
|
|
|
* target of aGUIEvent.
|
|
|
|
*/
|
2019-03-29 18:11:22 +03:00
|
|
|
dom::Element* ComputeFocusedEventTargetElement(WidgetGUIEvent* aGUIEvent);
|
2019-03-04 09:11:41 +03:00
|
|
|
|
2019-03-05 09:09:02 +03:00
|
|
|
/**
|
|
|
|
* MaybeHandleEventWithAnotherPresShell() may handle aGUIEvent with another
|
|
|
|
* PresShell.
|
|
|
|
*
|
|
|
|
* @param aEventTargetElement The event target element of aGUIEvent.
|
|
|
|
* @param aGUIEvent Handling event.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aGUIEvent.
|
|
|
|
* @param aRv [out] Returns error if this gets an
|
|
|
|
* error handling the event.
|
|
|
|
* @return false if caller needs to keep handling
|
|
|
|
* the event by itself.
|
|
|
|
* true if caller shouldn't keep handling
|
|
|
|
* the event. Note that when no PresShell
|
|
|
|
* can handle the event, this returns true.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-03-29 18:11:22 +03:00
|
|
|
bool MaybeHandleEventWithAnotherPresShell(dom::Element* aEventTargetElement,
|
2019-03-05 09:09:02 +03:00
|
|
|
WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
nsresult* aRv);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HandleRetargetedEvent() dispatches aGUIEvent on the PresShell without
|
|
|
|
* retargetting. This should be used only when caller computes final
|
|
|
|
* target of aGUIEvent.
|
|
|
|
*
|
|
|
|
* @param aGUIEvent Event to be dispatched.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aGUIEvent.
|
|
|
|
* @param aTarget The final target of aGUIEvent.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult HandleRetargetedEvent(WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
nsIContent* aTarget) {
|
|
|
|
AutoCurrentEventInfoSetter eventInfoSetter(*this, nullptr, aTarget);
|
|
|
|
if (!mPresShell->GetCurrentEventFrame()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIContent> overrideClickTarget;
|
Bug 1466208 - part 44: Rename PresShell::EventHandler::HandleEventInternal() to HandleEventWithCurrentEventInfo() r=smaug
In my understanding, `PresShell::EventHandler::HandleEvent()` may redirect
the event to another class or PresShell first. Otherwise, it computes
event target and sets current event info of mPresShell to it. Then, calls
`HandleEventInternal()` to dispatch the event. Then, `HandleEventInternal()`
may handle the event before dispatch, and/or prepare to dispatch, then,
finally dispatches the event and finalize the state of mPresShell and the
event. Therefore, `HandleEventInternal()` actually handles the event, but
the word, "internal" is not explicitly explain its different points from
`HandleEvent()`. Therefore, I think that `HandleEventWithCurrentEventInfo()`
is better name since `HandleEvent()` considers the current event info.
Differential Revision: https://phabricator.services.mozilla.com/D22462
--HG--
extra : moz-landing-system : lando
2019-03-12 07:25:13 +03:00
|
|
|
return HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
|
|
|
|
overrideClickTarget);
|
2019-03-05 09:09:02 +03:00
|
|
|
}
|
|
|
|
|
2019-03-06 09:03:31 +03:00
|
|
|
/**
|
|
|
|
* HandleEventWithFrameForPresShell() handles aGUIEvent with the frame
|
|
|
|
* for mPresShell.
|
|
|
|
*
|
|
|
|
* @param aFrameForPresShell The frame for mPresShell.
|
|
|
|
* @param aGUIEvent The handling event. It shouldn't be
|
|
|
|
* handled with using coordinates nor
|
|
|
|
* handled at focused content.
|
|
|
|
* @param aEventStatus [in/out] The status of aGUIEvent.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult HandleEventWithFrameForPresShell(nsIFrame* aFrameForPresShell,
|
|
|
|
WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
|
|
|
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
/**
|
Bug 1466208 - part 44: Rename PresShell::EventHandler::HandleEventInternal() to HandleEventWithCurrentEventInfo() r=smaug
In my understanding, `PresShell::EventHandler::HandleEvent()` may redirect
the event to another class or PresShell first. Otherwise, it computes
event target and sets current event info of mPresShell to it. Then, calls
`HandleEventInternal()` to dispatch the event. Then, `HandleEventInternal()`
may handle the event before dispatch, and/or prepare to dispatch, then,
finally dispatches the event and finalize the state of mPresShell and the
event. Therefore, `HandleEventInternal()` actually handles the event, but
the word, "internal" is not explicitly explain its different points from
`HandleEvent()`. Therefore, I think that `HandleEventWithCurrentEventInfo()`
is better name since `HandleEvent()` considers the current event info.
Differential Revision: https://phabricator.services.mozilla.com/D22462
--HG--
extra : moz-landing-system : lando
2019-03-12 07:25:13 +03:00
|
|
|
* HandleEventWithCurrentEventInfo() prepares to dispatch aEvent into the
|
|
|
|
* DOM, dispatches aEvent into the DOM with using current event info of
|
|
|
|
* mPresShell and notifies EventStateManager of that.
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
*
|
|
|
|
* @param aEvent Event to be dispatched.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aEvent.
|
|
|
|
* @param aIsHandlingNativeEvent true if aGUIEvent represents a native
|
|
|
|
* event.
|
|
|
|
* @param aOverrideClickTarget Override click event target.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1466208 - part 44: Rename PresShell::EventHandler::HandleEventInternal() to HandleEventWithCurrentEventInfo() r=smaug
In my understanding, `PresShell::EventHandler::HandleEvent()` may redirect
the event to another class or PresShell first. Otherwise, it computes
event target and sets current event info of mPresShell to it. Then, calls
`HandleEventInternal()` to dispatch the event. Then, `HandleEventInternal()`
may handle the event before dispatch, and/or prepare to dispatch, then,
finally dispatches the event and finalize the state of mPresShell and the
event. Therefore, `HandleEventInternal()` actually handles the event, but
the word, "internal" is not explicitly explain its different points from
`HandleEvent()`. Therefore, I think that `HandleEventWithCurrentEventInfo()`
is better name since `HandleEvent()` considers the current event info.
Differential Revision: https://phabricator.services.mozilla.com/D22462
--HG--
extra : moz-landing-system : lando
2019-03-12 07:25:13 +03:00
|
|
|
nsresult HandleEventWithCurrentEventInfo(WidgetEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
bool aIsHandlingNativeEvent,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
|
2019-03-07 09:30:08 +03:00
|
|
|
/**
|
|
|
|
* HandlingTimeAccumulator() may accumulate handling time of telemetry
|
|
|
|
* for each type of events.
|
|
|
|
*/
|
|
|
|
class MOZ_STACK_CLASS HandlingTimeAccumulator final {
|
|
|
|
public:
|
|
|
|
HandlingTimeAccumulator() = delete;
|
|
|
|
HandlingTimeAccumulator(const HandlingTimeAccumulator& aOther) = delete;
|
|
|
|
HandlingTimeAccumulator(const EventHandler& aEventHandler,
|
|
|
|
const WidgetEvent* aEvent);
|
|
|
|
~HandlingTimeAccumulator();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const EventHandler& mEventHandler;
|
|
|
|
const WidgetEvent* mEvent;
|
|
|
|
TimeStamp mHandlingStartTime;
|
|
|
|
};
|
|
|
|
|
2019-03-09 02:41:30 +03:00
|
|
|
/**
|
|
|
|
* RecordEventPreparationPerformance() records event preparation performance
|
2019-03-10 02:38:38 +03:00
|
|
|
* with telemetry only when aEvent is a trusted event.
|
2019-03-09 02:41:30 +03:00
|
|
|
*
|
|
|
|
* @param aEvent The handling event which we've finished
|
|
|
|
* preparing something to dispatch.
|
|
|
|
*/
|
|
|
|
void RecordEventPreparationPerformance(const WidgetEvent* aEvent);
|
|
|
|
|
2019-03-06 09:03:54 +03:00
|
|
|
/**
|
|
|
|
* RecordEventHandlingResponsePerformance() records event handling response
|
|
|
|
* performance with telemetry.
|
|
|
|
*
|
|
|
|
* @param aEvent The handled event.
|
|
|
|
*/
|
|
|
|
void RecordEventHandlingResponsePerformance(const WidgetEvent* aEvent);
|
|
|
|
|
2019-03-10 02:38:38 +03:00
|
|
|
/**
|
|
|
|
* PrepareToDispatchEvent() prepares to dispatch aEvent.
|
|
|
|
*
|
2019-03-26 13:04:43 +03:00
|
|
|
* @param aEvent The handling event.
|
2019-03-27 04:08:23 +03:00
|
|
|
* @param aEventStatus [in/out] The status of aEvent.
|
|
|
|
* @param aTouchIsNew [out] Set to true if the event is an
|
|
|
|
* eTouchMove event and it represents new
|
|
|
|
* touch. Otherwise, set to false.
|
2019-03-26 13:04:43 +03:00
|
|
|
* @return true if the caller can dispatch the
|
|
|
|
* event into the DOM.
|
2019-03-10 02:38:38 +03:00
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-03-27 04:08:23 +03:00
|
|
|
bool PrepareToDispatchEvent(WidgetEvent* aEvent,
|
2019-05-27 13:14:06 +03:00
|
|
|
nsEventStatus* aEventStatus, bool* aTouchIsNew);
|
2019-03-10 02:38:38 +03:00
|
|
|
|
2019-03-08 15:46:17 +03:00
|
|
|
/**
|
|
|
|
* MaybeHandleKeyboardEventBeforeDispatch() may handle aKeyboardEvent
|
|
|
|
* if it should do something before dispatched into the DOM.
|
|
|
|
*
|
|
|
|
* @param aKeyboardEvent The handling keyboard event.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void MaybeHandleKeyboardEventBeforeDispatch(
|
|
|
|
WidgetKeyboardEvent* aKeyboardEvent);
|
|
|
|
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03: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.
|
|
|
|
*/
|
2019-04-23 04:34:24 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
bool AdjustContextMenuKeyEvent(WidgetMouseEvent* aMouseEvent);
|
|
|
|
|
2019-04-23 04:34:24 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
bool PrepareToUseCaretPosition(nsIWidget* aEventWidget,
|
|
|
|
LayoutDeviceIntPoint& aTargetPt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the selected item and coordinates in device pixels relative to root
|
|
|
|
* document's root view for element, first ensuring the element is onscreen.
|
|
|
|
*/
|
2019-04-23 04:34:24 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
void GetCurrentItemAndPositionForElement(dom::Element* aFocusedElement,
|
|
|
|
nsIContent** aTargetToUse,
|
|
|
|
LayoutDeviceIntPoint& aTargetPt,
|
|
|
|
nsIWidget* aRootWidget);
|
|
|
|
|
|
|
|
nsIContent* GetOverrideClickTarget(WidgetGUIEvent* aGUIEvent,
|
|
|
|
nsIFrame* aFrame);
|
|
|
|
|
2019-03-10 02:39:16 +03:00
|
|
|
/**
|
|
|
|
* DispatchEvent() tries to dispatch aEvent and notifies aEventStateManager
|
|
|
|
* of doing it.
|
|
|
|
*
|
|
|
|
* @param aEventStateManager EventStateManager which should handle
|
|
|
|
* the event before/after dispatching
|
|
|
|
* aEvent into the DOM.
|
|
|
|
* @param aEvent The handling event.
|
|
|
|
* @param aTouchIsNew Set this to true when the message is
|
|
|
|
* eTouchMove and it's newly touched.
|
|
|
|
* Then, the "touchmove" event becomes
|
|
|
|
* cancelable.
|
|
|
|
* @param aEventStatus [in/out] The status of aEvent.
|
|
|
|
* @param aOverrideClickTarget Override click event target.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult DispatchEvent(EventStateManager* aEventStateManager,
|
|
|
|
WidgetEvent* aEvent, bool aTouchIsNew,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
|
|
|
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
/**
|
|
|
|
* DispatchEventToDOM() actually dispatches aEvent into the DOM tree.
|
|
|
|
*
|
|
|
|
* @param aEvent Event to be dispatched into the DOM tree.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aEvent.
|
|
|
|
* @param aEventCB The callback kicked when the event moves
|
|
|
|
* from the default group to the system group.
|
|
|
|
*/
|
|
|
|
nsresult DispatchEventToDOM(WidgetEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
nsPresShellEventCB* aEventCB);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DispatchTouchEventToDOM() dispatches touch events into the DOM tree.
|
|
|
|
*
|
|
|
|
* @param aEvent The source of events to be dispatched into the
|
|
|
|
* DOM tree.
|
|
|
|
* @param aEventStatus [in/out] EventStatus of aEvent.
|
|
|
|
* @param aEventCB The callback kicked when the events move
|
|
|
|
* from the default group to the system group.
|
|
|
|
* @param aTouchIsNew Set this to true when the message is eTouchMove
|
|
|
|
* and it's newly touched. Then, the "touchmove"
|
|
|
|
* event becomes cancelable.
|
|
|
|
*/
|
|
|
|
void DispatchTouchEventToDOM(WidgetEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
nsPresShellEventCB* aEventCB,
|
|
|
|
bool aTouchIsNew);
|
|
|
|
|
2019-03-11 04:52:40 +03:00
|
|
|
/**
|
|
|
|
* FinalizeHandlingEvent() should be called after calling DispatchEvent()
|
|
|
|
* and then, this cleans up the state of mPresShell and aEvent.
|
|
|
|
*
|
|
|
|
* @param aEvent The handled event.
|
|
|
|
*/
|
|
|
|
void FinalizeHandlingEvent(WidgetEvent* aEvent);
|
|
|
|
|
2019-03-04 09:12:22 +03:00
|
|
|
/**
|
|
|
|
* AutoCurrentEventInfoSetter() pushes and pops current event info of
|
|
|
|
* aEventHandler.mPresShell.
|
|
|
|
*/
|
|
|
|
struct MOZ_STACK_CLASS AutoCurrentEventInfoSetter final {
|
|
|
|
explicit AutoCurrentEventInfoSetter(EventHandler& aEventHandler)
|
|
|
|
: mEventHandler(aEventHandler) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mEventHandler.mCurrentEventInfoSetter);
|
|
|
|
mEventHandler.mCurrentEventInfoSetter = this;
|
|
|
|
mEventHandler.mPresShell->PushCurrentEventInfo(nullptr, nullptr);
|
|
|
|
}
|
|
|
|
AutoCurrentEventInfoSetter(EventHandler& aEventHandler, nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent)
|
|
|
|
: mEventHandler(aEventHandler) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mEventHandler.mCurrentEventInfoSetter);
|
|
|
|
mEventHandler.mCurrentEventInfoSetter = this;
|
|
|
|
mEventHandler.mPresShell->PushCurrentEventInfo(aFrame, aContent);
|
|
|
|
}
|
|
|
|
AutoCurrentEventInfoSetter(EventHandler& aEventHandler,
|
|
|
|
EventTargetData& aEventTargetData)
|
|
|
|
: mEventHandler(aEventHandler) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mEventHandler.mCurrentEventInfoSetter);
|
|
|
|
mEventHandler.mCurrentEventInfoSetter = this;
|
|
|
|
mEventHandler.mPresShell->PushCurrentEventInfo(
|
|
|
|
aEventTargetData.mFrame, aEventTargetData.mContent);
|
|
|
|
}
|
|
|
|
~AutoCurrentEventInfoSetter() {
|
|
|
|
mEventHandler.mPresShell->PopCurrentEventInfo();
|
|
|
|
mEventHandler.mCurrentEventInfoSetter = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
EventHandler& mEventHandler;
|
|
|
|
};
|
|
|
|
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
/**
|
|
|
|
* Wrapper methods to access methods of mPresShell.
|
|
|
|
*/
|
|
|
|
nsPresContext* GetPresContext() const {
|
|
|
|
return mPresShell->GetPresContext();
|
|
|
|
}
|
|
|
|
Document* GetDocument() const { return mPresShell->GetDocument(); }
|
|
|
|
nsCSSFrameConstructor* FrameConstructor() const {
|
|
|
|
return mPresShell->FrameConstructor();
|
|
|
|
}
|
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetFocusedDOMWindowInOurWindow() {
|
|
|
|
return mPresShell->GetFocusedDOMWindowInOurWindow();
|
|
|
|
}
|
2019-04-13 04:03:13 +03:00
|
|
|
already_AddRefed<PresShell> GetParentPresShellForEventHandling() {
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
return mPresShell->GetParentPresShellForEventHandling();
|
|
|
|
}
|
|
|
|
void PushDelayedEventIntoQueue(UniquePtr<DelayedEvent>&& aDelayedEvent) {
|
|
|
|
mPresShell->mDelayedEvents.AppendElement(std::move(aDelayedEvent));
|
|
|
|
}
|
|
|
|
|
|
|
|
OwningNonNull<PresShell> mPresShell;
|
2019-03-04 09:12:22 +03:00
|
|
|
AutoCurrentEventInfoSetter* mCurrentEventInfoSetter;
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
static TimeStamp sLastInputCreated;
|
|
|
|
static TimeStamp sLastInputProcessed;
|
2019-03-29 18:11:22 +03:00
|
|
|
static StaticRefPtr<dom::Element> sLastKeyDownEventTargetElement;
|
Bug 1466208 - part 1: Create stack class to handle events in PresShell r=smaug
PresShell::HandleEvent() and PresShell::HandleEventInternal() are too big.
Additionally, we have a lot of methods used only by them. So, if we'll
split those big methods, PresShell will have a lot of small methods which
are not grouped as a part of event handling. That's too bad because some
of them may depend on the calling order, etc.
So, for grouping them, PresShell should create a stack class instance to handle
each event. Then, we can store shared information in it only while we're
handling an event.
This patch creates PresShell::EventHandler and PresShell methods become
wrappers of the stack class, but this patch does not change any logic in the
code, i.e., just reorganizing existing methods.
Note that HandleEventWithTarget() and HandleEventInternal() need to take
WidgetEvent rather than WidgetGUIEvent. Additionally, some other methods
require WidgetGUIEvent to refer WidgetGUIEvent::mWidget. Therefore, this
patch does not make the new class store the event as a member.
Differential Revision: https://phabricator.services.mozilla.com/D16951
--HG--
extra : moz-landing-system : lando
2019-01-29 09:04:05 +03:00
|
|
|
};
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2012-05-16 21:32:40 +04:00
|
|
|
PresShell* GetRootPresShell();
|
|
|
|
|
|
|
|
nscolor GetDefaultBackgroundColorToDraw();
|
|
|
|
|
|
|
|
// The callback for the mPaintSuppressionTimer timer.
|
|
|
|
static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell);
|
|
|
|
|
2016-03-26 00:49:43 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Approximate frame visibility tracking implementation.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void UpdateApproximateFrameVisibility();
|
|
|
|
void DoUpdateApproximateFrameVisibility(bool aRemoveOnly);
|
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
void ClearApproximatelyVisibleFramesList(
|
|
|
|
const Maybe<OnNonvisible>& aNonvisibleAction = Nothing());
|
2016-09-12 08:19:08 +03:00
|
|
|
static void ClearApproximateFrameVisibilityVisited(nsView* aView,
|
|
|
|
bool aClear);
|
2018-03-12 21:17:34 +03:00
|
|
|
static void MarkFramesInListApproximatelyVisible(const nsDisplayList& aList);
|
2016-03-26 00:49:43 +03:00
|
|
|
void MarkFramesInSubtreeApproximatelyVisible(nsIFrame* aFrame,
|
|
|
|
const nsRect& aRect,
|
|
|
|
bool aRemoveOnly = false);
|
2013-02-25 04:59:22 +04:00
|
|
|
|
2016-09-12 08:19:08 +03:00
|
|
|
void DecApproximateVisibleCount(
|
|
|
|
VisibleFrames& aFrames,
|
2017-02-13 20:07:40 +03:00
|
|
|
const Maybe<OnNonvisible>& aNonvisibleAction = Nothing());
|
2016-04-21 11:21:58 +03:00
|
|
|
|
2016-03-26 00:49:43 +03:00
|
|
|
nsRevocableEventPtr<nsRunnableMethod<PresShell>>
|
|
|
|
mUpdateApproximateFrameVisibilityEvent;
|
|
|
|
|
2016-07-26 21:48:00 +03: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-26 00:49:43 +03:00
|
|
|
|
2018-12-05 19:29:18 +03:00
|
|
|
nsresult SetResolutionImpl(float aResolution, bool aScaleToResolution,
|
|
|
|
nsAtom* aOrigin);
|
2015-01-03 04:06:14 +03:00
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY bool VerifyIncrementalReflow();
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void DoVerifyReflow();
|
|
|
|
void VerifyHasDirtyRootAncestor(nsIFrame* aFrame);
|
|
|
|
void ShowEventTargetDebug();
|
|
|
|
|
|
|
|
bool mInVerifyReflow = false;
|
|
|
|
// The reflow root under which we're currently reflowing. Null when
|
|
|
|
// not in reflow.
|
|
|
|
nsIFrame* mCurrentReflowRoot = nullptr;
|
|
|
|
|
|
|
|
nsIFrame* mDrawEventTargetFrame = nullptr;
|
|
|
|
#endif // #ifdef DEBUG
|
|
|
|
|
2019-11-01 07:33:48 +03:00
|
|
|
// Send, and reset, the current per tick telemetry. This includes:
|
|
|
|
// * non-zero number of style and layout flushes
|
|
|
|
// * non-zero ms duration spent in style and reflow since the last tick.
|
|
|
|
void PingPerTickTelemetry(FlushType aFlushType);
|
2019-08-21 04:43:30 +03:00
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
private:
|
|
|
|
// IMPORTANT: The ownership implicit in the following member variables
|
|
|
|
// has been explicitly checked. If you add any members to this class,
|
|
|
|
// please make the ownership explicit (pinkerton, scc).
|
|
|
|
|
|
|
|
// These are the same Document and PresContext owned by the DocViewer.
|
|
|
|
// we must share ownership.
|
2019-12-11 15:18:33 +03:00
|
|
|
// mDocument and mPresContext should've never been cleared nor swapped with
|
|
|
|
// another instance while PresShell instance is alive so that it's safe to
|
|
|
|
// call their can-run- script methods without local RefPtr variables.
|
2019-12-11 15:18:00 +03:00
|
|
|
RefPtr<Document> const mDocument;
|
2019-12-11 15:18:33 +03:00
|
|
|
RefPtr<nsPresContext> const mPresContext;
|
2019-05-01 05:28:25 +03:00
|
|
|
// The document's style set owns it but we maintain a ref, may be null.
|
|
|
|
RefPtr<StyleSheet> mPrefStyleSheet;
|
|
|
|
UniquePtr<nsCSSFrameConstructor> mFrameConstructor;
|
|
|
|
nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
|
|
|
|
RefPtr<nsFrameSelection> mSelection;
|
|
|
|
RefPtr<nsCaret> mCaret;
|
|
|
|
RefPtr<nsCaret> mOriginalCaret;
|
|
|
|
RefPtr<AccessibleCaretEventHub> mAccessibleCaretEventHub;
|
|
|
|
// Pointer into mFrameConstructor - this is purely so that GetRootFrame() can
|
|
|
|
// be inlined:
|
|
|
|
nsFrameManager* mFrameManager;
|
|
|
|
WeakPtr<nsDocShell> mForwardingContainer;
|
|
|
|
|
|
|
|
// The `performance.now()` value when we last started to process reflows.
|
|
|
|
DOMHighResTimeStamp mLastReflowStart{0.0};
|
|
|
|
|
|
|
|
// At least on Win32 and Mac after interupting a reflow we need to post
|
|
|
|
// the resume reflow event off a timer to avoid event starvation because
|
|
|
|
// posted messages are processed before other messages when the modal
|
|
|
|
// moving/sizing loop is running, see bug 491700 for details.
|
|
|
|
nsCOMPtr<nsITimer> mReflowContinueTimer;
|
|
|
|
|
|
|
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
|
|
|
// We track allocated pointers in a debug-only hashtable to assert against
|
|
|
|
// missing/double frees.
|
|
|
|
nsTHashtable<nsPtrHashKey<void>> mAllocatedPointers;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// A list of stack weak frames. This is a pointer to the last item in the
|
|
|
|
// list.
|
|
|
|
AutoWeakFrame* mAutoWeakFrames;
|
|
|
|
|
|
|
|
// A hash table of heap allocated weak frames.
|
|
|
|
nsTHashtable<nsPtrHashKey<WeakFrame>> mWeakFrames;
|
|
|
|
|
|
|
|
class DirtyRootsList {
|
|
|
|
public:
|
|
|
|
// Add a dirty root.
|
|
|
|
void Add(nsIFrame* aFrame);
|
|
|
|
// Remove this frame if present.
|
|
|
|
void Remove(nsIFrame* aFrame);
|
|
|
|
// Remove and return one of the shallowest dirty roots from the list.
|
|
|
|
// (If two roots are at the same depth, order is indeterminate.)
|
|
|
|
nsIFrame* PopShallowestRoot();
|
|
|
|
// Remove all dirty roots.
|
|
|
|
void Clear();
|
|
|
|
// Is this frame one of the dirty roots?
|
|
|
|
bool Contains(nsIFrame* aFrame) const;
|
|
|
|
// Are there no dirty roots?
|
|
|
|
bool IsEmpty() const;
|
|
|
|
// Is the given frame an ancestor of any dirty root?
|
|
|
|
bool FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct FrameAndDepth {
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
const uint32_t mDepth;
|
|
|
|
|
|
|
|
// Easy conversion to nsIFrame*, as it's the most likely need.
|
|
|
|
operator nsIFrame*() const { return mFrame; }
|
|
|
|
|
|
|
|
// Used to sort by reverse depths, i.e., deeper < shallower.
|
|
|
|
class CompareByReverseDepth {
|
|
|
|
public:
|
|
|
|
bool Equals(const FrameAndDepth& aA, const FrameAndDepth& aB) const {
|
|
|
|
return aA.mDepth == aB.mDepth;
|
|
|
|
}
|
|
|
|
bool LessThan(const FrameAndDepth& aA, const FrameAndDepth& aB) const {
|
|
|
|
// Reverse depth! So '>' instead of '<'.
|
|
|
|
return aA.mDepth > aB.mDepth;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// List of all known dirty roots, sorted by decreasing depths.
|
|
|
|
nsTArray<FrameAndDepth> mList;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Reflow roots that need to be reflowed.
|
|
|
|
DirtyRootsList mDirtyRoots;
|
|
|
|
|
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
// These two fields capture call stacks of any changes that require a restyle
|
|
|
|
// or a reflow. Only the first change per restyle / reflow is recorded (the
|
|
|
|
// one that caused a call to SetNeedStyleFlush() / SetNeedLayoutFlush()).
|
|
|
|
UniqueProfilerBacktrace mStyleCause;
|
|
|
|
UniqueProfilerBacktrace mReflowCause;
|
|
|
|
#endif
|
2012-01-10 09:23:29 +04:00
|
|
|
|
2018-11-15 10:40:52 +03:00
|
|
|
nsTArray<UniquePtr<DelayedEvent>> mDelayedEvents;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-09-09 23:50:21 +04:00
|
|
|
nsRevocableEventPtr<nsSynthMouseMoveEvent> mSynthMouseMoveEvent;
|
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
TouchManager mTouchManager;
|
2015-02-20 10:12:00 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ZoomConstraintsClient> mZoomConstraintsClient;
|
2019-04-05 01:11:40 +03:00
|
|
|
RefPtr<GeckoMVMContext> mMVMContext;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MobileViewportManager> mMobileViewportManager;
|
2015-06-17 19:32:42 +03:00
|
|
|
|
2012-05-16 21:32:40 +04: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 14:13:17 +03:00
|
|
|
nsCOMPtr<nsITimer> mPaintSuppressionTimer;
|
2011-09-09 23:50:21 +04:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
nsCOMPtr<nsITimer> mDelayedPaintTimer;
|
2014-01-30 09:41:17 +04:00
|
|
|
|
2015-04-14 18:46:39 +03: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 14:13:17 +03:00
|
|
|
nsCOMPtr<nsIContent> mPointerEventTarget;
|
2015-04-14 18:46:39 +03:00
|
|
|
|
2019-04-23 04:27:47 +03:00
|
|
|
nsCOMPtr<nsIContent> mLastAnchorScrolledTo;
|
2018-06-26 00:42:25 +03:00
|
|
|
|
2019-04-23 04:34:26 +03: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 processing
|
|
|
|
// all our dirty roots. mContentToScrollTo has a content property storing the
|
|
|
|
// details for the scroll operation, see ScrollIntoViewData above.
|
|
|
|
nsCOMPtr<nsIContent> mContentToScrollTo;
|
|
|
|
|
2019-04-30 10:53:20 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
a11y::DocAccessible* mDocAccessible;
|
|
|
|
#endif // #ifdef ACCESSIBILITY
|
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
nsIFrame* mCurrentEventFrame;
|
|
|
|
nsCOMPtr<nsIContent> mCurrentEventContent;
|
|
|
|
nsTArray<nsIFrame*> mCurrentEventFrameStack;
|
|
|
|
nsCOMArray<nsIContent> mCurrentEventContentStack;
|
|
|
|
// Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
|
|
|
|
// we finish reflowing mCurrentReflowRoot.
|
|
|
|
nsTHashtable<nsPtrHashKey<nsIFrame>> mFramesToDirty;
|
|
|
|
nsTHashtable<nsPtrHashKey<nsIScrollableFrame>> mPendingScrollAnchorSelection;
|
|
|
|
nsTHashtable<nsPtrHashKey<nsIScrollableFrame>> mPendingScrollAnchorAdjustment;
|
|
|
|
|
|
|
|
nsCallbackEventRequest* mFirstCallbackEventRequest = nullptr;
|
|
|
|
nsCallbackEventRequest* mLastCallbackEventRequest = nullptr;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
nsPoint mMouseLocation;
|
|
|
|
// 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.
|
|
|
|
layers::ScrollableLayerGuid mMouseEventTargetGuid;
|
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
nsSize mVisualViewportSize;
|
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
// The focus information needed for async keyboard scrolling
|
|
|
|
FocusTarget mAPZFocusTarget;
|
|
|
|
|
2019-07-02 05:46:09 +03:00
|
|
|
using Arena = nsPresArena<8192, ArenaObjectID, eArenaObjectID_COUNT>;
|
|
|
|
Arena mFrameArena;
|
2019-05-01 05:28:25 +03:00
|
|
|
|
2019-05-01 05:27:53 +03:00
|
|
|
Maybe<nsPoint> mVisualViewportOffset;
|
|
|
|
|
|
|
|
// A pending visual scroll offset that we will ask APZ to scroll to
|
|
|
|
// during the next transaction. Cleared when we send the transaction.
|
|
|
|
// Only applicable to the RCD pres shell.
|
|
|
|
Maybe<VisualScrollUpdate> mPendingVisualScrollUpdate;
|
2019-04-30 04:52:53 +03:00
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
// Used to force allocation and rendering of proportionally more or
|
|
|
|
// less pixels in both dimensions.
|
|
|
|
Maybe<float> mResolution;
|
|
|
|
|
|
|
|
TimeStamp mLoadBegin; // used to time loads
|
|
|
|
|
2019-04-30 03:26:57 +03:00
|
|
|
TimeStamp mLastOSWake;
|
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
// Count of the number of times this presshell has been painted to a window.
|
|
|
|
uint64_t mPaintCount;
|
|
|
|
|
2017-06-28 22:11:04 +03:00
|
|
|
// The focus sequence number of the last processed input event
|
2018-03-07 14:13:17 +03:00
|
|
|
uint64_t mAPZFocusSequenceNumber;
|
2017-06-28 22:11:04 +03:00
|
|
|
|
2019-04-23 04:27:47 +03:00
|
|
|
nscoord mLastAnchorScrollPositionY = 0;
|
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
// Most recent canvas background color.
|
|
|
|
nscolor mCanvasBackgroundColor;
|
|
|
|
|
2019-04-23 04:27:47 +03:00
|
|
|
int32_t mActiveSuppressDisplayport;
|
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
uint32_t mPresShellId;
|
|
|
|
|
|
|
|
// Cached font inflation values. This is done to prevent changing of font
|
|
|
|
// inflation until a page is reloaded.
|
|
|
|
uint32_t mFontSizeInflationEmPerLine;
|
|
|
|
uint32_t mFontSizeInflationMinTwips;
|
|
|
|
uint32_t mFontSizeInflationLineThreshold;
|
|
|
|
|
|
|
|
int16_t mSelectionFlags;
|
|
|
|
|
|
|
|
// This is used to protect ourselves from triggering reflow while in the
|
|
|
|
// middle of frame construction and the like... it really shouldn't be
|
|
|
|
// needed, one hopes, but it is for now.
|
|
|
|
uint16_t mChangeNestCount;
|
|
|
|
|
|
|
|
// Flags controlling how our document is rendered. These persist
|
|
|
|
// between paints and so are tied with retained layer pixels.
|
|
|
|
// PresShell flushes retained layers when the rendering state
|
|
|
|
// changes in a way that prevents us from being able to (usefully)
|
|
|
|
// re-use old pixels.
|
|
|
|
RenderingStateFlags mRenderingStateFlags;
|
|
|
|
|
|
|
|
// Whether we're currently under a FlushPendingNotifications.
|
|
|
|
// This is used to handle flush reentry correctly.
|
|
|
|
// NOTE: This can't be a bitfield since AutoRestore has a reference to this
|
|
|
|
// variable.
|
|
|
|
bool mInFlush;
|
|
|
|
|
|
|
|
bool mCaretEnabled : 1;
|
|
|
|
|
2019-04-30 04:52:53 +03:00
|
|
|
// True if a layout flush might not be a no-op
|
|
|
|
bool mNeedLayoutFlush : 1;
|
|
|
|
|
|
|
|
// True if a style flush might not be a no-op
|
|
|
|
bool mNeedStyleFlush : 1;
|
|
|
|
|
|
|
|
// True if there are throttled animations that would be processed when
|
|
|
|
// performing a flush with mFlushAnimations == true.
|
|
|
|
bool mNeedThrottledAnimationFlush : 1;
|
|
|
|
|
|
|
|
bool mVisualViewportSizeSet : 1;
|
|
|
|
|
2019-05-01 05:28:25 +03:00
|
|
|
bool mDidInitialize : 1;
|
|
|
|
bool mIsDestroying : 1;
|
|
|
|
bool mIsReflowing : 1;
|
|
|
|
bool mIsObservingDocument : 1;
|
|
|
|
|
|
|
|
// Whether we shouldn't ever get to FlushPendingNotifications. This flag is
|
|
|
|
// meant only to sanity-check / assert that FlushPendingNotifications doesn't
|
|
|
|
// happen during certain periods of time. It shouldn't be made public nor used
|
|
|
|
// for other purposes.
|
|
|
|
bool mForbiddenToFlush : 1;
|
|
|
|
|
|
|
|
// We've been disconnected from the document. We will refuse to paint the
|
|
|
|
// document until either our timer fires or all frames are constructed.
|
|
|
|
bool mIsDocumentGone : 1;
|
|
|
|
bool mHaveShutDown : 1;
|
|
|
|
|
|
|
|
// For all documents we initially lock down painting.
|
|
|
|
bool mPaintingSuppressed : 1;
|
|
|
|
|
|
|
|
bool mLastRootReflowHadUnconstrainedBSize : 1;
|
|
|
|
|
|
|
|
// Indicates that it is safe to unlock painting once all pending reflows
|
|
|
|
// have been processed.
|
|
|
|
bool mShouldUnsuppressPainting : 1;
|
|
|
|
|
|
|
|
bool mIgnoreFrameDestruction : 1;
|
|
|
|
|
|
|
|
bool mIsActive : 1;
|
|
|
|
bool mFrozen : 1;
|
|
|
|
bool mIsFirstPaint : 1;
|
|
|
|
bool mObservesMutationsForPrint : 1;
|
|
|
|
|
|
|
|
// Whether the most recent interruptible reflow was actually interrupted:
|
|
|
|
bool mWasLastReflowInterrupted : 1;
|
|
|
|
|
|
|
|
// True if we're observing the refresh driver for style flushes.
|
|
|
|
bool mObservingStyleFlushes : 1;
|
|
|
|
|
|
|
|
// True if we're observing the refresh driver for layout flushes, that is, if
|
|
|
|
// we have a reflow scheduled.
|
|
|
|
//
|
|
|
|
// Guaranteed to be false if mReflowContinueTimer is non-null.
|
|
|
|
bool mObservingLayoutFlushes : 1;
|
|
|
|
|
|
|
|
bool mResizeEventPending : 1;
|
|
|
|
|
|
|
|
bool mFontSizeInflationForceEnabled : 1;
|
|
|
|
bool mFontSizeInflationDisabledInMasterProcess : 1;
|
|
|
|
bool mFontSizeInflationEnabled : 1;
|
|
|
|
|
|
|
|
bool mPaintingIsFrozen : 1;
|
|
|
|
|
|
|
|
// If a document belongs to an invisible DocShell, this flag must be set
|
|
|
|
// to true, so we can avoid any paint calls for widget related to this
|
|
|
|
// presshell.
|
|
|
|
bool mIsNeverPainting : 1;
|
|
|
|
|
|
|
|
// Whether the most recent change to the pres shell resolution was
|
|
|
|
// originated by the main thread.
|
|
|
|
bool mResolutionUpdated : 1;
|
|
|
|
|
|
|
|
// True if the resolution has been ever changed by APZ.
|
|
|
|
bool mResolutionUpdatedByApz : 1;
|
|
|
|
|
2019-05-10 14:15:43 +03:00
|
|
|
// Whether this presshell is hidden by 'vibility:hidden' on an ancestor
|
|
|
|
// nsSubDocumentFrame.
|
|
|
|
bool mUnderHiddenEmbedderElement : 1;
|
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mDocumentLoading : 1;
|
|
|
|
bool mNoDelayedMouseEvents : 1;
|
|
|
|
bool mNoDelayedKeyEvents : 1;
|
2012-05-16 21:32:40 +04:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mApproximateFrameVisibilityVisited : 1;
|
2013-02-25 04:59:22 +04:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mNextPaintCompressed : 1;
|
2014-01-30 09:41:17 +04:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mHasCSSBackgroundColor : 1;
|
2014-09-23 21:50:00 +04:00
|
|
|
|
2015-01-21 04:16:04 +03:00
|
|
|
// Whether the last chrome-only escape key event is consumed.
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mIsLastChromeOnlyEscapeKeyConsumed : 1;
|
2015-01-21 04:16:04 +03:00
|
|
|
|
2015-06-18 23:42:39 +03:00
|
|
|
// Whether the widget has received a paint message yet.
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mHasReceivedPaintMessage : 1;
|
2015-06-18 23:42:39 +03:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mIsLastKeyDownCanceled : 1;
|
2017-02-03 13:16:00 +03:00
|
|
|
|
2017-11-22 01:25:09 +03:00
|
|
|
// Whether we have ever handled a user input event
|
2018-03-07 14:13:17 +03:00
|
|
|
bool mHasHandledUserInput : 1;
|
2017-11-22 01:25:09 +03:00
|
|
|
|
2018-03-23 06:06:55 +03:00
|
|
|
// Whether we should dispatch keypress events even for non-printable keys
|
|
|
|
// for keeping backward compatibility.
|
|
|
|
bool mForceDispatchKeyPressEventsForNonPrintableKeys : 1;
|
2018-11-07 09:39:10 +03: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 06:06:55 +03:00
|
|
|
|
2019-04-18 15:57:37 +03:00
|
|
|
// Whether we should dispatch click events for non-primary mouse buttons.
|
|
|
|
bool mForceUseLegacyNonPrimaryDispatch : 1;
|
|
|
|
// Whether mForceUseLegacyNonPrimaryDispatch is initialised.
|
|
|
|
bool mInitializedWithClickEventDispatchingBlacklist : 1;
|
|
|
|
|
2019-04-30 03:26:57 +03:00
|
|
|
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;
|
2017-04-19 18:17:20 +03:00
|
|
|
|
2019-04-30 03:26:57 +03:00
|
|
|
static bool sDisableNonTestMouseEvents;
|
2017-04-19 22:53:30 +03:00
|
|
|
|
2018-03-07 14:13:17 +03:00
|
|
|
static bool sProcessInteractable;
|
2019-08-21 04:43:30 +03:00
|
|
|
|
2019-11-01 07:33:48 +03:00
|
|
|
layout_telemetry::Data mLayoutTelemetry;
|
2011-09-09 23:50:21 +04:00
|
|
|
};
|
|
|
|
|
2019-04-30 03:56:14 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(PresShell, NS_PRESSHELL_IID)
|
|
|
|
|
2016-11-30 06:14:27 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2016-11-30 06:14:28 +03:00
|
|
|
#endif // mozilla_PresShell_h
|