зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-inbound to mozilla-central. a=merge
This commit is contained in:
Коммит
7062e6b6a2
|
@ -0,0 +1,161 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=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/. */
|
||||
|
||||
#include "DOMtoATK.h"
|
||||
#include "nsUTF8Utils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
namespace DOMtoATK {
|
||||
|
||||
void
|
||||
AddBOMs(nsACString& aDest, const nsACString& aSource)
|
||||
{
|
||||
uint32_t destlength = 0;
|
||||
|
||||
// First compute how much room we will need.
|
||||
for (uint32_t srci = 0; srci < aSource.Length(); ) {
|
||||
int bytes = UTF8traits::bytes(aSource[srci]);
|
||||
if (bytes >= 4) {
|
||||
// Non-BMP character, will add a BOM after it.
|
||||
destlength += 3;
|
||||
}
|
||||
// Skip whole character encoding.
|
||||
srci += bytes;
|
||||
destlength += bytes;
|
||||
}
|
||||
|
||||
uint32_t desti = 0; // Index within aDest.
|
||||
|
||||
// Add BOMs after non-BMP characters.
|
||||
aDest.SetLength(destlength);
|
||||
for (uint32_t srci = 0; srci < aSource.Length(); ) {
|
||||
uint32_t bytes = UTF8traits::bytes(aSource[srci]);
|
||||
|
||||
MOZ_ASSERT(bytes <= aSource.Length() - srci, "We should have the whole sequence");
|
||||
|
||||
// Copy whole sequence.
|
||||
aDest.Replace(desti, bytes, Substring(aSource, srci, bytes));
|
||||
desti += bytes;
|
||||
srci += bytes;
|
||||
|
||||
if (bytes >= 4) {
|
||||
// More than 4 bytes in UTF-8 encoding exactly means more than 16 encoded
|
||||
// bits. This is thus a non-BMP character which needed a surrogate
|
||||
// pair to get encoded in UTF-16, add a BOM after it.
|
||||
|
||||
// And add a BOM after it.
|
||||
aDest.Replace(desti, 3, "\xEF\xBB\xBF");
|
||||
desti += 3;
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(desti == destlength, "Incoherency between computed length"
|
||||
"and actually translated length");
|
||||
}
|
||||
|
||||
void
|
||||
ATKStringConverterHelper::AdjustOffsets(gint* aStartOffset, gint* aEndOffset,
|
||||
gint count)
|
||||
{
|
||||
MOZ_ASSERT(!mAdjusted, "DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be called only once");
|
||||
|
||||
if (*aStartOffset > 0) {
|
||||
(*aStartOffset)--;
|
||||
mStartShifted = true;
|
||||
}
|
||||
|
||||
if (*aEndOffset != -1 && *aEndOffset < count) {
|
||||
(*aEndOffset)++;
|
||||
mEndShifted = true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
mAdjusted = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
gchar*
|
||||
ATKStringConverterHelper::FinishUTF16toUTF8(nsCString& aStr)
|
||||
{
|
||||
int skip = 0;
|
||||
|
||||
if (mStartShifted) {
|
||||
// AdjustOffsets added a leading character.
|
||||
|
||||
MOZ_ASSERT(aStr.Length() > 0, "There should be a leading character");
|
||||
MOZ_ASSERT(static_cast<int>(aStr.Length()) >= UTF8traits::bytes(aStr.CharAt(0)),
|
||||
"The leading character should be complete");
|
||||
|
||||
// drop first character
|
||||
skip = UTF8traits::bytes(aStr.CharAt(0));
|
||||
}
|
||||
|
||||
if (mEndShifted) {
|
||||
// AdjustOffsets added a trailing character.
|
||||
|
||||
MOZ_ASSERT(aStr.Length() > 0, "There should be a trailing character");
|
||||
|
||||
int trail = -1;
|
||||
// Find beginning of last character.
|
||||
for (trail = aStr.Length() - 1; trail >= 0; trail--) {
|
||||
if (!UTF8traits::isInSeq(aStr.CharAt(trail))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(trail >= 0,
|
||||
"There should be at least a whole trailing character");
|
||||
MOZ_ASSERT(trail + UTF8traits::bytes(aStr.CharAt(trail)) == static_cast<int>(aStr.Length()),
|
||||
"The trailing character should be complete");
|
||||
|
||||
// Drop the last character.
|
||||
aStr.Truncate(trail);
|
||||
}
|
||||
|
||||
// copy and return, libspi will free it
|
||||
return g_strdup(aStr.get() + skip);
|
||||
}
|
||||
|
||||
gchar*
|
||||
ATKStringConverterHelper::ConvertAdjusted(const nsAString& aStr)
|
||||
{
|
||||
MOZ_ASSERT(mAdjusted, "DOMtoATK::ATKStringConverterHelper::AdjustOffsets needs to be called before ATKStringConverterHelper::ConvertAdjusted");
|
||||
|
||||
NS_ConvertUTF16toUTF8 cautoStr(aStr);
|
||||
if (!cautoStr.get()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsAutoCString cautoStrBOMs;
|
||||
AddBOMs(cautoStrBOMs, cautoStr);
|
||||
return FinishUTF16toUTF8(cautoStrBOMs);
|
||||
}
|
||||
|
||||
gchar*
|
||||
Convert(const nsAString& aStr)
|
||||
{
|
||||
NS_ConvertUTF16toUTF8 cautoStr(aStr);
|
||||
if (!cautoStr.get()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsAutoCString cautoStrBOMs;
|
||||
AddBOMs(cautoStrBOMs, cautoStr);
|
||||
return g_strdup(cautoStrBOMs.get());
|
||||
}
|
||||
|
||||
void
|
||||
ConvertTexttoAsterisks(nsAString& aString)
|
||||
{
|
||||
for (uint32_t i = 0; i < aString.Length(); i++) {
|
||||
aString.ReplaceLiteral(i, 1, u"*");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,163 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=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/. */
|
||||
|
||||
#include "AccessibleWrap.h"
|
||||
#include "nsString.h"
|
||||
#include "nsMai.h"
|
||||
|
||||
/**
|
||||
* ATK offsets are counted in unicode codepoints, while DOM offsets are counted
|
||||
* in UTF-16 code units. That makes a difference for non-BMP characters,
|
||||
* which need two UTF-16 code units to be represented (a pair of surrogates),
|
||||
* while they are just one unicode character.
|
||||
*
|
||||
* To keep synchronization between ATK offsets (unicode codepoints) and DOM
|
||||
* offsets (UTF-16 code units), after translation from UTF-16 to UTF-8 we add a
|
||||
* BOM after each non-BMP character (which would otherwise use 2 UTF-16
|
||||
* code units for only 1 unicode codepoint).
|
||||
*
|
||||
* BOMs (Byte Order Marks, U+FEFF, also known as ZERO WIDTH NO-BREAK SPACE, but
|
||||
* that usage is deprecated) normally only appear at the beginning of unicode
|
||||
* files, but their occurrence within text (notably after cut&paste) is not
|
||||
* uncommon, and are thus considered as non-text.
|
||||
*
|
||||
* Since the selection requested through ATK may not contain both surrogates
|
||||
* at the ends of the selection, we need to fetch one UTF-16 code point more
|
||||
* on both side, and get rid of it before returning the string to ATK. The
|
||||
* ATKStringConverterHelper class maintains this, NewATKString should be used
|
||||
* to call it properly.
|
||||
*
|
||||
* In the end,
|
||||
* - if the start is between the high and low surrogates, the UTF-8 result
|
||||
* includes a BOM from it but not the character
|
||||
* - if the end is between the high and low surrogates, the UTF-8 result
|
||||
* includes the character but *not* the BOM
|
||||
* - all non-BMP characters that are fully in the string are in the UTF-8 result
|
||||
* as character followed by BOM
|
||||
*/
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
namespace DOMtoATK
|
||||
{
|
||||
|
||||
/**
|
||||
* Converts a string of accessible text into ATK gchar* string (by adding
|
||||
* BOMs). This can be used when offsets do not need to be adjusted because
|
||||
* ends of the string can not fall between surrogates.
|
||||
*/
|
||||
gchar* Convert(const nsAString& aStr);
|
||||
|
||||
/**
|
||||
* Add a BOM after each non-BMP character.
|
||||
*/
|
||||
void AddBOMs(nsACString& aDest, const nsACString& aSource);
|
||||
|
||||
/**
|
||||
* Replace all characters with asterisks (e.g. for password fields).
|
||||
*/
|
||||
void ConvertTexttoAsterisks(nsAString& aString);
|
||||
|
||||
/**
|
||||
* Parameterize conversion.
|
||||
*/
|
||||
enum class AtkStringConvertFlags : uint32_t {
|
||||
None = 0,
|
||||
ConvertTextToAsterisks = 1 << 0,
|
||||
};
|
||||
|
||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AtkStringConvertFlags)
|
||||
|
||||
class ATKStringConverterHelper {
|
||||
public:
|
||||
ATKStringConverterHelper(void) :
|
||||
#ifdef DEBUG
|
||||
mAdjusted (false),
|
||||
#endif
|
||||
mStartShifted (false),
|
||||
mEndShifted (false) { }
|
||||
|
||||
/**
|
||||
* In order to properly get non-BMP values, offsets need to be changed
|
||||
* to get one character more on each end, so that ConvertUTF16toUTF8 can
|
||||
* convert surrogates even if the originally requested offsets fall between
|
||||
* them.
|
||||
*/
|
||||
void AdjustOffsets(gint* aStartOffset, gint* aEndOffset, gint count);
|
||||
|
||||
/**
|
||||
* Converts a string of accessible text with adjusted offsets into ATK
|
||||
* gchar* string (by adding BOMs). Note, AdjustOffsets has to be called
|
||||
* before getting the text passed to this.
|
||||
*/
|
||||
gchar* ConvertAdjusted(const nsAString& aStr);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Remove the additional characters requested by PrepareUTF16toUTF8.
|
||||
*/
|
||||
gchar* FinishUTF16toUTF8(nsCString& aStr);
|
||||
|
||||
#ifdef DEBUG
|
||||
bool mAdjusted;
|
||||
#endif
|
||||
bool mStartShifted;
|
||||
bool mEndShifted;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get text from aAccessible, using ATKStringConverterHelper to properly
|
||||
* introduce appropriate BOMs.
|
||||
*/
|
||||
template <class AccessibleOrProxy>
|
||||
gchar* NewATKString(AccessibleOrProxy* aAccessible,
|
||||
gint aStartOffset, gint aEndOffset,
|
||||
AtkStringConvertFlags aFlags)
|
||||
{
|
||||
gint startOffset = aStartOffset, endOffset = aEndOffset;
|
||||
ATKStringConverterHelper converter;
|
||||
converter.AdjustOffsets(&startOffset, &endOffset,
|
||||
gint(aAccessible->CharacterCount()));
|
||||
nsAutoString str;
|
||||
aAccessible->TextSubstring(startOffset, endOffset, str);
|
||||
if (aFlags & AtkStringConvertFlags::ConvertTextToAsterisks)
|
||||
ConvertTexttoAsterisks(str);
|
||||
return converter.ConvertAdjusted(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a character from aAccessible, fetching more data as appropriate to
|
||||
* properly get non-BMP characters or a BOM as appropriate.
|
||||
*/
|
||||
template <class AccessibleCharAt>
|
||||
gunichar ATKCharacter(AccessibleCharAt* aAccessible, gint aOffset)
|
||||
{
|
||||
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
|
||||
gunichar character = static_cast<gunichar>(aAccessible->CharAt(aOffset));
|
||||
|
||||
if (NS_IS_LOW_SURROGATE(character)) {
|
||||
// Trailing surrogate, return BOM instead.
|
||||
return 0xFEFF;
|
||||
}
|
||||
|
||||
if (NS_IS_HIGH_SURROGATE(character)) {
|
||||
// Heading surrogate, get the trailing surrogate and combine them.
|
||||
gunichar characterLow = static_cast<gunichar>(aAccessible->CharAt(aOffset + 1));
|
||||
|
||||
if (!NS_IS_LOW_SURROGATE(characterLow)) {
|
||||
// It should have been a trailing surrogate... Flag the error.
|
||||
return 0xFFFD;
|
||||
}
|
||||
return SURROGATE_TO_UCS4(character, characterLow);
|
||||
}
|
||||
|
||||
return character;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
|
@ -14,6 +14,7 @@ SOURCES += [
|
|||
'ApplicationAccessibleWrap.cpp',
|
||||
'AtkSocketAccessible.cpp',
|
||||
'DocAccessibleWrap.cpp',
|
||||
'DOMtoATK.cpp',
|
||||
'nsMaiHyperlink.cpp',
|
||||
'nsMaiInterfaceAction.cpp',
|
||||
'nsMaiInterfaceComponent.cpp',
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
#include "nsIAccessibleTypes.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsUTF8Utils.h"
|
||||
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
#include "DOMtoATK.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
|
@ -128,8 +131,7 @@ ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString)
|
|||
{
|
||||
// convert each char to "*" when it's "password text"
|
||||
if (accWrap->NativeRole() == roles::PASSWORD_TEXT) {
|
||||
for (uint32_t i = 0; i < aString.Length(); i++)
|
||||
aString.ReplaceLiteral(i, 1, u"*");
|
||||
DOMtoATK::ConvertTexttoAsterisks(aString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,20 +144,20 @@ getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
|
|||
nsAutoString autoStr;
|
||||
if (accWrap) {
|
||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||
if (!text || !text->IsTextRole())
|
||||
if (!text || !text->IsTextRole() || text->IsDefunct())
|
||||
return nullptr;
|
||||
|
||||
text->TextSubstring(aStartOffset, aEndOffset, autoStr);
|
||||
return DOMtoATK::NewATKString(text, aStartOffset, aEndOffset,
|
||||
accWrap->NativeRole() == roles::PASSWORD_TEXT ?
|
||||
DOMtoATK::AtkStringConvertFlags::ConvertTextToAsterisks :
|
||||
DOMtoATK::AtkStringConvertFlags::None);
|
||||
|
||||
ConvertTexttoAsterisks(accWrap, autoStr);
|
||||
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||
proxy->TextSubstring(aStartOffset, aEndOffset, autoStr);
|
||||
return DOMtoATK::NewATKString(proxy, aStartOffset, aEndOffset,
|
||||
DOMtoATK::AtkStringConvertFlags::None);
|
||||
}
|
||||
|
||||
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
|
||||
|
||||
//copy and return, libspi will free it.
|
||||
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
|
@ -181,8 +183,8 @@ getTextAfterOffsetCB(AtkText *aText, gint aOffset,
|
|||
*aStartOffset = startOffset;
|
||||
*aEndOffset = endOffset;
|
||||
|
||||
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
|
||||
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
|
||||
// libspi will free it.
|
||||
return DOMtoATK::Convert(autoStr);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
|
@ -208,8 +210,8 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
|
|||
*aStartOffset = startOffset;
|
||||
*aEndOffset = endOffset;
|
||||
|
||||
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
|
||||
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
|
||||
// libspi will free it.
|
||||
return DOMtoATK::Convert(autoStr);
|
||||
}
|
||||
|
||||
static gunichar
|
||||
|
@ -221,13 +223,11 @@ getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
|
|||
if (!text || !text->IsTextRole()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// char16_t is unsigned short in Mozilla, gnuichar is guint32 in glib.
|
||||
return static_cast<gunichar>(text->CharAt(aOffset));
|
||||
return DOMtoATK::ATKCharacter(text, aOffset);
|
||||
}
|
||||
|
||||
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
|
||||
return static_cast<gunichar>(proxy->CharAt(aOffset));
|
||||
return DOMtoATK::ATKCharacter(proxy, aOffset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -257,8 +257,8 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
|
|||
*aStartOffset = startOffset;
|
||||
*aEndOffset = endOffset;
|
||||
|
||||
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
|
||||
return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nullptr;
|
||||
// libspi will free it.
|
||||
return DOMtoATK::Convert(autoStr);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
|
@ -68,10 +68,6 @@
|
|||
#include "nsWhitespaceTokenizer.h"
|
||||
#include "nsAttrName.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsICommandManager.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIEditingSession.h"
|
||||
|
|
|
@ -261,9 +261,12 @@ HandlerProvider::BuildDynamicIA2Data(DynamicIA2Data* aOutIA2Data)
|
|||
{
|
||||
MOZ_ASSERT(aOutIA2Data);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mTargetUnk);
|
||||
MOZ_ASSERT(IsTargetInterfaceCacheable());
|
||||
|
||||
if (!mTargetUnk) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<NEWEST_IA2_INTERFACE> target;
|
||||
HRESULT hr = mTargetUnk.get()->QueryInterface(NEWEST_IA2_IID,
|
||||
getter_AddRefs(target));
|
||||
|
@ -467,6 +470,11 @@ HandlerProvider::MarshalAs(REFIID aIid)
|
|||
HRESULT
|
||||
HandlerProvider::DisconnectHandlerRemotes()
|
||||
{
|
||||
// If a handlerProvider call is pending on another thread,
|
||||
// CoDisconnectObject won't release this HandlerProvider immediately.
|
||||
// However, the interceptor and its target (mTargetUnk) might be destroyed.
|
||||
mTargetUnk = nullptr;
|
||||
|
||||
IUnknown* unk = static_cast<IGeckoBackChannel*>(this);
|
||||
return ::CoDisconnectObject(unk, 0);
|
||||
}
|
||||
|
@ -544,6 +552,10 @@ HandlerProvider::Refresh(DynamicIA2Data* aOutData)
|
|||
{
|
||||
MOZ_ASSERT(mscom::IsCurrentThreadMTA());
|
||||
|
||||
if (!mTargetUnk) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
|
||||
if (!mscom::InvokeOnMainThread("HandlerProvider::BuildDynamicIA2Data",
|
||||
this, &HandlerProvider::BuildDynamicIA2Data,
|
||||
aOutData)) {
|
||||
|
@ -581,7 +593,11 @@ HandlerProvider::GetAllTextInfoMainThread(BSTR* aText,
|
|||
MOZ_ASSERT(aAttribRuns);
|
||||
MOZ_ASSERT(aNAttribRuns);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mTargetUnk);
|
||||
|
||||
if (!mTargetUnk) {
|
||||
*result = CO_E_OBJNOTCONNECTED;
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<IAccessibleHypertext2> ht;
|
||||
HRESULT hr = mTargetUnk->QueryInterface(IID_IAccessibleHypertext2,
|
||||
|
@ -657,6 +673,10 @@ HandlerProvider::get_AllTextInfo(BSTR* aText,
|
|||
{
|
||||
MOZ_ASSERT(mscom::IsCurrentThreadMTA());
|
||||
|
||||
if (!mTargetUnk) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
if (!mscom::InvokeOnMainThread("HandlerProvider::GetAllTextInfoMainThread",
|
||||
this,
|
||||
|
@ -677,7 +697,11 @@ HandlerProvider::GetRelationsInfoMainThread(IARelationData** aRelations,
|
|||
MOZ_ASSERT(aRelations);
|
||||
MOZ_ASSERT(aNRelations);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mTargetUnk);
|
||||
|
||||
if (!mTargetUnk) {
|
||||
*hr = CO_E_OBJNOTCONNECTED;
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<NEWEST_IA2_INTERFACE> acc;
|
||||
*hr = mTargetUnk.get()->QueryInterface(NEWEST_IA2_IID,
|
||||
|
@ -722,6 +746,10 @@ HandlerProvider::get_RelationsInfo(IARelationData** aRelations,
|
|||
{
|
||||
MOZ_ASSERT(mscom::IsCurrentThreadMTA());
|
||||
|
||||
if (!mTargetUnk) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
if (!mscom::InvokeOnMainThread("HandlerProvider::GetRelationsInfoMainThread",
|
||||
this,
|
||||
|
|
|
@ -8346,29 +8346,6 @@ var gIdentityHandler = {
|
|||
this._permissionReloadHint.removeAttribute("hidden");
|
||||
PanelView.forNode(this._identityPopupMainView)
|
||||
.descriptionHeightWorkaround();
|
||||
|
||||
// Set telemetry values for clearing a permission
|
||||
let histogram = Services.telemetry.getKeyedHistogramById("WEB_PERMISSION_CLEARED");
|
||||
|
||||
let permissionType = 0;
|
||||
if (aPermission.state == SitePermissions.ALLOW &&
|
||||
aPermission.scope == SitePermissions.SCOPE_PERSISTENT) {
|
||||
// 1 : clear permanently allowed permission
|
||||
permissionType = 1;
|
||||
} else if (aPermission.state == SitePermissions.BLOCK &&
|
||||
aPermission.scope == SitePermissions.SCOPE_PERSISTENT) {
|
||||
// 2 : clear permanently blocked permission
|
||||
permissionType = 2;
|
||||
} else if (aPermission.state == SitePermissions.ALLOW) {
|
||||
// 3 : clear temporary allowed permission
|
||||
permissionType = 3;
|
||||
} else if (aPermission.state == SitePermissions.BLOCK) {
|
||||
// 4 : clear temporary blocked permission
|
||||
permissionType = 4;
|
||||
}
|
||||
|
||||
histogram.add("(all)", permissionType);
|
||||
histogram.add(aPermission.id, permissionType);
|
||||
});
|
||||
|
||||
container.appendChild(button);
|
||||
|
|
|
@ -1918,12 +1918,18 @@
|
|||
this.finishMediaBlockTimer();
|
||||
} else {
|
||||
if (browser.audioMuted) {
|
||||
browser.unmute();
|
||||
if (this.linkedPanel) {
|
||||
// "Lazy Browser" should not invoke its unmute method
|
||||
browser.unmute();
|
||||
}
|
||||
this.removeAttribute("muted");
|
||||
BrowserUITelemetry.countTabMutingEvent("unmute", aMuteReason);
|
||||
hist.add(1 /* unmute */);
|
||||
} else {
|
||||
browser.mute();
|
||||
if (this.linkedPanel) {
|
||||
// "Lazy Browser" should not invoke its mute method
|
||||
browser.mute();
|
||||
}
|
||||
this.setAttribute("muted", "true");
|
||||
BrowserUITelemetry.countTabMutingEvent("mute", aMuteReason);
|
||||
hist.add(0 /* mute */);
|
||||
|
|
|
@ -44,6 +44,7 @@ add_task(async function() {
|
|||
let restartedTab = await restartTab(tab);
|
||||
|
||||
ok("muted" in get_tab_state(restartedTab), "Restored tab should still be in a muted state after restart");
|
||||
ok(!restartedTab.linkedPanel, "Restored tab should not be inserted");
|
||||
|
||||
BrowserTestUtils.removeTab(restartedTab);
|
||||
});
|
||||
|
|
|
@ -1869,8 +1869,9 @@ DebuggerServer.ObjectActorPreviewers.Object = [
|
|||
}
|
||||
} else if (obj.class == "Attr") {
|
||||
preview.value = hooks.createValueGrip(rawObj.value);
|
||||
} else if (rawObj instanceof Ci.nsIDOMText ||
|
||||
rawObj instanceof Ci.nsIDOMComment) {
|
||||
} else if (obj.class == "Text" ||
|
||||
obj.class == "CDATASection" ||
|
||||
obj.class == "Comment") {
|
||||
preview.textContent = hooks.createValueGrip(rawObj.textContent);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "nsIAttribute.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Base class for DOM Core's nsIDOMComment, DocumentType, nsIDOMText,
|
||||
* CDATASection and nsIDOMProcessingInstruction nodes.
|
||||
* Base class for DOM Core's Comment, DocumentType, Text,
|
||||
* CDATASection and ProcessingInstruction nodes.
|
||||
*/
|
||||
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -23,7 +24,6 @@
|
|||
#include "mozilla/InternalMutationEvent.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsChangeHint.h"
|
||||
|
@ -39,10 +39,10 @@
|
|||
#include "mozilla/Sprintf.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
CharacterData::CharacterData(already_AddRefed<dom::NodeInfo>& aNodeInfo)
|
||||
: nsIContent(aNodeInfo)
|
||||
{
|
||||
MOZ_ASSERT(mNodeInfo->NodeType() == TEXT_NODE ||
|
||||
|
@ -53,7 +53,7 @@ nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<mozilla::dom::NodeIn
|
|||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
||||
CharacterData::CharacterData(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
|
||||
: nsIContent(aNodeInfo)
|
||||
{
|
||||
MOZ_ASSERT(mNodeInfo->NodeType() == TEXT_NODE ||
|
||||
|
@ -64,7 +64,7 @@ nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<mozilla::dom::NodeIn
|
|||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode::~nsGenericDOMDataNode()
|
||||
CharacterData::~CharacterData()
|
||||
{
|
||||
NS_PRECONDITION(!IsInUncomposedDoc(),
|
||||
"Please remove this from the document properly");
|
||||
|
@ -73,30 +73,30 @@ nsGenericDOMDataNode::~nsGenericDOMDataNode()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(CharacterData)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CharacterData)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(CharacterData)
|
||||
return Element::CanSkip(tmp, aRemovingAllowed);
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(CharacterData)
|
||||
return Element::CanSkipInCC(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(CharacterData)
|
||||
return Element::CanSkipThis(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(CharacterData)
|
||||
if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
|
||||
char name[40];
|
||||
SprintfLiteral(name, "nsGenericDOMDataNode (len=%d)",
|
||||
SprintfLiteral(name, "CharacterData (len=%d)",
|
||||
tmp->mText.GetLength());
|
||||
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
|
||||
} else {
|
||||
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGenericDOMDataNode, tmp->mRefCnt.get())
|
||||
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(CharacterData, tmp->mRefCnt.get())
|
||||
}
|
||||
|
||||
if (!nsIContent::Traverse(tmp, cb)) {
|
||||
|
@ -104,7 +104,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericDOMDataNode)
|
|||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CharacterData)
|
||||
nsIContent::Unlink(tmp);
|
||||
|
||||
// Clear flag here because unlinking slots will clear the
|
||||
|
@ -117,9 +117,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGenericDOMDataNode)
|
|||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
|
||||
NS_INTERFACE_MAP_BEGIN(CharacterData)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsGenericDOMDataNode)
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(CharacterData)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
||||
|
@ -131,20 +131,19 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
|
|||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(nsGenericDOMDataNode)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(nsGenericDOMDataNode,
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(CharacterData)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(CharacterData,
|
||||
nsNodeUtils::LastRelease(this))
|
||||
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::GetNodeValueInternal(nsAString& aNodeValue)
|
||||
CharacterData::GetNodeValueInternal(nsAString& aNodeValue)
|
||||
{
|
||||
DebugOnly<nsresult> rv = GetData(aNodeValue);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetData() failed!");
|
||||
GetData(aNodeValue);
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::SetNodeValueInternal(const nsAString& aNodeValue,
|
||||
CharacterData::SetNodeValueInternal(const nsAString& aNodeValue,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
aError = SetTextInternal(0, mText.GetLength(), aNodeValue.BeginReading(),
|
||||
|
@ -153,10 +152,10 @@ nsGenericDOMDataNode::SetNodeValueInternal(const nsAString& aNodeValue,
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Implementation of nsIDOMCharacterData
|
||||
// Implementation of CharacterData
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::GetData(nsAString& aData) const
|
||||
void
|
||||
CharacterData::GetData(nsAString& aData) const
|
||||
{
|
||||
if (mText.Is2b()) {
|
||||
aData.Truncate();
|
||||
|
@ -173,36 +172,21 @@ nsGenericDOMDataNode::GetData(nsAString& aData) const
|
|||
aData.Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SetData(const nsAString& aData)
|
||||
{
|
||||
return SetTextInternal(0, mText.GetLength(), aData.BeginReading(),
|
||||
aData.Length(), true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::GetLength(uint32_t* aLength)
|
||||
{
|
||||
*aLength = mText.GetLength();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SubstringData(uint32_t aStart, uint32_t aCount,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SubstringData(aStart, aCount, aReturn, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::SubstringData(uint32_t aStart, uint32_t aCount,
|
||||
nsAString& aReturn, ErrorResult& rv)
|
||||
CharacterData::SetData(const nsAString& aData, ErrorResult& aRv)
|
||||
{
|
||||
nsresult rv = SetTextInternal(0, mText.GetLength(), aData.BeginReading(),
|
||||
aData.Length(), true);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CharacterData::SubstringData(uint32_t aStart, uint32_t aCount,
|
||||
nsAString& aReturn, ErrorResult& rv)
|
||||
{
|
||||
aReturn.Truncate();
|
||||
|
||||
|
@ -230,40 +214,49 @@ nsGenericDOMDataNode::SubstringData(uint32_t aStart, uint32_t aCount,
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::AppendData(const nsAString& aData)
|
||||
void
|
||||
CharacterData::AppendData(const nsAString& aData, ErrorResult& aRv)
|
||||
{
|
||||
return SetTextInternal(mText.GetLength(), 0, aData.BeginReading(),
|
||||
aData.Length(), true);
|
||||
InsertData(mText.GetLength(), aData, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
CharacterData::InsertData(uint32_t aOffset,
|
||||
const nsAString& aData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsresult rv = SetTextInternal(aOffset, 0, aData.BeginReading(),
|
||||
aData.Length(), true);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CharacterData::DeleteData(uint32_t aOffset, uint32_t aCount, ErrorResult& aRv)
|
||||
{
|
||||
nsresult rv = SetTextInternal(aOffset, aCount, nullptr, 0, true);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CharacterData::ReplaceData(uint32_t aOffset, uint32_t aCount,
|
||||
const nsAString& aData, ErrorResult& aRv)
|
||||
{
|
||||
nsresult rv = SetTextInternal(aOffset, aCount, aData.BeginReading(),
|
||||
aData.Length(), true);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::InsertData(uint32_t aOffset,
|
||||
const nsAString& aData)
|
||||
{
|
||||
return SetTextInternal(aOffset, 0, aData.BeginReading(),
|
||||
aData.Length(), true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::DeleteData(uint32_t aOffset, uint32_t aCount)
|
||||
{
|
||||
return SetTextInternal(aOffset, aCount, nullptr, 0, true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::ReplaceData(uint32_t aOffset, uint32_t aCount,
|
||||
const nsAString& aData)
|
||||
{
|
||||
return SetTextInternal(aOffset, aCount, aData.BeginReading(),
|
||||
aData.Length(), true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SetTextInternal(uint32_t aOffset, uint32_t aCount,
|
||||
const char16_t* aBuffer,
|
||||
uint32_t aLength, bool aNotify,
|
||||
CharacterDataChangeInfo::Details* aDetails)
|
||||
CharacterData::SetTextInternal(uint32_t aOffset, uint32_t aCount,
|
||||
const char16_t* aBuffer,
|
||||
uint32_t aLength, bool aNotify,
|
||||
CharacterDataChangeInfo::Details* aDetails)
|
||||
{
|
||||
NS_PRECONDITION(aBuffer || !aLength,
|
||||
"Null buffer passed to SetTextInternal!");
|
||||
|
@ -416,8 +409,8 @@ nsGenericDOMDataNode::SetTextInternal(uint32_t aOffset, uint32_t aCount,
|
|||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
nsGenericDOMDataNode::ToCString(nsAString& aBuf, int32_t aOffset,
|
||||
int32_t aLen) const
|
||||
CharacterData::ToCString(nsAString& aBuf, int32_t aOffset,
|
||||
int32_t aLen) const
|
||||
{
|
||||
if (mText.Is2b()) {
|
||||
const char16_t* cp = mText.Get2b() + aOffset;
|
||||
|
@ -465,9 +458,9 @@ nsGenericDOMDataNode::ToCString(nsAString& aBuf, int32_t aOffset,
|
|||
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
bool aCompileEventHandlers)
|
||||
CharacterData::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
bool aCompileEventHandlers)
|
||||
{
|
||||
NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
|
||||
NS_PRECONDITION(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
|
||||
|
@ -574,7 +567,7 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
CharacterData::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
{
|
||||
// Unset frame flags; if we need them again later, they'll get set again.
|
||||
UnsetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE |
|
||||
|
@ -626,88 +619,88 @@ nsGenericDOMDataNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
|||
}
|
||||
|
||||
already_AddRefed<nsINodeList>
|
||||
nsGenericDOMDataNode::GetChildren(uint32_t aFilter)
|
||||
CharacterData::GetChildren(uint32_t aFilter)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsGenericDOMDataNode::GetChildCount() const
|
||||
CharacterData::GetChildCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsIContent *
|
||||
nsGenericDOMDataNode::GetChildAt_Deprecated(uint32_t aIndex) const
|
||||
CharacterData::GetChildAt_Deprecated(uint32_t aIndex) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
int32_t
|
||||
nsGenericDOMDataNode::ComputeIndexOf(const nsINode* aPossibleChild) const
|
||||
CharacterData::ComputeIndexOf(const nsINode* aPossibleChild) const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::InsertChildBefore(nsIContent* aKid,
|
||||
nsIContent* aBeforeThis,
|
||||
bool aNotify)
|
||||
CharacterData::InsertChildBefore(nsIContent* aKid,
|
||||
nsIContent* aBeforeThis,
|
||||
bool aNotify)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::InsertChildAt_Deprecated(nsIContent* aKid,
|
||||
uint32_t aIndex,
|
||||
bool aNotify)
|
||||
CharacterData::InsertChildAt_Deprecated(nsIContent* aKid,
|
||||
uint32_t aIndex,
|
||||
bool aNotify)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
|
||||
CharacterData::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::RemoveChildNode(nsIContent* aKid, bool aNotify)
|
||||
CharacterData::RemoveChildNode(nsIContent* aKid, bool aNotify)
|
||||
{
|
||||
}
|
||||
|
||||
nsXBLBinding *
|
||||
nsGenericDOMDataNode::DoGetXBLBinding() const
|
||||
CharacterData::DoGetXBLBinding() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
nsGenericDOMDataNode::IsNodeOfType(uint32_t aFlags) const
|
||||
CharacterData::IsNodeOfType(uint32_t aFlags) const
|
||||
{
|
||||
return !(aFlags & ~eDATA_NODE);
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::SaveSubtreeState()
|
||||
CharacterData::SaveSubtreeState()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
nsGenericDOMDataNode::List(FILE* out, int32_t aIndent) const
|
||||
CharacterData::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::DumpContent(FILE* out, int32_t aIndent,
|
||||
bool aDumpAll) const
|
||||
CharacterData::DumpContent(FILE* out, int32_t aIndent,
|
||||
bool aDumpAll) const
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
nsGenericDOMDataNode::IsLink(nsIURI** aURI) const
|
||||
CharacterData::IsLink(nsIURI** aURI) const
|
||||
{
|
||||
*aURI = nullptr;
|
||||
return false;
|
||||
|
@ -715,181 +708,38 @@ nsGenericDOMDataNode::IsLink(nsIURI** aURI) const
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Implementation of the nsIDOMText interface
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SplitData(uint32_t aOffset, nsIContent** aReturn,
|
||||
bool aCloneAfterOriginal)
|
||||
{
|
||||
*aReturn = nullptr;
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoString cutText;
|
||||
uint32_t length = TextLength();
|
||||
|
||||
if (aOffset > length) {
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
uint32_t cutStartOffset = aCloneAfterOriginal ? aOffset : 0;
|
||||
uint32_t cutLength = aCloneAfterOriginal ? length - aOffset : aOffset;
|
||||
rv = SubstringData(cutStartOffset, cutLength, cutText);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIDocument* document = GetComposedDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, true);
|
||||
|
||||
// Use Clone for creating the new node so that the new node is of same class
|
||||
// as this node!
|
||||
nsCOMPtr<nsIContent> newContent = CloneDataNode(mNodeInfo, false);
|
||||
if (!newContent) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
// nsRange expects the CharacterDataChanged notification is followed
|
||||
// by an insertion of |newContent|. If you change this code,
|
||||
// make sure you make the appropriate changes in nsRange.
|
||||
newContent->SetText(cutText, true); // XXX should be false?
|
||||
|
||||
CharacterDataChangeInfo::Details details = {
|
||||
CharacterDataChangeInfo::Details::eSplit, newContent
|
||||
};
|
||||
rv = SetTextInternal(cutStartOffset, cutLength, nullptr, 0, true,
|
||||
aCloneAfterOriginal ? &details : nullptr);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> parent = GetParentNode();
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIContent> beforeNode = this;
|
||||
if (aCloneAfterOriginal) {
|
||||
beforeNode = beforeNode->GetNextSibling();
|
||||
}
|
||||
parent->InsertChildBefore(newContent, beforeNode, true);
|
||||
}
|
||||
|
||||
newContent.swap(*aReturn);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SplitText(uint32_t aOffset, nsIDOMText** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsIContent> newChild;
|
||||
nsresult rv = SplitData(aOffset, getter_AddRefs(newChild));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CallQueryInterface(newChild, aReturn);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsIContent*
|
||||
FirstLogicallyAdjacentTextNode(nsIContent* aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> parent = aNode->GetParent();
|
||||
|
||||
while (aNode) {
|
||||
nsIContent* sibling = aNode->GetPreviousSibling();
|
||||
if (!sibling || !sibling->IsNodeOfType(nsINode::eTEXT)) {
|
||||
return aNode;
|
||||
}
|
||||
aNode = sibling;
|
||||
}
|
||||
|
||||
return parent->GetFirstChild();
|
||||
}
|
||||
|
||||
static nsIContent*
|
||||
LastLogicallyAdjacentTextNode(nsIContent* aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> parent = aNode->GetParent();
|
||||
|
||||
while (aNode) {
|
||||
nsIContent* sibling = aNode->GetNextSibling();
|
||||
if (!sibling) break;
|
||||
|
||||
if (!sibling->IsNodeOfType(nsINode::eTEXT)) {
|
||||
return aNode;
|
||||
}
|
||||
|
||||
aNode = sibling;
|
||||
}
|
||||
|
||||
return parent->GetLastChild();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
|
||||
{
|
||||
nsIContent* parent = GetParent();
|
||||
|
||||
// Handle parent-less nodes
|
||||
if (!parent)
|
||||
return GetData(aWholeText);
|
||||
|
||||
int32_t index = parent->ComputeIndexOf(this);
|
||||
NS_WARNING_ASSERTION(index >= 0,
|
||||
"Trying to use .wholeText with an anonymous"
|
||||
"text node child of a binding parent?");
|
||||
NS_ENSURE_TRUE(index >= 0, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
nsCOMPtr<nsIContent> first = FirstLogicallyAdjacentTextNode(this);
|
||||
nsCOMPtr<nsIContent> last = LastLogicallyAdjacentTextNode(this);
|
||||
|
||||
aWholeText.Truncate();
|
||||
|
||||
nsCOMPtr<nsIDOMText> node;
|
||||
nsAutoString tmp;
|
||||
|
||||
while (true) {
|
||||
node = do_QueryInterface(first);
|
||||
node->GetData(tmp);
|
||||
aWholeText.Append(tmp);
|
||||
|
||||
if (first == last) {
|
||||
break;
|
||||
}
|
||||
|
||||
first = first->GetNextSibling();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Implementation of the nsIContent interface text functions
|
||||
|
||||
const nsTextFragment *
|
||||
nsGenericDOMDataNode::GetText()
|
||||
CharacterData::GetText()
|
||||
{
|
||||
return &mText;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsGenericDOMDataNode::TextLength() const
|
||||
CharacterData::TextLength() const
|
||||
{
|
||||
return TextDataLength();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SetText(const char16_t* aBuffer,
|
||||
uint32_t aLength,
|
||||
bool aNotify)
|
||||
CharacterData::SetText(const char16_t* aBuffer,
|
||||
uint32_t aLength,
|
||||
bool aNotify)
|
||||
{
|
||||
return SetTextInternal(0, mText.GetLength(), aBuffer, aLength, aNotify);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::AppendText(const char16_t* aBuffer,
|
||||
uint32_t aLength,
|
||||
bool aNotify)
|
||||
CharacterData::AppendText(const char16_t* aBuffer,
|
||||
uint32_t aLength,
|
||||
bool aNotify)
|
||||
{
|
||||
return SetTextInternal(mText.GetLength(), 0, aBuffer, aLength, aNotify);
|
||||
}
|
||||
|
||||
bool
|
||||
nsGenericDOMDataNode::TextIsOnlyWhitespace()
|
||||
CharacterData::TextIsOnlyWhitespace()
|
||||
{
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -904,7 +754,7 @@ nsGenericDOMDataNode::TextIsOnlyWhitespace()
|
|||
}
|
||||
|
||||
bool
|
||||
nsGenericDOMDataNode::ThreadSafeTextIsOnlyWhitespace() const
|
||||
CharacterData::ThreadSafeTextIsOnlyWhitespace() const
|
||||
{
|
||||
// FIXME: should this method take content language into account?
|
||||
if (mText.Is2b()) {
|
||||
|
@ -940,7 +790,7 @@ nsGenericDOMDataNode::ThreadSafeTextIsOnlyWhitespace() const
|
|||
}
|
||||
|
||||
bool
|
||||
nsGenericDOMDataNode::HasTextForTranslation()
|
||||
CharacterData::HasTextForTranslation()
|
||||
{
|
||||
if (NodeType() != TEXT_NODE &&
|
||||
NodeType() != CDATA_SECTION_NODE) {
|
||||
|
@ -980,20 +830,20 @@ nsGenericDOMDataNode::HasTextForTranslation()
|
|||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::AppendTextTo(nsAString& aResult)
|
||||
CharacterData::AppendTextTo(nsAString& aResult)
|
||||
{
|
||||
mText.AppendTo(aResult);
|
||||
}
|
||||
|
||||
bool
|
||||
nsGenericDOMDataNode::AppendTextTo(nsAString& aResult,
|
||||
const mozilla::fallible_t& aFallible)
|
||||
CharacterData::AppendTextTo(nsAString& aResult,
|
||||
const mozilla::fallible_t& aFallible)
|
||||
{
|
||||
return mText.AppendTo(aResult, aFallible);
|
||||
}
|
||||
|
||||
already_AddRefed<nsAtom>
|
||||
nsGenericDOMDataNode::GetCurrentValueAtom()
|
||||
CharacterData::GetCurrentValueAtom()
|
||||
{
|
||||
nsAutoString val;
|
||||
GetData(val);
|
||||
|
@ -1001,10 +851,12 @@ nsGenericDOMDataNode::GetCurrentValueAtom()
|
|||
}
|
||||
|
||||
void
|
||||
nsGenericDOMDataNode::AddSizeOfExcludingThis(nsWindowSizes& aSizes,
|
||||
size_t* aNodeSize) const
|
||||
CharacterData::AddSizeOfExcludingThis(nsWindowSizes& aSizes,
|
||||
size_t* aNodeSize) const
|
||||
{
|
||||
nsIContent::AddSizeOfExcludingThis(aSizes, aNodeSize);
|
||||
*aNodeSize += mText.SizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -5,12 +5,12 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Base class for DOM Core's nsIDOMComment, DocumentType, nsIDOMText,
|
||||
* CDATASection, and nsIDOMProcessingInstruction nodes.
|
||||
* Base class for DOM Core's Comment, DocumentType, Text,
|
||||
* CDATASection, and ProcessingInstruction nodes.
|
||||
*/
|
||||
|
||||
#ifndef nsGenericDOMDataNode_h___
|
||||
#define nsGenericDOMDataNode_h___
|
||||
#ifndef mozilla_dom_CharacterData_h
|
||||
#define mozilla_dom_CharacterData_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -24,7 +24,6 @@
|
|||
#include "mozilla/dom/ShadowRoot.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIDOMText;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -32,76 +31,69 @@ class HTMLSlotElement;
|
|||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#define DATA_NODE_FLAG_BIT(n_) NODE_FLAG_BIT(NODE_TYPE_SPECIFIC_BITS_OFFSET + (n_))
|
||||
#define CHARACTER_DATA_FLAG_BIT(n_) NODE_FLAG_BIT(NODE_TYPE_SPECIFIC_BITS_OFFSET + (n_))
|
||||
|
||||
// Data node specific flags
|
||||
enum {
|
||||
// This bit is set to indicate that if the text node changes to
|
||||
// non-whitespace, we may need to create a frame for it. This bit must
|
||||
// not be set on nodes that already have a frame.
|
||||
NS_CREATE_FRAME_IF_NON_WHITESPACE = DATA_NODE_FLAG_BIT(0),
|
||||
NS_CREATE_FRAME_IF_NON_WHITESPACE = CHARACTER_DATA_FLAG_BIT(0),
|
||||
|
||||
// This bit is set to indicate that if the text node changes to
|
||||
// whitespace, we may need to reframe it (or its ancestors).
|
||||
NS_REFRAME_IF_WHITESPACE = DATA_NODE_FLAG_BIT(1),
|
||||
NS_REFRAME_IF_WHITESPACE = CHARACTER_DATA_FLAG_BIT(1),
|
||||
|
||||
// This bit is set to indicate that we have a cached
|
||||
// TextIsOnlyWhitespace value
|
||||
NS_CACHED_TEXT_IS_ONLY_WHITESPACE = DATA_NODE_FLAG_BIT(2),
|
||||
NS_CACHED_TEXT_IS_ONLY_WHITESPACE = CHARACTER_DATA_FLAG_BIT(2),
|
||||
|
||||
// This bit is only meaningful if the NS_CACHED_TEXT_IS_ONLY_WHITESPACE
|
||||
// bit is set, and if so it indicates whether we're only whitespace or
|
||||
// not.
|
||||
NS_TEXT_IS_ONLY_WHITESPACE = DATA_NODE_FLAG_BIT(3),
|
||||
NS_TEXT_IS_ONLY_WHITESPACE = CHARACTER_DATA_FLAG_BIT(3),
|
||||
|
||||
// This bit is set if there is a NewlineProperty attached to the node
|
||||
// (used by nsTextFrame).
|
||||
NS_HAS_NEWLINE_PROPERTY = DATA_NODE_FLAG_BIT(4),
|
||||
NS_HAS_NEWLINE_PROPERTY = CHARACTER_DATA_FLAG_BIT(4),
|
||||
|
||||
// This bit is set if there is a FlowLengthProperty attached to the node
|
||||
// (used by nsTextFrame).
|
||||
NS_HAS_FLOWLENGTH_PROPERTY = DATA_NODE_FLAG_BIT(5),
|
||||
NS_HAS_FLOWLENGTH_PROPERTY = CHARACTER_DATA_FLAG_BIT(5),
|
||||
|
||||
// This bit is set if the node may be modified frequently. This is typically
|
||||
// specified if the instance is in <input> or <textarea>.
|
||||
NS_MAYBE_MODIFIED_FREQUENTLY = DATA_NODE_FLAG_BIT(6),
|
||||
NS_MAYBE_MODIFIED_FREQUENTLY = CHARACTER_DATA_FLAG_BIT(6),
|
||||
};
|
||||
|
||||
// Make sure we have enough space for those bits
|
||||
ASSERT_NODE_FLAGS_SPACE(NODE_TYPE_SPECIFIC_BITS_OFFSET + 7);
|
||||
|
||||
#undef DATA_NODE_FLAG_BIT
|
||||
#undef CHARACTER_DATA_FLAG_BIT
|
||||
|
||||
class nsGenericDOMDataNode : public nsIContent
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class CharacterData : public nsIContent
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
||||
NS_DECL_ADDSIZEOFEXCLUDINGTHIS
|
||||
|
||||
explicit nsGenericDOMDataNode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
||||
explicit nsGenericDOMDataNode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
||||
explicit CharacterData(already_AddRefed<dom::NodeInfo>& aNodeInfo);
|
||||
explicit CharacterData(already_AddRefed<dom::NodeInfo>&& aNodeInfo);
|
||||
|
||||
void MarkAsMaybeModifiedFrequently()
|
||||
{
|
||||
SetFlags(NS_MAYBE_MODIFIED_FREQUENTLY);
|
||||
}
|
||||
|
||||
NS_IMPL_FROMCONTENT_HELPER(CharacterData, IsCharacterData())
|
||||
|
||||
virtual void GetNodeValueInternal(nsAString& aNodeValue) override;
|
||||
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
|
||||
mozilla::ErrorResult& aError) override;
|
||||
|
||||
// Implementation for nsIDOMCharacterData
|
||||
nsresult GetData(nsAString& aData) const;
|
||||
nsresult SetData(const nsAString& aData);
|
||||
nsresult GetLength(uint32_t* aLength);
|
||||
nsresult SubstringData(uint32_t aOffset, uint32_t aCount,
|
||||
nsAString& aReturn);
|
||||
nsresult AppendData(const nsAString& aArg);
|
||||
nsresult InsertData(uint32_t aOffset, const nsAString& aArg);
|
||||
nsresult DeleteData(uint32_t aOffset, uint32_t aCount);
|
||||
nsresult ReplaceData(uint32_t aOffset, uint32_t aCount,
|
||||
const nsAString& aArg);
|
||||
ErrorResult& aError) override;
|
||||
|
||||
// nsINode methods
|
||||
virtual uint32_t GetChildCount() const override;
|
||||
|
@ -114,13 +106,13 @@ public:
|
|||
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
|
||||
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
|
||||
virtual void GetTextContentInternal(nsAString& aTextContent,
|
||||
mozilla::OOMReporter& aError) override
|
||||
OOMReporter& aError) override
|
||||
{
|
||||
GetNodeValue(aTextContent);
|
||||
}
|
||||
virtual void SetTextContentInternal(const nsAString& aTextContent,
|
||||
nsIPrincipal* aSubjectPrincipal,
|
||||
mozilla::ErrorResult& aError) override
|
||||
ErrorResult& aError) override
|
||||
{
|
||||
// Batch possible DOMSubtreeModified events.
|
||||
mozAutoSubtreeModified subtree(OwnerDoc(), nullptr);
|
||||
|
@ -153,7 +145,7 @@ public:
|
|||
virtual void AppendTextTo(nsAString& aResult) override;
|
||||
MOZ_MUST_USE
|
||||
virtual bool AppendTextTo(nsAString& aResult,
|
||||
const mozilla::fallible_t&) override;
|
||||
const fallible_t&) override;
|
||||
virtual void SaveSubtreeState() override;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -165,10 +157,10 @@ public:
|
|||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
virtual bool IsLink(nsIURI** aURI) const override;
|
||||
|
||||
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
||||
virtual nsresult Clone(dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
||||
bool aPreallocateChildren) const override
|
||||
{
|
||||
nsCOMPtr<nsINode> result = CloneDataNode(aNodeInfo, true);
|
||||
RefPtr<CharacterData> result = CloneDataNode(aNodeInfo, true);
|
||||
result.forget(aResult);
|
||||
|
||||
if (!*aResult) {
|
||||
|
@ -178,36 +170,17 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult SplitData(uint32_t aOffset, nsIContent** aReturn,
|
||||
bool aCloneAfterOriginal = true);
|
||||
|
||||
// WebIDL API
|
||||
// Our XPCOM GetData is just fine for WebIDL
|
||||
virtual void SetData(const nsAString& aData, mozilla::ErrorResult& rv)
|
||||
{
|
||||
rv = SetData(aData);
|
||||
}
|
||||
void GetData(nsAString& aData) const;
|
||||
virtual void SetData(const nsAString& aData, ErrorResult& rv);
|
||||
// nsINode::Length() returns the right thing for our length attribute
|
||||
void SubstringData(uint32_t aStart, uint32_t aCount, nsAString& aReturn,
|
||||
mozilla::ErrorResult& rv);
|
||||
void AppendData(const nsAString& aData, mozilla::ErrorResult& rv)
|
||||
{
|
||||
rv = AppendData(aData);
|
||||
}
|
||||
void InsertData(uint32_t aOffset, const nsAString& aData,
|
||||
mozilla::ErrorResult& rv)
|
||||
{
|
||||
rv = InsertData(aOffset, aData);
|
||||
}
|
||||
void DeleteData(uint32_t aOffset, uint32_t aCount, mozilla::ErrorResult& rv)
|
||||
{
|
||||
rv = DeleteData(aOffset, aCount);
|
||||
}
|
||||
ErrorResult& rv);
|
||||
void AppendData(const nsAString& aData, ErrorResult& rv);
|
||||
void InsertData(uint32_t aOffset, const nsAString& aData, ErrorResult& rv);
|
||||
void DeleteData(uint32_t aOffset, uint32_t aCount, ErrorResult& rv);
|
||||
void ReplaceData(uint32_t aOffset, uint32_t aCount, const nsAString& aData,
|
||||
mozilla::ErrorResult& rv)
|
||||
{
|
||||
rv = ReplaceData(aOffset, aCount, aData);
|
||||
}
|
||||
ErrorResult& rv);
|
||||
|
||||
uint32_t TextDataLength() const
|
||||
{
|
||||
|
@ -220,22 +193,18 @@ public:
|
|||
void ToCString(nsAString& aBuf, int32_t aOffset, int32_t aLen) const;
|
||||
#endif
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(nsGenericDOMDataNode)
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(CharacterData)
|
||||
|
||||
protected:
|
||||
virtual ~nsGenericDOMDataNode();
|
||||
virtual ~CharacterData();
|
||||
|
||||
virtual mozilla::dom::Element* GetNameSpaceElement() override
|
||||
virtual Element* GetNameSpaceElement() override
|
||||
{
|
||||
nsINode *parent = GetParentNode();
|
||||
|
||||
return parent && parent->IsElement() ? parent->AsElement() : nullptr;
|
||||
}
|
||||
|
||||
nsresult SplitText(uint32_t aOffset, nsIDOMText** aReturn);
|
||||
|
||||
nsresult GetWholeText(nsAString& aWholeText);
|
||||
|
||||
nsresult SetTextInternal(uint32_t aOffset, uint32_t aCount,
|
||||
const char16_t* aBuffer, uint32_t aLength,
|
||||
bool aNotify,
|
||||
|
@ -249,8 +218,8 @@ protected:
|
|||
* @param aCloneText if true the text content will be cloned too
|
||||
* @return the clone
|
||||
*/
|
||||
virtual nsGenericDOMDataNode *CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const = 0;
|
||||
virtual already_AddRefed<CharacterData>
|
||||
CloneDataNode(dom::NodeInfo *aNodeInfo, bool aCloneText) const = 0;
|
||||
|
||||
nsTextFragment mText;
|
||||
|
||||
|
@ -273,4 +242,7 @@ private:
|
|||
already_AddRefed<nsAtom> GetCurrentValueAtom();
|
||||
};
|
||||
|
||||
#endif /* nsGenericDOMDataNode_h___ */
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_CharacterData_h */
|
|
@ -5,7 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Implementations of DOM Core's nsIDOMComment node.
|
||||
* Implementations of DOM Core's Comment node.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -23,8 +23,7 @@ Comment::~Comment()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(Comment, nsGenericDOMDataNode, nsIDOMNode,
|
||||
nsIDOMCharacterData, nsIDOMComment)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(Comment, CharacterData, nsIDOMNode)
|
||||
|
||||
bool
|
||||
Comment::IsNodeOfType(uint32_t aFlags) const
|
||||
|
@ -32,16 +31,16 @@ Comment::IsNodeOfType(uint32_t aFlags) const
|
|||
return !(aFlags & ~(eCOMMENT | eDATA_NODE));
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
already_AddRefed<CharacterData>
|
||||
Comment::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
||||
{
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
Comment *it = new Comment(ni.forget());
|
||||
if (it && aCloneText) {
|
||||
RefPtr<Comment> it = new Comment(ni.forget());
|
||||
if (aCloneText) {
|
||||
it->mText = mText;
|
||||
}
|
||||
|
||||
return it;
|
||||
return it.forget();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
#define mozilla_dom_Comment_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Comment final : public nsGenericDOMDataNode,
|
||||
public nsIDOMComment
|
||||
class Comment final : public CharacterData,
|
||||
public nsIDOMNode
|
||||
{
|
||||
private:
|
||||
void Init()
|
||||
|
@ -28,13 +28,13 @@ private:
|
|||
|
||||
public:
|
||||
explicit Comment(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
: CharacterData(aNodeInfo)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
explicit Comment(nsNodeInfoManager* aNodeInfoManager)
|
||||
: nsGenericDOMDataNode(aNodeInfoManager->GetCommentNodeInfo())
|
||||
: CharacterData(aNodeInfoManager->GetCommentNodeInfo())
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
@ -42,18 +42,12 @@ public:
|
|||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
// nsIDOMComment
|
||||
// Empty interface
|
||||
|
||||
// nsINode
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
virtual already_AddRefed<CharacterData>
|
||||
CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
#include "mozilla/dom/DOMPointBinding.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/RuleNodeCacheConditions.h"
|
||||
#include "mozilla/ServoCSSParser.h"
|
||||
#include "nsCSSParser.h"
|
||||
#include "nsStyleTransformMatrix.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@
|
|||
== Implemention Notes ==
|
||||
When a new node gets bound to the tree, the BindToTree function gets called.
|
||||
The reverse case is UnbindFromTree.
|
||||
When the contents of a text node change, nsGenericDOMDataNode::SetTextInternal
|
||||
When the contents of a text node change, CharacterData::SetTextInternal
|
||||
gets called.
|
||||
*/
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
|||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset) :
|
||||
nsGenericDOMDataNode(aNodeInfo),
|
||||
CharacterData(aNodeInfo),
|
||||
mPublicId(aPublicId),
|
||||
mSystemId(aSystemId),
|
||||
mInternalSubset(aInternalSubset)
|
||||
|
@ -63,15 +63,15 @@ DocumentType::~DocumentType()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(DocumentType, nsGenericDOMDataNode, nsIDOMNode)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(DocumentType, CharacterData, nsIDOMNode)
|
||||
|
||||
bool
|
||||
DocumentType::IsNodeOfType(uint32_t aFlags) const
|
||||
{
|
||||
// Don't claim to be eDATA_NODE since we're just inheriting
|
||||
// nsGenericDOMDataNode for convinience. Doctypes aren't really
|
||||
// CharacterData for convenience. Doctypes aren't really
|
||||
// data nodes (they have a null .nodeValue and don't implement
|
||||
// nsIDOMCharacterData)
|
||||
// the DOM CharacterData interface)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -105,11 +105,11 @@ DocumentType::GetInternalSubset(nsAString& aInternalSubset) const
|
|||
aInternalSubset = mInternalSubset;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
already_AddRefed<CharacterData>
|
||||
DocumentType::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
||||
{
|
||||
already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
||||
return new DocumentType(ni, mPublicId, mSystemId, mInternalSubset);
|
||||
return do_AddRef(new DocumentType(ni, mPublicId, mSystemId, mInternalSubset));
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
#define DocumentType_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -26,7 +26,7 @@ namespace dom {
|
|||
// data. This is done simply for convenience and should be changed if
|
||||
// this restricts what should be done for character data.
|
||||
|
||||
class DocumentType final : public nsGenericDOMDataNode,
|
||||
class DocumentType final : public CharacterData,
|
||||
public nsIDOMNode
|
||||
{
|
||||
public:
|
||||
|
@ -55,8 +55,9 @@ public:
|
|||
// nsIContent overrides
|
||||
virtual const nsTextFragment* GetText() override;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
virtual already_AddRefed<CharacterData>
|
||||
CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
|
||||
|
|
|
@ -42,8 +42,6 @@
|
|||
#include "nsBidiPresUtils.h"
|
||||
#include "nsTextFrame.h"
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
|
|
|
@ -276,6 +276,10 @@ ShadowRoot::ApplicableRulesChanged()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!IsComposedDocParticipant()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIDocument* doc = OwnerDoc();
|
||||
if (nsIPresShell* shell = doc->GetShell()) {
|
||||
doc->BeginUpdate(UPDATE_STYLE);
|
||||
|
@ -284,7 +288,6 @@ ShadowRoot::ApplicableRulesChanged()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShadowRoot::InsertSheetAt(size_t aIndex, StyleSheet& aSheet)
|
||||
{
|
||||
|
|
|
@ -6,19 +6,128 @@
|
|||
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "nsTextNode.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
already_AddRefed<Text>
|
||||
Text::SplitText(uint32_t aOffset, ErrorResult& rv)
|
||||
Text::SplitText(uint32_t aOffset, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIContent> newChild;
|
||||
rv = SplitData(aOffset, getter_AddRefs(newChild));
|
||||
if (rv.Failed()) {
|
||||
nsAutoString cutText;
|
||||
uint32_t length = TextLength();
|
||||
|
||||
if (aOffset > length) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
return newChild.forget().downcast<Text>();
|
||||
|
||||
uint32_t cutStartOffset = aOffset;
|
||||
uint32_t cutLength = length - aOffset;
|
||||
SubstringData(cutStartOffset, cutLength, cutText, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDocument* document = GetComposedDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, true);
|
||||
|
||||
// Use Clone for creating the new node so that the new node is of same class
|
||||
// as this node!
|
||||
RefPtr<CharacterData> clone = CloneDataNode(mNodeInfo, false);
|
||||
MOZ_ASSERT(clone && clone->IsText());
|
||||
RefPtr<Text> newContent = static_cast<Text*>(clone.get());
|
||||
|
||||
// nsRange expects the CharacterDataChanged notification is followed
|
||||
// by an insertion of |newContent|. If you change this code,
|
||||
// make sure you make the appropriate changes in nsRange.
|
||||
newContent->SetText(cutText, true); // XXX should be false?
|
||||
|
||||
CharacterDataChangeInfo::Details details = {
|
||||
CharacterDataChangeInfo::Details::eSplit, newContent
|
||||
};
|
||||
nsresult rv = SetTextInternal(cutStartOffset, cutLength, nullptr, 0, true,
|
||||
&details);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> parent = GetParentNode();
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIContent> beforeNode = GetNextSibling();
|
||||
parent->InsertChildBefore(newContent, beforeNode, true);
|
||||
}
|
||||
|
||||
return newContent.forget();
|
||||
}
|
||||
|
||||
static Text*
|
||||
FirstLogicallyAdjacentTextNode(Text* aNode)
|
||||
{
|
||||
do {
|
||||
nsIContent* sibling = aNode->GetPreviousSibling();
|
||||
if (!sibling || !sibling->IsText()) {
|
||||
return aNode;
|
||||
}
|
||||
aNode = static_cast<Text*>(sibling);
|
||||
} while (1); // Must run out of previous siblings eventually!
|
||||
}
|
||||
|
||||
static Text*
|
||||
LastLogicallyAdjacentTextNode(Text* aNode)
|
||||
{
|
||||
do {
|
||||
nsIContent* sibling = aNode->GetNextSibling();
|
||||
if (!sibling || !sibling->IsText()) {
|
||||
return aNode;
|
||||
}
|
||||
|
||||
aNode = static_cast<Text*>(sibling);
|
||||
} while (1); // Must run out of next siblings eventually!
|
||||
}
|
||||
|
||||
void
|
||||
Text::GetWholeText(nsAString& aWholeText,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsIContent* parent = GetParent();
|
||||
|
||||
// Handle parent-less nodes
|
||||
if (!parent) {
|
||||
GetData(aWholeText);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t index = parent->ComputeIndexOf(this);
|
||||
NS_WARNING_ASSERTION(index >= 0,
|
||||
"Trying to use .wholeText with an anonymous"
|
||||
"text node child of a binding parent?");
|
||||
if (NS_WARN_IF(index < 0)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
Text* first = FirstLogicallyAdjacentTextNode(this);
|
||||
Text* last = LastLogicallyAdjacentTextNode(this);
|
||||
|
||||
aWholeText.Truncate();
|
||||
|
||||
nsAutoString tmp;
|
||||
|
||||
while (true) {
|
||||
first->GetData(tmp);
|
||||
aWholeText.Append(tmp);
|
||||
|
||||
if (first == last) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsIContent* next = first->GetNextSibling();
|
||||
MOZ_ASSERT(next && next->IsText(),
|
||||
"How did we run out of text before hitting `last`?");
|
||||
first = static_cast<Text*>(next);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<Text>
|
||||
|
|
|
@ -7,31 +7,26 @@
|
|||
#ifndef mozilla_dom_Text_h
|
||||
#define mozilla_dom_Text_h
|
||||
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Text : public nsGenericDOMDataNode
|
||||
class Text : public CharacterData
|
||||
{
|
||||
public:
|
||||
explicit Text(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
: CharacterData(aNodeInfo)
|
||||
{}
|
||||
|
||||
explicit Text(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
: CharacterData(aNodeInfo)
|
||||
{}
|
||||
|
||||
using nsGenericDOMDataNode::GetWholeText;
|
||||
|
||||
// WebIDL API
|
||||
already_AddRefed<Text> SplitText(uint32_t aOffset, ErrorResult& rv);
|
||||
void GetWholeText(nsAString& aWholeText, ErrorResult& rv)
|
||||
{
|
||||
rv = GetWholeText(aWholeText);
|
||||
}
|
||||
void GetWholeText(nsAString& aWholeText, ErrorResult& rv);
|
||||
|
||||
static already_AddRefed<Text>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
|
@ -43,14 +38,14 @@ public:
|
|||
|
||||
inline mozilla::dom::Text* nsINode::GetAsText()
|
||||
{
|
||||
return IsNodeOfType(eTEXT) ? static_cast<mozilla::dom::Text*>(this)
|
||||
: nullptr;
|
||||
return IsText() ? static_cast<mozilla::dom::Text*>(this)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
inline const mozilla::dom::Text* nsINode::GetAsText() const
|
||||
{
|
||||
return IsNodeOfType(eTEXT) ? static_cast<const mozilla::dom::Text*>(this)
|
||||
: nullptr;
|
||||
return IsText() ? static_cast<const mozilla::dom::Text*>(this)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
#endif // mozilla_dom_Text_h
|
||||
|
|
|
@ -73,7 +73,6 @@ EXPORTS += [
|
|||
'nsDOMTokenList.h',
|
||||
'nsFocusManager.h',
|
||||
'nsFrameMessageManager.h',
|
||||
'nsGenericDOMDataNode.h',
|
||||
'nsGlobalWindow.h', # Because binding headers include it.
|
||||
'nsGlobalWindowInner.h', # Because binding headers include it.
|
||||
'nsGlobalWindowOuter.h', # Because binding headers include it.
|
||||
|
@ -153,6 +152,7 @@ EXPORTS.mozilla.dom += [
|
|||
'BarProps.h',
|
||||
'BodyUtil.h',
|
||||
'BorrowedAttrInfo.h',
|
||||
'CharacterData.h',
|
||||
'ChildIterator.h',
|
||||
'ChromeNodeList.h',
|
||||
'ChromeUtils.h',
|
||||
|
@ -231,6 +231,7 @@ UNIFIED_SOURCES += [
|
|||
'BarProps.cpp',
|
||||
'BodyUtil.cpp',
|
||||
'BorrowedAttrInfo.cpp',
|
||||
'CharacterData.cpp',
|
||||
'ChildIterator.cpp',
|
||||
'ChromeNodeList.cpp',
|
||||
'ChromeUtils.cpp',
|
||||
|
@ -296,7 +297,6 @@ UNIFIED_SOURCES += [
|
|||
'nsFocusManager.cpp',
|
||||
'nsFrameLoader.cpp',
|
||||
'nsGenConImageContent.cpp',
|
||||
'nsGenericDOMDataNode.cpp',
|
||||
'nsGlobalWindowCommands.cpp',
|
||||
'nsHistory.cpp',
|
||||
'nsHTMLContentSerializer.cpp',
|
||||
|
|
|
@ -6715,8 +6715,12 @@ nsContentUtils::DispatchXULCommand(nsIContent* aTarget,
|
|||
RefPtr<XULCommandEvent> xulCommand = new XULCommandEvent(doc, presContext,
|
||||
nullptr);
|
||||
xulCommand->InitCommandEvent(NS_LITERAL_STRING("command"), true, true,
|
||||
doc->GetInnerWindow(), 0, aCtrl, aAlt, aShift,
|
||||
aMeta, aSourceEvent, aInputSource);
|
||||
nsGlobalWindowInner::Cast(doc->GetInnerWindow()),
|
||||
0, aCtrl, aAlt, aShift,
|
||||
aMeta,
|
||||
aSourceEvent ?
|
||||
aSourceEvent->InternalDOMEvent() : nullptr,
|
||||
aInputSource, IgnoreErrors());
|
||||
|
||||
if (aShell) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
|
|
@ -2113,7 +2113,7 @@ public:
|
|||
|
||||
/**
|
||||
* This method creates and dispatches "command" event, which implements
|
||||
* nsIDOMXULCommandEvent.
|
||||
* XULCommandEvent.
|
||||
* If aShell is not null, dispatching goes via
|
||||
* nsIPresShell::HandleDOMEventWithTarget.
|
||||
*/
|
||||
|
|
|
@ -73,8 +73,6 @@
|
|||
#include "nsITabChild.h"
|
||||
|
||||
#include "nsRange.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "mozilla/dom/DocumentType.h"
|
||||
#include "mozilla/dom/NodeIterator.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
#include "mozilla/Encoding.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
|
@ -44,9 +41,12 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsStringBuffer.h"
|
||||
#include "mozilla/dom/Comment.h"
|
||||
#include "mozilla/dom/DocumentType.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
|
||||
|
@ -418,13 +418,13 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
|
|||
}
|
||||
case nsINode::PROCESSING_INSTRUCTION_NODE:
|
||||
{
|
||||
mSerializer->AppendProcessingInstruction(static_cast<nsIContent*>(node),
|
||||
mSerializer->AppendProcessingInstruction(static_cast<ProcessingInstruction*>(node),
|
||||
aStartOffset, aEndOffset, aStr);
|
||||
break;
|
||||
}
|
||||
case nsINode::COMMENT_NODE:
|
||||
{
|
||||
mSerializer->AppendComment(static_cast<nsIContent*>(node),
|
||||
mSerializer->AppendComment(static_cast<Comment*>(node),
|
||||
aStartOffset, aEndOffset, aStr);
|
||||
break;
|
||||
}
|
||||
|
@ -1600,7 +1600,7 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
|
|||
{
|
||||
// some special casing for text nodes
|
||||
nsCOMPtr<nsINode> t = do_QueryInterface(aNode);
|
||||
if (IsTextNode(t))
|
||||
if (auto nodeAsText = t->GetAsText())
|
||||
{
|
||||
// if not at beginning of text node, we are done
|
||||
if (offset > 0)
|
||||
|
@ -1608,9 +1608,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
|
|||
// unless everything before us in just whitespace. NOTE: we need a more
|
||||
// general solution that truly detects all cases of non-significant
|
||||
// whitesace with no false alarms.
|
||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(aNode);
|
||||
nsAutoString text;
|
||||
nodeAsText->SubstringData(0, offset, text);
|
||||
nodeAsText->SubstringData(0, offset, text, IgnoreErrors());
|
||||
text.CompressWhitespace();
|
||||
if (!text.IsEmpty())
|
||||
return NS_OK;
|
||||
|
@ -1676,7 +1675,7 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
|
|||
{
|
||||
// some special casing for text nodes
|
||||
nsCOMPtr<nsINode> n = do_QueryInterface(aNode);
|
||||
if (IsTextNode(n))
|
||||
if (auto nodeAsText = n->GetAsText())
|
||||
{
|
||||
// if not at end of text node, we are done
|
||||
uint32_t len = n->Length();
|
||||
|
@ -1685,9 +1684,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
|
|||
// unless everything after us in just whitespace. NOTE: we need a more
|
||||
// general solution that truly detects all cases of non-significant
|
||||
// whitespace with no false alarms.
|
||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(aNode);
|
||||
nsAutoString text;
|
||||
nodeAsText->SubstringData(offset, len-offset, text);
|
||||
nodeAsText->SubstringData(offset, len-offset, text, IgnoreErrors());
|
||||
text.CompressWhitespace();
|
||||
if (!text.IsEmpty())
|
||||
return NS_OK;
|
||||
|
|
|
@ -1009,19 +1009,19 @@ inline nsIContent* nsINode::AsContent()
|
|||
}
|
||||
|
||||
#define NS_IMPL_FROMCONTENT_HELPER(_class, _check) \
|
||||
static _class* FromContent(nsIContent* aContent) \
|
||||
static _class* FromContent(nsINode* aContent) \
|
||||
{ \
|
||||
return aContent->_check ? static_cast<_class*>(aContent) : nullptr; \
|
||||
} \
|
||||
static const _class* FromContent(const nsIContent* aContent) \
|
||||
static const _class* FromContent(const nsINode* aContent) \
|
||||
{ \
|
||||
return aContent->_check ? static_cast<const _class*>(aContent) : nullptr; \
|
||||
} \
|
||||
static _class* FromContentOrNull(nsIContent* aContent) \
|
||||
static _class* FromContentOrNull(nsINode* aContent) \
|
||||
{ \
|
||||
return aContent ? FromContent(aContent) : nullptr; \
|
||||
} \
|
||||
static const _class* FromContentOrNull(const nsIContent* aContent) \
|
||||
static const _class* FromContentOrNull(const nsINode* aContent) \
|
||||
{ \
|
||||
return aContent ? FromContent(aContent) : nullptr; \
|
||||
}
|
||||
|
|
|
@ -16,8 +16,10 @@ class nsIDocument;
|
|||
namespace mozilla {
|
||||
class Encoding;
|
||||
namespace dom {
|
||||
class Comment;
|
||||
class DocumentType;
|
||||
class Element;
|
||||
class ProcessingInstruction;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -44,12 +46,13 @@ class nsIContentSerializer : public nsISupports {
|
|||
int32_t aStartOffset, int32_t aEndOffset,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
|
||||
NS_IMETHOD AppendProcessingInstruction(mozilla::dom::ProcessingInstruction* aPI,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset,
|
||||
NS_IMETHOD AppendComment(mozilla::dom::Comment* aComment,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset, nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendDoctype(mozilla::dom::DocumentType* aDoctype,
|
||||
|
|
|
@ -2385,22 +2385,6 @@ nsINode::UnbindObject(nsISupports* aObject)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsINode::GetBoundMutationObservers(nsTArray<RefPtr<nsDOMMutationObserver> >& aResult)
|
||||
{
|
||||
nsCOMArray<nsISupports>* objects =
|
||||
static_cast<nsCOMArray<nsISupports>*>(GetProperty(nsGkAtoms::keepobjectsalive));
|
||||
if (objects) {
|
||||
for (int32_t i = 0; i < objects->Count(); ++i) {
|
||||
nsCOMPtr<nsDOMMutationObserver> mo = do_QueryInterface(objects->ObjectAt(i));
|
||||
if (mo) {
|
||||
MOZ_ASSERT(!aResult.Contains(mo));
|
||||
aResult.AppendElement(mo.forget());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<AccessibleNode>
|
||||
nsINode::GetAccessibleNode()
|
||||
{
|
||||
|
|
|
@ -406,8 +406,7 @@ public:
|
|||
eHTML_FORM_CONTROL = 1 << 6,
|
||||
/** document fragments */
|
||||
eDOCUMENT_FRAGMENT = 1 << 7,
|
||||
/** data nodes (comments, PIs, text). Nodes of this type always
|
||||
returns a non-null value for nsIContent::GetText() */
|
||||
/** character data nodes (comments, PIs, text). */
|
||||
eDATA_NODE = 1 << 8,
|
||||
/** HTMLMediaElement */
|
||||
eMEDIA = 1 << 9,
|
||||
|
@ -499,6 +498,16 @@ public:
|
|||
return const_cast<nsINode*>(this)->AsContent();
|
||||
}
|
||||
|
||||
/*
|
||||
* Return whether the node is a Text node (which might be an actual
|
||||
* textnode, or might be a CDATA section).
|
||||
*/
|
||||
bool IsText() const
|
||||
{
|
||||
uint32_t nodeType = NodeType();
|
||||
return nodeType == TEXT_NODE || nodeType == CDATA_SECTION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this node as Text if it is one, otherwise null. This is defined
|
||||
* inline in Text.h.
|
||||
|
@ -506,6 +515,27 @@ public:
|
|||
mozilla::dom::Text* GetAsText();
|
||||
const mozilla::dom::Text* GetAsText() const;
|
||||
|
||||
/*
|
||||
* Return whether the node is a ProcessingInstruction node.
|
||||
*/
|
||||
bool IsProcessingInstruction() const
|
||||
{
|
||||
return NodeType() == PROCESSING_INSTRUCTION_NODE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return whether the node is a CharacterData node (text, cdata,
|
||||
* comment, processing instruction)
|
||||
*/
|
||||
bool IsCharacterData() const
|
||||
{
|
||||
uint32_t nodeType = NodeType();
|
||||
return nodeType == TEXT_NODE ||
|
||||
nodeType == CDATA_SECTION_NODE ||
|
||||
nodeType == PROCESSING_INSTRUCTION_NODE ||
|
||||
nodeType == COMMENT_NODE;
|
||||
}
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() = 0;
|
||||
|
||||
/**
|
||||
|
@ -1751,7 +1781,6 @@ public:
|
|||
// aObject alive anymore.
|
||||
void UnbindObject(nsISupports* aObject);
|
||||
|
||||
void GetBoundMutationObservers(nsTArray<RefPtr<nsDOMMutationObserver> >& aResult);
|
||||
void GenerateXPath(nsAString& aResult);
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise>
|
||||
|
|
|
@ -55,12 +55,19 @@ public:
|
|||
NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
|
||||
int32_t aStartOffset, int32_t aEndOffset,
|
||||
nsAString& aStr) override;
|
||||
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
|
||||
NS_IMETHOD AppendProcessingInstruction(mozilla::dom::ProcessingInstruction* aPI,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset,
|
||||
nsAString& aStr) override { return NS_OK; }
|
||||
NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset,
|
||||
int32_t aEndOffset, nsAString& aStr) override { return NS_OK; }
|
||||
nsAString& aStr) override
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD AppendComment(mozilla::dom::Comment* aComment,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset, nsAString& aStr) override
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD AppendDoctype(mozilla::dom::DocumentType* aDoctype,
|
||||
nsAString& aStr) override { return NS_OK; }
|
||||
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsINodeList.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsTextFrame.h"
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/DocumentType.h"
|
||||
#include "mozilla/dom/RangeBinding.h"
|
||||
|
@ -32,6 +31,7 @@
|
|||
#include "mozilla/dom/DOMStringList.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
|
@ -1897,9 +1897,9 @@ RangeSubtreeIterator::Init(nsRange *aRange)
|
|||
nsCOMPtr<nsINode> node = aRange->GetStartContainer(rv);
|
||||
if (!node) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> startData = do_QueryInterface(node);
|
||||
if (startData || (node->IsElement() &&
|
||||
node->AsElement()->GetChildCount() == aRange->GetStartOffset(rv))) {
|
||||
if (node->IsCharacterData() ||
|
||||
(node->IsElement() &&
|
||||
node->AsElement()->GetChildCount() == aRange->GetStartOffset(rv))) {
|
||||
mStart = node;
|
||||
}
|
||||
|
||||
|
@ -1910,8 +1910,8 @@ RangeSubtreeIterator::Init(nsRange *aRange)
|
|||
node = aRange->GetEndContainer(rv);
|
||||
if (!node) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> endData = do_QueryInterface(node);
|
||||
if (endData || (node->IsElement() && aRange->GetEndOffset(rv) == 0)) {
|
||||
if (node->IsCharacterData() ||
|
||||
(node->IsElement() && aRange->GetEndOffset(rv) == 0)) {
|
||||
mEnd = node;
|
||||
}
|
||||
|
||||
|
@ -2171,8 +2171,7 @@ ValidateCurrentNode(nsRange* aRange, RangeSubtreeIterator& aIter)
|
|||
NS_ENSURE_SUCCESS(res, false);
|
||||
|
||||
if (before || after) {
|
||||
nsCOMPtr<nsIDOMCharacterData> charData = do_QueryInterface(node);
|
||||
if (charData) {
|
||||
if (node->IsCharacterData()) {
|
||||
// If we're dealing with the start/end container which is a character
|
||||
// node, pretend that the node is in the range.
|
||||
if (before && node == aRange->GetStartContainer()) {
|
||||
|
@ -2289,27 +2288,23 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
// XXX_kin: We need to also handle ProcessingInstruction
|
||||
// XXX_kin: according to the spec.
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> charData(do_QueryInterface(node));
|
||||
|
||||
if (charData)
|
||||
{
|
||||
if (auto charData = CharacterData::FromContent(node)) {
|
||||
uint32_t dataLength = 0;
|
||||
|
||||
if (node == startContainer)
|
||||
{
|
||||
if (node == endContainer)
|
||||
{
|
||||
if (node == startContainer) {
|
||||
if (node == endContainer) {
|
||||
// This range is completely contained within a single text node.
|
||||
// Delete or extract the data between startOffset and endOffset.
|
||||
|
||||
if (endOffset > startOffset)
|
||||
{
|
||||
if (endOffset > startOffset) {
|
||||
if (retval) {
|
||||
nsAutoString cutValue;
|
||||
rv = charData->SubstringData(startOffset, endOffset - startOffset,
|
||||
cutValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult err;
|
||||
charData->SubstringData(startOffset, endOffset - startOffset,
|
||||
cutValue, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
nsCOMPtr<nsINode> clone = node->CloneNode(false, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
|
@ -2322,27 +2317,30 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
}
|
||||
|
||||
nsMutationGuard guard;
|
||||
rv = charData->DeleteData(startOffset, endOffset - startOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult err;
|
||||
charData->DeleteData(startOffset, endOffset - startOffset, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
NS_ENSURE_STATE(!guard.Mutated(0) ||
|
||||
ValidateCurrentNode(this, iter));
|
||||
}
|
||||
|
||||
handled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// Delete or extract everything after startOffset.
|
||||
|
||||
rv = charData->GetLength(&dataLength);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
dataLength = charData->Length();
|
||||
|
||||
if (dataLength >= startOffset) {
|
||||
if (retval) {
|
||||
nsAutoString cutValue;
|
||||
rv = charData->SubstringData(startOffset, dataLength, cutValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult err;
|
||||
charData->SubstringData(startOffset, dataLength, cutValue, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
nsCOMPtr<nsINode> clone = node->CloneNode(false, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
|
@ -2355,7 +2353,11 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
}
|
||||
|
||||
nsMutationGuard guard;
|
||||
rv = charData->DeleteData(startOffset, dataLength);
|
||||
ErrorResult err;
|
||||
charData->DeleteData(startOffset, dataLength, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_STATE(!guard.Mutated(0) ||
|
||||
ValidateCurrentNode(this, iter));
|
||||
|
@ -2364,14 +2366,15 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
handled = true;
|
||||
}
|
||||
}
|
||||
else if (node == endContainer)
|
||||
{
|
||||
else if (node == endContainer) {
|
||||
// Delete or extract everything before endOffset.
|
||||
if (retval) {
|
||||
nsAutoString cutValue;
|
||||
rv = charData->SubstringData(0, endOffset, cutValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult err;
|
||||
charData->SubstringData(0, endOffset, cutValue, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
nsCOMPtr<nsINode> clone = node->CloneNode(false, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
|
@ -2384,16 +2387,18 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
}
|
||||
|
||||
nsMutationGuard guard;
|
||||
rv = charData->DeleteData(0, endOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult err;
|
||||
charData->DeleteData(0, endOffset, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
NS_ENSURE_STATE(!guard.Mutated(0) ||
|
||||
ValidateCurrentNode(this, iter));
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled && (node == endContainer || node == startContainer))
|
||||
{
|
||||
if (!handled && (node == endContainer || node == startContainer)) {
|
||||
if (node && node->IsElement() &&
|
||||
((node == endContainer && endOffset == 0) ||
|
||||
(node == startContainer &&
|
||||
|
@ -2407,8 +2412,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
}
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
if (!handled) {
|
||||
// node was not handled above, so it must be completely contained
|
||||
// within the range. Just remove it from the tree!
|
||||
nodeToResult = node;
|
||||
|
@ -2428,8 +2432,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
NS_ENSURE_STATE(commonAncestor);
|
||||
|
||||
nsCOMPtr<nsINode> parentCounterNode = node;
|
||||
while (parentCounterNode && parentCounterNode != commonAncestor)
|
||||
{
|
||||
while (parentCounterNode && parentCounterNode != commonAncestor) {
|
||||
++parentCount;
|
||||
parentCounterNode = parentCounterNode->GetParentNode();
|
||||
NS_ENSURE_STATE(parentCounterNode);
|
||||
|
@ -2444,8 +2447,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ErrorResult res;
|
||||
if (farthestAncestor)
|
||||
{
|
||||
if (farthestAncestor) {
|
||||
nsCOMPtr<nsINode> n = do_QueryInterface(commonCloneAncestor);
|
||||
n->AppendChild(*farthestAncestor, res);
|
||||
res.WouldReportJSException();
|
||||
|
@ -2483,8 +2485,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
|
|||
if (!iter.IsDone() && retval) {
|
||||
// Find the equivalent of commonAncestor in the cloned tree.
|
||||
nsCOMPtr<nsINode> newCloneAncestor = nodeToResult;
|
||||
for (uint32_t i = parentCount; i; --i)
|
||||
{
|
||||
for (uint32_t i = parentCount; i; --i) {
|
||||
newCloneAncestor = newCloneAncestor->GetParentNode();
|
||||
NS_ENSURE_STATE(newCloneAncestor);
|
||||
}
|
||||
|
@ -2724,23 +2725,16 @@ nsRange::CloneContents(ErrorResult& aRv)
|
|||
// XXX_kin: We need to also handle ProcessingInstruction
|
||||
// XXX_kin: according to the spec.
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> charData(do_QueryInterface(clone));
|
||||
|
||||
if (charData)
|
||||
if (auto charData = CharacterData::FromContent(clone))
|
||||
{
|
||||
if (node == mEnd.Container()) {
|
||||
// We only need the data before mEndOffset, so get rid of any
|
||||
// data after it.
|
||||
|
||||
uint32_t dataLength = 0;
|
||||
aRv = charData->GetLength(&dataLength);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t dataLength = charData->Length();
|
||||
if (dataLength > (uint32_t)mEnd.Offset())
|
||||
{
|
||||
aRv = charData->DeleteData(mEnd.Offset(), dataLength - mEnd.Offset());
|
||||
charData->DeleteData(mEnd.Offset(), dataLength - mEnd.Offset(), aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2753,7 +2747,7 @@ nsRange::CloneContents(ErrorResult& aRv)
|
|||
|
||||
if (mStart.Offset() > 0)
|
||||
{
|
||||
aRv = charData->DeleteData(0, mStart.Offset());
|
||||
charData->DeleteData(0, mStart.Offset(), aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2911,7 +2905,8 @@ nsRange::InsertNode(nsINode& aNode, ErrorResult& aRv)
|
|||
nsCOMPtr<nsINode> referenceNode;
|
||||
nsCOMPtr<nsINode> referenceParentNode = tStartContainer;
|
||||
|
||||
nsCOMPtr<nsIDOMText> startTextNode(do_QueryInterface(tStartContainer));
|
||||
RefPtr<Text> startTextNode =
|
||||
tStartContainer ? tStartContainer->GetAsText() : nullptr;
|
||||
nsCOMPtr<nsINodeList> tChildList;
|
||||
if (startTextNode) {
|
||||
referenceParentNode = tStartContainer->GetParentNode();
|
||||
|
@ -2926,8 +2921,7 @@ nsRange::InsertNode(nsINode& aNode, ErrorResult& aRv)
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMText> secondPart;
|
||||
aRv = startTextNode->SplitText(tStartOffset, getter_AddRefs(secondPart));
|
||||
RefPtr<Text> secondPart = startTextNode->SplitText(tStartOffset, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
@ -3108,20 +3102,23 @@ nsRange::ToString(nsAString& aReturn)
|
|||
|
||||
// effeciency hack for simple case
|
||||
if (mStart.Container() == mEnd.Container()) {
|
||||
nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(mStart.Container());
|
||||
Text* textNode = mStart.Container() ? mStart.Container()->GetAsText() : nullptr;
|
||||
|
||||
if (textNode)
|
||||
{
|
||||
#ifdef DEBUG_range
|
||||
// If debug, dump it:
|
||||
nsCOMPtr<nsIContent> cN = do_QueryInterface(mStart.Container());
|
||||
if (cN) cN->List(stdout);
|
||||
textNode->List(stdout);
|
||||
printf("End Range dump: -----------------------\n");
|
||||
#endif /* DEBUG */
|
||||
|
||||
// grab the text
|
||||
if (NS_FAILED(textNode->SubstringData(mStart.Offset(),mEnd.Offset()-mStart.Offset(),aReturn)))
|
||||
IgnoredErrorResult rv;
|
||||
textNode->SubstringData(mStart.Offset(), mEnd.Offset() - mStart.Offset(),
|
||||
aReturn, rv);
|
||||
if (rv.Failed()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -3146,16 +3143,16 @@ nsRange::ToString(nsAString& aReturn)
|
|||
// If debug, dump it:
|
||||
n->List(stdout);
|
||||
#endif /* DEBUG */
|
||||
nsCOMPtr<nsIDOMText> textNode(do_QueryInterface(n));
|
||||
Text* textNode = n->GetAsText();
|
||||
if (textNode) // if it's a text node, get the text
|
||||
{
|
||||
if (n == mStart.Container()) { // only include text past start offset
|
||||
uint32_t strLength;
|
||||
textNode->GetLength(&strLength);
|
||||
textNode->SubstringData(mStart.Offset(),strLength-mStart.Offset(),tempString);
|
||||
uint32_t strLength = textNode->Length();
|
||||
textNode->SubstringData(mStart.Offset(), strLength-mStart.Offset(),
|
||||
tempString, IgnoreErrors());
|
||||
aReturn += tempString;
|
||||
} else if (n == mEnd.Container()) { // only include text before end offset
|
||||
textNode->SubstringData(0,mEnd.Offset(),tempString);
|
||||
textNode->SubstringData(0, mEnd.Offset(), tempString, IgnoreErrors());
|
||||
aReturn += tempString;
|
||||
} else { // grab the whole kit-n-kaboodle
|
||||
textNode->GetData(tempString);
|
||||
|
@ -3239,7 +3236,7 @@ GetTextFrameForContent(nsIContent* aContent, bool aFlushLayout)
|
|||
|
||||
const bool frameWillBeUnsuppressed =
|
||||
presShell->FrameConstructor()->EnsureFrameForTextNodeIsCreatedAfterFlush(
|
||||
static_cast<nsGenericDOMDataNode*>(aContent));
|
||||
static_cast<CharacterData*>(aContent));
|
||||
if (aFlushLayout) {
|
||||
doc->FlushPendingNotifications(FlushType::Layout);
|
||||
} else if (frameWillBeUnsuppressed) {
|
||||
|
@ -3752,7 +3749,7 @@ ElementIsVisibleNoFlush(Element* aElement)
|
|||
static void
|
||||
AppendTransformedText(InnerTextAccumulator& aResult, nsIContent* aContainer)
|
||||
{
|
||||
auto textNode = static_cast<nsGenericDOMDataNode*>(aContainer);
|
||||
auto textNode = static_cast<CharacterData*>(aContainer);
|
||||
|
||||
nsIFrame* frame = textNode->GetPrimaryFrame();
|
||||
if (!IsVisibleAndNotInReplacedElement(frame)) {
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCRT.h"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMText node.
|
||||
* Implementation of DOM Core's Text node.
|
||||
*/
|
||||
|
||||
#include "nsTextNode.h"
|
||||
|
@ -55,19 +55,19 @@ public:
|
|||
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
||||
|
||||
virtual nsGenericDOMDataNode *CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override
|
||||
virtual already_AddRefed<CharacterData>
|
||||
CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override
|
||||
{
|
||||
already_AddRefed<mozilla::dom::NodeInfo> ni =
|
||||
RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
||||
nsAttributeTextNode *it = new nsAttributeTextNode(ni,
|
||||
mNameSpaceID,
|
||||
mAttrName);
|
||||
if (it && aCloneText) {
|
||||
RefPtr<nsAttributeTextNode> it =
|
||||
new nsAttributeTextNode(ni, mNameSpaceID, mAttrName);
|
||||
if (aCloneText) {
|
||||
it->mText = mText;
|
||||
}
|
||||
|
||||
return it;
|
||||
return it.forget();
|
||||
}
|
||||
|
||||
// Public method for the event to run
|
||||
|
@ -99,8 +99,7 @@ nsTextNode::~nsTextNode()
|
|||
|
||||
// Use the CC variant of this, even though this class does not define
|
||||
// a new CC participant, to make QIing to the CC interfaces faster.
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(nsTextNode, nsGenericDOMDataNode, nsIDOMNode,
|
||||
nsIDOMText, nsIDOMCharacterData)
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(nsTextNode, CharacterData, nsIDOMNode)
|
||||
|
||||
JSObject*
|
||||
nsTextNode::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
|
@ -114,16 +113,16 @@ nsTextNode::IsNodeOfType(uint32_t aFlags) const
|
|||
return !(aFlags & ~(eTEXT | eDATA_NODE));
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
already_AddRefed<CharacterData>
|
||||
nsTextNode::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
||||
{
|
||||
already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
||||
nsTextNode *it = new nsTextNode(ni);
|
||||
RefPtr<nsTextNode> it = new nsTextNode(ni);
|
||||
if (aCloneText) {
|
||||
it->mText = mText;
|
||||
}
|
||||
|
||||
return it;
|
||||
return it.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -140,9 +139,9 @@ nsresult
|
|||
nsTextNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent, bool aCompileEventHandlers)
|
||||
{
|
||||
nsresult rv = nsGenericDOMDataNode::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
aCompileEventHandlers);
|
||||
nsresult rv = CharacterData::BindToTree(aDocument, aParent,
|
||||
aBindingParent,
|
||||
aCompileEventHandlers);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
SetDirectionFromNewTextNode(this);
|
||||
|
@ -154,7 +153,7 @@ void nsTextNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
|||
{
|
||||
ResetDirectionSetByTextNode(this);
|
||||
|
||||
nsGenericDOMDataNode::UnbindFromTree(aDeep, aNullParent);
|
||||
CharacterData::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
#define nsTextNode_h
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMText node.
|
||||
* Implementation of DOM Core's Text node.
|
||||
*/
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
class nsNodeInfoManager;
|
||||
|
@ -22,7 +22,7 @@ class nsNodeInfoManager;
|
|||
* Class used to implement DOM text nodes
|
||||
*/
|
||||
class nsTextNode : public mozilla::dom::Text,
|
||||
public nsIDOMText
|
||||
public nsIDOMNode
|
||||
{
|
||||
private:
|
||||
void Init()
|
||||
|
@ -47,18 +47,12 @@ public:
|
|||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
// nsIDOMText
|
||||
NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::)
|
||||
|
||||
// nsINode
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
virtual already_AddRefed<CharacterData>
|
||||
CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include "nsXMLContentSerializer.h"
|
||||
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -28,8 +26,10 @@
|
|||
#include "nsCRT.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "mozilla/dom/Comment.h"
|
||||
#include "mozilla/dom/DocumentType.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
#include "mozilla/intl/LineBreaker.h"
|
||||
#include "nsParserConstants.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
|
@ -254,23 +254,18 @@ nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSerializer::AppendProcessingInstruction(nsIContent* aPI,
|
||||
nsXMLContentSerializer::AppendProcessingInstruction(ProcessingInstruction* aPI,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset,
|
||||
nsAString& aStr)
|
||||
{
|
||||
nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(aPI);
|
||||
NS_ENSURE_ARG(pi);
|
||||
nsresult rv;
|
||||
nsAutoString target, data, start;
|
||||
|
||||
NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(aStr), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = pi->GetTarget(target);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
aPI->GetTarget(target);
|
||||
|
||||
rv = pi->GetData(data);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
aPI->GetData(data);
|
||||
|
||||
NS_ENSURE_TRUE(start.AppendLiteral("<?", mozilla::fallible), NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(start.Append(target, mozilla::fallible), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -303,18 +298,13 @@ nsXMLContentSerializer::AppendProcessingInstruction(nsIContent* aPI,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSerializer::AppendComment(nsIContent* aComment,
|
||||
nsXMLContentSerializer::AppendComment(Comment* aComment,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset,
|
||||
nsAString& aStr)
|
||||
{
|
||||
nsCOMPtr<nsIDOMComment> comment = do_QueryInterface(aComment);
|
||||
NS_ENSURE_ARG(comment);
|
||||
nsresult rv;
|
||||
nsAutoString data;
|
||||
|
||||
rv = comment->GetData(data);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
aComment->GetData(data);
|
||||
|
||||
int32_t dataLength = data.Length();
|
||||
if (aStartOffset || (aEndOffset != -1 && aEndOffset < dataLength)) {
|
||||
|
|
|
@ -50,12 +50,13 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
int32_t aStartOffset, int32_t aEndOffset,
|
||||
nsAString& aStr) override;
|
||||
|
||||
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
|
||||
NS_IMETHOD AppendProcessingInstruction(mozilla::dom::ProcessingInstruction* aPI,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset,
|
||||
nsAString& aStr) override;
|
||||
|
||||
NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset,
|
||||
NS_IMETHOD AppendComment(mozilla::dom::Comment* aComment,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset, nsAString& aStr) override;
|
||||
|
||||
NS_IMETHOD AppendDoctype(mozilla::dom::DocumentType* aDoctype,
|
||||
|
|
|
@ -51,8 +51,7 @@ function testComment(aText)
|
|||
var types = [ Comment, CharacterData, Node ];
|
||||
checkTypes(comment, "comment", types);
|
||||
|
||||
var interfaces = [ "nsIDOMComment", "nsIDOMCharacterData", "nsIDOMNode",
|
||||
"nsIDOMEventTarget" ];
|
||||
var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(comment, "comment", interfaces);
|
||||
|
||||
testCharacterData(comment, aText);
|
||||
|
@ -82,8 +81,7 @@ function testPI(aTarget, aData, aShouldSucceed, aReason)
|
|||
var types = [ ProcessingInstruction, Node ];
|
||||
checkTypes(pi, "processing instruction", types);
|
||||
|
||||
var interfaces = [ "nsIDOMProcessingInstruction", "nsIDOMNode",
|
||||
"nsIDOMEventTarget" ];
|
||||
var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(pi, "processing instruction", interfaces);
|
||||
|
||||
is(pi.target, aTarget, "Check target");
|
||||
|
|
|
@ -75,8 +75,7 @@ function testComment(aText)
|
|||
var types = [ Comment, CharacterData, Node ];
|
||||
checkTypes(comment, "comment", types);
|
||||
|
||||
var interfaces = [ "nsIDOMComment", "nsIDOMCharacterData", "nsIDOMNode",
|
||||
"nsIDOMEventTarget" ];
|
||||
var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(comment, "comment", interfaces);
|
||||
|
||||
testCharacterData(comment, aText);
|
||||
|
@ -94,8 +93,7 @@ function testCDATASection(aText, aShouldSucceed)
|
|||
var types = [ CDATASection, CharacterData, Node ];
|
||||
checkTypes(cdataSection, "CDATA section", types);
|
||||
|
||||
var interfaces = [ "nsIDOMCharacterData",
|
||||
"nsIDOMNode", "nsIDOMEventTarget" ];
|
||||
var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(cdataSection, "CDATA section", interfaces);
|
||||
|
||||
testCharacterData(cdataSection, aText);
|
||||
|
@ -126,8 +124,7 @@ function testPI(aTarget, aData, aShouldSucceed, aReason)
|
|||
var types = [ ProcessingInstruction, Node ];
|
||||
checkTypes(pi, "processing instruction", types);
|
||||
|
||||
var interfaces = [ "nsIDOMProcessingInstruction", "nsIDOMNode",
|
||||
"nsIDOMEventTarget" ];
|
||||
var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(pi, "processing instruction", interfaces);
|
||||
|
||||
is(pi.target, aTarget, "Check target");
|
||||
|
|
|
@ -149,9 +149,6 @@ function runTest() {
|
|||
m = null;
|
||||
});
|
||||
m.observe(div, { attributes: true, attributeFilter: ["foo"] });
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributes, true);
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributeFilter.length, 1)
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributeFilter[0], "foo")
|
||||
div.setAttribute("foo", "bar");
|
||||
}
|
||||
|
||||
|
@ -180,9 +177,6 @@ function testThisBind() {
|
|||
m = null;
|
||||
}).bind(window));
|
||||
m.observe(div, { attributes: true, attributeOldValue: true, subtree: true });
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributes, true)
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].attributeOldValue, true)
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[0].getObservingInfo()[0].subtree, true)
|
||||
div.setAttribute("foo", "bar2");
|
||||
div.removeAttribute("foo");
|
||||
div.removeChild(child);
|
||||
|
@ -226,10 +220,6 @@ function testCharacterData() {
|
|||
m3.observe(div, { characterData: true, subtree: true });
|
||||
m3.observe(div, { characterData: true, subtree: false });
|
||||
m4.observe(div.firstChild, { characterData: true, subtree: false });
|
||||
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers().length, 3)
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[2].getObservingInfo()[0].characterData, true)
|
||||
is(SpecialPowers.wrap(div).getBoundMutationObservers()[2].getObservingInfo()[0].subtree, false)
|
||||
|
||||
div.firstChild.data = "bar";
|
||||
}
|
||||
|
@ -303,18 +293,12 @@ function testChildList4() {
|
|||
};
|
||||
m = new M(callback);
|
||||
m.observe(df, { childList: true, characterData: true, characterDataOldValue: true, subtree: true });
|
||||
is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].childList, true)
|
||||
is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].characterData, true)
|
||||
is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].characterDataOldValue, true)
|
||||
is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo()[0].subtree, true)
|
||||
ok(SpecialPowers.compare(SpecialPowers.wrap(df).getBoundMutationObservers()[0].mutationCallback, callback))
|
||||
m.observe(div, { childList: true });
|
||||
is(SpecialPowers.wrap(df).getBoundMutationObservers()[0].getObservingInfo().length, 2)
|
||||
|
||||
|
||||
// Make sure transient observers aren't leaked.
|
||||
var leakTest = new M(function(){});
|
||||
leakTest.observe(div, { characterData: true, subtree: true });
|
||||
|
||||
|
||||
div.insertBefore(df, s2);
|
||||
s1.firstChild.data = "bar"; // This should *not* create a record.
|
||||
t1.data = "Hello the whole "; // This should create a record.
|
||||
|
@ -578,8 +562,6 @@ function testTakeRecords() {
|
|||
m = null;
|
||||
});
|
||||
m.observe(div, { attributes: true, attributeOldValue: true });
|
||||
// Note, [0] points to a mutation observer which is there for a leak test!
|
||||
ok(SpecialPowers.compare(SpecialPowers.wrap(div).getBoundMutationObservers()[1], m));
|
||||
var mutationEventCount = 0;
|
||||
div.addEventListener("DOMAttrModified", mutationListener);
|
||||
div.setAttribute("foo", "bar");
|
||||
|
|
|
@ -17,10 +17,8 @@ const nsIDOMSerializer = I.nsIDOMSerializer;
|
|||
const nsIDOMDocument = I.nsIDOMDocument;
|
||||
const nsIDOMElement = I.nsIDOMElement;
|
||||
const nsIDOMNode = I.nsIDOMNode;
|
||||
const nsIDOMCharacterData = I.nsIDOMCharacterData;
|
||||
const nsIDOMNodeList = I.nsIDOMNodeList;
|
||||
const nsIDOMXULElement = I.nsIDOMXULElement;
|
||||
const nsIDOMProcessingInstruction = I.nsIDOMProcessingInstruction;
|
||||
|
||||
function DOMParser() {
|
||||
var parser = C["@mozilla.org/xmlextras/domparser;1"].createInstance(nsIDOMParser);
|
||||
|
@ -100,18 +98,14 @@ function do_compare_attrs(e1, e2) {
|
|||
|
||||
function do_check_equiv(dom1, dom2) {
|
||||
Assert.equal(dom1.nodeType, dom2.nodeType);
|
||||
// There's no classinfo around, so we'll need to do some QIing to
|
||||
// make sure the right interfaces are flattened as needed.
|
||||
switch (dom1.nodeType) {
|
||||
case nsIDOMNode.PROCESSING_INSTRUCTION_NODE:
|
||||
Assert.equal(dom1.QueryInterface(nsIDOMProcessingInstruction).target,
|
||||
dom2.QueryInterface(nsIDOMProcessingInstruction).target);
|
||||
Assert.equal(dom1.target, dom2.target);
|
||||
Assert.equal(dom1.data, dom2.data);
|
||||
case nsIDOMNode.TEXT_NODE:
|
||||
case nsIDOMNode.CDATA_SECTION_NODE:
|
||||
case nsIDOMNode.COMMENT_NODE:
|
||||
Assert.equal(dom1.QueryInterface(nsIDOMCharacterData).data,
|
||||
dom2.QueryInterface(nsIDOMCharacterData).data);
|
||||
Assert.equal(dom1.data, dom2.data);
|
||||
break;
|
||||
case nsIDOMNode.ELEMENT_NODE:
|
||||
Assert.equal(dom1.namespaceURI, dom2.namespaceURI);
|
||||
|
|
|
@ -340,6 +340,11 @@ function run_miscellaneous_tests() {
|
|||
getParsedDocument(filePath).then(do_miscellaneous_tests);
|
||||
}
|
||||
|
||||
function isText(node) {
|
||||
return node.nodeType == node.TEXT_NODE ||
|
||||
node.nodeType == node.CDATA_SECTION_NODE;
|
||||
}
|
||||
|
||||
function do_miscellaneous_tests(doc) {
|
||||
var tests = doc.getElementsByTagName("test");
|
||||
|
||||
|
@ -360,7 +365,7 @@ function do_miscellaneous_tests(doc) {
|
|||
// Text range manipulation.
|
||||
if ((endOffset > startOffset) &&
|
||||
(startContainer == endContainer) &&
|
||||
(startContainer instanceof Ci.nsIDOMText)) {
|
||||
isText(startContainer)) {
|
||||
// Invalid start node
|
||||
try {
|
||||
baseRange.setStart(null, 0);
|
||||
|
@ -386,7 +391,7 @@ function do_miscellaneous_tests(doc) {
|
|||
}
|
||||
|
||||
// Invalid index
|
||||
var newOffset = startContainer instanceof Ci.nsIDOMText ?
|
||||
var newOffset = isText(startContainer) ?
|
||||
startContainer.nodeValue.length + 1 :
|
||||
startContainer.childNodes.length + 1;
|
||||
try {
|
||||
|
@ -449,7 +454,8 @@ function do_miscellaneous_tests(doc) {
|
|||
baseRange.setEnd(doc.firstChild, 2);
|
||||
var frag = baseRange.extractContents();
|
||||
Assert.equal(frag.childNodes.length, 1);
|
||||
Assert.ok(frag.firstChild instanceof Ci.nsIDOMComment);
|
||||
Assert.ok(ChromeUtils.getClassName(frag.firstChild) == "Comment");
|
||||
Assert.equal(frag.firstChild.nodeType, frag.COMMENT_NODE);
|
||||
Assert.equal(frag.firstChild.nodeValue, "f");
|
||||
|
||||
/* smaug also requested attribute tests. Sadly, those are not yet supported
|
||||
|
|
|
@ -140,7 +140,6 @@ DOMInterfaces = {
|
|||
},
|
||||
|
||||
'CharacterData': {
|
||||
'nativeType': 'nsGenericDOMDataNode',
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<script>
|
||||
try { o1 = document.createElement('canvas') } catch (e) {}
|
||||
try { o2 = o1.transferControlToOffscreen() } catch (e) {}
|
||||
try { o2.getContext("webgl", { }) } catch (e) {}
|
||||
</script>
|
||||
</html>
|
|
@ -51,3 +51,4 @@ load 1349067.html
|
|||
pref(gfx.offscreencanvas.enabled,true) load 1348976-1.html
|
||||
load 1357092.html
|
||||
load 1441613.html
|
||||
pref(gfx.offscreencanvas.enabled,true) load 1443671.html
|
||||
|
|
|
@ -39,6 +39,7 @@ class ExtendableEvent;
|
|||
class KeyboardEvent;
|
||||
class TimeEvent;
|
||||
class WantsPopupControlCheck;
|
||||
class XULCommandEvent;
|
||||
#define GENERATED_EVENT(EventClass_) class EventClass_;
|
||||
#include "mozilla/dom/GeneratedEventList.h"
|
||||
#undef GENERATED_EVENT
|
||||
|
@ -132,6 +133,12 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// XULCommandEvent has a non-autogeneratable initCommandEvent.
|
||||
virtual XULCommandEvent* AsXULCommandEvent()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// nsIDOMEvent Interface
|
||||
NS_DECL_NSIDOMEVENT
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(FocusEvent, UIEvent, nsIDOMFocusEvent)
|
||||
|
||||
FocusEvent::FocusEvent(EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
InternalFocusEvent* aEvent)
|
||||
|
@ -27,14 +25,6 @@ FocusEvent::FocusEvent(EventTarget* aOwner,
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRelatedTarget);
|
||||
*aRelatedTarget = GetRelatedTarget().take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<EventTarget>
|
||||
FocusEvent::GetRelatedTarget()
|
||||
{
|
||||
|
|
|
@ -9,20 +9,14 @@
|
|||
#include "mozilla/dom/FocusEventBinding.h"
|
||||
#include "mozilla/dom/UIEvent.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "nsIDOMFocusEvent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class FocusEvent : public UIEvent,
|
||||
public nsIDOMFocusEvent
|
||||
class FocusEvent : public UIEvent
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMFOCUSEVENT
|
||||
|
||||
// Forward to base class
|
||||
NS_FORWARD_TO_UIEVENT
|
||||
NS_INLINE_DECL_REFCOUNTING_INHERITED(FocusEvent, UIEvent)
|
||||
|
||||
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "mozilla/dom/MouseScrollEvent.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "prtime.h"
|
||||
#include "nsIDOMMouseScrollEvent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -57,15 +56,15 @@ MouseScrollEvent::InitMouseScrollEvent(const nsAString& aType,
|
|||
aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
|
||||
aRelatedTarget);
|
||||
mEvent->AsMouseScrollEvent()->mIsHorizontal =
|
||||
(aAxis == nsIDOMMouseScrollEvent::HORIZONTAL_AXIS);
|
||||
(aAxis == MouseScrollEventBinding::HORIZONTAL_AXIS);
|
||||
}
|
||||
|
||||
int32_t
|
||||
MouseScrollEvent::Axis()
|
||||
{
|
||||
return mEvent->AsMouseScrollEvent()->mIsHorizontal ?
|
||||
static_cast<int32_t>(nsIDOMMouseScrollEvent::HORIZONTAL_AXIS) :
|
||||
static_cast<int32_t>(nsIDOMMouseScrollEvent::VERTICAL_AXIS);
|
||||
MouseScrollEventBinding::HORIZONTAL_AXIS :
|
||||
MouseScrollEventBinding::VERTICAL_AXIS;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -33,7 +33,6 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(XULCommandEvent, UIEvent,
|
|||
mSourceEvent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XULCommandEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
||||
|
||||
bool
|
||||
|
@ -42,103 +41,54 @@ XULCommandEvent::AltKey()
|
|||
return mEvent->AsInputEvent()->IsAlt();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandEvent::GetAltKey(bool* aIsDown)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsDown);
|
||||
*aIsDown = AltKey();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
XULCommandEvent::CtrlKey()
|
||||
{
|
||||
return mEvent->AsInputEvent()->IsControl();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandEvent::GetCtrlKey(bool* aIsDown)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsDown);
|
||||
*aIsDown = CtrlKey();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
XULCommandEvent::ShiftKey()
|
||||
{
|
||||
return mEvent->AsInputEvent()->IsShift();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandEvent::GetShiftKey(bool* aIsDown)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsDown);
|
||||
*aIsDown = ShiftKey();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
XULCommandEvent::MetaKey()
|
||||
{
|
||||
return mEvent->AsInputEvent()->IsMeta();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandEvent::GetMetaKey(bool* aIsDown)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsDown);
|
||||
*aIsDown = MetaKey();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
XULCommandEvent::InputSource()
|
||||
{
|
||||
return mInputSource;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandEvent::GetInputSource(uint16_t* aInputSource)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInputSource);
|
||||
*aInputSource = InputSource();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSourceEvent);
|
||||
nsCOMPtr<nsIDOMEvent> event = GetSourceEvent();
|
||||
event.forget(aSourceEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
XULCommandEvent::InitCommandEvent(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
mozIDOMWindow* aView,
|
||||
nsGlobalWindowInner* aView,
|
||||
int32_t aDetail,
|
||||
bool aCtrlKey,
|
||||
bool aAltKey,
|
||||
bool aShiftKey,
|
||||
bool aMetaKey,
|
||||
nsIDOMEvent* aSourceEvent,
|
||||
uint16_t aInputSource)
|
||||
Event* aSourceEvent,
|
||||
uint16_t aInputSource,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
|
||||
if (NS_WARN_IF(mEvent->mFlags.mIsBeingDispatched)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* view = nsGlobalWindowInner::Cast(nsPIDOMWindowInner::From(aView));
|
||||
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, view, aDetail);
|
||||
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
|
||||
|
||||
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
|
||||
aShiftKey, aMetaKey);
|
||||
mSourceEvent = aSourceEvent;
|
||||
mInputSource = aInputSource;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -4,20 +4,18 @@
|
|||
* 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/. */
|
||||
|
||||
// This class implements a XUL "command" event. See nsIDOMXULCommandEvent.idl
|
||||
// This class implements a XUL "command" event. See XULCommandEvent.webidl
|
||||
|
||||
#ifndef mozilla_dom_XULCommandEvent_h_
|
||||
#define mozilla_dom_XULCommandEvent_h_
|
||||
|
||||
#include "mozilla/dom/UIEvent.h"
|
||||
#include "mozilla/dom/XULCommandEventBinding.h"
|
||||
#include "nsIDOMXULCommandEvent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class XULCommandEvent : public UIEvent,
|
||||
public nsIDOMXULCommandEvent
|
||||
class XULCommandEvent : public UIEvent
|
||||
{
|
||||
public:
|
||||
XULCommandEvent(EventTarget* aOwner,
|
||||
|
@ -26,16 +24,17 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent)
|
||||
NS_DECL_NSIDOMXULCOMMANDEVENT
|
||||
|
||||
// Forward our inherited virtual methods to the base class
|
||||
NS_FORWARD_TO_UIEVENT
|
||||
|
||||
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
return XULCommandEventBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
virtual XULCommandEvent* AsXULCommandEvent() override
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
bool AltKey();
|
||||
bool CtrlKey();
|
||||
bool ShiftKey();
|
||||
|
@ -56,12 +55,8 @@ public:
|
|||
bool aCtrlKey, bool aAltKey,
|
||||
bool aShiftKey, bool aMetaKey,
|
||||
Event* aSourceEvent,
|
||||
uint16_t aInputSource)
|
||||
{
|
||||
InitCommandEvent(aType, aCanBubble, aCancelable, aView->AsInner(),
|
||||
aDetail, aCtrlKey, aAltKey, aShiftKey, aMetaKey,
|
||||
aSourceEvent, aInputSource);
|
||||
}
|
||||
uint16_t aInputSource,
|
||||
ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
~XULCommandEvent() {}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "nsEditorCID.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsTextControlFrame.h"
|
||||
|
|
|
@ -16,15 +16,11 @@ typedef double DOMHighResTimeStamp;
|
|||
typedef unsigned long long nsViewID;
|
||||
|
||||
// Core
|
||||
interface nsIDOMCharacterData;
|
||||
interface nsIDOMComment;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMDocumentFragment;
|
||||
interface nsIDOMElement;
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMNodeList;
|
||||
interface nsIDOMProcessingInstruction;
|
||||
interface nsIDOMText;
|
||||
|
||||
// Needed for raises() in our IDL
|
||||
%{C++
|
||||
|
|
|
@ -8,8 +8,6 @@ with Files("**"):
|
|||
BUG_COMPONENT = ("Core", "DOM")
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMCharacterData.idl',
|
||||
'nsIDOMComment.idl',
|
||||
'nsIDOMDocument.idl',
|
||||
'nsIDOMDocumentFragment.idl',
|
||||
'nsIDOMDOMException.idl',
|
||||
|
@ -17,8 +15,6 @@ XPIDL_SOURCES += [
|
|||
'nsIDOMNode.idl',
|
||||
'nsIDOMNodeList.idl',
|
||||
'nsIDOMNSEditableElement.idl',
|
||||
'nsIDOMProcessingInstruction.idl',
|
||||
'nsIDOMText.idl',
|
||||
'nsIDOMXMLDocument.idl',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMNode.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMCharacterData interface extends nsIDOMNode with a set of
|
||||
* attributes and methods for accessing character data in the DOM.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[uuid(4109a2d2-e7af-445d-bb72-c7c9b875f35e)]
|
||||
interface nsIDOMCharacterData : nsIDOMNode
|
||||
{
|
||||
attribute DOMString data;
|
||||
// raises(DOMException) on setting
|
||||
// raises(DOMException) on retrieval
|
||||
|
||||
readonly attribute unsigned long length;
|
||||
DOMString substringData(in unsigned long offset,
|
||||
in unsigned long count)
|
||||
raises(DOMException);
|
||||
void appendData(in DOMString arg)
|
||||
raises(DOMException);
|
||||
void insertData(in unsigned long offset,
|
||||
in DOMString arg)
|
||||
raises(DOMException);
|
||||
void deleteData(in unsigned long offset,
|
||||
in unsigned long count)
|
||||
raises(DOMException);
|
||||
void replaceData(in unsigned long offset,
|
||||
in unsigned long count,
|
||||
in DOMString arg)
|
||||
raises(DOMException);
|
||||
};
|
|
@ -1,20 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMCharacterData.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMComment interface inherits from nsIDOMCharacterData and represents
|
||||
* the content of a comment, i.e., all the characters between the starting
|
||||
* '<!--' and ending '-->'.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[uuid(e7866ff8-b7fc-494f-87c0-fb017d8a4d30)]
|
||||
interface nsIDOMComment : nsIDOMCharacterData
|
||||
{
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMCharacterData.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMProcessingInstruction interface represents a
|
||||
* "processing instruction", used in XML as a way to keep processor-specific
|
||||
* information in the text of the document.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/ and
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[uuid(5a139df7-04d0-438d-bd18-d8122564258f)]
|
||||
interface nsIDOMProcessingInstruction : nsIDOMCharacterData
|
||||
{
|
||||
readonly attribute DOMString target;
|
||||
};
|
|
@ -1,29 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMCharacterData.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMText interface inherits from nsIDOMCharacterData and represents
|
||||
* the textual content (termed character data in XML) of an Element or Attr.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[uuid(67273994-6aff-4091-9de9-b788a249f783)]
|
||||
interface nsIDOMText : nsIDOMCharacterData
|
||||
{
|
||||
nsIDOMText splitText(in unsigned long offset)
|
||||
raises(DOMException);
|
||||
|
||||
/**
|
||||
* The concatenation of all logically adjacent text nodes with this text
|
||||
* node, where "logically adjacent" consists of all text nodes which can be
|
||||
* reached by traversing the document tree in either direction without
|
||||
* passing an element, comment, or processing-instruction boundary.
|
||||
*/
|
||||
readonly attribute DOMString wholeText;
|
||||
};
|
|
@ -12,12 +12,9 @@ XPIDL_SOURCES += [
|
|||
'nsIDOMEvent.idl',
|
||||
'nsIDOMEventListener.idl',
|
||||
'nsIDOMEventTarget.idl',
|
||||
'nsIDOMFocusEvent.idl',
|
||||
'nsIDOMMouseEvent.idl',
|
||||
'nsIDOMMouseScrollEvent.idl',
|
||||
'nsIDOMNotifyPaintEvent.idl',
|
||||
'nsIDOMNSEvent.idl',
|
||||
'nsIDOMScrollAreaEvent.idl',
|
||||
'nsIDOMUIEvent.idl',
|
||||
'nsIDOMWheelEvent.idl',
|
||||
]
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMUIEvent.idl"
|
||||
|
||||
[builtinclass, uuid(ceab9fcd-2cae-42cb-b692-effa7ec48848)]
|
||||
interface nsIDOMFocusEvent : nsIDOMUIEvent
|
||||
{
|
||||
readonly attribute nsIDOMEventTarget relatedTarget;
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMMouseEvent.idl"
|
||||
|
||||
[builtinclass, uuid(327bdd54-f772-4015-b856-9692154a066c)]
|
||||
interface nsIDOMMouseScrollEvent : nsIDOMMouseEvent
|
||||
{
|
||||
const long HORIZONTAL_AXIS = 1;
|
||||
const long VERTICAL_AXIS = 2;
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMUIEvent.idl"
|
||||
|
||||
[builtinclass, uuid(5883e564-e676-4652-9421-7df6132016b2)]
|
||||
interface nsIDOMScrollAreaEvent : nsIDOMUIEvent
|
||||
{
|
||||
};
|
|
@ -11,7 +11,6 @@ XPIDL_SOURCES += [
|
|||
'nsIDOMXULButtonElement.idl',
|
||||
'nsIDOMXULCheckboxElement.idl',
|
||||
'nsIDOMXULCommandDispatcher.idl',
|
||||
'nsIDOMXULCommandEvent.idl',
|
||||
'nsIDOMXULContainerElement.idl',
|
||||
'nsIDOMXULControlElement.idl',
|
||||
'nsIDOMXULDescriptionElement.idl',
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
|
||||
/**
|
||||
* This interface is supported by command events, which are dispatched to
|
||||
* XUL elements as a result of mouse or keyboard activation.
|
||||
*/
|
||||
|
||||
#include "nsIDOMUIEvent.idl"
|
||||
|
||||
[builtinclass, uuid(564496b4-1174-48ec-927d-edeb66b86757)]
|
||||
interface nsIDOMXULCommandEvent : nsIDOMUIEvent
|
||||
{
|
||||
/**
|
||||
* Command events support the same set of modifier keys as mouse and key
|
||||
* events.
|
||||
*/
|
||||
readonly attribute boolean ctrlKey;
|
||||
readonly attribute boolean shiftKey;
|
||||
readonly attribute boolean altKey;
|
||||
readonly attribute boolean metaKey;
|
||||
|
||||
/**
|
||||
* The input source, if this event was triggered by a mouse event.
|
||||
*/
|
||||
readonly attribute unsigned short inputSource;
|
||||
|
||||
/**
|
||||
* If the command event was redispatched because of a command= attribute
|
||||
* on the original target, sourceEvent will be set to the original DOM Event.
|
||||
* Otherwise, sourceEvent is null.
|
||||
*/
|
||||
readonly attribute nsIDOMEvent sourceEvent;
|
||||
|
||||
/**
|
||||
* Creates a new command event with the given attributes.
|
||||
*/
|
||||
void initCommandEvent(in DOMString typeArg,
|
||||
in boolean canBubbleArg,
|
||||
in boolean cancelableArg,
|
||||
in mozIDOMWindow viewArg,
|
||||
in long detailArg,
|
||||
in boolean ctrlKeyArg,
|
||||
in boolean altKeyArg,
|
||||
in boolean shiftKeyArg,
|
||||
in boolean metaKeyArg,
|
||||
in nsIDOMEvent sourceEvent,
|
||||
in unsigned short inputSource);
|
||||
};
|
|
@ -2163,6 +2163,60 @@ ContentParent::~ContentParent()
|
|||
!sBrowserContentParents->Contains(mRemoteType) ||
|
||||
!sBrowserContentParents->Get(mRemoteType)->Contains(this));
|
||||
}
|
||||
#ifdef NIGHTLY_BUILD
|
||||
MessageChannel* channel = GetIPCChannel();
|
||||
|
||||
if (channel && !channel->Unsound_IsClosed()) {
|
||||
nsString friendlyName;
|
||||
FriendlyName(friendlyName, false);
|
||||
|
||||
AddRef();
|
||||
nsrefcnt refcnt = Release();
|
||||
uint32_t numQueuedMessages = 0;
|
||||
numQueuedMessages = channel->Unsound_NumQueuedMessages();
|
||||
|
||||
nsPrintfCString msg("queued-ipc-messages/content-parent"
|
||||
"(%s, pid=%d, %s, 0x%p, refcnt=%" PRIuPTR
|
||||
", numQueuedMessages=%d, remoteType=%s, "
|
||||
"mCalledClose=%s, mCalledKillHard=%s, "
|
||||
"mShutdownPending=%s, mIPCOpen=%s)",
|
||||
NS_ConvertUTF16toUTF8(friendlyName).get(),
|
||||
Pid(), "open channel",
|
||||
static_cast<nsIContentParent*>(this), refcnt,
|
||||
numQueuedMessages,
|
||||
NS_ConvertUTF16toUTF8(mRemoteType).get(),
|
||||
mCalledClose ? "true" : "false",
|
||||
mCalledKillHard ? "true" : "false",
|
||||
mShutdownPending ? "true" : "false",
|
||||
mIPCOpen ? "true" : "false");
|
||||
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorMsg"),
|
||||
msg);
|
||||
switch (channel->GetChannelState__TotallyRacy()) {
|
||||
case ChannelOpening:
|
||||
MOZ_CRASH("MessageChannel destroyed without being closed " \
|
||||
"(mChannelState == ChannelOpening).");
|
||||
break;
|
||||
case ChannelConnected:
|
||||
MOZ_CRASH("MessageChannel destroyed without being closed " \
|
||||
"(mChannelState == ChannelConnected).");
|
||||
break;
|
||||
case ChannelTimeout:
|
||||
MOZ_CRASH("MessageChannel destroyed without being closed " \
|
||||
"(mChannelState == ChannelTimeout).");
|
||||
break;
|
||||
case ChannelClosing:
|
||||
MOZ_CRASH("MessageChannel destroyed without being closed " \
|
||||
"(mChannelState == ChannelClosing).");
|
||||
break;
|
||||
case ChannelError:
|
||||
MOZ_CRASH("MessageChannel destroyed without being closed " \
|
||||
"(mChannelState == ChannelError).");
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("MessageChannel destroyed without being closed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -17,7 +17,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=841850
|
|||
|
||||
var observer = {
|
||||
observe: function(subject, topic, data) {
|
||||
if(topic == "content-document-global-created" && data =="http://example.com") {
|
||||
//Subject location check added for Bug 1391823 to avoid removeAsyncObserver from being called multiple times
|
||||
if(topic == "content-document-global-created" && data =="http://example.com" && subject.location.href == "http://example.com/tests/dom/security/test/mixedcontentblocker/file_frameNavigation_innermost.html?blankTarget") {
|
||||
parent.parent.postMessage({"test": "blankTarget", "msg": "opened an http link with target=_blank from a secure page"}, "http://mochi.test:8888");
|
||||
SpecialPowers.removeAsyncObserver(observer, "content-document-global-created");
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/dom/HTMLSharedElement.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include "mozilla/dom/NodeFilterBinding.h"
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/dom/TreeWalker.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
@ -29,11 +30,9 @@
|
|||
#include "nsFrameLoader.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsIDOMWindowUtils.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -431,12 +430,10 @@ ResourceReader::OnWalkAttribute(nsIDOMNode* aNode,
|
|||
}
|
||||
|
||||
static nsresult
|
||||
GetXMLStyleSheetLink(nsIDOMProcessingInstruction *aPI, nsAString &aHref)
|
||||
GetXMLStyleSheetLink(dom::ProcessingInstruction *aPI, nsAString &aHref)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString data;
|
||||
rv = aPI->GetData(data);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
aPI->GetData(data);
|
||||
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::href, aHref);
|
||||
return NS_OK;
|
||||
|
@ -445,14 +442,15 @@ GetXMLStyleSheetLink(nsIDOMProcessingInstruction *aPI, nsAString &aHref)
|
|||
nsresult
|
||||
ResourceReader::OnWalkDOMNode(nsIDOMNode* aNode)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
if (!content) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Fixup xml-stylesheet processing instructions
|
||||
nsCOMPtr<nsIDOMProcessingInstruction> nodeAsPI = do_QueryInterface(aNode);
|
||||
if (nodeAsPI) {
|
||||
if (auto nodeAsPI = dom::ProcessingInstruction::FromContent(content)) {
|
||||
nsAutoString target;
|
||||
rv = nodeAsPI->GetTarget(target);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nodeAsPI->GetTarget(target);
|
||||
if (target.EqualsLiteral("xml-stylesheet")) {
|
||||
nsAutoString href;
|
||||
GetXMLStyleSheetLink(nodeAsPI, href);
|
||||
|
@ -463,11 +461,6 @@ ResourceReader::OnWalkDOMNode(nsIDOMNode* aNode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
if (!content) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Test the node to see if it's an image, frame, iframe, css, js
|
||||
if (content->IsHTMLElement(nsGkAtoms::img)) {
|
||||
return OnWalkAttribute(aNode, "src");
|
||||
|
@ -602,7 +595,7 @@ private:
|
|||
const char* aAttribute,
|
||||
const char* aNamespaceURI = "");
|
||||
nsresult FixupAnchor(nsINode* aNode);
|
||||
nsresult FixupXMLStyleSheetLink(nsIDOMProcessingInstruction* aPI,
|
||||
nsresult FixupXMLStyleSheetLink(dom::ProcessingInstruction* aPI,
|
||||
const nsAString& aHref);
|
||||
|
||||
using IWBP = nsIWebBrowserPersist;
|
||||
|
@ -787,15 +780,13 @@ AppendXMLAttr(const nsAString& key, const nsAString& aValue, nsAString& aBuffer)
|
|||
}
|
||||
|
||||
nsresult
|
||||
PersistNodeFixup::FixupXMLStyleSheetLink(nsIDOMProcessingInstruction* aPI,
|
||||
PersistNodeFixup::FixupXMLStyleSheetLink(dom::ProcessingInstruction* aPI,
|
||||
const nsAString& aHref)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPI);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsAutoString data;
|
||||
rv = aPI->GetData(data);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
aPI->GetData(data);
|
||||
|
||||
nsAutoString href;
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
|
@ -844,10 +835,10 @@ PersistNodeFixup::FixupXMLStyleSheetLink(nsIDOMProcessingInstruction* aPI,
|
|||
if (!alternate.IsEmpty()) {
|
||||
AppendXMLAttr(NS_LITERAL_STRING("alternate"), alternate, newData);
|
||||
}
|
||||
aPI->SetData(newData);
|
||||
aPI->SetData(newData, IgnoreErrors());
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -884,22 +875,25 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aNodeIn->IsContent());
|
||||
|
||||
// Fixup xml-stylesheet processing instructions
|
||||
nsCOMPtr<nsIDOMProcessingInstruction> nodeAsPI = do_QueryInterface(aNodeIn);
|
||||
if (nodeAsPI) {
|
||||
if (auto nodeAsPI =
|
||||
dom::ProcessingInstruction::FromContent(aNodeIn->AsContent())) {
|
||||
nsAutoString target;
|
||||
nodeAsPI->GetTarget(target);
|
||||
if (target.EqualsLiteral("xml-stylesheet"))
|
||||
{
|
||||
nsresult rv = GetNodeToFixup(aNodeIn, aNodeOut);
|
||||
if (NS_SUCCEEDED(rv) && *aNodeOut) {
|
||||
nsCOMPtr<nsIDOMProcessingInstruction> outNode =
|
||||
do_QueryInterface(*aNodeOut);
|
||||
MOZ_ASSERT((*aNodeOut)->IsProcessingInstruction());
|
||||
auto nodeAsPI =
|
||||
static_cast<dom::ProcessingInstruction*>(*aNodeOut);
|
||||
nsAutoString href;
|
||||
GetXMLStyleSheetLink(nodeAsPI, href);
|
||||
if (!href.IsEmpty()) {
|
||||
FixupURI(href);
|
||||
FixupXMLStyleSheetLink(outNode, href);
|
||||
FixupXMLStyleSheetLink(nodeAsPI, href);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,8 +104,6 @@ interface Node : EventTarget {
|
|||
[ChromeOnly]
|
||||
readonly attribute URI? baseURIObject;
|
||||
[ChromeOnly]
|
||||
sequence<MutationObserver> getBoundMutationObservers();
|
||||
[ChromeOnly]
|
||||
DOMString generateXPath();
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,18 +4,38 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This interface is supported by command events, which are dispatched to
|
||||
* XUL elements as a result of mouse or keyboard activation.
|
||||
*/
|
||||
[Func="IsChromeOrXBL"]
|
||||
interface XULCommandEvent : UIEvent
|
||||
{
|
||||
/**
|
||||
* Command events support the same set of modifier keys as mouse and key
|
||||
* events.
|
||||
*/
|
||||
readonly attribute boolean ctrlKey;
|
||||
readonly attribute boolean shiftKey;
|
||||
readonly attribute boolean altKey;
|
||||
readonly attribute boolean metaKey;
|
||||
|
||||
/**
|
||||
* The input source, if this event was triggered by a mouse event.
|
||||
*/
|
||||
readonly attribute unsigned short inputSource;
|
||||
|
||||
/**
|
||||
* If the command event was redispatched because of a command= attribute
|
||||
* on the original target, sourceEvent will be set to the original DOM Event.
|
||||
* Otherwise, sourceEvent is null.
|
||||
*/
|
||||
readonly attribute Event? sourceEvent;
|
||||
|
||||
/**
|
||||
* Creates a new command event with the given attributes.
|
||||
*/
|
||||
[Throws]
|
||||
void initCommandEvent(DOMString type,
|
||||
optional boolean canBubble = false,
|
||||
optional boolean cancelable = false,
|
||||
|
|
|
@ -15,8 +15,7 @@ CDATASection::~CDATASection()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(CDATASection, nsGenericDOMDataNode, nsIDOMNode,
|
||||
nsIDOMCharacterData, nsIDOMText)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(CDATASection, CharacterData, nsIDOMNode)
|
||||
|
||||
JSObject*
|
||||
CDATASection::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
|
@ -30,16 +29,16 @@ CDATASection::IsNodeOfType(uint32_t aFlags) const
|
|||
return !(aFlags & ~(eTEXT | eDATA_NODE));
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
already_AddRefed<CharacterData>
|
||||
CDATASection::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
||||
{
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
CDATASection *it = new CDATASection(ni.forget());
|
||||
if (it && aCloneText) {
|
||||
RefPtr<CDATASection> it = new CDATASection(ni.forget());
|
||||
if (aCloneText) {
|
||||
it->mText = mText;
|
||||
}
|
||||
|
||||
return it;
|
||||
return it.forget();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -9,12 +9,13 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class CDATASection final : public Text,
|
||||
public nsIDOMText
|
||||
public nsIDOMNode
|
||||
{
|
||||
private:
|
||||
void Init()
|
||||
|
@ -43,18 +44,12 @@ public:
|
|||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
// nsIDOMText
|
||||
NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::)
|
||||
|
||||
// nsINode
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
virtual already_AddRefed<CharacterData>
|
||||
CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace dom {
|
|||
|
||||
ProcessingInstruction::ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
const nsAString& aData)
|
||||
: nsGenericDOMDataNode(Move(aNodeInfo))
|
||||
: CharacterData(Move(aNodeInfo))
|
||||
{
|
||||
MOZ_ASSERT(mNodeInfo->NodeType() == nsINode::PROCESSING_INSTRUCTION_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
|
@ -62,9 +62,7 @@ ProcessingInstruction::~ProcessingInstruction()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(ProcessingInstruction, nsGenericDOMDataNode,
|
||||
nsIDOMNode, nsIDOMCharacterData,
|
||||
nsIDOMProcessingInstruction)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(ProcessingInstruction, CharacterData, nsIDOMNode)
|
||||
|
||||
JSObject*
|
||||
ProcessingInstruction::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
|
@ -72,14 +70,6 @@ ProcessingInstruction::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProt
|
|||
return ProcessingInstructionBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ProcessingInstruction::GetTarget(nsAString& aTarget)
|
||||
{
|
||||
aTarget = NodeName();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessingInstruction::GetAttrValue(nsAtom *aName, nsAString& aValue)
|
||||
{
|
||||
|
@ -95,14 +85,14 @@ ProcessingInstruction::IsNodeOfType(uint32_t aFlags) const
|
|||
return !(aFlags & ~(ePROCESSING_INSTRUCTION | eDATA_NODE));
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
already_AddRefed<CharacterData>
|
||||
ProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const
|
||||
{
|
||||
nsAutoString data;
|
||||
nsGenericDOMDataNode::GetData(data);
|
||||
GetData(data);
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
return new ProcessingInstruction(ni.forget(), data);
|
||||
return do_AddRef(new ProcessingInstruction(ni.forget(), data));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
#define mozilla_dom_ProcessingInstruction_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ProcessingInstruction : public nsGenericDOMDataNode,
|
||||
public nsIDOMProcessingInstruction
|
||||
class ProcessingInstruction : public CharacterData,
|
||||
public nsIDOMNode
|
||||
{
|
||||
public:
|
||||
ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
|
@ -25,18 +25,12 @@ public:
|
|||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
// nsIDOMProcessingInstruction
|
||||
NS_DECL_NSIDOMPROCESSINGINSTRUCTION
|
||||
|
||||
// nsINode
|
||||
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
virtual already_AddRefed<CharacterData>
|
||||
CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const override;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, int32_t aIndent) const override;
|
||||
|
@ -46,10 +40,13 @@ public:
|
|||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
|
||||
// WebIDL API
|
||||
void GetTarget(nsString& aTarget)
|
||||
void GetTarget(nsAString& aTarget)
|
||||
{
|
||||
aTarget = NodeName();
|
||||
}
|
||||
|
||||
NS_IMPL_FROMCONTENT_HELPER(ProcessingInstruction, IsProcessingInstruction())
|
||||
|
||||
protected:
|
||||
virtual ~ProcessingInstruction();
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace dom {
|
|||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(XMLStylesheetProcessingInstruction,
|
||||
ProcessingInstruction,
|
||||
nsIDOMNode,
|
||||
nsIDOMProcessingInstruction,
|
||||
nsIStyleSheetLinkingElement)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(XMLStylesheetProcessingInstruction)
|
||||
|
@ -79,7 +78,7 @@ void
|
|||
XMLStylesheetProcessingInstruction::SetNodeValueInternal(const nsAString& aNodeValue,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsGenericDOMDataNode::SetNodeValueInternal(aNodeValue, aError);
|
||||
CharacterData::SetNodeValueInternal(aNodeValue, aError);
|
||||
if (!aError.Failed()) {
|
||||
UpdateStyleSheetInternal(nullptr, nullptr, true);
|
||||
}
|
||||
|
@ -178,14 +177,14 @@ XMLStylesheetProcessingInstruction::GetStyleSheetInfo(nsAString& aTitle,
|
|||
aType.AssignLiteral("text/css");
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
already_AddRefed<CharacterData>
|
||||
XMLStylesheetProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
||||
bool aCloneText) const
|
||||
{
|
||||
nsAutoString data;
|
||||
nsGenericDOMDataNode::GetData(data);
|
||||
GetData(data);
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
return new XMLStylesheetProcessingInstruction(ni.forget(), data);
|
||||
return do_AddRef(new XMLStylesheetProcessingInstruction(ni.forget(), data));
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -64,13 +64,12 @@ public:
|
|||
|
||||
virtual void SetData(const nsAString& aData, mozilla::ErrorResult& rv) override
|
||||
{
|
||||
nsGenericDOMDataNode::SetData(aData, rv);
|
||||
CharacterData::SetData(aData, rv);
|
||||
if (rv.Failed()) {
|
||||
return;
|
||||
}
|
||||
UpdateStyleSheetInternal(nullptr, nullptr, true);
|
||||
}
|
||||
using ProcessingInstruction::SetData; // Prevent hiding overloaded virtual function.
|
||||
|
||||
protected:
|
||||
virtual ~XMLStylesheetProcessingInstruction();
|
||||
|
@ -83,8 +82,9 @@ protected:
|
|||
nsAString& aType,
|
||||
nsAString& aMedia,
|
||||
bool* aIsAlternate) final;
|
||||
nsGenericDOMDataNode* CloneDataNode(mozilla::dom::NodeInfo* aNodeInfo,
|
||||
bool aCloneText) const final;
|
||||
already_AddRefed<CharacterData>
|
||||
CloneDataNode(mozilla::dom::NodeInfo* aNodeInfo,
|
||||
bool aCloneText) const final;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
|
@ -43,7 +42,6 @@
|
|||
#include "nsIContentPolicy.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsNodeUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
@ -218,7 +216,7 @@ nsXMLContentSink::MaybePrettyPrint()
|
|||
}
|
||||
|
||||
static void
|
||||
CheckXSLTParamPI(nsIDOMProcessingInstruction* aPi,
|
||||
CheckXSLTParamPI(ProcessingInstruction* aPi,
|
||||
nsIDocumentTransformer* aProcessor,
|
||||
nsIDocument* aDocument)
|
||||
{
|
||||
|
@ -282,8 +280,7 @@ nsXMLContentSink::DidBuildModel(bool aTerminated)
|
|||
for (nsIContent* child = mDocument->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
|
||||
nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(child);
|
||||
if (auto pi = ProcessingInstruction::FromContent(child)) {
|
||||
CheckXSLTParamPI(pi, mXSLTProcessor, mDocument);
|
||||
}
|
||||
else if (child->IsElement()) {
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "txExprResult.h"
|
||||
#include "txIXPathContext.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsINode.h"
|
||||
|
@ -17,6 +16,7 @@
|
|||
#include "txURIUtils.h"
|
||||
#include "txXPathTreeWalker.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "mozilla/dom/XPathResultBinding.h"
|
||||
|
||||
using mozilla::Move;
|
||||
|
@ -126,15 +126,10 @@ XPathExpression::EvaluateWithContext(nsINode& aContextNode,
|
|||
|
||||
if (nodeType == nsINode::TEXT_NODE ||
|
||||
nodeType == nsINode::CDATA_SECTION_NODE) {
|
||||
nsCOMPtr<nsIDOMCharacterData> textNode =
|
||||
do_QueryInterface(&aContextNode);
|
||||
if (!textNode) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
Text* textNode = aContextNode.GetAsText();
|
||||
MOZ_ASSERT(textNode);
|
||||
|
||||
uint32_t textLength;
|
||||
textNode->GetLength(&textLength);
|
||||
uint32_t textLength = textNode->Length();
|
||||
if (textLength == 0) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return nullptr;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "nsIAttribute.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
#include "nsXULTooltipListener.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsIDOMXULCommandEvent.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
@ -93,6 +92,7 @@
|
|||
#include "mozilla/dom/BoxObject.h"
|
||||
#include "mozilla/dom/HTMLIFrameElement.h"
|
||||
#include "mozilla/dom/MutationEventBinding.h"
|
||||
#include "mozilla/dom/XULCommandEvent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -1364,11 +1364,10 @@ nsXULElement::DispatchXULCommand(const EventChainVisitor& aVisitor,
|
|||
Event* event = domEvent->InternalDOMEvent();
|
||||
NS_ENSURE_STATE(!SameCOMIdentity(event->GetOriginalTarget(),
|
||||
commandElt));
|
||||
nsCOMPtr<nsIDOMXULCommandEvent> commandEvent =
|
||||
do_QueryInterface(domEvent);
|
||||
RefPtr<XULCommandEvent> commandEvent = event->AsXULCommandEvent();
|
||||
if (commandEvent) {
|
||||
commandEvent->GetSourceEvent(getter_AddRefs(domEvent));
|
||||
commandEvent->GetInputSource(&inputSource);
|
||||
domEvent = commandEvent->GetSourceEvent();
|
||||
inputSource = commandEvent->InputSource();
|
||||
} else {
|
||||
domEvent = nullptr;
|
||||
}
|
||||
|
@ -1406,12 +1405,11 @@ nsXULElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
|||
!IsXULElement(nsGkAtoms::command)) {
|
||||
// Check that we really have an xul command event. That will be handled
|
||||
// in a special way.
|
||||
nsCOMPtr<nsIDOMXULCommandEvent> xulEvent =
|
||||
do_QueryInterface(aVisitor.mDOMEvent);
|
||||
// See if we have a command elt. If so, we execute on the command
|
||||
// instead of on our content element.
|
||||
nsAutoString command;
|
||||
if (xulEvent &&
|
||||
if (aVisitor.mDOMEvent &&
|
||||
aVisitor.mDOMEvent->InternalDOMEvent()->AsXULCommandEvent() &&
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::command, command) &&
|
||||
!command.IsEmpty()) {
|
||||
// Stop building the event target chain for the original event.
|
||||
|
|
|
@ -104,18 +104,19 @@ CompositionTransaction::DoTransaction()
|
|||
|
||||
// Advance caret: This requires the presentation shell to get the selection.
|
||||
if (mReplaceLength == 0) {
|
||||
nsresult rv = mTextNode->InsertData(mOffset, mStringToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
ErrorResult rv;
|
||||
mTextNode->InsertData(mOffset, mStringToInsert, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
mEditorBase->RangeUpdaterRef().
|
||||
SelAdjInsertText(*mTextNode, mOffset, mStringToInsert);
|
||||
} else {
|
||||
uint32_t replaceableLength = mTextNode->TextLength() - mOffset;
|
||||
nsresult rv =
|
||||
mTextNode->ReplaceData(mOffset, mReplaceLength, mStringToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
ErrorResult rv;
|
||||
mTextNode->ReplaceData(mOffset, mReplaceLength, mStringToInsert, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
mEditorBase->RangeUpdaterRef().
|
||||
SelAdjDeleteText(mTextNode, mOffset, mReplaceLength);
|
||||
|
@ -131,7 +132,7 @@ CompositionTransaction::DoTransaction()
|
|||
remainLength > 0) {
|
||||
Text* text = static_cast<Text*>(node.get());
|
||||
uint32_t textLength = text->TextLength();
|
||||
text->DeleteData(0, remainLength);
|
||||
text->DeleteData(0, remainLength, IgnoreErrors());
|
||||
mEditorBase->RangeUpdaterRef().SelAdjDeleteText(text, 0, remainLength);
|
||||
remainLength -= textLength;
|
||||
node = node->GetNextSibling();
|
||||
|
@ -157,11 +158,14 @@ CompositionTransaction::UndoTransaction()
|
|||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult rv = mTextNode->DeleteData(mOffset, mStringToInsert.Length());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult err;
|
||||
mTextNode->DeleteData(mOffset, mStringToInsert.Length(), err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
||||
// set the selection to the insertion point where the string was removed
|
||||
rv = selection->Collapse(mTextNode, mOffset);
|
||||
nsresult rv = selection->Collapse(mTextNode, mOffset);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Selection could not be collapsed after undo of IME insert.");
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -146,8 +146,8 @@ DeleteRangeTransaction::CreateTxnsToDeleteBetween(
|
|||
MOZ_DIAGNOSTIC_ASSERT(numToDel > 0);
|
||||
}
|
||||
|
||||
RefPtr<nsGenericDOMDataNode> charDataNode =
|
||||
static_cast<nsGenericDOMDataNode*>(aStart.Container());
|
||||
RefPtr<CharacterData> charDataNode =
|
||||
static_cast<CharacterData*>(aStart.Container());
|
||||
|
||||
RefPtr<DeleteTextTransaction> deleteTextTransaction =
|
||||
DeleteTextTransaction::MaybeCreate(*mEditorBase, *charDataNode,
|
||||
|
@ -211,8 +211,8 @@ DeleteRangeTransaction::CreateTxnsToDeleteContent(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<nsGenericDOMDataNode> dataNode =
|
||||
static_cast<nsGenericDOMDataNode*>(aPoint.Container());
|
||||
RefPtr<CharacterData> dataNode =
|
||||
static_cast<CharacterData*>(aPoint.Container());
|
||||
RefPtr<DeleteTextTransaction> deleteTextTransaction =
|
||||
DeleteTextTransaction::MaybeCreate(*mEditorBase, *dataNode,
|
||||
startOffset, numToDelete);
|
||||
|
|
|
@ -23,7 +23,7 @@ using namespace dom;
|
|||
// static
|
||||
already_AddRefed<DeleteTextTransaction>
|
||||
DeleteTextTransaction::MaybeCreate(EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
CharacterData& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLengthToDelete)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ DeleteTextTransaction::MaybeCreate(EditorBase& aEditorBase,
|
|||
already_AddRefed<DeleteTextTransaction>
|
||||
DeleteTextTransaction::MaybeCreateForPreviousCharacter(
|
||||
EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
CharacterData& aCharData,
|
||||
uint32_t aOffset)
|
||||
{
|
||||
if (NS_WARN_IF(!aOffset)) {
|
||||
|
@ -65,7 +65,7 @@ DeleteTextTransaction::MaybeCreateForPreviousCharacter(
|
|||
already_AddRefed<DeleteTextTransaction>
|
||||
DeleteTextTransaction::MaybeCreateForNextCharacter(
|
||||
EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
CharacterData& aCharData,
|
||||
uint32_t aOffset)
|
||||
{
|
||||
nsAutoString data;
|
||||
|
@ -87,7 +87,7 @@ DeleteTextTransaction::MaybeCreateForNextCharacter(
|
|||
|
||||
DeleteTextTransaction::DeleteTextTransaction(
|
||||
EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
CharacterData& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLengthToDelete)
|
||||
: mEditorBase(&aEditorBase)
|
||||
|
@ -123,12 +123,15 @@ DeleteTextTransaction::DoTransaction()
|
|||
}
|
||||
|
||||
// Get the text that we're about to delete
|
||||
nsresult rv = mCharData->SubstringData(mOffset, mLengthToDelete,
|
||||
mDeletedText);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
rv = mCharData->DeleteData(mOffset, mLengthToDelete);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
ErrorResult err;
|
||||
mCharData->SubstringData(mOffset, mLengthToDelete, mDeletedText, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
||||
mCharData->DeleteData(mOffset, mLengthToDelete, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
||||
mEditorBase->RangeUpdaterRef().
|
||||
|
@ -158,7 +161,9 @@ DeleteTextTransaction::UndoTransaction()
|
|||
if (NS_WARN_IF(!mCharData)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
return mCharData->InsertData(mOffset, mDeletedText);
|
||||
ErrorResult rv;
|
||||
mCharData->InsertData(mOffset, mDeletedText, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#define DeleteTextTransaction_h
|
||||
|
||||
#include "mozilla/EditTransactionBase.h"
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsID.h"
|
||||
#include "nsString.h"
|
||||
#include "nscore.h"
|
||||
|
@ -26,7 +26,7 @@ class DeleteTextTransaction final : public EditTransactionBase
|
|||
{
|
||||
protected:
|
||||
DeleteTextTransaction(EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
dom::CharacterData& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLengthToDelete);
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
*/
|
||||
static already_AddRefed<DeleteTextTransaction>
|
||||
MaybeCreate(EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
dom::CharacterData& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLengthToDelete);
|
||||
|
||||
|
@ -57,11 +57,11 @@ public:
|
|||
*/
|
||||
static already_AddRefed<DeleteTextTransaction>
|
||||
MaybeCreateForPreviousCharacter(EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
dom::CharacterData& aCharData,
|
||||
uint32_t aOffset);
|
||||
static already_AddRefed<DeleteTextTransaction>
|
||||
MaybeCreateForNextCharacter(EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
dom::CharacterData& aCharData,
|
||||
uint32_t aOffset);
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,7 @@ protected:
|
|||
RefPtr<EditorBase> mEditorBase;
|
||||
|
||||
// The CharacterData node to operate upon.
|
||||
RefPtr<nsGenericDOMDataNode> mCharData;
|
||||
RefPtr<dom::CharacterData> mCharData;
|
||||
|
||||
// The offset into mCharData where the deletion is to take place.
|
||||
uint32_t mOffset;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "mozilla/TextInputListener.h" // for TextInputListener
|
||||
#include "mozilla/TextServicesDocument.h" // for TextServicesDocument
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/dom/CharacterData.h" // for CharacterData
|
||||
#include "mozilla/dom/Element.h" // for Element, nsINode::AsElement
|
||||
#include "mozilla/dom/HTMLBodyElement.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
|
@ -69,7 +70,6 @@
|
|||
#include "nsIAbsorbingTransaction.h" // for nsIAbsorbingTransaction
|
||||
#include "nsAtom.h" // for nsAtom
|
||||
#include "nsIContent.h" // for nsIContent
|
||||
#include "nsIDOMCharacterData.h" // for nsIDOMCharacterData
|
||||
#include "nsIDOMDocument.h" // for nsIDOMDocument
|
||||
#include "nsIDOMElement.h" // for nsIDOMElement
|
||||
#include "nsIDOMEvent.h" // for nsIDOMEvent
|
||||
|
@ -2915,9 +2915,8 @@ EditorBase::InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert,
|
|||
if (!mActionListeners.IsEmpty()) {
|
||||
AutoActionListenerArray listeners(mActionListeners);
|
||||
for (auto& listener : listeners) {
|
||||
listener->DidInsertText(
|
||||
static_cast<nsIDOMCharacterData*>(insertedTextNode->AsDOMNode()),
|
||||
insertedOffset, aStringToInsert, rv);
|
||||
listener->DidInsertText(insertedTextNode, insertedOffset,
|
||||
aStringToInsert, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3043,15 +3042,16 @@ EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
|||
if (!mActionListeners.IsEmpty() && length) {
|
||||
AutoActionListenerArray listeners(mActionListeners);
|
||||
for (auto& listener : listeners) {
|
||||
listener->WillDeleteText(
|
||||
static_cast<nsIDOMCharacterData*>(aCharData.AsDOMNode()), 0, length);
|
||||
listener->WillDeleteText(&aCharData, 0, length);
|
||||
}
|
||||
}
|
||||
|
||||
// We don't support undo here, so we don't really need all of the transaction
|
||||
// machinery, therefore we can run our transaction directly, breaking all of
|
||||
// the rules!
|
||||
nsresult rv = aCharData.SetData(aString);
|
||||
ErrorResult res;
|
||||
aCharData.SetData(aString, res);
|
||||
nsresult rv = res.StealNSResult();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -3082,14 +3082,10 @@ EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
|||
AutoActionListenerArray listeners(mActionListeners);
|
||||
for (auto& listener : listeners) {
|
||||
if (length) {
|
||||
listener->DidDeleteText(
|
||||
static_cast<nsIDOMCharacterData*>(aCharData.AsDOMNode()), 0,
|
||||
length, rv);
|
||||
listener->DidDeleteText(&aCharData, 0, length, rv);
|
||||
}
|
||||
if (!aString.IsEmpty()) {
|
||||
listener->DidInsertText(
|
||||
static_cast<nsIDOMCharacterData*>(aCharData.AsDOMNode()), 0,
|
||||
aString, rv);
|
||||
listener->DidInsertText(&aCharData, 0, aString, rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3098,7 +3094,7 @@ EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
|||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::DeleteText(nsGenericDOMDataNode& aCharData,
|
||||
EditorBase::DeleteText(CharacterData& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLength)
|
||||
{
|
||||
|
@ -3115,9 +3111,7 @@ EditorBase::DeleteText(nsGenericDOMDataNode& aCharData,
|
|||
if (!mActionListeners.IsEmpty()) {
|
||||
AutoActionListenerArray listeners(mActionListeners);
|
||||
for (auto& listener : listeners) {
|
||||
listener->WillDeleteText(
|
||||
static_cast<nsIDOMCharacterData*>(GetAsDOMNode(&aCharData)), aOffset,
|
||||
aLength);
|
||||
listener->WillDeleteText(&aCharData, aOffset, aLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3132,9 +3126,7 @@ EditorBase::DeleteText(nsGenericDOMDataNode& aCharData,
|
|||
if (!mActionListeners.IsEmpty()) {
|
||||
AutoActionListenerArray listeners(mActionListeners);
|
||||
for (auto& listener : listeners) {
|
||||
listener->DidDeleteText(
|
||||
static_cast<nsIDOMCharacterData*>(GetAsDOMNode(&aCharData)), aOffset,
|
||||
aLength, rv);
|
||||
listener->DidDeleteText(&aCharData, aOffset, aLength, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3219,10 +3211,10 @@ EditorBase::SplitNodeImpl(const EditorDOMPoint& aStartOfRightNode,
|
|||
// Fix right node
|
||||
nsAutoString leftText;
|
||||
rightAsText->SubstringData(0, aStartOfRightNode.Offset(),
|
||||
leftText);
|
||||
rightAsText->DeleteData(0, aStartOfRightNode.Offset());
|
||||
leftText, IgnoreErrors());
|
||||
rightAsText->DeleteData(0, aStartOfRightNode.Offset(), IgnoreErrors());
|
||||
// Fix left node
|
||||
leftAsText->GetAsText()->SetData(leftText);
|
||||
leftAsText->GetAsText()->SetData(leftText, IgnoreErrors());
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!rightAsText && !leftAsText);
|
||||
// Otherwise it's an interior node, so shuffle around the children. Go
|
||||
|
@ -3389,7 +3381,7 @@ EditorBase::JoinNodesImpl(nsINode* aNodeToKeep,
|
|||
aNodeToKeep->GetAsText()->GetData(rightText);
|
||||
aNodeToJoin->GetAsText()->GetData(leftText);
|
||||
leftText += rightText;
|
||||
aNodeToKeep->GetAsText()->SetData(leftText);
|
||||
aNodeToKeep->GetAsText()->SetData(leftText, IgnoreErrors());
|
||||
} else {
|
||||
// Otherwise it's an interior node, so shuffle around the children.
|
||||
nsCOMPtr<nsINodeList> childNodes = aNodeToJoin->ChildNodes();
|
||||
|
@ -4359,7 +4351,8 @@ EditorBase::DeleteSelectionImpl(EDirection aAction,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> deleteCharData(do_QueryInterface(deleteNode));
|
||||
RefPtr<CharacterData> deleteCharData =
|
||||
CharacterData::FromContentOrNull(deleteNode);
|
||||
AutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction);
|
||||
|
||||
if (mRules && mRules->AsHTMLEditRules()) {
|
||||
|
@ -4681,8 +4674,8 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
|
|||
// there is a priorNode, so delete its last child (if chardata, delete the
|
||||
// last char). if it has no children, delete it
|
||||
if (priorNode->IsNodeOfType(nsINode::eDATA_NODE)) {
|
||||
RefPtr<nsGenericDOMDataNode> priorNodeAsCharData =
|
||||
static_cast<nsGenericDOMDataNode*>(priorNode.get());
|
||||
RefPtr<CharacterData> priorNodeAsCharData =
|
||||
static_cast<CharacterData*>(priorNode.get());
|
||||
uint32_t length = priorNode->Length();
|
||||
// Bail out for empty chardata XXX: Do we want to do something else?
|
||||
if (NS_WARN_IF(!length)) {
|
||||
|
@ -4721,8 +4714,8 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
|
|||
// there is a nextNode, so delete its first child (if chardata, delete the
|
||||
// first char). if it has no children, delete it
|
||||
if (nextNode->IsNodeOfType(nsINode::eDATA_NODE)) {
|
||||
RefPtr<nsGenericDOMDataNode> nextNodeAsCharData =
|
||||
static_cast<nsGenericDOMDataNode*>(nextNode.get());
|
||||
RefPtr<CharacterData> nextNodeAsCharData =
|
||||
static_cast<CharacterData*>(nextNode.get());
|
||||
uint32_t length = nextNode->Length();
|
||||
// Bail out for empty chardata XXX: Do we want to do something else?
|
||||
if (NS_WARN_IF(!length)) {
|
||||
|
@ -4754,8 +4747,8 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
|
|||
if (NS_WARN_IF(aAction != ePrevious && aAction != eNext)) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<nsGenericDOMDataNode> nodeAsCharData =
|
||||
static_cast<nsGenericDOMDataNode*>(node.get());
|
||||
RefPtr<CharacterData> nodeAsCharData =
|
||||
static_cast<CharacterData*>(node.get());
|
||||
// We have chardata, so delete a char at the proper offset
|
||||
RefPtr<DeleteTextTransaction> deleteTextTransaction =
|
||||
aAction == ePrevious ?
|
||||
|
@ -4801,8 +4794,8 @@ EditorBase::CreateTxnForDeleteRange(nsRange* aRangeToDelete,
|
|||
if (NS_WARN_IF(aAction != ePrevious && aAction != eNext)) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<nsGenericDOMDataNode> selectedNodeAsCharData =
|
||||
static_cast<nsGenericDOMDataNode*>(selectedNode.get());
|
||||
RefPtr<CharacterData> selectedNodeAsCharData =
|
||||
static_cast<CharacterData*>(selectedNode.get());
|
||||
// we are deleting from a chardata node, so do a character deletion
|
||||
uint32_t position = 0;
|
||||
if (aAction == ePrevious) {
|
||||
|
|
|
@ -562,7 +562,7 @@ protected:
|
|||
int32_t* aOffset,
|
||||
int32_t* aLength);
|
||||
|
||||
nsresult DeleteText(nsGenericDOMDataNode& aElement,
|
||||
nsresult DeleteText(dom::CharacterData& aElement,
|
||||
uint32_t aOffset, uint32_t aLength);
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "mozilla/dom/DataTransfer.h"
|
||||
#include "mozilla/dom/DragEvent.h"
|
||||
#include "nsIDOMDocument.h" // for nsIDOMDocument
|
||||
#include "nsIDOMElement.h" // for nsIDOMElement
|
||||
#include "nsIDOMEvent.h" // for nsIDOMEvent
|
||||
#include "nsIDOMEventTarget.h" // for nsIDOMEventTarget
|
||||
#include "nsIDOMMouseEvent.h" // for nsIDOMMouseEvent
|
||||
|
@ -220,14 +219,12 @@ EditorEventListener::Disconnect()
|
|||
}
|
||||
UninstallFromEditor();
|
||||
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
nsCOMPtr<nsIDOMElement> domFocus;
|
||||
fm->GetFocusedElement(getter_AddRefs(domFocus));
|
||||
nsCOMPtr<nsINode> focusedElement = do_QueryInterface(domFocus);
|
||||
nsIContent* focusedContent = fm->GetFocusedContent();
|
||||
mozilla::dom::Element* root = mEditorBase->GetRoot();
|
||||
if (focusedElement && root &&
|
||||
nsContentUtils::ContentIsDescendantOf(focusedElement, root)) {
|
||||
if (focusedContent && root &&
|
||||
nsContentUtils::ContentIsDescendantOf(focusedContent, root)) {
|
||||
// Reset the Selection ancestor limiter and SelectionController state
|
||||
// that EditorBase::InitializeSelection set up.
|
||||
mEditorBase->FinalizeSelection();
|
||||
|
@ -1102,12 +1099,11 @@ EditorEventListener::Focus(InternalFocusEvent* aFocusEvent)
|
|||
// make sure that the element is really focused in case an earlier
|
||||
// listener in the chain changed the focus.
|
||||
if (editableRoot) {
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
NS_ENSURE_TRUE(fm, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
fm->GetFocusedElement(getter_AddRefs(element));
|
||||
if (!element) {
|
||||
nsIContent* focusedContent = fm->GetFocusedContent();
|
||||
if (!focusedContent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1116,11 +1112,9 @@ EditorEventListener::Focus(InternalFocusEvent* aFocusEvent)
|
|||
|
||||
nsCOMPtr<nsIContent> originalTargetAsContent =
|
||||
do_QueryInterface(originalTarget);
|
||||
nsCOMPtr<nsIContent> focusedElementAsContent =
|
||||
do_QueryInterface(element);
|
||||
|
||||
if (!SameCOMIdentity(
|
||||
focusedElementAsContent->FindFirstNonChromeOnlyAccessContent(),
|
||||
focusedContent->FindFirstNonChromeOnlyAccessContent(),
|
||||
originalTargetAsContent->FindFirstNonChromeOnlyAccessContent())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1150,12 +1144,11 @@ EditorEventListener::Blur(InternalFocusEvent* aBlurEvent)
|
|||
|
||||
// check if something else is focused. If another element is focused, then
|
||||
// we should not change the selection.
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
NS_ENSURE_TRUE(fm, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
fm->GetFocusedElement(getter_AddRefs(element));
|
||||
if (!element) {
|
||||
nsIContent* content = fm->GetFocusedContent();
|
||||
if (!content || !content->IsElement()) {
|
||||
RefPtr<EditorBase> editorBase(mEditorBase);
|
||||
editorBase->FinalizeSelection();
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ HTMLEditor::ShowGrabber(Element& aElement)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::StartMoving(nsIDOMElement* aHandle)
|
||||
HTMLEditor::StartMoving()
|
||||
{
|
||||
nsCOMPtr<nsIContent> parentContent = mGrabber->GetParent();
|
||||
if (NS_WARN_IF(!parentContent) || NS_WARN_IF(!mAbsolutelyPositionedObject)) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "nsAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
@ -2793,8 +2792,8 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
|||
if (startNode->GetAsText() &&
|
||||
startNode->Length() > static_cast<uint32_t>(startOffset)) {
|
||||
// Delete to last character
|
||||
OwningNonNull<nsGenericDOMDataNode> dataNode =
|
||||
*static_cast<nsGenericDOMDataNode*>(startNode.get());
|
||||
OwningNonNull<CharacterData> dataNode =
|
||||
*static_cast<CharacterData*>(startNode.get());
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
rv = mHTMLEditor->DeleteText(dataNode, startOffset,
|
||||
startNode->Length() - startOffset);
|
||||
|
@ -2803,8 +2802,8 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
|||
if (endNode->GetAsText() && endOffset) {
|
||||
// Delete to first character
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
OwningNonNull<nsGenericDOMDataNode> dataNode =
|
||||
*static_cast<nsGenericDOMDataNode*>(endNode.get());
|
||||
OwningNonNull<CharacterData> dataNode =
|
||||
*static_cast<CharacterData*>(endNode.get());
|
||||
rv = mHTMLEditor->DeleteText(dataNode, 0, endOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
#include "nscore.h"
|
||||
|
||||
class nsAtom;
|
||||
class nsIDOMCharacterData;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsIEditor;
|
||||
class nsINode;
|
||||
|
|
|
@ -3194,7 +3194,7 @@ HTMLEditor::DeleteNode(nsIDOMNode* aNode)
|
|||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::DeleteText(nsGenericDOMDataNode& aCharData,
|
||||
HTMLEditor::DeleteText(CharacterData& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLength)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
#include "nsIEditorStyleSheets.h"
|
||||
|
@ -39,6 +38,7 @@ class nsDocumentFragment;
|
|||
class nsITransferable;
|
||||
class nsIClipboard;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMMouseEvent;
|
||||
class nsILinkHandler;
|
||||
class nsTableWrapperFrame;
|
||||
|
@ -386,7 +386,7 @@ public:
|
|||
EStripWrappers aStripWrappers) override;
|
||||
nsresult DeleteNode(nsINode* aNode);
|
||||
NS_IMETHOD DeleteNode(nsIDOMNode* aNode) override;
|
||||
nsresult DeleteText(nsGenericDOMDataNode& aTextNode, uint32_t aOffset,
|
||||
nsresult DeleteText(dom::CharacterData& aTextNode, uint32_t aOffset,
|
||||
uint32_t aLength);
|
||||
virtual nsresult
|
||||
InsertTextImpl(nsIDocument& aDocument,
|
||||
|
@ -1332,7 +1332,7 @@ protected:
|
|||
void HideGrabber();
|
||||
|
||||
ManualNACPtr CreateGrabber(nsIContent& aParentContent);
|
||||
nsresult StartMoving(nsIDOMElement* aHandle);
|
||||
nsresult StartMoving();
|
||||
nsresult SetFinalPosition(int32_t aX, int32_t aY);
|
||||
void AddPositioningOffset(int32_t& aX, int32_t& aY);
|
||||
void SnapToGrid(int32_t& newX, int32_t& newY);
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "nsGkAtoms.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -2009,8 +2008,7 @@ nsresult FindTargetNode(nsINode *aStart, nsCOMPtr<nsINode> &aResult)
|
|||
// Is this child the magical cookie?
|
||||
if (child->IsNodeOfType(nsINode::eCOMMENT)) {
|
||||
nsAutoString data;
|
||||
nsresult rv = static_cast<Comment*>(child.get())->GetData(data);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
static_cast<Comment*>(child.get())->GetData(data);
|
||||
|
||||
if (data.EqualsLiteral(kInsertCookie)) {
|
||||
// Yes it is! Return an error so we bubble out and short-circuit the
|
||||
|
|
|
@ -823,7 +823,7 @@ HTMLEditor::OnMouseMove(nsIDOMMouseEvent* aMouseEvent)
|
|||
if (DeprecatedAbs(clientX - mOriginalX) * 2 >= xThreshold ||
|
||||
DeprecatedAbs(clientY - mOriginalY) * 2 >= yThreshold) {
|
||||
mGrabberClicked = false;
|
||||
StartMoving(nullptr);
|
||||
StartMoving();
|
||||
}
|
||||
}
|
||||
if (mIsMoving) {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "nsError.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIHTMLObjectResizer.h"
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче