Files
palemoon27/dom/base/nsGenConImageContent.cpp
T
roytam1 34aef48624 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 895274 part.44 Rename NS_POINTER_ENTER to ePointerEnter r=smaug (2055d66902)
- Bug 895274 part.45 Rename NS_POINTER_OUT to ePointerOut r=smaug (efc0b6b1f5)
- Bug 895274 part.46 Rename NS_POINTER_OVER to ePointerOver r=smaug (06898047f7)
- Bug 895274 part.47 Rename NS_POINTER_DOWN to ePointerDown r=smaug (eadcd864c2)
- Bug 895274 part.48 Rename NS_POINTER_UP to ePointerUp r=smaug (9a04678318)
- Bug 895274 part.49 Rename NS_POINTER_MOVE to ePointerMove r=smaug (8963a5e5e3)
- Bug 895274 part.50 Rename NS_CONTEXTMENU_MESSAGE_START to eContextMenuFirst r=smaug (5eea077f97)
- Bug 895274 part.51 Rename NS_CONTEXTMENU to eContextMenu r=smaug (df9153a883)
- Bug 895274 part.52 Get rid of NS_PAGE_RESTORE due to unused r=smaug (5555386a4f)
- Bug 895274 part.53 Rename NS_STREAM_EVENT_START to eStreamEventFirst r=smaug (873f2e5b5c)
- Bug 895274 part.54 Rename NS_READYSTATECHANGE to eReadyStateChange r=smaug (21d91c9a87)
- Bug 895274 part.55 Rename NS_BEFORE_PAGE_UNLOAD to eBeforeUnload r=smaug (1da6db3491)
- Bug 1203272 - Fix build of nsMemoryReporterManager on linux systems without mallinfo(). r=glandium,njn. (4a99986dc4)
- Bug 895274 part.56 Rename NS_POPSTATE to ePopState r=smaug (c51dbbb2e0)
- Bug 895274 part.57 Rename NS_LOAD_ERROR to eLoadError r=smaug (e4b267ec78)
- Bug 895274 part.58 Rename NS_IMAGE_ABORT to eImageAbort r=smaug (88a62156dd)
- Bug 895274 part.59 Rename NS_HASHCHANGE to eHashChange r=smaug (7552f57017)
- Bug 895274 part.60 Rename NS_PAGE_UNLOAD to eUnload r=smaug (20153f814e)
- Bug 895274 part.61 Rename NS_LOAD to eLoad r=smaug (1072bcbb81)
- Bug 895274 part.62 Rename NS_FORM_EVENT_START to eFormEventFirst r=smaug (e99f85df0c)
- Bug 895274 part.63 Rename NS_FORM_SUBMIT to eFormSubmit r=smaug (b7ebab7fe0)
- Bug 895274 part.64 Rename NS_FORM_RESET to eFormReset r=smaug (74a3518bf6)
- Bug 895274 part.65 Rename NS_FORM_CHANGE to eFormChange r=smaug (64dafe9aaa)
- Bug 895274 part.66 Rename NS_FORM_SELECTED to eFormSelect r=smaug (4437b9a60c)
- Bug 895274 part.67 Rename NS_FORM_INVALID to eFormInvalid r=smaug (8122f6e301)
- Bug 895274 part.68 Rename NS_FOCUS_EVENT_START to eFocusEventFirst r=smaug (5066c46dc1)
- Bug 895274 part.69 Rename NS_FOCUS_CONTENT to eFocus r=smaug (79a443a14c)
- Bug 895274 part.70 Rename NS_BLUR_CONTENT to eBlur r=smaug (64515beb6a)
- Bug 895274 part.71 Rename NS_UI_EVENT_START to eLegacyUIEventFirst r=smaug (02b8a5cccd)
- Bug 895274 part.72 Rename NS_UI_ACTIVATE to eLegacyDOMActivate r=smaug (884aa917ec)
- Bug 895274 part.73 Rename NS_UI_FOCUSIN to eLegacyDOMFocusIn r=smaug (905f681593)
- Bug 895274 part.74 Rename NS_UI_FOCUSOUT to eLegacyDOMFocusOut r=smaug (b38a2ab56c)
- Bug 895274 part.75 Rename NS_DRAGDROP_EVENT_START to eDragDropEventFirst, define eDragDropEventLast and correct the type and name of event message in DataTransfer r=smaug (e8ac6a9112)
- Bug 895274 part.76 Rename NS_DRAGDROP_LEAVE to eDragLeave r=smaug (6948c3cddc)
- Bug 895274 part.77 Rename NS_DRAGDROP_DROP to eDrop r=smaug (9e67b051ee)
- Bug 895274 part.78 Rename NS_DRAGDROP_START to eDragStart r=smaug (f13fc7cf41)
- Bug 1184967 P1 Set RequestMode based on LoadInfo securityMode and client request content policy. r=nsm (b6d7f3fed7)
- Bug 1173934 Disable broken fetch-frame-resources.https.html wpt tests. r=jgraham (7d8e203c6a)
- Bug 1187722 Fix bad origins, error page handling, and spec issues in fetch-frame-resources.https.html. r=jgraham (fecdaeddfc)
- Bug 1184967 P2 Update fetch-frame-resource.https.html CORS checks to expect pass. r=jgraham (7550cba86d)
- Bug 1184967 P3 Switch mochitest redirect tests back to returning a CORS Response. r=nsm (2f803e26ac)
- spacing (21c5e1f343)
2022-04-25 09:31:40 +08:00

133 lines
4.2 KiB
C++

/* -*- 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
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* A fake content node class so that the image frame for
* content: url(foo);
* in CSS can have an nsIImageLoadingContent but use an
* imgIRequest that's already been loaded from the style system.
*/
#include "nsContentCreatorFunctions.h"
#include "nsXMLElement.h"
#include "nsImageLoadingContent.h"
#include "imgIRequest.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
using namespace mozilla;
class nsGenConImageContent final : public nsXMLElement,
public nsImageLoadingContent
{
public:
explicit nsGenConImageContent(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsXMLElement(aNodeInfo)
{
// nsImageLoadingContent starts out broken, so we start out
// suppressed to match it.
AddStatesSilently(NS_EVENT_STATE_SUPPRESSED);
}
nsresult Init(imgRequestProxy* aImageRequest)
{
// No need to notify, since we have no frame.
return UseAsPrimaryRequest(aImageRequest, false, eImageLoadType_Normal);
}
// nsIContent overrides
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers) override;
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
virtual EventStates IntrinsicState() const override;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override
{
MOZ_ASSERT(IsInNativeAnonymousSubtree());
if (aVisitor.mEvent->mMessage == eLoad ||
aVisitor.mEvent->mMessage == eLoadError) {
// Don't propagate the events to the parent.
return NS_OK;
}
return nsXMLElement::PreHandleEvent(aVisitor);
}
protected:
nsIContent* AsContent() override { return this; }
private:
virtual ~nsGenConImageContent();
public:
NS_DECL_ISUPPORTS_INHERITED
};
NS_IMPL_ISUPPORTS_INHERITED(nsGenConImageContent,
nsXMLElement,
nsIImageLoadingContent,
imgINotificationObserver,
imgIOnloadBlocker)
nsresult
NS_NewGenConImageContent(nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
imgRequestProxy* aImageRequest)
{
NS_PRECONDITION(aImageRequest, "Must have request!");
nsGenConImageContent *it = new nsGenConImageContent(aNodeInfo);
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult = it);
nsresult rv = it->Init(aImageRequest);
if (NS_FAILED(rv))
NS_RELEASE(*aResult);
return rv;
}
nsGenConImageContent::~nsGenConImageContent()
{
DestroyImageLoadingContent();
}
nsresult
nsGenConImageContent::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv;
rv = nsXMLElement::BindToTree(aDocument, aParent, aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
aCompileEventHandlers);
return NS_OK;
}
void
nsGenConImageContent::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
nsXMLElement::UnbindFromTree(aDeep, aNullParent);
}
EventStates
nsGenConImageContent::IntrinsicState() const
{
EventStates state = nsXMLElement::IntrinsicState();
EventStates imageState = nsImageLoadingContent::ImageState();
if (imageState.HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED)) {
// We should never be in an error state; if the image fails to load, we
// just go to the suppressed state.
imageState |= NS_EVENT_STATE_SUPPRESSED;
imageState &= ~NS_EVENT_STATE_BROKEN;
}
imageState &= ~NS_EVENT_STATE_LOADING;
return state | imageState;
}