зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1614208 - Stop including PresShell.h and nsPresContext.h from Element.h. r=smaug
nsPresContext.h is only used for unit conversion, which can be done by Units.h in a similar fashion. PresShell.h was needed for some capturing-content stuff which can be moved out of line. Differential Revision: https://phabricator.services.mozilla.com/D62170 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6615ff9fad
Коммит
b997cfcaf4
|
@ -26,6 +26,7 @@
|
|||
#include "mozilla/dom/MutationObservers.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "mozilla/dom/nsCSPContext.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
|
@ -3106,6 +3107,31 @@ static const char* GetFullscreenError(CallerType aCallerType,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void Element::SetCapture(bool aRetargetToElement) {
|
||||
// If there is already an active capture, ignore this request. This would
|
||||
// occur if a splitter, frame resizer, etc had already captured and we don't
|
||||
// want to override those.
|
||||
if (!PresShell::GetCapturingContent()) {
|
||||
PresShell::SetCapturingContent(
|
||||
this, CaptureFlags::PreventDragStart |
|
||||
(aRetargetToElement ? CaptureFlags::RetargetToElement
|
||||
: CaptureFlags::None));
|
||||
}
|
||||
}
|
||||
|
||||
void Element::SetCaptureAlways(bool aRetargetToElement) {
|
||||
PresShell::SetCapturingContent(
|
||||
this, CaptureFlags::PreventDragStart | CaptureFlags::IgnoreAllowedState |
|
||||
(aRetargetToElement ? CaptureFlags::RetargetToElement
|
||||
: CaptureFlags::None));
|
||||
}
|
||||
|
||||
void Element::ReleaseCapture() {
|
||||
if (PresShell::GetCapturingContent() == this) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> Element::RequestFullscreen(CallerType aCallerType,
|
||||
ErrorResult& aRv) {
|
||||
auto request = FullscreenRequest::Create(this, aCallerType, aRv);
|
||||
|
|
|
@ -21,14 +21,12 @@
|
|||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsINodeList.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "Units.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/FlushType.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/PseudoStyleType.h"
|
||||
#include "mozilla/RustCell.h"
|
||||
#include "mozilla/SMILAttr.h"
|
||||
|
@ -1171,31 +1169,11 @@ class Element : public FragmentOrElement {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
void SetCapture(bool aRetargetToElement) {
|
||||
// If there is already an active capture, ignore this request. This would
|
||||
// occur if a splitter, frame resizer, etc had already captured and we don't
|
||||
// want to override those.
|
||||
if (!PresShell::GetCapturingContent()) {
|
||||
PresShell::SetCapturingContent(
|
||||
this, CaptureFlags::PreventDragStart |
|
||||
(aRetargetToElement ? CaptureFlags::RetargetToElement
|
||||
: CaptureFlags::None));
|
||||
}
|
||||
}
|
||||
void SetCapture(bool aRetargetToElement);
|
||||
|
||||
void SetCaptureAlways(bool aRetargetToElement) {
|
||||
PresShell::SetCapturingContent(
|
||||
this, CaptureFlags::PreventDragStart |
|
||||
CaptureFlags::IgnoreAllowedState |
|
||||
(aRetargetToElement ? CaptureFlags::RetargetToElement
|
||||
: CaptureFlags::None));
|
||||
}
|
||||
void SetCaptureAlways(bool aRetargetToElement);
|
||||
|
||||
void ReleaseCapture() {
|
||||
if (PresShell::GetCapturingContent() == this) {
|
||||
PresShell::ReleaseCapturingContent();
|
||||
}
|
||||
}
|
||||
void ReleaseCapture();
|
||||
|
||||
already_AddRefed<Promise> RequestFullscreen(CallerType, ErrorResult&);
|
||||
void RequestPointerLock(CallerType aCallerType);
|
||||
|
@ -1266,48 +1244,52 @@ class Element : public FragmentOrElement {
|
|||
MOZ_CAN_RUN_SCRIPT int32_t ScrollHeight();
|
||||
MOZ_CAN_RUN_SCRIPT void MozScrollSnap();
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ClientTop() {
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().y);
|
||||
return CSSPixel::FromAppUnits(GetClientAreaRect().y).Rounded();
|
||||
}
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ClientLeft() {
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().x);
|
||||
return CSSPixel::FromAppUnits(GetClientAreaRect().x).Rounded();
|
||||
}
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ClientWidth() {
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().Width());
|
||||
return CSSPixel::FromAppUnits(GetClientAreaRect().Width()).Rounded();
|
||||
}
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ClientHeight() {
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().Height());
|
||||
return CSSPixel::FromAppUnits(GetClientAreaRect().Height()).Rounded();
|
||||
}
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ScrollTopMin() {
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
return sf ? nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().y)
|
||||
: 0;
|
||||
if (!sf) {
|
||||
return 0;
|
||||
}
|
||||
return CSSPixel::FromAppUnits(sf->GetScrollRange().y).Rounded();
|
||||
}
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ScrollTopMax() {
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
return sf ? nsPresContext::AppUnitsToIntCSSPixels(
|
||||
sf->GetScrollRange().YMost())
|
||||
: 0;
|
||||
if (!sf) {
|
||||
return 0;
|
||||
}
|
||||
return CSSPixel::FromAppUnits(sf->GetScrollRange().YMost()).Rounded();
|
||||
}
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ScrollLeftMin() {
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
return sf ? nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().x)
|
||||
: 0;
|
||||
if (!sf) {
|
||||
return 0;
|
||||
}
|
||||
return CSSPixel::FromAppUnits(sf->GetScrollRange().x).Rounded();
|
||||
}
|
||||
MOZ_CAN_RUN_SCRIPT int32_t ScrollLeftMax() {
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
return sf ? nsPresContext::AppUnitsToIntCSSPixels(
|
||||
sf->GetScrollRange().XMost())
|
||||
: 0;
|
||||
if (!sf) {
|
||||
return 0;
|
||||
}
|
||||
return CSSPixel::FromAppUnits(sf->GetScrollRange().XMost()).Rounded();
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT double ClientHeightDouble() {
|
||||
return nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
GetClientAreaRect().Height());
|
||||
return CSSPixel::FromAppUnits(GetClientAreaRect().Height());
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT double ClientWidthDouble() {
|
||||
return nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
GetClientAreaRect().Width());
|
||||
return CSSPixel::FromAppUnits(GetClientAreaRect().Width());
|
||||
}
|
||||
|
||||
// This function will return the block size of first line box, no matter if
|
||||
|
|
|
@ -460,14 +460,13 @@ void HTMLCanvasElement::AfterMaybeChangeAttr(int32_t aNamespaceID,
|
|||
}
|
||||
}
|
||||
|
||||
void HTMLCanvasElement::HandlePrintCallback(
|
||||
nsPresContext::nsPresContextType aType) {
|
||||
void HTMLCanvasElement::HandlePrintCallback(nsPresContext* aPresContext) {
|
||||
// Only call the print callback here if 1) we're in a print testing mode or
|
||||
// print preview mode, 2) the canvas has a print callback and 3) the callback
|
||||
// hasn't already been called. For real printing the callback is handled in
|
||||
// nsSimplePageSequenceFrame::PrePrintNextPage.
|
||||
if ((aType == nsPresContext::eContext_PageLayout ||
|
||||
aType == nsPresContext::eContext_PrintPreview) &&
|
||||
if ((aPresContext->Type() == nsPresContext::eContext_PageLayout ||
|
||||
aPresContext->Type() == nsPresContext::eContext_PrintPreview) &&
|
||||
!mPrintState && GetMozPrintCallback()) {
|
||||
DispatchPrintCallback(nullptr);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
class nsICanvasRenderingContextInternal;
|
||||
class nsITimerCallback;
|
||||
enum class gfxAlphaType;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -402,7 +403,7 @@ class HTMLCanvasElement final : public nsGenericHTMLElement,
|
|||
|
||||
bool IsPrintCallbackDone();
|
||||
|
||||
void HandlePrintCallback(nsPresContext::nsPresContextType aType);
|
||||
void HandlePrintCallback(nsPresContext*);
|
||||
|
||||
nsresult DispatchPrintCallback(nsITimerCallback* aCallback);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "MediaPlaybackDelayPolicy.h"
|
||||
#include "MediaPromiseDefs.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "Visibility.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "DecoderTraits.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
namespace mozilla {
|
||||
|
||||
struct SVGMark;
|
||||
enum class StyleStrokeLinecap : uint8_t;
|
||||
|
||||
class SVGPathDataParser; // IWYU pragma: keep
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ class nsDisplayCanvas final : public nsPaintedDisplayItem {
|
|||
nsDisplayListBuilder* aDisplayListBuilder) override {
|
||||
HTMLCanvasElement* element =
|
||||
static_cast<HTMLCanvasElement*>(mFrame->GetContent());
|
||||
element->HandlePrintCallback(mFrame->PresContext()->Type());
|
||||
element->HandlePrintCallback(mFrame->PresContext());
|
||||
|
||||
switch (element->GetCurrentContextType()) {
|
||||
case CanvasContextType::Canvas2D:
|
||||
|
@ -438,7 +438,7 @@ already_AddRefed<Layer> nsHTMLCanvasFrame::BuildLayer(
|
|||
nsIntSize canvasSizeInPx = GetCanvasSize();
|
||||
|
||||
nsPresContext* presContext = PresContext();
|
||||
element->HandlePrintCallback(presContext->Type());
|
||||
element->HandlePrintCallback(presContext);
|
||||
|
||||
if (canvasSizeInPx.width <= 0 || canvasSizeInPx.height <= 0 || area.IsEmpty())
|
||||
return nullptr;
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "mozilla/AspectRatio.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/SmallPointerArray.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/WritingModes.h"
|
||||
#include "nsDirection.h"
|
||||
#include "nsFrameList.h"
|
||||
|
@ -99,6 +100,7 @@
|
|||
class nsAtom;
|
||||
class nsPresContext;
|
||||
class nsView;
|
||||
class nsFrameSelection;
|
||||
class nsIWidget;
|
||||
class nsISelectionController;
|
||||
class nsBoxLayoutState;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsParserCIID.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "nsCharsetSource.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "mozilla/dom/PrototypeDocumentContentSink.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
|
Загрузка…
Ссылка в новой задаче