From 00812e30dfa70f9b1a752cf0d09de00f6d401c85 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Wed, 26 Jun 2019 01:51:45 +0300 Subject: Attach FrameProperties to each frame instead of using a shared hashtable Dispense the shared hashtable and instead attach the frame property list directly to nsIFrame. --- dom/base/nsDocument.cpp | 3 +- dom/base/nsWindowMemoryReporter.cpp | 9 + dom/base/nsWindowMemoryReporter.h | 1 + layout/base/ActiveLayerTracker.cpp | 15 +- layout/base/FrameLayerBuilder.cpp | 32 ++- layout/base/FrameProperties.h | 440 ++++++++++++++++++++++++++++++ layout/base/FramePropertyTable.cpp | 239 ----------------- layout/base/FramePropertyTable.h | 442 ------------------------------- layout/base/OverflowChangedTracker.h | 4 +- layout/base/RestyleManager.cpp | 10 +- layout/base/RestyleManagerBase.cpp | 88 +++--- layout/base/RestyleManagerBase.h | 13 +- layout/base/moz.build | 3 +- layout/base/nsBidiPresUtils.cpp | 5 +- layout/base/nsCSSFrameConstructor.cpp | 23 +- layout/base/nsCSSRendering.cpp | 10 +- layout/base/nsDisplayList.cpp | 8 +- layout/base/nsDisplayList.h | 2 +- layout/base/nsIPresShell.h | 11 +- layout/base/nsLayoutUtils.cpp | 16 +- layout/base/nsPresContext.cpp | 3 +- layout/base/nsPresContext.h | 11 - layout/base/nsPresShell.cpp | 35 +-- layout/base/nsPresShell.h | 11 +- layout/forms/nsTextControlFrame.cpp | 14 +- layout/forms/nsTextControlFrame.h | 2 +- layout/generic/ReflowInput.cpp | 36 +-- layout/generic/RubyUtils.cpp | 6 +- layout/generic/StickyScrollContainer.cpp | 26 +- layout/generic/nsBlockFrame.cpp | 58 ++-- layout/generic/nsBlockFrame.h | 4 +- layout/generic/nsBulletFrame.cpp | 6 +- layout/generic/nsCanvasFrame.cpp | 4 +- layout/generic/nsCanvasFrame.h | 2 +- layout/generic/nsContainerFrame.cpp | 70 +++-- layout/generic/nsContainerFrame.h | 10 +- layout/generic/nsFlexContainerFrame.cpp | 22 +- layout/generic/nsFloatManager.cpp | 9 +- layout/generic/nsFontInflationData.cpp | 12 +- layout/generic/nsFrame.cpp | 177 +++++++------ layout/generic/nsGridContainerFrame.cpp | 80 +++--- layout/generic/nsGridContainerFrame.h | 12 +- layout/generic/nsIFrame.h | 75 +++++- layout/generic/nsLineLayout.cpp | 4 +- layout/generic/nsPlaceholderFrame.cpp | 2 +- layout/generic/nsTextFrame.cpp | 59 ++--- layout/mathml/nsMathMLContainerFrame.cpp | 7 +- layout/mathml/nsMathMLmtableFrame.cpp | 14 +- layout/svg/SVGTextFrame.cpp | 10 +- layout/svg/nsSVGEffects.cpp | 47 ++-- layout/svg/nsSVGEffects.h | 2 +- layout/svg/nsSVGFilterFrame.cpp | 4 +- layout/svg/nsSVGGradientFrame.cpp | 4 +- layout/svg/nsSVGIntegrationUtils.cpp | 5 +- layout/svg/nsSVGPatternFrame.cpp | 4 +- layout/svg/nsSVGUtils.cpp | 5 +- layout/tables/nsTableFrame.cpp | 31 ++- layout/tables/nsTableFrame.h | 3 +- layout/tables/nsTableRowFrame.cpp | 10 +- layout/tables/nsTableRowGroupFrame.cpp | 6 +- layout/tables/nsTableWrapperFrame.cpp | 4 +- layout/xul/nsBox.cpp | 7 +- layout/xul/nsMenuFrame.cpp | 6 +- 63 files changed, 1043 insertions(+), 1250 deletions(-) create mode 100644 layout/base/FrameProperties.h delete mode 100644 layout/base/FramePropertyTable.cpp delete mode 100644 layout/base/FramePropertyTable.h diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index a6ed419df..d8abc174f 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -11943,7 +11943,8 @@ nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const &aWindowSizes->mLayoutPresShellSize, &aWindowSizes->mLayoutStyleSetsSize, &aWindowSizes->mLayoutTextRunsSize, - &aWindowSizes->mLayoutPresContextSize); + &aWindowSizes->mLayoutPresContextSize, + &aWindowSizes->mLayoutFramePropertiesSize); } aWindowSizes->mPropertyTablesSize += diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp index acec4acfb..8f4bf6b11 100644 --- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -400,6 +400,12 @@ CollectWindowReports(nsGlobalWindow *aWindow, aWindowTotalSizes->mLayoutPresContextSize += windowSizes.mLayoutPresContextSize; + REPORT_SIZE("/layout/frame-properties", windowSizes.mLayoutFramePropertiesSize, + "Memory used for frame properties attached to frames " + "within a window."); + aWindowTotalSizes->mLayoutFramePropertiesSize += + windowSizes.mLayoutFramePropertiesSize; + // There are many different kinds of frames, but it is very likely // that only a few matter. Implement a cutoff so we don't bloat // about:memory with many uninteresting entries. @@ -563,6 +569,9 @@ nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport, REPORT("window-objects/layout/pres-contexts", windowTotalSizes.mLayoutPresContextSize, "This is the sum of all windows' 'layout/pres-contexts' numbers."); + REPORT("window-objects/layout/frame-properties", windowTotalSizes.mLayoutFramePropertiesSize, + "This is the sum of all windows' 'layout/frame-properties' numbers."); + size_t frameTotal = 0; #define FRAME_ID(classname) \ frameTotal += windowTotalSizes.mArenaStats.FRAME_ID_STAT_FIELD(classname); diff --git a/dom/base/nsWindowMemoryReporter.h b/dom/base/nsWindowMemoryReporter.h index b9e986959..5d40dc9f5 100644 --- a/dom/base/nsWindowMemoryReporter.h +++ b/dom/base/nsWindowMemoryReporter.h @@ -33,6 +33,7 @@ class nsWindowSizes { macro(Style, mLayoutStyleSetsSize) \ macro(Other, mLayoutTextRunsSize) \ macro(Other, mLayoutPresContextSize) \ + macro(Other, mLayoutFramePropertiesSize) \ macro(Other, mPropertyTablesSize) \ public: diff --git a/layout/base/ActiveLayerTracker.cpp b/layout/base/ActiveLayerTracker.cpp index 4f60f82d7..ecee4897a 100644 --- a/layout/base/ActiveLayerTracker.cpp +++ b/layout/base/ActiveLayerTracker.cpp @@ -178,7 +178,7 @@ LayerActivityTracker::NotifyExpired(LayerActivity* aObject) f->SchedulePaint(); } f->RemoveStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY); - f->Properties().Delete(LayerActivityProperty()); + f->DeleteProperty(LayerActivityProperty()); } else { c->DeleteProperty(nsGkAtoms::LayerActivity); } @@ -190,15 +190,13 @@ GetLayerActivity(nsIFrame* aFrame) if (!aFrame->HasAnyStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY)) { return nullptr; } - FrameProperties properties = aFrame->Properties(); - return properties.Get(LayerActivityProperty()); + return aFrame->GetProperty(LayerActivityProperty()); } static LayerActivity* GetLayerActivityForUpdate(nsIFrame* aFrame) { - FrameProperties properties = aFrame->Properties(); - LayerActivity* layerActivity = properties.Get(LayerActivityProperty()); + LayerActivity* layerActivity = aFrame->GetProperty(LayerActivityProperty()); if (layerActivity) { gLayerActivityTracker->MarkUsed(layerActivity); } else { @@ -208,7 +206,7 @@ GetLayerActivityForUpdate(nsIFrame* aFrame) layerActivity = new LayerActivity(aFrame); gLayerActivityTracker->AddObject(layerActivity); aFrame->AddStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY); - properties.Set(LayerActivityProperty(), layerActivity); + aFrame->SetProperty(LayerActivityProperty(), layerActivity); } return layerActivity; } @@ -225,8 +223,7 @@ ActiveLayerTracker::TransferActivityToContent(nsIFrame* aFrame, nsIContent* aCon if (!aFrame->HasAnyStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY)) { return; } - FrameProperties properties = aFrame->Properties(); - LayerActivity* layerActivity = properties.Remove(LayerActivityProperty()); + LayerActivity* layerActivity = aFrame->RemoveProperty(LayerActivityProperty()); aFrame->RemoveStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY); if (!layerActivity) { return; @@ -248,7 +245,7 @@ ActiveLayerTracker::TransferActivityToFrame(nsIContent* aContent, nsIFrame* aFra layerActivity->mContent = nullptr; layerActivity->mFrame = aFrame; aFrame->AddStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY); - aFrame->Properties().Set(LayerActivityProperty(), layerActivity); + aFrame->SetProperty(LayerActivityProperty(), layerActivity); } static void diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 9aaa28fb5..e87d9dc09 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -165,10 +165,10 @@ FrameLayerBuilder::DisplayItemData::AddFrame(nsIFrame* aFrame) mFrameList.AppendElement(aFrame); nsTArray* array = - aFrame->Properties().Get(FrameLayerBuilder::LayerManagerDataProperty()); + aFrame->GetProperty(FrameLayerBuilder::LayerManagerDataProperty()); if (!array) { array = new nsTArray(); - aFrame->Properties().Set(FrameLayerBuilder::LayerManagerDataProperty(), array); + aFrame->SetProperty(FrameLayerBuilder::LayerManagerDataProperty(), array); } array->AppendElement(this); } @@ -181,7 +181,7 @@ FrameLayerBuilder::DisplayItemData::RemoveFrame(nsIFrame* aFrame) MOZ_RELEASE_ASSERT(result, "Can't remove a frame that wasn't added!"); nsTArray* array = - aFrame->Properties().Get(FrameLayerBuilder::LayerManagerDataProperty()); + aFrame->GetProperty(FrameLayerBuilder::LayerManagerDataProperty()); MOZ_RELEASE_ASSERT(array, "Must be already stored on the frame!"); array->RemoveElement(this); } @@ -268,7 +268,7 @@ FrameLayerBuilder::DisplayItemData::~DisplayItemData() continue; } nsTArray *array = - reinterpret_cast*>(frame->Properties().Get(LayerManagerDataProperty())); + reinterpret_cast*>(frame->GetProperty(LayerManagerDataProperty())); array->RemoveElement(this); } @@ -390,8 +390,7 @@ public: /* static */ void FrameLayerBuilder::DestroyDisplayItemDataFor(nsIFrame* aFrame) { - FrameProperties props = aFrame->Properties(); - props.Delete(LayerManagerDataProperty()); + aFrame->DeleteProperty(LayerManagerDataProperty()); } struct AssignedDisplayItem @@ -1823,7 +1822,7 @@ FrameLayerBuilder::DisplayItemData* FrameLayerBuilder::GetDisplayItemData(nsIFrame* aFrame, uint32_t aKey) { const nsTArray* array = - aFrame->Properties().Get(LayerManagerDataProperty()); + aFrame->GetProperty(LayerManagerDataProperty()); if (array) { for (uint32_t i = 0; i < array->Length(); i++) { DisplayItemData* item = AssertDisplayItemData(array->ElementAt(i)); @@ -2052,7 +2051,7 @@ FrameLayerBuilder::GetDisplayItemDataForManager(nsDisplayItem* aItem, LayerManager* aManager) { const nsTArray* array = - aItem->Frame()->Properties().Get(LayerManagerDataProperty()); + aItem->Frame()->GetProperty(LayerManagerDataProperty()); if (array) { for (uint32_t i = 0; i < array->Length(); i++) { DisplayItemData* item = AssertDisplayItemData(array->ElementAt(i)); @@ -2069,7 +2068,7 @@ bool FrameLayerBuilder::HasRetainedDataFor(nsIFrame* aFrame, uint32_t aDisplayItemKey) { const nsTArray* array = - aFrame->Properties().Get(LayerManagerDataProperty()); + aFrame->GetProperty(LayerManagerDataProperty()); if (array) { for (uint32_t i = 0; i < array->Length(); i++) { if (AssertDisplayItemData(array->ElementAt(i))->mDisplayItemKey == aDisplayItemKey) { @@ -2084,7 +2083,7 @@ void FrameLayerBuilder::IterateRetainedDataFor(nsIFrame* aFrame, DisplayItemDataCallback aCallback) { const nsTArray* array = - aFrame->Properties().Get(LayerManagerDataProperty()); + aFrame->GetProperty(LayerManagerDataProperty()); if (!array) { return; } @@ -2151,7 +2150,7 @@ FrameLayerBuilder::ClearCachedGeometry(nsDisplayItem* aItem) FrameLayerBuilder::GetDebugOldLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKey) { const nsTArray* array = - aFrame->Properties().Get(LayerManagerDataProperty()); + aFrame->GetProperty(LayerManagerDataProperty()); if (!array) { return nullptr; @@ -2171,7 +2170,7 @@ FrameLayerBuilder::GetDebugOldLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKe FrameLayerBuilder::GetDebugSingleOldPaintedLayerForFrame(nsIFrame* aFrame) { const nsTArray* array = - aFrame->Properties().Get(LayerManagerDataProperty()); + aFrame->GetProperty(LayerManagerDataProperty()); if (!array) { return nullptr; @@ -5656,7 +5655,7 @@ FrameLayerBuilder::InvalidateAllLayers(LayerManager* aManager) FrameLayerBuilder::InvalidateAllLayersForFrame(nsIFrame *aFrame) { const nsTArray* array = - aFrame->Properties().Get(LayerManagerDataProperty()); + aFrame->GetProperty(LayerManagerDataProperty()); if (array) { for (uint32_t i = 0; i < array->Length(); i++) { AssertDisplayItemData(array->ElementAt(i))->mParent->mInvalidateAllLayers = true; @@ -5673,7 +5672,7 @@ FrameLayerBuilder::GetDedicatedLayer(nsIFrame* aFrame, uint32_t aDisplayItemKey) // in the secondary manager const nsTArray* array = - aFrame->Properties().Get(LayerManagerDataProperty()); + aFrame->GetProperty(LayerManagerDataProperty()); if (array) { for (uint32_t i = 0; i < array->Length(); i++) { DisplayItemData *element = AssertDisplayItemData(array->ElementAt(i)); @@ -5729,7 +5728,7 @@ FrameLayerBuilder::GetPaintedLayerScaleForFrame(nsIFrame* aFrame) } const nsTArray* array = - f->Properties().Get(LayerManagerDataProperty()); + f->GetProperty(LayerManagerDataProperty()); if (!array) { continue; } @@ -6165,9 +6164,8 @@ FrameLayerBuilder::GetMostRecentGeometry(nsDisplayItem* aItem) typedef nsTArray DataArray; // Retrieve the array of DisplayItemData associated with our frame. - FrameProperties properties = aItem->Frame()->Properties(); const DataArray* dataArray = - properties.Get(LayerManagerDataProperty()); + aItem->Frame()->GetProperty(LayerManagerDataProperty()); if (!dataArray) { return nullptr; } diff --git a/layout/base/FrameProperties.h b/layout/base/FrameProperties.h new file mode 100644 index 000000000..bba3ee06b --- /dev/null +++ b/layout/base/FrameProperties.h @@ -0,0 +1,440 @@ +/* -*- Mode: C++; tab-width: 20; 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/. */ + +#ifndef FRAMEPROPERTIES_H_ +#define FRAMEPROPERTIES_H_ + +#include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" +#include "mozilla/TypeTraits.h" +#include "mozilla/Unused.h" +#include "nsTArray.h" +#include "nsThreadUtils.h" + +class nsIFrame; + +namespace mozilla { + +struct FramePropertyDescriptorUntyped +{ + /** + * mDestructor will be called if it's non-null. + */ + typedef void UntypedDestructor(void* aPropertyValue); + UntypedDestructor* mDestructor; + /** + * mDestructorWithFrame will be called if it's non-null and mDestructor + * is null. WARNING: The frame passed to mDestructorWithFrame may + * be a dangling frame pointer, if this is being called during + * presshell teardown. Do not use it except to compare against + * other frame pointers. No frame will have been allocated with + * the same address yet. + */ + typedef void UntypedDestructorWithFrame(const nsIFrame* aFrame, + void* aPropertyValue); + UntypedDestructorWithFrame* mDestructorWithFrame; + /** + * mDestructor and mDestructorWithFrame may both be null, in which case + * no value destruction is a no-op. + */ + +protected: + /** + * At most one destructor should be passed in. In general, you should + * just use the static function FramePropertyDescriptor::New* below + * instead of using this constructor directly. + */ + constexpr FramePropertyDescriptorUntyped( + UntypedDestructor* aDtor, UntypedDestructorWithFrame* aDtorWithFrame) + : mDestructor(aDtor) + , mDestructorWithFrame(aDtorWithFrame) + {} +}; + +/** + * A pointer to a FramePropertyDescriptor serves as a unique property ID. + * The FramePropertyDescriptor stores metadata about the property. + * Currently the only metadata is a destructor function. The destructor + * function is called on property values when they are overwritten or + * deleted. + * + * To use this class, declare a global (i.e., file, class or function-scope + * static member) FramePropertyDescriptor and pass its address as + * aProperty in the FramePropertyTable methods. + */ +template +struct FramePropertyDescriptor : public FramePropertyDescriptorUntyped +{ + typedef void Destructor(T* aPropertyValue); + typedef void DestructorWithFrame(const nsIFrame* aaFrame, + T* aPropertyValue); + + template + static constexpr const FramePropertyDescriptor NewWithDestructor() + { + return { Destruct, nullptr }; + } + + template + static constexpr + const FramePropertyDescriptor NewWithDestructorWithFrame() + { + return { nullptr, DestructWithFrame }; + } + + static constexpr const FramePropertyDescriptor NewWithoutDestructor() + { + return { nullptr, nullptr }; + } + +private: + constexpr FramePropertyDescriptor( + UntypedDestructor* aDtor, UntypedDestructorWithFrame* aDtorWithFrame) + : FramePropertyDescriptorUntyped(aDtor, aDtorWithFrame) + {} + + template + static void Destruct(void* aPropertyValue) + { + Dtor(static_cast(aPropertyValue)); + } + + template + static void DestructWithFrame(const nsIFrame* aFrame, void* aPropertyValue) + { + Dtor(aFrame, static_cast(aPropertyValue)); + } +}; + +// SmallValueHolder is a placeholder intended to be used as template +// argument of FramePropertyDescriptor for types which can fit into the +// size of a pointer directly. This class should never be defined, so +// that we won't use it for unexpected purpose by mistake. +template +class SmallValueHolder; + +namespace detail { + +template +struct FramePropertyTypeHelper +{ + typedef T* Type; +}; +template +struct FramePropertyTypeHelper> +{ + typedef T Type; +}; + +} + +/** + * The FrameProperties class is optimized for storing 0 or 1 properties on + * a given frame. Storing very large numbers of properties on a single + * frame will not be efficient. + * + * Property values are passed as void* but do not actually have to be + * valid pointers. You can use NS_INT32_TO_PTR/NS_PTR_TO_INT32 to + * store int32_t values. Null/zero values can be stored and retrieved. + * Of course, the destructor function (if any) must handle such values + * correctly. + */ +class FrameProperties +{ +public: + template + using Descriptor = const FramePropertyDescriptor*; + using UntypedDescriptor = const FramePropertyDescriptorUntyped*; + + template + using PropertyType = typename detail::FramePropertyTypeHelper::Type; + + explicit FrameProperties() + { + } + + ~FrameProperties() + { + MOZ_ASSERT(mProperties.Length() == 0, "forgot to delete properties"); + } + + /** + * Set a property value. This requires a linear search through + * the properties of the frame. Any existing value for the property + * is destroyed. + */ + template + void Set(Descriptor aProperty, PropertyType aValue, + const nsIFrame* aFrame) + { + void* ptr = ReinterpretHelper::ToPointer(aValue); + SetInternal(aProperty, ptr, aFrame); + } + + /** + * @return true if @aProperty is set. This requires a linear search through the + * properties of the frame. + * + * In most cases, this shouldn't be used outside of assertions, because if + * you're doing a lookup anyway it would be far more efficient to call Get() + * or Remove() and check the aFoundResult outparam to find out whether the + * property is set. Legitimate non-assertion uses include: + * + * - Checking if a frame property is set in cases where that's all we want + * to know (i.e., we don't intend to read the actual value or remove the + * property). + * + * - Calling Has() before Set() in cases where we don't want to overwrite + * an existing value for the frame property. + */ + template + bool Has(Descriptor aProperty) const + { + return mProperties.IndexOf(aProperty, 0, PropertyComparator()) != nsTArray::NoIndex; + } + + /** + * Get a property value. This requires a linear search through + * lookup (using the frame as the key) and a linear search through + * the properties of the frame. If the frame has no such property, + * returns zero-filled result, which means null for pointers and + * zero for integers and floating point types. + * @param aFoundResult if non-null, receives a value 'true' iff + * the frame has a value for the property. This lets callers + * disambiguate a null result, which can mean 'no such property' or + * 'property value is null'. + */ + template + PropertyType Get(Descriptor aProperty, + bool* aFoundResult = nullptr) const + { + void* ptr = GetInternal(aProperty, aFoundResult); + return ReinterpretHelper::FromPointer(ptr); + } + /** + * Remove a property value. This requires a linear search through + * the properties of the frame. The old property value is returned + * (and not destroyed). If the frame has no such property, + * returns zero-filled result, which means null for pointers and + * zero for integers and floating point types. + * @param aFoundResult if non-null, receives a value 'true' iff + * the frame had a value for the property. This lets callers + * disambiguate a null result, which can mean 'no such property' or + * 'property value is null'. + */ + template + PropertyType Remove(Descriptor aProperty, + bool* aFoundResult = nullptr) + { + void* ptr = RemoveInternal(aProperty, aFoundResult); + return ReinterpretHelper::FromPointer(ptr); + } + /** + * Remove and destroy a property value. This requires a linear search + * through the properties of the frame. If the frame has no such + * property, nothing happens. + */ + template + void Delete(Descriptor aProperty, const nsIFrame* aFrame) + { + DeleteInternal(aProperty, aFrame); + } + /** + * Remove and destroy all property values for the frame. + */ + void DeleteAll(const nsIFrame* aFrame) { + mozilla::DebugOnly len = mProperties.Length(); + for (auto& prop : mProperties) { + prop.DestroyValueFor(aFrame); + MOZ_ASSERT(mProperties.Length() == len); + } + mProperties.Clear(); + } + + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { + // We currently report only the shallow size of the mProperties array. + // As for the PropertyValue entries: we don't need to measure the mProperty + // field of because it always points to static memory, and we can't measure + // mValue because the type is opaque. + // XXX Can we do better, e.g. with a method on the descriptor? + return mProperties.ShallowSizeOfExcludingThis(aMallocSizeOf); + } + +private: + friend class ::nsIFrame; + + // Prevent copying of FrameProperties; we should always return/pass around + // references to it, not copies! + FrameProperties(const FrameProperties&) = delete; + FrameProperties& operator=(const FrameProperties&) = delete; + + inline void + SetInternal(UntypedDescriptor aProperty, void* aValue, + const nsIFrame* aFrame); + + inline void* + GetInternal(UntypedDescriptor aProperty, bool* aFoundResult) const; + + inline void* + RemoveInternal(UntypedDescriptor aProperty, bool* aFoundResult); + + inline void + DeleteInternal(UntypedDescriptor aProperty, const nsIFrame* aFrame); + + template + struct ReinterpretHelper + { + static_assert(sizeof(PropertyType) <= sizeof(void*), + "size of the value must never be larger than a pointer"); + + static void* ToPointer(PropertyType aValue) + { + void* ptr = nullptr; + memcpy(&ptr, &aValue, sizeof(aValue)); + return ptr; + } + + static PropertyType FromPointer(void* aPtr) + { + PropertyType value; + memcpy(&value, &aPtr, sizeof(value)); + return value; + } + }; + + template + struct ReinterpretHelper + { + static void* ToPointer(T* aValue) + { + return static_cast(aValue); + } + + static T* FromPointer(void* aPtr) + { + return static_cast(aPtr); + } + }; + + /** + * Stores a property descriptor/value pair. + */ + struct PropertyValue { + PropertyValue() : mProperty(nullptr), mValue(nullptr) {} + PropertyValue(UntypedDescriptor aProperty, void* aValue) + : mProperty(aProperty), mValue(aValue) {} + + void DestroyValueFor(const nsIFrame* aFrame) { + if (mProperty->mDestructor) { + mProperty->mDestructor(mValue); + } else if (mProperty->mDestructorWithFrame) { + mProperty->mDestructorWithFrame(aFrame, mValue); + } + } + + UntypedDescriptor mProperty; + void* mValue; + }; + + /** + * Used with an array of PropertyValues to allow lookups that compare + * only on the FramePropertyDescriptor. + */ + class PropertyComparator { + public: + bool Equals(const PropertyValue& a, const PropertyValue& b) const { + return a.mProperty == b.mProperty; + } + bool Equals(UntypedDescriptor a, const PropertyValue& b) const { + return a == b.mProperty; + } + bool Equals(const PropertyValue& a, UntypedDescriptor b) const { + return a.mProperty == b; + } + }; + + nsTArray mProperties; +}; + +/** + * This class encapsulates the properties of a frame. + */ +inline void* +FrameProperties::GetInternal(UntypedDescriptor aProperty, + bool* aFoundResult) const +{ + MOZ_ASSERT(aProperty, "Null property?"); + + auto index = mProperties.IndexOf(aProperty, 0, PropertyComparator()); + if (index == nsTArray::NoIndex) { + if (aFoundResult) { + *aFoundResult = false; + } + return nullptr; + } + + if (aFoundResult) { + *aFoundResult = true; + } + +return mProperties.ElementAt(index).mValue; +} + +inline void +FrameProperties::SetInternal(UntypedDescriptor aProperty, void* aValue, + const nsIFrame* aFrame) +{ + MOZ_ASSERT(aProperty, "Null property?"); + + auto index = mProperties.IndexOf(aProperty, 0, PropertyComparator()); + if (index != nsTArray::NoIndex) { + PropertyValue* pv = &mProperties.ElementAt(index); + pv->DestroyValueFor(aFrame); + pv->mValue = aValue; + return; + } + + mProperties.AppendElement(PropertyValue(aProperty, aValue)); +} + +inline void* +FrameProperties::RemoveInternal(UntypedDescriptor aProperty, bool* aFoundResult) +{ + MOZ_ASSERT(aProperty, "Null property?"); + + auto index = mProperties.IndexOf(aProperty, 0, PropertyComparator()); + if (index == nsTArray::NoIndex) { + if (aFoundResult) { + *aFoundResult = false; + } + return nullptr; + } + +if (aFoundResult) { + *aFoundResult = true; +} + +void* result = mProperties.ElementAt(index).mValue; +mProperties.RemoveElementAt(index); + +return result; +} + +inline void +FrameProperties::DeleteInternal(UntypedDescriptor aProperty, + const nsIFrame* aFrame) +{ + MOZ_ASSERT(aProperty, "Null property?"); + + auto index = mProperties.IndexOf(aProperty, 0, PropertyComparator()); + if (index != nsTArray::NoIndex) { + mProperties.ElementAt(index).DestroyValueFor(aFrame); + mProperties.RemoveElementAt(index); + } +} + +} // namespace mozilla + +#endif /* FRAMEPROPERTIES_H_ */ diff --git a/layout/base/FramePropertyTable.cpp b/layout/base/FramePropertyTable.cpp deleted file mode 100644 index 0fd9b1c37..000000000 --- a/layout/base/FramePropertyTable.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; 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 "FramePropertyTable.h" - -#include "mozilla/MemoryReporting.h" - -namespace mozilla { - -void -FramePropertyTable::SetInternal( - const nsIFrame* aFrame, UntypedDescriptor aProperty, void* aValue) -{ - NS_ASSERTION(aFrame, "Null frame?"); - NS_ASSERTION(aProperty, "Null property?"); - - if (mLastFrame != aFrame || !mLastEntry) { - mLastFrame = aFrame; - mLastEntry = mEntries.PutEntry(aFrame); - } - Entry* entry = mLastEntry; - - if (!entry->mProp.IsArray()) { - if (!entry->mProp.mProperty) { - // Empty entry, so we can just store our property in the empty slot - entry->mProp.mProperty = aProperty; - entry->mProp.mValue = aValue; - return; - } - if (entry->mProp.mProperty == aProperty) { - // Just overwrite the current value - entry->mProp.DestroyValueFor(aFrame); - entry->mProp.mValue = aValue; - return; - } - - // We need to expand the single current entry to an array - PropertyValue current = entry->mProp; - entry->mProp.mProperty = nullptr; - static_assert(sizeof(nsTArray) <= sizeof(void *), - "Property array must fit entirely within entry->mProp.mValue"); - new (&entry->mProp.mValue) nsTArray(4); - entry->mProp.ToArray()->AppendElement(current); - } - - nsTArray* array = entry->mProp.ToArray(); - nsTArray::index_type index = - array->IndexOf(aProperty, 0, PropertyComparator()); - if (index != nsTArray::NoIndex) { - PropertyValue* pv = &array->ElementAt(index); - pv->DestroyValueFor(aFrame); - pv->mValue = aValue; - return; - } - - array->AppendElement(PropertyValue(aProperty, aValue)); -} - -void* -FramePropertyTable::GetInternal( - const nsIFrame* aFrame, UntypedDescriptor aProperty, bool* aFoundResult) -{ - NS_ASSERTION(aFrame, "Null frame?"); - NS_ASSERTION(aProperty, "Null property?"); - - if (aFoundResult) { - *aFoundResult = false; - } - - if (mLastFrame != aFrame) { - mLastFrame = aFrame; - mLastEntry = mEntries.GetEntry(mLastFrame); - } - Entry* entry = mLastEntry; - if (!entry) - return nullptr; - - if (entry->mProp.mProperty == aProperty) { - if (aFoundResult) { - *aFoundResult = true; - } - return entry->mProp.mValue; - } - if (!entry->mProp.IsArray()) { - // There's just one property and it's not the one we want, bail - return nullptr; - } - - nsTArray* array = entry->mProp.ToArray(); - nsTArray::index_type index = - array->IndexOf(aProperty, 0, PropertyComparator()); - if (index == nsTArray::NoIndex) - return nullptr; - - if (aFoundResult) { - *aFoundResult = true; - } - - return array->ElementAt(index).mValue; -} - -void* -FramePropertyTable::RemoveInternal( - const nsIFrame* aFrame, UntypedDescriptor aProperty, bool* aFoundResult) -{ - NS_ASSERTION(aFrame, "Null frame?"); - NS_ASSERTION(aProperty, "Null property?"); - - if (aFoundResult) { - *aFoundResult = false; - } - - if (mLastFrame != aFrame) { - mLastFrame = aFrame; - mLastEntry = mEntries.GetEntry(aFrame); - } - Entry* entry = mLastEntry; - if (!entry) - return nullptr; - - if (entry->mProp.mProperty == aProperty) { - // There's only one entry and it's the one we want - void* value = entry->mProp.mValue; - - // Here it's ok to use RemoveEntry() -- which may resize mEntries -- - // because we null mLastEntry at the same time. - mEntries.RemoveEntry(entry); - mLastEntry = nullptr; - if (aFoundResult) { - *aFoundResult = true; - } - return value; - } - if (!entry->mProp.IsArray()) { - // There's just one property and it's not the one we want, bail - return nullptr; - } - - nsTArray* array = entry->mProp.ToArray(); - nsTArray::index_type index = - array->IndexOf(aProperty, 0, PropertyComparator()); - if (index == nsTArray::NoIndex) { - // No such property, bail - return nullptr; - } - - if (aFoundResult) { - *aFoundResult = true; - } - - void* result = array->ElementAt(index).mValue; - - uint32_t last = array->Length() - 1; - array->ElementAt(index) = array->ElementAt(last); - array->RemoveElementAt(last); - - if (last == 1) { - PropertyValue pv = array->ElementAt(0); - array->~nsTArray(); - entry->mProp = pv; - } - - return result; -} - -void -FramePropertyTable::DeleteInternal( - const nsIFrame* aFrame, UntypedDescriptor aProperty) -{ - NS_ASSERTION(aFrame, "Null frame?"); - NS_ASSERTION(aProperty, "Null property?"); - - bool found; - void* v = RemoveInternal(aFrame, aProperty, &found); - if (found) { - PropertyValue pv(aProperty, v); - pv.DestroyValueFor(aFrame); - } -} - -/* static */ void -FramePropertyTable::DeleteAllForEntry(Entry* aEntry) -{ - if (!aEntry->mProp.IsArray()) { - aEntry->mProp.DestroyValueFor(aEntry->GetKey()); - return; - } - - nsTArray* array = aEntry->mProp.ToArray(); - for (uint32_t i = 0; i < array->Length(); ++i) { - array->ElementAt(i).DestroyValueFor(aEntry->GetKey()); - } - array->~nsTArray(); -} - -void -FramePropertyTable::DeleteAllFor(const nsIFrame* aFrame) -{ - NS_ASSERTION(aFrame, "Null frame?"); - - Entry* entry = mEntries.GetEntry(aFrame); - if (!entry) - return; - - if (mLastFrame == aFrame) { - // Flush cache. We assume DeleteAllForEntry will be called before - // a frame is destroyed. - mLastFrame = nullptr; - mLastEntry = nullptr; - } - - DeleteAllForEntry(entry); - - // mLastEntry points into mEntries, so we use RawRemoveEntry() which will not - // resize mEntries. - mEntries.RawRemoveEntry(entry); -} - -void -FramePropertyTable::DeleteAll() -{ - mLastFrame = nullptr; - mLastEntry = nullptr; - - for (auto iter = mEntries.Iter(); !iter.Done(); iter.Next()) { - DeleteAllForEntry(iter.Get()); - } - mEntries.Clear(); -} - -size_t -FramePropertyTable::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const -{ - return mEntries.SizeOfExcludingThis(aMallocSizeOf); -} - -} // namespace mozilla diff --git a/layout/base/FramePropertyTable.h b/layout/base/FramePropertyTable.h deleted file mode 100644 index e9847efbf..000000000 --- a/layout/base/FramePropertyTable.h +++ /dev/null @@ -1,442 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; 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/. */ - -#ifndef FRAMEPROPERTYTABLE_H_ -#define FRAMEPROPERTYTABLE_H_ - -#include "mozilla/MemoryReporting.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/Unused.h" -#include "nsTArray.h" -#include "nsTHashtable.h" -#include "nsHashKeys.h" - -class nsIFrame; - -namespace mozilla { - -struct FramePropertyDescriptorUntyped -{ - /** - * mDestructor will be called if it's non-null. - */ - typedef void UntypedDestructor(void* aPropertyValue); - UntypedDestructor* mDestructor; - /** - * mDestructorWithFrame will be called if it's non-null and mDestructor - * is null. WARNING: The frame passed to mDestructorWithFrame may - * be a dangling frame pointer, if this is being called during - * presshell teardown. Do not use it except to compare against - * other frame pointers. No frame will have been allocated with - * the same address yet. - */ - typedef void UntypedDestructorWithFrame(const nsIFrame* aFrame, - void* aPropertyValue); - UntypedDestructorWithFrame* mDestructorWithFrame; - /** - * mDestructor and mDestructorWithFrame may both be null, in which case - * no value destruction is a no-op. - */ - -protected: - /** - * At most one destructor should be passed in. In general, you should - * just use the static function FramePropertyDescriptor::New* below - * instead of using this constructor directly. - */ - constexpr FramePropertyDescriptorUntyped( - UntypedDestructor* aDtor, UntypedDestructorWithFrame* aDtorWithFrame) - : mDestructor(aDtor) - , mDestructorWithFrame(aDtorWithFrame) - {} -}; - -/** - * A pointer to a FramePropertyDescriptor serves as a unique property ID. - * The FramePropertyDescriptor stores metadata about the property. - * Currently the only metadata is a destructor function. The destructor - * function is called on property values when they are overwritten or - * deleted. - * - * To use this class, declare a global (i.e., file, class or function-scope - * static member) FramePropertyDescriptor and pass its address as - * aProperty in the FramePropertyTable methods. - */ -template -struct FramePropertyDescriptor : public FramePropertyDescriptorUntyped -{ - typedef void Destructor(T* aPropertyValue); - typedef void DestructorWithFrame(const nsIFrame* aaFrame, - T* aPropertyValue); - - template - static constexpr const FramePropertyDescriptor NewWithDestructor() - { - return { Destruct, nullptr }; - } - - template - static constexpr - const FramePropertyDescriptor NewWithDestructorWithFrame() - { - return { nullptr, DestructWithFrame }; - } - - static constexpr const FramePropertyDescriptor NewWithoutDestructor() - { - return { nullptr, nullptr }; - } - -private: - constexpr FramePropertyDescriptor( - UntypedDestructor* aDtor, UntypedDestructorWithFrame* aDtorWithFrame) - : FramePropertyDescriptorUntyped(aDtor, aDtorWithFrame) - {} - - template - static void Destruct(void* aPropertyValue) - { - Dtor(static_cast(aPropertyValue)); - } - - template - static void DestructWithFrame(const nsIFrame* aFrame, void* aPropertyValue) - { - Dtor(aFrame, static_cast(aPropertyValue)); - } -}; - -// SmallValueHolder is a placeholder intended to be used as template -// argument of FramePropertyDescriptor for types which can fit into the -// size of a pointer directly. This class should never be defined, so -// that we won't use it for unexpected purpose by mistake. -template -class SmallValueHolder; - -namespace detail { - -template -struct FramePropertyTypeHelper -{ - typedef T* Type; -}; -template -struct FramePropertyTypeHelper> -{ - typedef T Type; -}; - -} - -/** - * The FramePropertyTable is optimized for storing 0 or 1 properties on - * a given frame. Storing very large numbers of properties on a single - * frame will not be efficient. - * - * Property values are passed as void* but do not actually have to be - * valid pointers. You can use NS_INT32_TO_PTR/NS_PTR_TO_INT32 to - * store int32_t values. Null/zero values can be stored and retrieved. - * Of course, the destructor function (if any) must handle such values - * correctly. - */ -class FramePropertyTable { -public: - template - using Descriptor = const FramePropertyDescriptor*; - using UntypedDescriptor = const FramePropertyDescriptorUntyped*; - - template - using PropertyType = typename detail::FramePropertyTypeHelper::Type; - - FramePropertyTable() : mLastFrame(nullptr), mLastEntry(nullptr) - { - } - ~FramePropertyTable() - { - DeleteAll(); - } - - /** - * Set a property value on a frame. This requires one hashtable - * lookup (using the frame as the key) and a linear search through - * the properties of that frame. Any existing value for the property - * is destroyed. - */ - template - void Set(const nsIFrame* aFrame, Descriptor aProperty, - PropertyType aValue) - { - void* ptr = ReinterpretHelper::ToPointer(aValue); - SetInternal(aFrame, aProperty, ptr); - } - - /** - * @return true if @aProperty is set for @aFrame. This requires one hashtable - * lookup (using the frame as the key) and a linear search through the - * properties of that frame. - * - * In most cases, this shouldn't be used outside of assertions, because if - * you're doing a lookup anyway it would be far more efficient to call Get() - * or Remove() and check the aFoundResult outparam to find out whether the - * property is set. Legitimate non-assertion uses include: - * - * - Checking if a frame property is set in cases where that's all we want - * to know (i.e., we don't intend to read the actual value or remove the - * property). - * - * - Calling Has() before Set() in cases where we don't want to overwrite - * an existing value for the frame property. - */ - template - bool Has(const nsIFrame* aFrame, Descriptor aProperty) - { - bool foundResult = false; - mozilla::Unused << GetInternal(aFrame, aProperty, &foundResult); - return foundResult; - } - - /** - * Get a property value for a frame. This requires one hashtable - * lookup (using the frame as the key) and a linear search through - * the properties of that frame. If the frame has no such property, - * returns zero-filled result, which means null for pointers and - * zero for integers and floating point types. - * @param aFoundResult if non-null, receives a value 'true' iff - * the frame has a value for the property. This lets callers - * disambiguate a null result, which can mean 'no such property' or - * 'property value is null'. - */ - template - PropertyType Get(const nsIFrame* aFrame, Descriptor aProperty, - bool* aFoundResult = nullptr) - { - void* ptr = GetInternal(aFrame, aProperty, aFoundResult); - return ReinterpretHelper::FromPointer(ptr); - } - /** - * Remove a property value for a frame. This requires one hashtable - * lookup (using the frame as the key) and a linear search through - * the properties of that frame. The old property value is returned - * (and not destroyed). If the frame has no such property, - * returns zero-filled result, which means null for pointers and - * zero for integers and floating point types. - * @param aFoundResult if non-null, receives a value 'true' iff - * the frame had a value for the property. This lets callers - * disambiguate a null result, which can mean 'no such property' or - * 'property value is null'. - */ - template - PropertyType Remove(const nsIFrame* aFrame, Descriptor aProperty, - bool* aFoundResult = nullptr) - { - void* ptr = RemoveInternal(aFrame, aProperty, aFoundResult); - return ReinterpretHelper::FromPointer(ptr); - } - /** - * Remove and destroy a property value for a frame. This requires one - * hashtable lookup (using the frame as the key) and a linear search - * through the properties of that frame. If the frame has no such - * property, nothing happens. - */ - template - void Delete(const nsIFrame* aFrame, Descriptor aProperty) - { - DeleteInternal(aFrame, aProperty); - } - /** - * Remove and destroy all property values for a frame. This requires one - * hashtable lookup (using the frame as the key). - */ - void DeleteAllFor(const nsIFrame* aFrame); - /** - * Remove and destroy all property values for all frames. - */ - void DeleteAll(); - - size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; - -protected: - void SetInternal(const nsIFrame* aFrame, UntypedDescriptor aProperty, - void* aValue); - - void* GetInternal(const nsIFrame* aFrame, UntypedDescriptor aProperty, - bool* aFoundResult); - - void* RemoveInternal(const nsIFrame* aFrame, UntypedDescriptor aProperty, - bool* aFoundResult); - - void DeleteInternal(const nsIFrame* aFrame, UntypedDescriptor aProperty); - - template - struct ReinterpretHelper - { - static_assert(sizeof(PropertyType) <= sizeof(void*), - "size of the value must never be larger than a pointer"); - - static void* ToPointer(PropertyType aValue) - { - void* ptr = nullptr; - memcpy(&ptr, &aValue, sizeof(aValue)); - return ptr; - } - - static PropertyType FromPointer(void* aPtr) - { - PropertyType value; - memcpy(&value, &aPtr, sizeof(value)); - return value; - } - }; - - template - struct ReinterpretHelper - { - static void* ToPointer(T* aValue) - { - return static_cast(aValue); - } - - static T* FromPointer(void* aPtr) - { - return static_cast(aPtr); - } - }; - - /** - * Stores a property descriptor/value pair. It can also be used to - * store an nsTArray of PropertyValues. - */ - struct PropertyValue { - PropertyValue() : mProperty(nullptr), mValue(nullptr) {} - PropertyValue(UntypedDescriptor aProperty, void* aValue) - : mProperty(aProperty), mValue(aValue) {} - - bool IsArray() { return !mProperty && mValue; } - nsTArray* ToArray() - { - NS_ASSERTION(IsArray(), "Must be array"); - return reinterpret_cast*>(&mValue); - } - - void DestroyValueFor(const nsIFrame* aFrame) { - if (mProperty->mDestructor) { - mProperty->mDestructor(mValue); - } else if (mProperty->mDestructorWithFrame) { - mProperty->mDestructorWithFrame(aFrame, mValue); - } - } - - size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) { - size_t n = 0; - // We don't need to measure mProperty because it always points to static - // memory. As for mValue: if it's a single value we can't measure it, - // because the type is opaque; if it's an array, we measure the array - // storage, but we can't measure the individual values, again because - // their types are opaque. - if (IsArray()) { - nsTArray* array = ToArray(); - n += array->ShallowSizeOfExcludingThis(aMallocSizeOf); - } - return n; - } - - UntypedDescriptor mProperty; - void* mValue; - }; - - /** - * Used with an array of PropertyValues to allow lookups that compare - * only on the FramePropertyDescriptor. - */ - class PropertyComparator { - public: - bool Equals(const PropertyValue& a, const PropertyValue& b) const { - return a.mProperty == b.mProperty; - } - bool Equals(UntypedDescriptor a, const PropertyValue& b) const { - return a == b.mProperty; - } - bool Equals(const PropertyValue& a, UntypedDescriptor b) const { - return a.mProperty == b; - } - }; - - /** - * Our hashtable entry. The key is an nsIFrame*, the value is a - * PropertyValue representing one or more property/value pairs. - */ - class Entry : public nsPtrHashKey - { - public: - explicit Entry(KeyTypePointer aKey) : nsPtrHashKey(aKey) {} - Entry(const Entry &toCopy) : - nsPtrHashKey(toCopy), mProp(toCopy.mProp) {} - - size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) { - return mProp.SizeOfExcludingThis(aMallocSizeOf); - } - - PropertyValue mProp; - }; - - static void DeleteAllForEntry(Entry* aEntry); - - // Note that mLastEntry points into mEntries, so we need to be careful about - // not triggering a resize of mEntries, e.g. use RawRemoveEntry() instead of - // RemoveEntry() in some places. - nsTHashtable mEntries; - const nsIFrame* mLastFrame; - Entry* mLastEntry; -}; - -/** - * This class encapsulates the properties of a frame. - */ -class FrameProperties { -public: - template using Descriptor = FramePropertyTable::Descriptor; - template using PropertyType = FramePropertyTable::PropertyType; - - FrameProperties(FramePropertyTable* aTable, const nsIFrame* aFrame) - : mTable(aTable), mFrame(aFrame) {} - - template - void Set(Descriptor aProperty, PropertyType aValue) const - { - mTable->Set(mFrame, aProperty, aValue); - } - - template - bool Has(Descriptor aProperty) const - { - return mTable->Has(mFrame, aProperty); - } - - template - PropertyType Get(Descriptor aProperty, - bool* aFoundResult = nullptr) const - { - return mTable->Get(mFrame, aProperty, aFoundResult); - } - template - PropertyType Remove(Descriptor aProperty, - bool* aFoundResult = nullptr) const - { - return mTable->Remove(mFrame, aProperty, aFoundResult); - } - template - void Delete(Descriptor aProperty) - { - mTable->Delete(mFrame, aProperty); - } - -private: - FramePropertyTable* mTable; - const nsIFrame* mFrame; -}; - -} // namespace mozilla - -#endif /* FRAMEPROPERTYTABLE_H_ */ diff --git a/layout/base/OverflowChangedTracker.h b/layout/base/OverflowChangedTracker.h index a18d64b46..40145c65c 100644 --- a/layout/base/OverflowChangedTracker.h +++ b/layout/base/OverflowChangedTracker.h @@ -112,12 +112,12 @@ public: // Take a faster path that doesn't require unioning the overflow areas // of our children. - NS_ASSERTION(frame->Properties().Get( + NS_ASSERTION(frame->GetProperty( nsIFrame::DebugInitialOverflowPropertyApplied()), "InitialOverflowProperty must be set first."); nsOverflowAreas* overflow = - frame->Properties().Get(nsIFrame::InitialOverflowProperty()); + frame->GetProperty(nsIFrame::InitialOverflowProperty()); if (overflow) { // FinishAndStoreOverflow will change the overflow areas passed in, // so make a copy. diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index de8f10224..124b5535e 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -1122,10 +1122,10 @@ GetPrevContinuationWithPossiblySameStyle(nsIFrame* aFrame) // We're the first continuation, so we can just get the frame // property directly prevContinuation = - aFrame->Properties().Get(nsIFrame::IBSplitPrevSibling()); + aFrame->GetProperty(nsIFrame::IBSplitPrevSibling()); if (prevContinuation) { prevContinuation = - prevContinuation->Properties().Get(nsIFrame::IBSplitPrevSibling()); + prevContinuation->GetProperty(nsIFrame::IBSplitPrevSibling()); } } @@ -1313,8 +1313,7 @@ RestyleManager::ReparentStyleContext(nsIFrame* aFrame) // oldContext)" check will prevent us from redoing work. if ((aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) && !aFrame->GetPrevContinuation()) { - nsIFrame* sib = - aFrame->Properties().Get(nsIFrame::IBSplitSibling()); + nsIFrame* sib = aFrame->GetProperty(nsIFrame::IBSplitSibling()); if (sib) { ReparentStyleContext(sib); } @@ -3349,7 +3348,6 @@ ElementRestyler::ComputeStyleChangeFor(nsIFrame* aFrame, // line), we might restyle more than that. nsPresContext* presContext = aFrame->PresContext(); - FramePropertyTable* propTable = presContext->PropertyTable(); TreeMatchContext treeMatchContext(true, nsRuleWalker::eRelevantLinkUnvisited, @@ -3363,7 +3361,7 @@ ElementRestyler::ComputeStyleChangeFor(nsIFrame* aFrame, nsTArray visibleKidsOfHiddenElement; nsIFrame* nextIBSibling; for (nsIFrame* ibSibling = aFrame; ibSibling; ibSibling = nextIBSibling) { - nextIBSibling = RestyleManager::GetNextBlockInInlineSibling(propTable, ibSibling); + nextIBSibling = RestyleManager::GetNextBlockInInlineSibling(ibSibling); if (nextIBSibling) { // Don't allow some ib-split siblings to be processed with diff --git a/layout/base/RestyleManagerBase.cpp b/layout/base/RestyleManagerBase.cpp index d96d9dbbb..6770f9464 100644 --- a/layout/base/RestyleManagerBase.cpp +++ b/layout/base/RestyleManagerBase.cpp @@ -385,8 +385,6 @@ RestyleManagerBase::DebugVerifyStyleTree(nsIFrame* aFrame) #endif // DEBUG -NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(ChangeListProperty, bool) - /** * Sync views on aFrame and all of aFrame's descendants (following placeholders), * if aChange has nsChangeHint_SyncFrameView. @@ -521,10 +519,9 @@ RecomputePosition(nsIFrame* aFrame) // normal position, go ahead and add the offsets directly. // First, we need to ensure that the normal position is stored though. nsPoint normalPosition = cont->GetNormalPosition(); - auto props = cont->Properties(); - const auto& prop = nsIFrame::NormalPositionProperty(); - if (!props.Get(prop)) { - props.Set(prop, new nsPoint(normalPosition)); + if (!cont->GetProperty(nsIFrame::NormalPositionProperty())) { + cont->SetProperty(nsIFrame::NormalPositionProperty(), + new nsPoint(normalPosition)); } cont->SetPosition(normalPosition + nsPoint(newOffsets.left, newOffsets.top)); @@ -739,8 +736,7 @@ RestyleManagerBase::GetNearestAncestorFrame(nsIContent* aContent) } /* static */ nsIFrame* -RestyleManagerBase::GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, - nsIFrame* aFrame) +RestyleManagerBase::GetNextBlockInInlineSibling(nsIFrame* aFrame) { NS_ASSERTION(!aFrame->GetPrevContinuation(), "must start with the first continuation"); @@ -750,8 +746,7 @@ RestyleManagerBase::GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, return nullptr; } - return static_cast - (aPropTable->Get(aFrame, nsIFrame::IBSplitSibling())); + return aFrame->GetProperty(nsIFrame::IBSplitSibling()); } static void @@ -1028,10 +1023,10 @@ RestyleManagerBase::GetNextContinuationWithSameStyle( // We're the last continuation, so we have to hop back to the first // before getting the frame property nextContinuation = - aFrame->FirstContinuation()->Properties().Get(nsIFrame::IBSplitSibling()); + aFrame->FirstContinuation()->GetProperty(nsIFrame::IBSplitSibling()); if (nextContinuation) { nextContinuation = - nextContinuation->Properties().Get(nsIFrame::IBSplitSibling()); + nextContinuation->GetProperty(nsIFrame::IBSplitSibling()); } } @@ -1060,14 +1055,52 @@ RestyleManagerBase::ProcessRestyledFrames(nsStyleChangeList& aChangeList) { NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(), "Someone forgot a script blocker"); - if (aChangeList.IsEmpty()) - return NS_OK; + +// See bug 1378219 comment 9: +// Recursive calls here are a bit worrying, but apparently do happen in the +// wild (although not currently in any of our automated tests). Try to get a +// stack from Nightly/Dev channel to figure out what's going on and whether +// it's OK. +MOZ_DIAGNOSTIC_ASSERT(!mDestroyedFrames, "ProcessRestyledFrames recursion"); + +if (aChangeList.IsEmpty()) + return NS_OK; + +// If mDestroyedFrames is null, we want to create a new hashtable here +// and destroy it on exit; but if it is already non-null (because we're in +// a recursive call), we will continue to use the existing table to +// accumulate destroyed frames, and NOT clear mDestroyedFrames on exit. +// We use a MaybeClearDestroyedFrames helper to conditionally reset the +// mDestroyedFrames pointer when this method returns. +typedef decltype(mDestroyedFrames) DestroyedFramesT; +class MOZ_RAII MaybeClearDestroyedFrames +{ +private: + DestroyedFramesT& mDestroyedFramesRef; // ref to caller's mDestroyedFrames + const bool mResetOnDestruction; +public: + explicit MaybeClearDestroyedFrames(DestroyedFramesT& aTarget) + : mDestroyedFramesRef(aTarget) + , mResetOnDestruction(!aTarget) // reset only if target starts out null + { + } + ~MaybeClearDestroyedFrames() + { + if (mResetOnDestruction) { + mDestroyedFramesRef.reset(nullptr); + } + } +}; + +MaybeClearDestroyedFrames maybeClear(mDestroyedFrames); +if (!mDestroyedFrames) { + mDestroyedFrames = MakeUnique>>(); +} PROFILER_LABEL("RestyleManager", "ProcessRestyledFrames", js::ProfileEntry::Category::CSS); nsPresContext* presContext = PresContext(); - FramePropertyTable* propTable = presContext->PropertyTable(); nsCSSFrameConstructor* frameConstructor = presContext->FrameConstructor(); // Handle nsChangeHint_CSSOverflowChange, by either updating the @@ -1135,15 +1168,6 @@ RestyleManagerBase::ProcessRestyledFrames(nsStyleChangeList& aChangeList) // processing restyles frameConstructor->BeginUpdate(); - // Mark frames so that we skip frames that die along the way, bug 123049. - // A frame can be in the list multiple times with different hints. Further - // optmization is possible if nsStyleChangeList::AppendChange could coalesce - for (const nsStyleChangeData& data : aChangeList) { - if (data.mFrame) { - propTable->Set(data.mFrame, ChangeListProperty(), true); - } - } - bool didUpdateCursor = false; for (const nsStyleChangeData& data : aChangeList) { @@ -1157,7 +1181,7 @@ RestyleManagerBase::ProcessRestyledFrames(nsStyleChangeList& aChangeList) "Reflow hint bits set without actually asking for a reflow"); // skip any frame that has been destroyed due to a ripple effect - if (frame && !propTable->Get(frame, ChangeListProperty())) { + if (frame && mDestroyedFrames->Contains(frame)) { continue; } @@ -1409,15 +1433,11 @@ RestyleManagerBase::ProcessRestyledFrames(nsStyleChangeList& aChangeList) frameConstructor->EndUpdate(); - // cleanup references and verify the style tree. Note that the latter needs - // to happen once we've processed the whole list, since until then the tree - // is not in fact in a consistent state. - for (const nsStyleChangeData& data : aChangeList) { - if (data.mFrame) { - propTable->Delete(data.mFrame, ChangeListProperty()); - } - #ifdef DEBUG + // Verify the style tree. Note that this needs to happen once we've + // processed the whole list, since until then the tree is not in fact in a + // consistent state. + for (const nsStyleChangeData& data : aChangeList) { // reget frame from content since it may have been regenerated... if (data.mContent) { nsIFrame* frame = data.mContent->GetPrimaryFrame(); @@ -1429,8 +1449,8 @@ RestyleManagerBase::ProcessRestyledFrames(nsStyleChangeList& aChangeList) NS_WARNING("Unable to test style tree integrity -- no content node " "(and not a viewport frame)"); } -#endif } +#endif aChangeList.Clear(); return NS_OK; diff --git a/layout/base/RestyleManagerBase.h b/layout/base/RestyleManagerBase.h index f81f5e73f..d92c3d1f7 100644 --- a/layout/base/RestyleManagerBase.h +++ b/layout/base/RestyleManagerBase.h @@ -72,6 +72,11 @@ public: // WillDestroyFrameTree hasn't been called yet. void NotifyDestroyingFrame(nsIFrame* aFrame) { mOverflowChangedTracker.RemoveFrame(aFrame); + // If ProcessRestyledFrames is tracking frames which have been + // destroyed (to avoid re-visiting them), add this one to its set. + if (mDestroyedFrames) { + mDestroyedFrames->PutEntry(aFrame); + } } // Note: It's the caller's responsibility to make sure to wrap a @@ -127,6 +132,12 @@ private: nsPresContext* mPresContext; // weak, can be null after Disconnect(). uint32_t mRestyleGeneration; uint32_t mHoverGeneration; + + // Used to keep track of frames that have been destroyed during + // ProcessRestyledFrames, so we don't try to touch them again even if + // they're referenced again later in the changelist. + mozilla::UniquePtr>> mDestroyedFrames; + // True if we're already waiting for a refresh notification. bool mObservingRefreshDriver; @@ -146,7 +157,7 @@ protected: GetNearestAncestorFrame(nsIContent* aContent); static nsIFrame* - GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, nsIFrame* aFrame); + GetNextBlockInInlineSibling(nsIFrame* aFrame); /** * Get the next continuation or similar ib-split sibling (assuming diff --git a/layout/base/moz.build b/layout/base/moz.build index d3e417f16..4308a6e4d 100644 --- a/layout/base/moz.build +++ b/layout/base/moz.build @@ -61,7 +61,7 @@ EXPORTS += [ 'DisplayItemScrollClip.h', 'DisplayListClipState.h', 'FrameLayerBuilder.h', - 'FramePropertyTable.h', + 'FrameProperties.h', 'LayerState.h', 'LayoutLogging.h', 'nsArenaMemoryStats.h', @@ -126,7 +126,6 @@ UNIFIED_SOURCES += [ 'DisplayListClipState.cpp', 'DottedCornerFinder.cpp', 'FrameLayerBuilder.cpp', - 'FramePropertyTable.cpp', 'GeometryUtils.cpp', 'LayoutLogging.cpp', 'MaskLayerImageCache.cpp', diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index b3c20aabb..887563504 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -753,7 +753,6 @@ nsBidiPresUtils::ResolveParagraph(BidiParagraphData* aBpd) nsIContent* content = nullptr; int32_t contentTextLength = 0; - FramePropertyTable* propTable = aBpd->mPresContext->PropertyTable(); nsLineBox* currentLine = nullptr; #ifdef DEBUG @@ -809,7 +808,7 @@ nsBidiPresUtils::ResolveParagraph(BidiParagraphData* aBpd) } precedingControl = kBidiLevelNone; lastEmbedingLevel = embeddingLevel; - propTable->Set(frame, nsIFrame::BidiDataProperty(), bidiData); + frame->SetProperty(nsIFrame::BidiDataProperty(), bidiData); }; for (; ;) { @@ -1787,7 +1786,7 @@ nsBidiPresUtils::RemoveBidiContinuation(BidiParagraphData *aBpd, if (frame != NS_BIDI_CONTROL_FRAME) { // Make the frame and its continuation ancestors fluid, // so they can be reused or deleted by normal reflow code - frame->Properties().Set(nsIFrame::BidiDataProperty(), bidiData); + frame->SetProperty(nsIFrame::BidiDataProperty(), bidiData); frame->AddStateBits(NS_FRAME_IS_BIDI); while (frame) { nsIFrame* prev = frame->GetPrevContinuation(); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 07a5b80e7..ec676ca92 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -492,9 +492,8 @@ static nsContainerFrame* GetIBSplitSibling(nsIFrame* aFrame) // We only store the "ib-split sibling" annotation with the first // frame in the continuation chain. Walk back to find that frame now. - return static_cast - (aFrame->FirstContinuation()-> - Properties().Get(nsIFrame::IBSplitSibling())); + return aFrame->FirstContinuation()-> + GetProperty(nsIFrame::IBSplitSibling()); } static nsContainerFrame* GetIBSplitPrevSibling(nsIFrame* aFrame) @@ -503,9 +502,8 @@ static nsContainerFrame* GetIBSplitPrevSibling(nsIFrame* aFrame) // We only store the ib-split sibling annotation with the first // frame in the continuation chain. Walk back to find that frame now. - return static_cast - (aFrame->FirstContinuation()-> - Properties().Get(nsIFrame::IBSplitPrevSibling())); + return aFrame->FirstContinuation()-> + GetProperty(nsIFrame::IBSplitPrevSibling()); } static nsContainerFrame* @@ -526,7 +524,7 @@ GetLastIBSplitSibling(nsIFrame* aFrame, bool aReturnEmptyTrailingInline) } static void -SetFrameIsIBSplit(nsContainerFrame* aFrame, nsIFrame* aIBSplitSibling) +SetFrameIsIBSplit(nsContainerFrame* aFrame, nsContainerFrame* aIBSplitSibling) { NS_PRECONDITION(aFrame, "bad args!"); @@ -547,9 +545,8 @@ SetFrameIsIBSplit(nsContainerFrame* aFrame, nsIFrame* aIBSplitSibling) // Store the ib-split sibling (if we were given one) with the // first frame in the flow. - FramePropertyTable* props = aFrame->PresContext()->PropertyTable(); - props->Set(aFrame, nsIFrame::IBSplitSibling(), aIBSplitSibling); - props->Set(aIBSplitSibling, nsIFrame::IBSplitPrevSibling(), aFrame); + aFrame->SetProperty(nsIFrame::IBSplitSibling(), aIBSplitSibling); + aIBSplitSibling->SetProperty(nsIFrame::IBSplitPrevSibling(), aFrame); } } @@ -6075,11 +6072,11 @@ AddGenConPseudoToFrame(nsIFrame* aOwnerFrame, nsIContent* aContent) NS_ASSERTION(nsLayoutUtils::IsFirstContinuationOrIBSplitSibling(aOwnerFrame), "property should only be set on first continuation/ib-sibling"); - FrameProperties props = aOwnerFrame->Properties(); - nsIFrame::ContentArray* value = props.Get(nsIFrame::GenConProperty()); + nsIFrame::ContentArray* value = + aOwnerFrame->GetProperty(nsIFrame::GenConProperty()); if (!value) { value = new nsIFrame::ContentArray; - props.Set(nsIFrame::GenConProperty(), value); + aOwnerFrame->SetProperty(nsIFrame::GenConProperty(), value); } value->AppendElement(aContent); } diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index ff9edf742..119c6c8a2 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -293,13 +293,13 @@ protected: if (!prevCont && (aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) { nsIFrame* block = - aFrame->Properties().Get(nsIFrame::IBSplitPrevSibling()); + aFrame->GetProperty(nsIFrame::IBSplitPrevSibling()); if (block) { // The {ib} properties are only stored on first continuations NS_ASSERTION(!block->GetPrevContinuation(), "Incorrect value for IBSplitPrevSibling"); prevCont = - block->Properties().Get(nsIFrame::IBSplitPrevSibling()); + block->GetProperty(nsIFrame::IBSplitPrevSibling()); NS_ASSERTION(prevCont, "How did that happen?"); } } @@ -313,9 +313,9 @@ protected: (aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) { // The {ib} properties are only stored on first continuations aFrame = aFrame->FirstContinuation(); - nsIFrame* block = aFrame->Properties().Get(nsIFrame::IBSplitSibling()); + nsIFrame* block = aFrame->GetProperty(nsIFrame::IBSplitSibling()); if (block) { - nextCont = block->Properties().Get(nsIFrame::IBSplitSibling()); + nextCont = block->GetProperty(nsIFrame::IBSplitSibling()); NS_ASSERTION(nextCont, "How did that happen?"); } } @@ -842,7 +842,7 @@ static nsRect GetOutlineInnerRect(nsIFrame* aFrame) { nsRect* savedOutlineInnerRect = - aFrame->Properties().Get(nsIFrame::OutlineInnerRectProperty()); + aFrame->GetProperty(nsIFrame::OutlineInnerRectProperty()); if (savedOutlineInnerRect) return *savedOutlineInnerRect; NS_NOTREACHED("we should have saved a frame property"); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index a55ec1e39..e35e027e3 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -666,7 +666,7 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer, // EffectCompositor needs to know that we refused to run this animation // asynchronously so that it will not throttle the main thread // animation. - aFrame->Properties().Set(nsIFrame::RefusedAsyncAnimationProperty(), true); + aFrame->SetProperty(nsIFrame::RefusedAsyncAnimationProperty(), true); // We need to schedule another refresh driver run so that EffectCompositor // gets a chance to unthrottle the animation. @@ -902,15 +902,13 @@ void nsDisplayListBuilder::MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame, const DisplayItemClip* oldClip = mClipState.GetClipForContainingBlockDescendants(); const DisplayItemScrollClip* sc = mClipState.GetCurrentInnermostScrollClip(); OutOfFlowDisplayData* data = new OutOfFlowDisplayData(oldClip, sc, dirty); - aFrame->Properties().Set(nsDisplayListBuilder::OutOfFlowDisplayDataProperty(), data); + aFrame->SetProperty(nsDisplayListBuilder::OutOfFlowDisplayDataProperty(), data); MarkFrameForDisplay(aFrame, aDirtyFrame); } static void UnmarkFrameForDisplay(nsIFrame* aFrame) { - nsPresContext* presContext = aFrame->PresContext(); - presContext->PropertyTable()-> - Delete(aFrame, nsDisplayListBuilder::OutOfFlowDisplayDataProperty()); + aFrame->DeleteProperty(nsDisplayListBuilder::OutOfFlowDisplayDataProperty()); for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetParentOrPlaceholderFor(f)) { diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index fcdc9e4fc..c81d34fac 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -1003,7 +1003,7 @@ public: static OutOfFlowDisplayData* GetOutOfFlowData(nsIFrame* aFrame) { - return aFrame->Properties().Get(OutOfFlowDisplayDataProperty()); + return aFrame->GetProperty(OutOfFlowDisplayDataProperty()); } nsPresContext* CurrentPresContext() { diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 4016cc0a9..865f5534c 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -1533,11 +1533,12 @@ public: bool aFlushOnHoverChange) = 0; virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, - nsArenaMemoryStats *aArenaObjectsSize, - size_t *aPresShellSize, - size_t *aStyleSetsSize, - size_t *aTextRunsSize, - size_t *aPresContextSize) = 0; + nsArenaMemoryStats* aArenaObjectsSize, + size_t* aPresShellSize, + size_t* aStyleSetsSize, + size_t* aTextRunsSize, + size_t* aPresContextSize, + size_t* aFramePropertiesSize) = 0; /** * Methods that retrieve the cached font inflation preferences. diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 07befdc81..06690b208 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -2057,13 +2057,13 @@ NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(ScrollbarThumbLayerized, bool) /* static */ void nsLayoutUtils::SetScrollbarThumbLayerization(nsIFrame* aThumbFrame, bool aLayerize) { - aThumbFrame->Properties().Set(ScrollbarThumbLayerized(), aLayerize); + aThumbFrame->SetProperty(ScrollbarThumbLayerized(), aLayerize); } bool nsLayoutUtils::IsScrollbarThumbLayerized(nsIFrame* aThumbFrame) { - return aThumbFrame->Properties().Get(ScrollbarThumbLayerized()); + return aThumbFrame->GetProperty(ScrollbarThumbLayerized()); } // static @@ -4427,7 +4427,7 @@ nsLayoutUtils::GetNextContinuationOrIBSplitSibling(nsIFrame *aFrame) // frame in the continuation chain. Walk back to find that frame now. aFrame = aFrame->FirstContinuation(); - return aFrame->Properties().Get(nsIFrame::IBSplitSibling()); + return aFrame->GetProperty(nsIFrame::IBSplitSibling()); } return nullptr; @@ -4440,7 +4440,7 @@ nsLayoutUtils::FirstContinuationOrIBSplitSibling(nsIFrame *aFrame) if (result->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) { while (true) { nsIFrame* f = - result->Properties().Get(nsIFrame::IBSplitPrevSibling()); + result->GetProperty(nsIFrame::IBSplitPrevSibling()); if (!f) break; result = f; @@ -4456,10 +4456,10 @@ nsLayoutUtils::LastContinuationOrIBSplitSibling(nsIFrame *aFrame) nsIFrame *result = aFrame->FirstContinuation(); if (result->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) { while (true) { - nsIFrame* f = - result->Properties().Get(nsIFrame::IBSplitSibling()); - if (!f) + nsIFrame* f = result->GetProperty(nsIFrame::IBSplitSibling()); + if (!f) { break; + } result = f; } } @@ -4476,7 +4476,7 @@ nsLayoutUtils::IsFirstContinuationOrIBSplitSibling(nsIFrame *aFrame) return false; } if ((aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) && - aFrame->Properties().Get(nsIFrame::IBSplitPrevSibling())) { + aFrame->GetProperty(nsIFrame::IBSplitPrevSibling())) { return false; } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 3106ff386..befb5deb2 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2741,8 +2741,7 @@ nsPresContext::GetPrimaryFrameFor(nsIContent* aContent) size_t nsPresContext::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { - return mPropertyTable.SizeOfExcludingThis(aMallocSizeOf) + - mLangGroupFontPrefs.SizeOfExcludingThis(aMallocSizeOf); + return mLangGroupFontPrefs.SizeOfExcludingThis(aMallocSizeOf); // Measurement of other members may be added later if DMD finds it is // worthwhile. diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index d8f876291..a2b9bb533 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -22,7 +22,6 @@ #include "nsITimer.h" #include "nsCRT.h" #include "nsIWidgetListener.h" -#include "FramePropertyTable.h" #include "nsGkAtoms.h" #include "nsCycleCollectionParticipant.h" #include "nsChangeHint.h" @@ -140,7 +139,6 @@ class nsRootPresContext; class nsPresContext : public nsIObserver, public mozilla::SupportsWeakPtr { public: - typedef mozilla::FramePropertyTable FramePropertyTable; typedef mozilla::LangGroupFontPrefs LangGroupFontPrefs; typedef mozilla::ScrollbarStyles ScrollbarStyles; typedef mozilla::StaticPresData StaticPresData; @@ -867,9 +865,6 @@ public: nsIPrintSettings* GetPrintSettings() { return mPrintSettings; } - /* Accessor for table of frame properties */ - FramePropertyTable* PropertyTable() { return &mPropertyTable; } - /* Helper function that ensures that this prescontext is shown in its docshell if it's the most recent prescontext for the docshell. Returns whether the prescontext is now being shown. @@ -1064,11 +1059,6 @@ public: */ nsIFrame* GetPrimaryFrameFor(nsIContent* aContent); - void NotifyDestroyingFrame(nsIFrame* aFrame) - { - PropertyTable()->DeleteAllFor(aFrame); - } - virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); @@ -1294,7 +1284,6 @@ protected: nsCOMPtr mPrintSettings; nsCOMPtr mPrefChangedTimer; - FramePropertyTable mPropertyTable; nsInvalidateRequestList mInvalidateRequestsSinceLastPaint; nsInvalidateRequestList mUndeliveredInvalidateRequestsBeforeLastPaint; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index d4fbebbf2..dacc6603b 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1306,19 +1306,6 @@ PresShell::Destroy() // Destroy the frame manager. This will destroy the frame hierarchy mFrameConstructor->WillDestroyFrameTree(); - // Destroy all frame properties (whose destruction was suppressed - // while destroying the frame tree, but which might contain more - // frames within the properties. - if (mPresContext) { - // Clear out the prescontext's property table -- since our frame tree is - // now dead, we shouldn't be looking up any more properties in that table. - // We want to do this before we call DetachShell() on the prescontext, so - // property destructors can usefully call GetPresShell() on the - // prescontext. - mPresContext->PropertyTable()->DeleteAll(); - } - - NS_WARNING_ASSERTION(!mWeakFrames, "Weak frames alive after destroying FrameManager"); while (mWeakFrames) { @@ -2047,7 +2034,7 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) } // Remove frame properties - mPresContext->NotifyDestroyingFrame(aFrame); + aFrame->DeleteAllProperties(); if (aFrame == mCurrentEventFrame) { mCurrentEventContent = aFrame->GetContent(); @@ -2076,8 +2063,7 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) // frame from FrameLayerBuilder::DisplayItemData::mFrameList -- otherwise // the DisplayItemData destructor will use the destroyed frame when it // tries to remove it from the (array) value of this property. - mPresContext->PropertyTable()-> - Delete(aFrame, FrameLayerBuilder::LayerManagerDataProperty()); + aFrame->DeleteProperty( FrameLayerBuilder::LayerManagerDataProperty()); } } @@ -10929,11 +10915,12 @@ PresShell::GetRootPresShell() void PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf, - nsArenaMemoryStats *aArenaObjectsSize, - size_t *aPresShellSize, - size_t *aStyleSetsSize, - size_t *aTextRunsSize, - size_t *aPresContextSize) + nsArenaMemoryStats* aArenaObjectsSize, + size_t* aPresShellSize, + size_t* aStyleSetsSize, + size_t* aTextRunsSize, + size_t* aPresContextSize, + size_t* aFramePropertiesSize) { mFrameArena.AddSizeOfExcludingThis(aMallocSizeOf, aArenaObjectsSize); *aPresShellSize += aMallocSizeOf(this); @@ -10953,6 +10940,12 @@ PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf, *aTextRunsSize += SizeOfTextRuns(aMallocSizeOf); *aPresContextSize += mPresContext->SizeOfIncludingThis(aMallocSizeOf); + + nsIFrame* rootFrame = mFrameConstructor->GetRootFrame(); + if (rootFrame) { + *aFramePropertiesSize += + rootFrame->SizeOfFramePropertiesForTree(aMallocSizeOf); + } } size_t diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index 1a8dd3fef..10548880a 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -384,11 +384,12 @@ public: virtual void LoadComplete() override; void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, - nsArenaMemoryStats *aArenaObjectsSize, - size_t *aPresShellSize, - size_t *aStyleSetsSize, - size_t *aTextRunsSize, - size_t *aPresContextSize) override; + nsArenaMemoryStats* aArenaObjectsSize, + size_t* aPresShellSize, + size_t* aStyleSetsSize, + size_t* aTextRunsSize, + size_t* aPresContextSize, + size_t* aFramePropertiesSize) override; size_t SizeOfTextRuns(mozilla::MallocSizeOf aMallocSizeOf) const; virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver) override; diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index a7f7d40a8..f8fdf3420 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -124,10 +124,10 @@ nsTextControlFrame::DestroyFrom(nsIFrame* aDestructRoot) { mScrollEvent.Revoke(); - EditorInitializer* initializer = Properties().Get(TextControlInitializer()); + EditorInitializer* initializer = GetProperty(TextControlInitializer()); if (initializer) { initializer->Revoke(); - Properties().Delete(TextControlInitializer()); + DeleteProperty(TextControlInitializer()); } // Unbind the text editor state object from the frame. The editor will live @@ -410,12 +410,12 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray& aElements) if (initEagerly) { NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(), "Someone forgot a script blocker?"); - EditorInitializer* initializer = Properties().Get(TextControlInitializer()); + EditorInitializer* initializer = GetProperty(TextControlInitializer()); if (initializer) { initializer->Revoke(); } initializer = new EditorInitializer(this); - Properties().Set(TextControlInitializer(),initializer); + SetProperty(TextControlInitializer(),initializer); nsContentUtils::AddScriptRunner(initializer); } @@ -1262,7 +1262,7 @@ nsTextControlFrame::SetInitialChildList(ChildListID aListID, NS_ASSERTION(txtCtrl, "Content not a text control element"); txtCtrl->InitializeKeyboardEventListeners(); - nsPoint* contentScrollPos = Properties().Get(ContentScrollPos()); + nsPoint* contentScrollPos = GetProperty(ContentScrollPos()); if (contentScrollPos) { // If we have a scroll pos stored to be passed to our anonymous // div, do it here! @@ -1271,7 +1271,7 @@ nsTextControlFrame::SetInitialChildList(ChildListID aListID, nsPresState fakePresState; fakePresState.SetScrollState(*contentScrollPos); statefulFrame->RestoreState(&fakePresState); - Properties().Remove(ContentScrollPos()); + RemoveProperty(ContentScrollPos()); delete contentScrollPos; } } @@ -1421,7 +1421,7 @@ nsTextControlFrame::RestoreState(nsPresState* aState) // Most likely, we don't have our anonymous content constructed yet, which // would cause us to end up here. In this case, we'll just store the scroll // pos ourselves, and forward it to the scroll frame later when it's created. - Properties().Set(ContentScrollPos(), new nsPoint(aState->GetScrollPosition())); + SetProperty(ContentScrollPos(), new nsPoint(aState->GetScrollPosition())); return NS_OK; } diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index 9d4d0b77c..7fa39c5fb 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -327,7 +327,7 @@ private: nsresult GetRootNodeAndInitializeEditor(nsIDOMElement **aRootElement); void FinishedInitializer() { - Properties().Delete(TextControlInitializer()); + DeleteProperty(TextControlInitializer()); } private: diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index bbff77ad4..78eca8c6c 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -999,13 +999,13 @@ ReflowInput::ComputeRelativeOffsets(WritingMode aWM, // Convert the offsets to physical coordinates and store them on the frame aComputedOffsets = offsets.GetPhysicalMargin(aWM); - FrameProperties props = aFrame->Properties(); - nsMargin* physicalOffsets = props.Get(nsIFrame::ComputedOffsetProperty()); + nsMargin* physicalOffsets = + aFrame->GetProperty(nsIFrame::ComputedOffsetProperty()); if (physicalOffsets) { *physicalOffsets = aComputedOffsets; } else { - props.Set(nsIFrame::ComputedOffsetProperty(), - new nsMargin(aComputedOffsets)); + aFrame->SetProperty(nsIFrame::ComputedOffsetProperty(), + new nsMargin(aComputedOffsets)); } } @@ -1015,21 +1015,22 @@ ReflowInput::ApplyRelativePositioning(nsIFrame* aFrame, nsPoint* aPosition) { if (!aFrame->IsRelativelyPositioned()) { - NS_ASSERTION(!aFrame->Properties().Get(nsIFrame::NormalPositionProperty()), + NS_ASSERTION(!aFrame->GetProperty(nsIFrame::NormalPositionProperty()), "We assume that changing the 'position' property causes " "frame reconstruction. If that ever changes, this code " "should call " - "props.Delete(nsIFrame::NormalPositionProperty())"); + "aFrame->DeleteProperty(nsIFrame::NormalPositionProperty())"); return; } // Store the normal position - FrameProperties props = aFrame->Properties(); - nsPoint* normalPosition = props.Get(nsIFrame::NormalPositionProperty()); + nsPoint* normalPosition = + aFrame->GetProperty(nsIFrame::NormalPositionProperty()); if (normalPosition) { *normalPosition = *aPosition; } else { - props.Set(nsIFrame::NormalPositionProperty(), new nsPoint(*aPosition)); + aFrame->SetProperty(nsIFrame::NormalPositionProperty(), + new nsPoint(*aPosition)); } const nsStyleDisplay* display = aFrame->StyleDisplay(); @@ -2452,20 +2453,20 @@ ReflowInput::InitConstraints(nsPresContext* aPresContext, } static void -UpdateProp(FrameProperties& aProps, +UpdateProp(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, bool aNeeded, nsMargin& aNewValue) { if (aNeeded) { - nsMargin* propValue = aProps.Get(aProperty); + nsMargin* propValue = aFrame->GetProperty(aProperty); if (propValue) { *propValue = aNewValue; } else { - aProps.Set(aProperty, new nsMargin(aNewValue)); + aFrame->SetProperty(aProperty, new nsMargin(aNewValue)); } } else { - aProps.Delete(aProperty); + aFrame->DeleteProperty(aProperty); } } @@ -2482,8 +2483,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, // Since we are in reflow, we don't need to store these properties anymore // unless they are dependent on width, in which case we store the new value. nsPresContext *presContext = mFrame->PresContext(); - FrameProperties props(presContext->PropertyTable(), mFrame); - props.Delete(nsIFrame::UsedBorderProperty()); + mFrame->DeleteProperty(nsIFrame::UsedBorderProperty()); // Compute margins from the specified margin style information. These // become the default computed values, and may be adjusted below @@ -2494,7 +2494,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, // ... but if we did that, we'd need to fix nsFrame::GetUsedMargin // to use it even when the margins are all zero (since sometimes // they get treated as auto) - ::UpdateProp(props, nsIFrame::UsedMarginProperty(), needMarginProp, + ::UpdateProp(mFrame, nsIFrame::UsedMarginProperty(), needMarginProp, ComputedPhysicalMargin()); @@ -2530,7 +2530,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, auto ApplyBaselinePadding = [this, &needPaddingProp] (LogicalAxis aAxis, Prop aProp) { bool found; - nscoord val = mFrame->Properties().Get(aProp, &found); + nscoord val = mFrame->GetProperty(aProp, &found); if (found) { NS_ASSERTION(val != nscoord(0), "zero in this property is useless"); WritingMode wm = GetWritingMode(); @@ -2603,7 +2603,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, ComputedPhysicalBorderPadding().SizeTo(0,0,0,0); } } - ::UpdateProp(props, nsIFrame::UsedPaddingProperty(), needPaddingProp, + ::UpdateProp(mFrame, nsIFrame::UsedPaddingProperty(), needPaddingProp, ComputedPhysicalPadding()); } diff --git a/layout/generic/RubyUtils.cpp b/layout/generic/RubyUtils.cpp index f340663bc..05dd25413 100644 --- a/layout/generic/RubyUtils.cpp +++ b/layout/generic/RubyUtils.cpp @@ -19,21 +19,21 @@ NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(ReservedISize, nscoord) RubyUtils::SetReservedISize(nsIFrame* aFrame, nscoord aISize) { MOZ_ASSERT(IsExpandableRubyBox(aFrame)); - aFrame->Properties().Set(ReservedISize(), aISize); + aFrame->SetProperty(ReservedISize(), aISize); } /* static */ void RubyUtils::ClearReservedISize(nsIFrame* aFrame) { MOZ_ASSERT(IsExpandableRubyBox(aFrame)); - aFrame->Properties().Remove(ReservedISize()); + aFrame->RemoveProperty(ReservedISize()); } /* static */ nscoord RubyUtils::GetReservedISize(nsIFrame* aFrame) { MOZ_ASSERT(IsExpandableRubyBox(aFrame)); - return aFrame->Properties().Get(ReservedISize()); + return aFrame->GetProperty(ReservedISize()); } AutoRubyTextContainerArray::AutoRubyTextContainerArray( diff --git a/layout/generic/StickyScrollContainer.cpp b/layout/generic/StickyScrollContainer.cpp index d61a7e042..ca68992c3 100644 --- a/layout/generic/StickyScrollContainer.cpp +++ b/layout/generic/StickyScrollContainer.cpp @@ -45,12 +45,12 @@ StickyScrollContainer::GetStickyScrollContainerForFrame(nsIFrame* aFrame) // return nullptr; } - FrameProperties props = static_cast(do_QueryFrame(scrollFrame))-> - Properties(); - StickyScrollContainer* s = props.Get(StickyScrollContainerProperty()); + auto frame = static_cast(do_QueryFrame(scrollFrame)); + StickyScrollContainer* s = + frame->GetProperty(StickyScrollContainerProperty()); if (!s) { s = new StickyScrollContainer(scrollFrame); - props.Set(StickyScrollContainerProperty(), s); + frame->SetProperty(StickyScrollContainerProperty(), s); } return s; } @@ -69,9 +69,9 @@ StickyScrollContainer::NotifyReparentedFrameAcrossScrollFrameBoundary(nsIFrame* // we aren't going to handle that. return; } - FrameProperties props = static_cast(do_QueryFrame(oldScrollFrame))-> - Properties(); - StickyScrollContainer* oldSSC = props.Get(StickyScrollContainerProperty()); + StickyScrollContainer* oldSSC = + static_cast(do_QueryFrame(oldScrollFrame))-> + GetProperty(StickyScrollContainerProperty()); if (!oldSSC) { // aOldParent had no sticky descendants, so aFrame doesn't have any sticky // descendants, and we're done here. @@ -95,8 +95,7 @@ StickyScrollContainer::NotifyReparentedFrameAcrossScrollFrameBoundary(nsIFrame* StickyScrollContainer* StickyScrollContainer::GetStickyScrollContainerForScrollFrame(nsIFrame* aFrame) { - FrameProperties props = aFrame->Properties(); - return props.Get(StickyScrollContainerProperty()); + return aFrame->GetProperty(StickyScrollContainerProperty()); } static nscoord @@ -141,13 +140,12 @@ StickyScrollContainer::ComputeStickyOffsets(nsIFrame* aFrame) scrollContainerSize.height); // Store the offset - FrameProperties props = aFrame->Properties(); - nsMargin* offsets = props.Get(nsIFrame::ComputedOffsetProperty()); + nsMargin* offsets = aFrame->GetProperty(nsIFrame::ComputedOffsetProperty()); if (offsets) { *offsets = computedOffsets; } else { - props.Set(nsIFrame::ComputedOffsetProperty(), - new nsMargin(computedOffsets)); + aFrame->SetProperty(nsIFrame::ComputedOffsetProperty(), + new nsMargin(computedOffsets)); } } @@ -162,7 +160,7 @@ StickyScrollContainer::ComputeStickyLimits(nsIFrame* aFrame, nsRect* aStick, aContain->SetRect(nscoord_MIN/2, nscoord_MIN/2, nscoord_MAX, nscoord_MAX); const nsMargin* computedOffsets = - aFrame->Properties().Get(nsIFrame::ComputedOffsetProperty()); + aFrame->GetProperty(nsIFrame::ComputedOffsetProperty()); if (!computedOffsets) { // We haven't reflowed the scroll frame yet, so offsets haven't been // computed. Bail. diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 851e3406c..a37bfc06b 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -326,10 +326,8 @@ nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot) nsLineBox::DeleteLineList(presContext, mLines, aDestructRoot, &mFrames); - FramePropertyTable* props = presContext->PropertyTable(); - if (HasPushedFloats()) { - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, PushedFloatProperty()); RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS); } @@ -343,13 +341,13 @@ nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot) } if (GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) { - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowOutOfFlowsProperty()); RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS); } if (HasOutsideBullet()) { - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, OutsideBulletProperty()); RemoveStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); } @@ -1669,7 +1667,7 @@ nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput, // our computed size due to overflowing their containing block. (E.g. this // ensures we fill the last row when a multi-row grid item is fragmented). bool found; - nscoord bSize = Properties().Get(FragStretchBSizeProperty(), &found); + nscoord bSize = GetProperty(FragStretchBSizeProperty(), &found); if (found) { finalSize.BSize(wm) = std::max(bSize, finalSize.BSize(wm)); } @@ -1679,7 +1677,7 @@ nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput, if (MOZ_UNLIKELY(aReflowInput.mFlags.mBClampMarginBoxMinSize) && NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) { bool found; - nscoord cbSize = Properties().Get(BClampMarginBoxMinSizeProperty(), &found); + nscoord cbSize = GetProperty(BClampMarginBoxMinSizeProperty(), &found); if (found) { auto marginBoxBSize = finalSize.BSize(wm) + aReflowInput.ComputedLogicalMargin().BStartEnd(wm); @@ -1697,11 +1695,10 @@ nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput, finalSize.BSize(wm) = std::max(0, finalSize.BSize(wm)); *aBEndEdgeOfChildren = blockEndEdgeOfChildren; - FrameProperties properties = Properties(); if (blockEndEdgeOfChildren != finalSize.BSize(wm) - borderPadding.BEnd(wm)) { - properties.Set(BlockEndEdgeOfChildrenProperty(), blockEndEdgeOfChildren); + SetProperty(BlockEndEdgeOfChildrenProperty(), blockEndEdgeOfChildren); } else { - properties.Delete(BlockEndEdgeOfChildrenProperty()); + DeleteProperty(BlockEndEdgeOfChildrenProperty()); } aMetrics.SetSize(wm, finalSize); @@ -1834,7 +1831,7 @@ nsBlockFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) { bool found; nscoord blockEndEdgeOfChildren = - Properties().Get(BlockEndEdgeOfChildrenProperty(), &found); + GetProperty(BlockEndEdgeOfChildrenProperty(), &found); if (found) { ConsiderBlockEndEdgeOfChildren(GetWritingMode(), blockEndEdgeOfChildren, aOverflowAreas); @@ -4985,7 +4982,7 @@ nsBlockFrame::GetOverflowLines() const if (!HasOverflowLines()) { return nullptr; } - FrameLines* prop = Properties().Get(OverflowLinesProperty()); + FrameLines* prop = GetProperty(OverflowLinesProperty()); NS_ASSERTION(prop && !prop->mLines.empty() && prop->mLines.front()->GetChildCount() == 0 ? prop->mFrames.IsEmpty() : prop->mLines.front()->mFirstChild == prop->mFrames.FirstChild(), @@ -4999,7 +4996,7 @@ nsBlockFrame::RemoveOverflowLines() if (!HasOverflowLines()) { return nullptr; } - FrameLines* prop = Properties().Remove(OverflowLinesProperty()); + FrameLines* prop = RemoveProperty(OverflowLinesProperty()); NS_ASSERTION(prop && !prop->mLines.empty() && prop->mLines.front()->GetChildCount() == 0 ? prop->mFrames.IsEmpty() : prop->mLines.front()->mFirstChild == prop->mFrames.FirstChild(), @@ -5012,7 +5009,7 @@ void nsBlockFrame::DestroyOverflowLines() { NS_ASSERTION(HasOverflowLines(), "huh?"); - FrameLines* prop = Properties().Remove(OverflowLinesProperty()); + FrameLines* prop = RemoveProperty(OverflowLinesProperty()); NS_ASSERTION(prop && prop->mLines.empty(), "value should always be stored but empty when destroying"); RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_LINES); @@ -5032,10 +5029,9 @@ nsBlockFrame::SetOverflowLines(FrameLines* aOverflowLines) NS_ASSERTION(!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_LINES), "Overwriting existing overflow lines"); - FrameProperties props = Properties(); // Verify that we won't overwrite an existing overflow list - NS_ASSERTION(!props.Get(OverflowLinesProperty()), "existing overflow list"); - props.Set(OverflowLinesProperty(), aOverflowLines); + NS_ASSERTION(!GetProperty(OverflowLinesProperty()), "existing overflow list"); + SetProperty(OverflowLinesProperty(), aOverflowLines); AddStateBits(NS_BLOCK_HAS_OVERFLOW_LINES); } @@ -5088,7 +5084,7 @@ nsBlockFrame::GetInsideBullet() const return nullptr; } NS_ASSERTION(!HasOutsideBullet(), "invalid bullet state"); - nsBulletFrame* frame = Properties().Get(InsideBulletProperty()); + nsBulletFrame* frame = GetProperty(InsideBulletProperty()); NS_ASSERTION(frame && frame->GetType() == nsGkAtoms::bulletFrame, "bogus inside bullet frame"); return frame; @@ -5109,8 +5105,7 @@ nsBlockFrame::GetOutsideBulletList() const return nullptr; } NS_ASSERTION(!HasInsideBullet(), "invalid bullet state"); - nsFrameList* list = - Properties().Get(OutsideBulletProperty()); + nsFrameList* list = GetProperty(OutsideBulletProperty()); NS_ASSERTION(list && list->GetLength() == 1 && list->FirstChild()->GetType() == nsGkAtoms::bulletFrame, "bogus outside bullet list"); @@ -5123,8 +5118,7 @@ nsBlockFrame::GetPushedFloats() const if (!HasPushedFloats()) { return nullptr; } - nsFrameList* result = - Properties().Get(PushedFloatProperty()); + nsFrameList* result = GetProperty(PushedFloatProperty()); NS_ASSERTION(result, "value should always be non-empty when state set"); return result; } @@ -5137,7 +5131,7 @@ nsBlockFrame::EnsurePushedFloats() return result; result = new (PresContext()->PresShell()) nsFrameList; - Properties().Set(PushedFloatProperty(), result); + SetProperty(PushedFloatProperty(), result); AddStateBits(NS_BLOCK_HAS_PUSHED_FLOATS); return result; @@ -5149,7 +5143,7 @@ nsBlockFrame::RemovePushedFloats() if (!HasPushedFloats()) { return nullptr; } - nsFrameList *result = Properties().Remove(PushedFloatProperty()); + nsFrameList *result = RemoveProperty(PushedFloatProperty()); RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS); NS_ASSERTION(result, "value should always be non-empty when state set"); return result; @@ -5619,7 +5613,7 @@ nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame, if (mLine != line_end) { *aFoundValidLine = true; if (mLine != cursor) { - aFrame->Properties().Set(nsBlockFrame::LineCursorProperty(), mLine); + aFrame->SetProperty(nsBlockFrame::LineCursorProperty(), mLine); } return; } @@ -6769,7 +6763,7 @@ void nsBlockFrame::ClearLineCursor() return; } - Properties().Delete(LineCursorProperty()); + DeleteProperty(LineCursorProperty()); RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -6780,7 +6774,7 @@ void nsBlockFrame::SetupLineCursor() return; } - Properties().Set(LineCursorProperty(), mLines.front()); + SetProperty(LineCursorProperty(), mLines.front()); AddStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -6790,9 +6784,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) return nullptr; } - FrameProperties props = Properties(); - - nsLineBox* property = props.Get(LineCursorProperty()); + nsLineBox* property = GetProperty(LineCursorProperty()); LineIterator cursor = mLines.begin(property); nsRect cursorArea = cursor->GetVisualOverflowArea(); @@ -6808,7 +6800,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) } if (cursor.get() != property) { - props.Set(LineCursorProperty(), cursor.get()); + SetProperty(LineCursorProperty(), cursor.get()); } return cursor.get(); @@ -7021,11 +7013,11 @@ nsBlockFrame::CreateBulletFrameForListItem(bool aCreateBulletList, if (aListStylePositionInside) { nsFrameList bulletList(bullet, bullet); AddFrames(bulletList, nullptr); - Properties().Set(InsideBulletProperty(), bullet); + SetProperty(InsideBulletProperty(), bullet); AddStateBits(NS_BLOCK_FRAME_HAS_INSIDE_BULLET); } else { nsFrameList* bulletList = new (shell) nsFrameList(bullet, bullet); - Properties().Set(OutsideBulletProperty(), bulletList); + SetProperty(OutsideBulletProperty(), bulletList); AddStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); } } diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index bb41a6e99..f515cc26f 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -215,7 +215,7 @@ public: ~AutoLineCursorSetup() { if (mOrigCursor) { - mFrame->Properties().Set(LineCursorProperty(), mOrigCursor); + mFrame->SetProperty(LineCursorProperty(), mOrigCursor); } else { mFrame->ClearLineCursor(); } @@ -416,7 +416,7 @@ protected: NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(LineCursorProperty, nsLineBox) bool HasLineCursor() { return GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR; } nsLineBox* GetLineCursor() { - return HasLineCursor() ? Properties().Get(LineCursorProperty()) : nullptr; + return HasLineCursor() ? GetProperty(LineCursorProperty()) : nullptr; } nsLineBox* NewLineBox(nsIFrame* aFrame, bool aIsBlock) { diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index aa8794321..f6595e8f6 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -903,7 +903,7 @@ nsBulletFrame::GetFontSizeInflation() const if (!HasFontSizeInflation()) { return 1.0f; } - return Properties().Get(FontSizeInflationProperty()); + return GetProperty(FontSizeInflationProperty()); } void @@ -912,13 +912,13 @@ nsBulletFrame::SetFontSizeInflation(float aInflation) if (aInflation == 1.0f) { if (HasFontSizeInflation()) { RemoveStateBits(BULLET_FRAME_HAS_FONT_INFLATION); - Properties().Delete(FontSizeInflationProperty()); + DeleteProperty(FontSizeInflationProperty()); } return; } AddStateBits(BULLET_FRAME_HAS_FONT_INFLATION); - Properties().Set(FontSizeInflationProperty(), aInflation); + SetProperty(FontSizeInflationProperty(), aInflation); } already_AddRefed diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index 70a2117cf..1a8812fb7 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -300,7 +300,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder, // above. destRect.Round(); RefPtr dt = - Frame()->Properties().Get(nsIFrame::CachedBackgroundImageDT()); + Frame()->GetProperty(nsIFrame::CachedBackgroundImageDT()); DrawTarget* destDT = dest->GetDrawTarget(); if (dt) { BlitSurface(destDT, destRect, dt); @@ -317,7 +317,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext context(ctx); PaintInternal(aBuilder, &context, bgClipRect, &bgClipRect); BlitSurface(dest->GetDrawTarget(), destRect, dt); - frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), + frame->SetProperty(nsIFrame::CachedBackgroundImageDT(), dt.forget().take()); return; } diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index 236ffb9c7..8bd9dbf79 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -201,7 +201,7 @@ public: virtual void NotifyRenderingChanged() override { - mFrame->Properties().Delete(nsIFrame::CachedBackgroundImageDT()); + mFrame->DeleteProperty(nsIFrame::CachedBackgroundImageDT()); } virtual bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) override diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 813d19dfe..2933ac4cf 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -78,7 +78,7 @@ nsContainerFrame::SetInitialChildList(ChildListID aListID, "Only top layer frames should have backdrop"); MOZ_ASSERT(GetStateBits() & NS_FRAME_OUT_OF_FLOW, "Top layer frames should be out-of-flow"); - MOZ_ASSERT(!Properties().Get(BackdropProperty()), + MOZ_ASSERT(!GetProperty(BackdropProperty()), "We shouldn't have setup backdrop frame list before"); #ifdef DEBUG { @@ -93,7 +93,7 @@ nsContainerFrame::SetInitialChildList(ChildListID aListID, #endif nsFrameList* list = new (PresContext()->PresShell()) nsFrameList(aChildList); - Properties().Set(BackdropProperty(), list); + SetProperty(BackdropProperty(), list); } else { MOZ_ASSERT_UNREACHABLE("Unexpected child list"); } @@ -189,18 +189,17 @@ nsContainerFrame::DestroyAbsoluteFrames(nsIFrame* aDestructRoot) void nsContainerFrame::SafelyDestroyFrameListProp(nsIFrame* aDestructRoot, nsIPresShell* aPresShell, - FramePropertyTable* aPropTable, FrameListPropertyDescriptor aProp) { // Note that the last frame can be removed through another route and thus // delete the property -- that's why we fetch the property again before // removing each frame rather than fetching it once and iterating the list. - while (nsFrameList* frameList = aPropTable->Get(this, aProp)) { + while (nsFrameList* frameList = GetProperty(aProp)) { nsIFrame* frame = frameList->RemoveFirstChild(); if (MOZ_LIKELY(frame)) { frame->DestroyFrom(aDestructRoot); } else { - aPropTable->Remove(this, aProp); + RemoveProperty(aProp); frameList->Delete(aPresShell); return; } @@ -223,22 +222,21 @@ nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot) // Destroy frames on the auxiliary frame lists and delete the lists. nsPresContext* pc = PresContext(); nsIPresShell* shell = pc->PresShell(); - FramePropertyTable* props = pc->PropertyTable(); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, OverflowProperty()); + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers) || - !(props->Get(this, nsContainerFrame::OverflowContainersProperty()) || - props->Get(this, nsContainerFrame::ExcessOverflowContainersProperty())), + !(GetProperty(nsContainerFrame::OverflowContainersProperty()) || + GetProperty(nsContainerFrame::ExcessOverflowContainersProperty())), "this type of frame should't have overflow containers"); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowContainersProperty()); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, ExcessOverflowContainersProperty()); - MOZ_ASSERT(!props->Get(this, BackdropProperty()) || + MOZ_ASSERT(!GetProperty(BackdropProperty()) || StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE, "only top layer frame may have backdrop"); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, BackdropProperty()); + SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); nsSplittableFrame::DestroyFrom(aDestructRoot); } @@ -278,12 +276,11 @@ nsContainerFrame::GetChildList(ChildListID aListID) const static void AppendIfNonempty(const nsIFrame* aFrame, - FramePropertyTable* aPropTable, nsContainerFrame::FrameListPropertyDescriptor aProperty, nsTArray* aLists, nsIFrame::ChildListID aListID) { - if (nsFrameList* list = aPropTable->Get(aFrame, aProperty)) { + if (nsFrameList* list = aFrame->GetProperty(aProperty)) { list->AppendIfNonempty(aLists, aListID); } } @@ -292,20 +289,19 @@ void nsContainerFrame::GetChildLists(nsTArray* aLists) const { mFrames.AppendIfNonempty(aLists, kPrincipalList); - FramePropertyTable* propTable = PresContext()->PropertyTable(); - ::AppendIfNonempty(this, propTable, OverflowProperty(), + ::AppendIfNonempty(this, OverflowProperty(), aLists, kOverflowList); if (IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) { - ::AppendIfNonempty(this, propTable, OverflowContainersProperty(), + ::AppendIfNonempty(this, OverflowContainersProperty(), aLists, kOverflowContainersList); - ::AppendIfNonempty(this, propTable, ExcessOverflowContainersProperty(), + ::AppendIfNonempty(this, ExcessOverflowContainersProperty(), aLists, kExcessOverflowContainersList); } // Bypass BackdropProperty hashtable lookup for any in-flow frames // since frames in the top layer (only which can have backdrop) are // definitely out-of-flow. if (GetStateBits() & NS_FRAME_OUT_OF_FLOW) { - ::AppendIfNonempty(this, propTable, BackdropProperty(), + ::AppendIfNonempty(this, BackdropProperty(), aLists, kBackdropList); } nsSplittableFrame::GetChildLists(aLists); @@ -1335,15 +1331,15 @@ nsContainerFrame::DisplayOverflowContainers(nsDisplayListBuilder* aBuilder, } static bool -TryRemoveFrame(nsIFrame* aFrame, FramePropertyTable* aPropTable, +TryRemoveFrame(nsIFrame* aFrame, nsContainerFrame::FrameListPropertyDescriptor aProp, nsIFrame* aChildToRemove) { - nsFrameList* list = aPropTable->Get(aFrame, aProp); + nsFrameList* list = aFrame->GetProperty(aProp); if (list && list->StartRemoveFrame(aChildToRemove)) { // aChildToRemove *may* have been removed from this list. if (list->IsEmpty()) { - aPropTable->Remove(aFrame, aProp); + aFrame->RemoveProperty(aProp); list->Delete(aFrame->PresContext()->PresShell()); } return true; @@ -1356,13 +1352,12 @@ nsContainerFrame::MaybeStealOverflowContainerFrame(nsIFrame* aChild) { bool removed = false; if (MOZ_UNLIKELY(aChild->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) { - FramePropertyTable* propTable = PresContext()->PropertyTable(); // Try removing from the overflow container list. - removed = ::TryRemoveFrame(this, propTable, OverflowContainersProperty(), + removed = ::TryRemoveFrame(this, OverflowContainersProperty(), aChild); if (!removed) { // It might be in the excess overflow container list. - removed = ::TryRemoveFrame(this, propTable, + removed = ::TryRemoveFrame(this, ExcessOverflowContainersProperty(), aChild); } @@ -1377,10 +1372,9 @@ nsContainerFrame::StealFrame(nsIFrame* aChild) if (!mFrames.ContainsFrame(aChild)) { nsFrameList* list = GetOverflowFrames(); if (!list || !list->ContainsFrame(aChild)) { - FramePropertyTable* propTable = PresContext()->PropertyTable(); - list = propTable->Get(this, OverflowContainersProperty()); + list = GetProperty(OverflowContainersProperty()); if (!list || !list->ContainsFrame(aChild)) { - list = propTable->Get(this, ExcessOverflowContainersProperty()); + list = GetProperty(ExcessOverflowContainersProperty()); MOZ_ASSERT(list && list->ContainsFrame(aChild), "aChild isn't our child" " or on a frame list not supported by StealFrame"); } @@ -1536,20 +1530,20 @@ nsContainerFrame::SetOverflowFrames(const nsFrameList& aOverflowFrames) nsPresContext* pc = PresContext(); nsFrameList* newList = new (pc->PresShell()) nsFrameList(aOverflowFrames); - pc->PropertyTable()->Set(this, OverflowProperty(), newList); + SetProperty(OverflowProperty(), newList); } nsFrameList* nsContainerFrame::GetPropTableFrames( FrameListPropertyDescriptor aProperty) const { - return PresContext()->PropertyTable()->Get(this, aProperty); + return GetProperty(aProperty); } nsFrameList* nsContainerFrame::RemovePropTableFrames(FrameListPropertyDescriptor aProperty) { - return PresContext()->PropertyTable()->Remove(this, aProperty); + return RemoveProperty(aProperty); } void @@ -1563,7 +1557,7 @@ nsContainerFrame::SetPropTableFrames(nsFrameList* aFrameList, IsFrameOfType(nsIFrame::eCanContainOverflowContainers), "this type of frame can't have overflow containers"); MOZ_ASSERT(!GetPropTableFrames(aProperty)); - PresContext()->PropertyTable()->Set(this, aProperty, aFrameList); + SetProperty(aProperty, aFrameList); } /** @@ -2253,13 +2247,11 @@ nsOverflowContinuationTracker::EndFinish(nsIFrame* aChild) return; } // Forget mOverflowContList if it was deleted. - nsPresContext* pc = aChild->PresContext(); - FramePropertyTable* propTable = pc->PropertyTable(); - nsFrameList* eoc = propTable->Get( - mParent, nsContainerFrame::ExcessOverflowContainersProperty()); + nsFrameList* eoc = mParent->GetProperty + (nsContainerFrame::ExcessOverflowContainersProperty()); if (eoc != mOverflowContList) { - nsFrameList* oc = static_cast(propTable->Get(mParent, - nsContainerFrame::OverflowContainersProperty())); + nsFrameList* oc = static_cast(mParent->GetProperty + (nsContainerFrame::OverflowContainersProperty())); if (oc != mOverflowContList) { // mOverflowContList was deleted mPrevOverflowCont = nullptr; diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h index a9f6d52df..ddf993d91 100644 --- a/layout/generic/nsContainerFrame.h +++ b/layout/generic/nsContainerFrame.h @@ -24,9 +24,6 @@ #define NS_FRAME_NO_DELETE_NEXT_IN_FLOW_CHILD 0x0010 class nsOverflowContinuationTracker; -namespace mozilla { -class FramePropertyTable; -} // namespace mozilla // Some macros for container classes to do sanity checking on // width/height/x/y values computed during reflow. @@ -548,7 +545,7 @@ public: // Use this to suppress the CRAZY_SIZE assertions. NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(DebugReflowingWithInfiniteISize, bool) bool IsCrazySizeAssertSuppressed() const { - return Properties().Get(DebugReflowingWithInfiniteISize()); + return GetProperty(DebugReflowingWithInfiniteISize()); } #endif @@ -716,7 +713,6 @@ protected: */ void SafelyDestroyFrameListProp(nsIFrame* aDestructRoot, nsIPresShell* aPresShell, - mozilla::FramePropertyTable* aPropTable, FrameListPropertyDescriptor aProp); // ========================================================================== @@ -898,7 +894,7 @@ inline nsFrameList* nsContainerFrame::GetOverflowFrames() const { - nsFrameList* list = Properties().Get(OverflowProperty()); + nsFrameList* list = GetProperty(OverflowProperty()); NS_ASSERTION(!list || !list->IsEmpty(), "Unexpected empty overflow list"); return list; } @@ -907,7 +903,7 @@ inline nsFrameList* nsContainerFrame::StealOverflowFrames() { - nsFrameList* list = Properties().Remove(OverflowProperty()); + nsFrameList* list = RemoveProperty(OverflowProperty()); NS_ASSERTION(!list || !list->IsEmpty(), "Unexpected empty overflow list"); return list; } diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 3818d3cb7..94bce1e7a 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -1816,8 +1816,8 @@ nsFlexContainerFrame::MeasureAscentAndHeightForFlexItem( nsPresContext* aPresContext, ReflowInput& aChildReflowInput) { - const FrameProperties props = aItem.Frame()->Properties(); - if (const auto* cachedResult = props.Get(CachedFlexMeasuringReflow())) { + if (const auto* cachedResult = + aItem.Frame()->GetProperty(CachedFlexMeasuringReflow())) { if (cachedResult->IsValidFor(aChildReflowInput)) { return *cachedResult; } @@ -1847,7 +1847,7 @@ nsFlexContainerFrame::MeasureAscentAndHeightForFlexItem( auto result = new CachedMeasuringReflowResult(aChildReflowInput, childDesiredSize); - props.Set(CachedFlexMeasuringReflow(), result); + aItem.Frame()->SetProperty(CachedFlexMeasuringReflow(), result); return *result; } @@ -1855,7 +1855,7 @@ nsFlexContainerFrame::MeasureAscentAndHeightForFlexItem( nsFlexContainerFrame::MarkIntrinsicISizesDirty() { for (nsIFrame* childFrame : mFrames) { - childFrame->Properties().Delete(CachedFlexMeasuringReflow()); + childFrame->DeleteProperty(CachedFlexMeasuringReflow()); } nsContainerFrame::MarkIntrinsicISizesDirty(); } @@ -4236,25 +4236,26 @@ class MOZ_RAII AutoFlexItemMainSizeOverride final public: explicit AutoFlexItemMainSizeOverride(FlexItem& aItem MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mItemProps(aItem.Frame()->Properties()) + : mItemFrame(aItem.Frame()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; - MOZ_ASSERT(!mItemProps.Has(nsIFrame::FlexItemMainSizeOverride()), + MOZ_ASSERT(!mItemFrame->HasProperty(nsIFrame::FlexItemMainSizeOverride()), "FlexItemMainSizeOverride prop shouldn't be set already; " "it should only be set temporarily (& not recursively)"); NS_ASSERTION(aItem.HasIntrinsicRatio(), "This should only be needed for items with an aspect ratio"); - mItemProps.Set(nsIFrame::FlexItemMainSizeOverride(), aItem.GetMainSize()); + mItemFrame->SetProperty(nsIFrame::FlexItemMainSizeOverride(), + aItem.GetMainSize()); } ~AutoFlexItemMainSizeOverride() { - mItemProps.Remove(nsIFrame::FlexItemMainSizeOverride()); + mItemFrame->RemoveProperty(nsIFrame::FlexItemMainSizeOverride()); } private: - const FrameProperties mItemProps; + nsIFrame* mItemFrame; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; @@ -4668,8 +4669,7 @@ nsFlexContainerFrame::MoveFlexItemToFinalPosition( // If item is relpos, look up its offsets (cached from prev reflow) LogicalMargin logicalOffsets(outerWM); if (NS_STYLE_POSITION_RELATIVE == aItem.Frame()->StyleDisplay()->mPosition) { - FrameProperties props = aItem.Frame()->Properties(); - nsMargin* cachedOffsets = props.Get(nsIFrame::ComputedOffsetProperty()); + nsMargin* cachedOffsets = aItem.Frame()->GetProperty(nsIFrame::ComputedOffsetProperty()); MOZ_ASSERT(cachedOffsets, "relpos previously-reflowed frame should've cached its offsets"); logicalOffsets = LogicalMargin(outerWM, *cachedOffsets); diff --git a/layout/generic/nsFloatManager.cpp b/layout/generic/nsFloatManager.cpp index 2c0ff1f38..4e7e7ff91 100644 --- a/layout/generic/nsFloatManager.cpp +++ b/layout/generic/nsFloatManager.cpp @@ -331,7 +331,7 @@ nsFloatManager::GetRegionFor(WritingMode aWM, nsIFrame* aFloat, const nsSize& aContainerSize) { LogicalRect region = aFloat->GetLogicalRect(aWM, aContainerSize); - void* storedRegion = aFloat->Properties().Get(FloatRegionProperty()); + void* storedRegion = aFloat->GetProperty(FloatRegionProperty()); if (storedRegion) { nsMargin margin = *static_cast(storedRegion); region.Inflate(aWM, LogicalMargin(aWM, margin)); @@ -346,15 +346,14 @@ nsFloatManager::StoreRegionFor(WritingMode aWM, nsIFrame* aFloat, { nsRect region = aRegion.GetPhysicalRect(aWM, aContainerSize); nsRect rect = aFloat->GetRect(); - FrameProperties props = aFloat->Properties(); if (region.IsEqualEdges(rect)) { - props.Delete(FloatRegionProperty()); + aFloat->DeleteProperty(FloatRegionProperty()); } else { - nsMargin* storedMargin = props.Get(FloatRegionProperty()); + nsMargin* storedMargin = aFloat->GetProperty(FloatRegionProperty()); if (!storedMargin) { storedMargin = new nsMargin(); - props.Set(FloatRegionProperty(), storedMargin); + aFloat->SetProperty(FloatRegionProperty(), storedMargin); } *storedMargin = region - rect; } diff --git a/layout/generic/nsFontInflationData.cpp b/layout/generic/nsFontInflationData.cpp index 9e9a51999..831658c9e 100644 --- a/layout/generic/nsFontInflationData.cpp +++ b/layout/generic/nsFontInflationData.cpp @@ -6,7 +6,7 @@ /* Per-block-formatting-context manager of font size inflation for pan and zoom UI. */ #include "nsFontInflationData.h" -#include "FramePropertyTable.h" +#include "FrameProperties.h" #include "nsTextControlFrame.h" #include "nsListControlFrame.h" #include "nsComboboxControlFrame.h" @@ -27,7 +27,7 @@ nsFontInflationData::FindFontInflationDataFor(const nsIFrame *aFrame) NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT, "should have found a flow root"); - return bfc->Properties().Get(FontInflationDataProperty()); + return bfc->GetProperty(FontInflationDataProperty()); } /* static */ bool @@ -36,8 +36,7 @@ nsFontInflationData::UpdateFontInflationDataISizeFor(const ReflowInput& aReflowI nsIFrame *bfc = aReflowInput.mFrame; NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT, "should have been given a flow root"); - FrameProperties bfcProps(bfc->Properties()); - nsFontInflationData *data = bfcProps.Get(FontInflationDataProperty()); + nsFontInflationData *data = bfc->GetProperty(FontInflationDataProperty()); bool oldInflationEnabled; nscoord oldNCAISize; if (data) { @@ -45,7 +44,7 @@ nsFontInflationData::UpdateFontInflationDataISizeFor(const ReflowInput& aReflowI oldInflationEnabled = data->mInflationEnabled; } else { data = new nsFontInflationData(bfc); - bfcProps.Set(FontInflationDataProperty(), data); + bfc->SetProperty(FontInflationDataProperty(), data); oldNCAISize = -1; oldInflationEnabled = true; /* not relevant */ } @@ -65,8 +64,7 @@ nsFontInflationData::MarkFontInflationDataTextDirty(nsIFrame *aBFCFrame) NS_ASSERTION(aBFCFrame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT, "should have been given a flow root"); - FrameProperties bfcProps(aBFCFrame->Properties()); - nsFontInflationData *data = bfcProps.Get(FontInflationDataProperty()); + nsFontInflationData *data = aBFCFrame->GetProperty(FontInflationDataProperty()); if (data) { data->MarkTextDirty(); } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index fa5b24d40..bd96f213b 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -168,13 +168,12 @@ NS_DECLARE_FRAME_PROPERTY_DELETABLE(BoxMetricsProperty, nsBoxLayoutMetrics) static void InitBoxMetrics(nsIFrame* aFrame, bool aClear) { - FrameProperties props = aFrame->Properties(); if (aClear) { - props.Delete(BoxMetricsProperty()); + aFrame->DeleteProperty(BoxMetricsProperty()); } nsBoxLayoutMetrics* metrics = new nsBoxLayoutMetrics(); - props.Set(BoxMetricsProperty(), metrics); + aFrame->SetProperty(BoxMetricsProperty(), metrics); static_cast(aFrame)->nsFrame::MarkIntrinsicISizesDirty(); metrics->mBlockAscent = 0; @@ -254,7 +253,7 @@ nsIFrame::HasAbsolutelyPositionedChildren() const { nsAbsoluteContainingBlock* nsIFrame::GetAbsoluteContainingBlock() const { NS_ASSERTION(IsAbsoluteContainer(), "The frame is not marked as an abspos container correctly"); - nsAbsoluteContainingBlock* absCB = Properties().Get(AbsoluteContainingBlockProperty()); + nsAbsoluteContainingBlock* absCB = GetProperty(AbsoluteContainingBlockProperty()); NS_ASSERTION(absCB, "The frame is marked as an abspos container but doesn't have the property"); return absCB; } @@ -263,25 +262,25 @@ void nsIFrame::MarkAsAbsoluteContainingBlock() { MOZ_ASSERT(GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); - NS_ASSERTION(!Properties().Get(AbsoluteContainingBlockProperty()), + NS_ASSERTION(!GetProperty(AbsoluteContainingBlockProperty()), "Already has an abs-pos containing block property?"); NS_ASSERTION(!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN), "Already has NS_FRAME_HAS_ABSPOS_CHILDREN state bit?"); AddStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN); - Properties().Set(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListID())); + SetProperty(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListID())); } void nsIFrame::MarkAsNotAbsoluteContainingBlock() { NS_ASSERTION(!HasAbsolutelyPositionedChildren(), "Think of the children!"); - NS_ASSERTION(Properties().Get(AbsoluteContainingBlockProperty()), + NS_ASSERTION(GetProperty(AbsoluteContainingBlockProperty()), "Should have an abs-pos containing block property"); NS_ASSERTION(HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN), "Should have NS_FRAME_HAS_ABSPOS_CHILDREN state bit"); MOZ_ASSERT(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)); RemoveStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN); - Properties().Delete(AbsoluteContainingBlockProperty()); + DeleteProperty(AbsoluteContainingBlockProperty()); } bool @@ -652,32 +651,30 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot) } // If we have any IB split siblings, clear their references to us. - // (Note: This has to happen before we call shell->NotifyDestroyingFrame, - // because that clears our Properties() table.) + // (Note: This has to happen before we clear our Properties() table.) if (mState & NS_FRAME_PART_OF_IBSPLIT) { // Delete previous sibling's reference to me. - nsIFrame* prevSib = Properties().Get(nsIFrame::IBSplitPrevSibling()); + nsIFrame* prevSib = GetProperty(nsIFrame::IBSplitPrevSibling()); if (prevSib) { NS_WARNING_ASSERTION( - this == prevSib->Properties().Get(nsIFrame::IBSplitSibling()), + this == prevSib->GetProperty(nsIFrame::IBSplitSibling()), "IB sibling chain is inconsistent"); - prevSib->Properties().Delete(nsIFrame::IBSplitSibling()); + prevSib->DeleteProperty(nsIFrame::IBSplitSibling()); } // Delete next sibling's reference to me. - nsIFrame* nextSib = Properties().Get(nsIFrame::IBSplitSibling()); + nsIFrame* nextSib = GetProperty(nsIFrame::IBSplitSibling()); if (nextSib) { NS_WARNING_ASSERTION( - this == nextSib->Properties().Get(nsIFrame::IBSplitPrevSibling()), + this == nextSib->GetProperty(nsIFrame::IBSplitPrevSibling()), "IB sibling chain is inconsistent"); - nextSib->Properties().Delete(nsIFrame::IBSplitPrevSibling()); + nextSib->DeleteProperty(nsIFrame::IBSplitPrevSibling()); } } bool isPrimaryFrame = (mContent && mContent->GetPrimaryFrame() == this); if (isPrimaryFrame) { - // This needs to happen before shell->NotifyDestroyingFrame because - // that clears our Properties() table. + // This needs to happen before we clear our Properties() table. ActiveLayerTracker::TransferActivityToContent(this, mContent); // Unfortunately, we need to do this for all frames being reframed @@ -712,9 +709,8 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot) } } - // Disable visibility tracking. Note that we have to do this before calling - // NotifyDestroyingFrame(), which will clear frame properties and make us lose - // track of whether we were previously visible or not. + // Disable visibility tracking. Note that we have to do this before we clear + // frame properties and lose track of whether we were previously visible. // XXX(seth): It'd be ideal to assert that we're already marked nonvisible // here, but it's unfortunately tricky to guarantee in the face of things like // frame reconstruction induced by style changes. @@ -742,6 +738,10 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot) mContent->SetPrimaryFrame(nullptr); } + // Delete all properties attached to the frame, to ensure any property + // destructors that need the frame pointer are handled properly. + DeleteAllProperties(); + // Must retrieve the object ID before calling destructors, so the // vtable is still valid. // @@ -860,22 +860,21 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) // calls GetUsed(Margin|Border|Padding)() before the next reflow, we // can give an accurate answer. // We don't want to set the property if one already exists. - FrameProperties props = Properties(); nsMargin oldValue(0, 0, 0, 0); nsMargin newValue(0, 0, 0, 0); const nsStyleMargin* oldMargin = aOldStyleContext->PeekStyleMargin(); if (oldMargin && oldMargin->GetMargin(oldValue)) { if ((!StyleMargin()->GetMargin(newValue) || oldValue != newValue) && - !props.Get(UsedMarginProperty())) { - props.Set(UsedMarginProperty(), new nsMargin(oldValue)); + !GetProperty(UsedMarginProperty())) { + SetProperty(UsedMarginProperty(), new nsMargin(oldValue)); } } const nsStylePadding* oldPadding = aOldStyleContext->PeekStylePadding(); if (oldPadding && oldPadding->GetPadding(oldValue)) { if ((!StylePadding()->GetPadding(newValue) || oldValue != newValue) && - !props.Get(UsedPaddingProperty())) { - props.Set(UsedPaddingProperty(), new nsMargin(oldValue)); + !GetProperty(UsedPaddingProperty())) { + SetProperty(UsedPaddingProperty(), new nsMargin(oldValue)); } } @@ -884,8 +883,8 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) oldValue = oldBorder->GetComputedBorder(); newValue = StyleBorder()->GetComputedBorder(); if (oldValue != newValue && - !props.Get(UsedBorderProperty())) { - props.Set(UsedBorderProperty(), new nsMargin(oldValue)); + !GetProperty(UsedBorderProperty())) { + SetProperty(UsedBorderProperty(), new nsMargin(oldValue)); } } } @@ -961,7 +960,7 @@ nsIFrame::GetUsedMargin() const IsSVGText()) return margin; - nsMargin *m = Properties().Get(UsedMarginProperty()); + nsMargin *m = GetProperty(UsedMarginProperty()); if (m) { margin = *m; } else { @@ -1000,7 +999,7 @@ nsIFrame::GetUsedBorder() const return border; } - nsMargin *b = Properties().Get(UsedBorderProperty()); + nsMargin *b = GetProperty(UsedBorderProperty()); if (b) { border = *b; } else { @@ -1037,7 +1036,7 @@ nsIFrame::GetUsedPadding() const } } - nsMargin *p = Properties().Get(UsedPaddingProperty()); + nsMargin *p = GetProperty(UsedPaddingProperty()); if (p) { padding = *p; } else { @@ -1478,8 +1477,7 @@ nsIFrame::GetVisibility() const } bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Get(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); @@ -1552,15 +1550,14 @@ nsIFrame::EnableVisibilityTracking() return; // Nothing to do. } - FrameProperties props = Properties(); - MOZ_ASSERT(!props.Has(VisibilityStateProperty()), + MOZ_ASSERT(!HasProperty(VisibilityStateProperty()), "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set"); // Add the state bit so we know to track visibility for this frame, and // initialize the frame property. AddStateBits(NS_FRAME_VISIBILITY_IS_TRACKED); - props.Set(VisibilityStateProperty(), 0); + SetProperty(VisibilityStateProperty(), 0); nsIPresShell* presShell = PresContext()->PresShell(); if (!presShell) { @@ -1582,8 +1579,7 @@ nsIFrame::DisableVisibilityTracking() } bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Remove(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = RemoveProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); @@ -1605,8 +1601,7 @@ nsIFrame::DecApproximateVisibleCount(Maybe aNonvisibleAction MOZ_ASSERT(GetStateBits() & NS_FRAME_VISIBILITY_IS_TRACKED); bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Get(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); @@ -1614,7 +1609,7 @@ nsIFrame::DecApproximateVisibleCount(Maybe aNonvisibleAction "decrementing its visible count?"); visibleCount--; - props.Set(VisibilityStateProperty(), visibleCount); + SetProperty(VisibilityStateProperty(), visibleCount); if (visibleCount > 0) { return; } @@ -1629,14 +1624,13 @@ nsIFrame::IncApproximateVisibleCount() MOZ_ASSERT(GetStateBits() & NS_FRAME_VISIBILITY_IS_TRACKED); bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Get(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); visibleCount++; - props.Set(VisibilityStateProperty(), visibleCount); + SetProperty(VisibilityStateProperty(), visibleCount); if (visibleCount > 1) { return; } @@ -4943,10 +4937,9 @@ nsFrame::ComputeSizeWithIntrinsicDimensions(nsRenderingContext* aRenderingConte // If FlexItemMainSizeOverride frame-property is set, then that means the // flex container is imposing a main-size on this flex item for it to use // as its size in the container's main axis. - FrameProperties props = Properties(); bool didImposeMainSize; nscoord imposedMainSize = - props.Get(nsIFrame::FlexItemMainSizeOverride(), &didImposeMainSize); + GetProperty(nsIFrame::FlexItemMainSizeOverride(), &didImposeMainSize); if (didImposeMainSize) { imposedMainSizeStyleCoord.emplace(imposedMainSize, nsStyleCoord::CoordConstructor); @@ -5686,7 +5679,7 @@ nsIFrame::GetView() const return nullptr; // Check for a property on the frame - nsView* value = Properties().Get(ViewProperty()); + nsView* value = GetProperty(ViewProperty()); NS_ASSERTION(value, "frame state bit was set but frame has no view"); return value; } @@ -5709,7 +5702,7 @@ nsIFrame::SetView(nsView* aView) #endif // Set a property on the frame - Properties().Set(ViewProperty(), aView); + SetProperty(ViewProperty(), aView); // Set the frame state bit that says the frame has a view AddStateBits(NS_FRAME_HAS_VIEW); @@ -6098,7 +6091,7 @@ static void InvalidateFrameInternal(nsIFrame *aFrame, bool aHasDisplayItem = tru SchedulePaintInternal(aFrame); } if (aFrame->HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { - aFrame->Properties().Delete(nsIFrame::InvalidationRect()); + aFrame->DeleteProperty(nsIFrame::InvalidationRect()); aFrame->RemoveStateBits(NS_FRAME_HAS_INVALID_RECT); } } @@ -6173,13 +6166,13 @@ nsIFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey) return; } - nsRect* rect = Properties().Get(InvalidationRect()); + nsRect* rect = GetProperty(InvalidationRect()); if (!rect) { if (alreadyInvalid) { return; } rect = new nsRect(); - Properties().Set(InvalidationRect(), rect); + SetProperty(InvalidationRect(), rect); AddStateBits(NS_FRAME_HAS_INVALID_RECT); } @@ -6280,7 +6273,7 @@ nsIFrame::IsInvalid(nsRect& aRect) } if (HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { - nsRect* rect = Properties().Get(InvalidationRect()); + nsRect* rect = GetProperty(InvalidationRect()); NS_ASSERTION(rect, "Must have an invalid rect if NS_FRAME_HAS_INVALID_RECT is set!"); aRect = *rect; } else { @@ -6368,8 +6361,8 @@ ComputeEffectsRect(nsIFrame* aFrame, const nsRect& aOverflowRect, // TODO: We could also take account of clipPath and mask to reduce the // visual overflow, but that's not essential. if (aFrame->StyleEffects()->HasFilters()) { - aFrame->Properties(). - Set(nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); + aFrame->SetProperty + (nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); r = nsSVGUtils::GetPostFilterVisualOverflowRect(aFrame, aOverflowRect); } return r; @@ -6407,8 +6400,8 @@ ComputeEffectsRect(nsIFrame* aFrame, const nsRect& aOverflowRect, // the frame dies. if (nsSVGIntegrationUtils::UsingEffectsForFrame(aFrame)) { - aFrame->Properties(). - Set(nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); + aFrame->SetProperty + (nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); r = nsSVGIntegrationUtils::ComputePostEffectsVisualOverflowRect(aFrame, r); } @@ -6422,7 +6415,7 @@ nsIFrame::MovePositionBy(const nsPoint& aTranslation) const nsMargin* computedOffsets = nullptr; if (IsRelativelyPositioned()) { - computedOffsets = Properties().Get(nsIFrame::ComputedOffsetProperty()); + computedOffsets = GetProperty(nsIFrame::ComputedOffsetProperty()); } ReflowInput::ApplyRelativePositioning(this, computedOffsets ? *computedOffsets : nsMargin(), @@ -6435,7 +6428,7 @@ nsIFrame::GetNormalRect() const { // It might be faster to first check // StyleDisplay()->IsRelativelyPositionedStyle(). - nsPoint* normalPosition = Properties().Get(NormalPositionProperty()); + nsPoint* normalPosition = GetProperty(NormalPositionProperty()); if (normalPosition) { return nsRect(*normalPosition, GetSize()); } @@ -6447,7 +6440,7 @@ nsIFrame::GetNormalPosition() const { // It might be faster to first check // StyleDisplay()->IsRelativelyPositionedStyle(). - nsPoint* normalPosition = Properties().Get(NormalPositionProperty()); + nsPoint* normalPosition = GetProperty(NormalPositionProperty()); if (normalPosition) { return *normalPosition; } @@ -6506,7 +6499,7 @@ nsIFrame::GetOverflowAreasRelativeToSelf() const { if (IsTransformed()) { nsOverflowAreas* preTransformOverflows = - Properties().Get(PreTransformOverflowAreasProperty()); + GetProperty(PreTransformOverflowAreasProperty()); if (preTransformOverflows) { return nsOverflowAreas(preTransformOverflows->VisualOverflow(), preTransformOverflows->ScrollableOverflow()); @@ -6533,7 +6526,7 @@ nsIFrame::GetScrollableOverflowRectRelativeToSelf() const { if (IsTransformed()) { nsOverflowAreas* preTransformOverflows = - Properties().Get(PreTransformOverflowAreasProperty()); + GetProperty(PreTransformOverflowAreasProperty()); if (preTransformOverflows) return preTransformOverflows->ScrollableOverflow(); } @@ -6545,7 +6538,7 @@ nsIFrame::GetVisualOverflowRectRelativeToSelf() const { if (IsTransformed()) { nsOverflowAreas* preTransformOverflows = - Properties().Get(PreTransformOverflowAreasProperty()); + GetProperty(PreTransformOverflowAreasProperty()); if (preTransformOverflows) return preTransformOverflows->VisualOverflow(); } @@ -6555,7 +6548,7 @@ nsIFrame::GetVisualOverflowRectRelativeToSelf() const nsRect nsIFrame::GetPreEffectsVisualOverflowRect() const { - nsRect* r = Properties().Get(nsIFrame::PreEffectsBBoxProperty()); + nsRect* r = GetProperty(nsIFrame::PreEffectsBBoxProperty()); return r ? *r : GetVisualOverflowRectRelativeToSelf(); } @@ -6758,11 +6751,11 @@ nsIFrame::ListGeneric(nsACString& aTo, const char* aPrefix, uint32_t aFlags) con aTo += nsPrintfCString(" next-%s=%p", fluid?"in-flow":"continuation", static_cast(GetNextContinuation())); } - void* IBsibling = Properties().Get(IBSplitSibling()); + void* IBsibling = GetProperty(IBSplitSibling()); if (IBsibling) { aTo += nsPrintfCString(" IBSplitSibling=%p", IBsibling); } - void* IBprevsibling = Properties().Get(IBSplitPrevSibling()); + void* IBprevsibling = GetProperty(IBSplitPrevSibling()); if (IBprevsibling) { aTo += nsPrintfCString(" IBSplitPrevSibling=%p", IBprevsibling); } @@ -7164,8 +7157,7 @@ nsFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) // If the embedding level isn't set, just use the CSS direction // property. bool hasBidiData; - FrameBidiData bidiData = - Properties().Get(BidiDataProperty(), &hasBidiData); + FrameBidiData bidiData = GetProperty(BidiDataProperty(), &hasBidiData); bool isRTL = hasBidiData ? IS_LEVEL_RTL(bidiData.embeddingLevel) : StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL; @@ -8315,7 +8307,7 @@ nsIFrame::ClearOverflowRects() return false; } if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) { - Properties().Delete(OverflowAreasProperty()); + DeleteProperty(OverflowAreasProperty()); } mOverflow.mType = NS_FRAME_OVERFLOW_NONE; return true; @@ -8328,8 +8320,7 @@ nsIFrame::ClearOverflowRects() nsOverflowAreas* nsIFrame::GetOverflowAreasProperty() { - FrameProperties props = Properties(); - nsOverflowAreas* overflow = props.Get(OverflowAreasProperty()); + nsOverflowAreas* overflow = GetProperty(OverflowAreasProperty()); if (overflow) { return overflow; // the property already exists @@ -8338,7 +8329,7 @@ nsIFrame::GetOverflowAreasProperty() // The property isn't set yet, so allocate a new rect, set the property, // and return the newly allocated rect overflow = new nsOverflowAreas; - props.Set(OverflowAreasProperty(), overflow); + SetProperty(OverflowAreasProperty(), overflow); return overflow; } @@ -8349,7 +8340,7 @@ bool nsIFrame::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas) { if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) { - nsOverflowAreas* overflow = Properties().Get(OverflowAreasProperty()); + nsOverflowAreas* overflow = GetProperty(OverflowAreasProperty()); bool changed = *overflow != aOverflowAreas; *overflow = aOverflowAreas; @@ -8593,7 +8584,7 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas, } // Keep this code in sync with GetOutlineInnerRect in nsCSSRendering.cpp. - aFrame->Properties().Set(nsIFrame::OutlineInnerRectProperty(), + aFrame->SetProperty(nsIFrame::OutlineInnerRectProperty(), new nsRect(innerRect)); const nscoord offset = outline->mOutlineOffset; nsRect outerRect(innerRect); @@ -8635,22 +8626,22 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, if (!aOverflowAreas.VisualOverflow().IsEqualEdges(bounds) || !aOverflowAreas.ScrollableOverflow().IsEqualEdges(bounds)) { nsOverflowAreas* initial = - Properties().Get(nsIFrame::InitialOverflowProperty()); + GetProperty(nsIFrame::InitialOverflowProperty()); if (!initial) { - Properties().Set(nsIFrame::InitialOverflowProperty(), + SetProperty(nsIFrame::InitialOverflowProperty(), new nsOverflowAreas(aOverflowAreas)); } else if (initial != &aOverflowAreas) { *initial = aOverflowAreas; } } else { - Properties().Delete(nsIFrame::InitialOverflowProperty()); + DeleteProperty(nsIFrame::InitialOverflowProperty()); } #ifdef DEBUG - Properties().Set(nsIFrame::DebugInitialOverflowPropertyApplied(), true); + SetProperty(nsIFrame::DebugInitialOverflowPropertyApplied(), true); #endif } else { #ifdef DEBUG - Properties().Delete(nsIFrame::DebugInitialOverflowPropertyApplied()); + DeleteProperty(nsIFrame::DebugInitialOverflowPropertyApplied()); #endif } @@ -8745,8 +8736,8 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, } if (hasTransform) { - Properties().Set(nsIFrame::PreTransformOverflowAreasProperty(), - new nsOverflowAreas(aOverflowAreas)); + SetProperty(nsIFrame::PreTransformOverflowAreasProperty(), + new nsOverflowAreas(aOverflowAreas)); if (Combines3DTransformWithAncestors()) { /* If we're a preserve-3d leaf frame, then our pre-transform overflow should be correct. Our @@ -8771,7 +8762,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, } } } else { - Properties().Delete(nsIFrame::PreTransformOverflowAreasProperty()); + DeleteProperty(nsIFrame::PreTransformOverflowAreasProperty()); } /* Revert the size change in case some caller is depending on this. */ @@ -8803,7 +8794,7 @@ nsIFrame::RecomputePerspectiveChildrenOverflow(const nsIFrame* aStartFrame) } if (child->HasPerspective()) { nsOverflowAreas* overflow = - child->Properties().Get(nsIFrame::InitialOverflowProperty()); + child->GetProperty(nsIFrame::InitialOverflowProperty()); nsRect bounds(nsPoint(0, 0), child->GetSize()); if (overflow) { nsOverflowAreas overflowCopy = *overflow; @@ -8915,7 +8906,7 @@ GetIBSplitSiblingForAnonymousBlock(const nsIFrame* aFrame) * property. */ nsIFrame *ibSplitSibling = - aFrame->Properties().Get(nsIFrame::IBSplitPrevSibling()); + aFrame->GetProperty(nsIFrame::IBSplitPrevSibling()); NS_ASSERTION(ibSplitSibling, "Broken frame tree?"); return ibSplitSibling; } @@ -9825,7 +9816,7 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState, nsBoxLayoutMetrics* nsFrame::BoxMetrics() const { - nsBoxLayoutMetrics* metrics = Properties().Get(BoxMetricsProperty()); + nsBoxLayoutMetrics* metrics = GetProperty(BoxMetricsProperty()); NS_ASSERTION(metrics, "A box layout method was called but InitBoxMetrics was never called"); return metrics; } @@ -10069,6 +10060,24 @@ nsFrame::HasCSSTransitions() return collection && collection->mAnimations.Length() > 0; } +size_t +nsIFrame::SizeOfFramePropertiesForTree(MallocSizeOf aMallocSizeOf) const +{ + size_t result = 0; + + result += mProperties.SizeOfExcludingThis(aMallocSizeOf); + + FrameChildListIterator iter(this); + while (!iter.IsDone()) { + for (const nsIFrame* f : iter.CurrentList()) { + result += f->SizeOfFramePropertiesForTree(aMallocSizeOf); + } + iter.Next(); + } + + return result; +} + // Box layout debugging #ifdef DEBUG_REFLOW int32_t gIndent2 = 0; diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index fbd61f783..3a2d5ad1d 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -2000,7 +2000,7 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::GridReflowInput ++fragment; firstInFlow = pif; } - mSharedGridData = firstInFlow->Properties().Get(SharedGridData::Prop()); + mSharedGridData = firstInFlow->GetProperty(SharedGridData::Prop()); MOZ_ASSERT(mSharedGridData, "first-in-flow must have SharedGridData"); // Find the start row for this fragment and undo breaks after that row @@ -2809,7 +2809,7 @@ nsGridContainerFrame::GridItemCB(nsIFrame* aChild) { MOZ_ASSERT((aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW) && aChild->IsAbsolutelyPositioned()); - nsRect* cb = aChild->Properties().Get(GridItemContainingBlockRect()); + nsRect* cb = aChild->GetProperty(GridItemContainingBlockRect()); MOZ_ASSERT(cb, "this method must only be called on grid items, and the grid " "container should've reflowed this item by now and set up cb"); return *cb; @@ -2836,7 +2836,7 @@ nsGridContainerFrame::AddImplicitNamedAreas( // Lazily create the ImplicitNamedAreas. if (!areas) { areas = new ImplicitNamedAreas; - Properties().Set(ImplicitNamedAreasProperty(), areas); + SetProperty(ImplicitNamedAreasProperty(), areas); } mozilla::css::GridNamedArea area; @@ -2868,7 +2868,7 @@ nsGridContainerFrame::InitImplicitNamedAreas(const nsStylePosition* aStyle) AddImplicitNamedAreas(aStyle->mGridTemplateColumns.mLineNameLists); AddImplicitNamedAreas(aStyle->mGridTemplateRows.mLineNameLists); if (areas && areas->Count() == 0) { - Properties().Delete(ImplicitNamedAreasProperty()); + DeleteProperty(ImplicitNamedAreasProperty()); } } @@ -3711,7 +3711,7 @@ MeasuringReflow(nsIFrame* aChild, } #ifdef DEBUG // This will suppress various CRAZY_SIZE warnings for this reflow. - parent->Properties().Set( + parent->SetProperty( nsContainerFrame::DebugReflowingWithInfiniteISize(), true); #endif auto wm = aChild->GetWritingMode(); @@ -3724,10 +3724,10 @@ MeasuringReflow(nsIFrame* aChild, } if (aBMinSizeClamp != NS_MAXSIZE) { riFlags |= ReflowInput::B_CLAMP_MARGIN_BOX_MIN_SIZE; - aChild->Properties().Set(nsIFrame::BClampMarginBoxMinSizeProperty(), + aChild->SetProperty(nsIFrame::BClampMarginBoxMinSizeProperty(), aBMinSizeClamp); } else { - aChild->Properties().Delete(nsIFrame::BClampMarginBoxMinSizeProperty()); + aChild->DeleteProperty(nsIFrame::BClampMarginBoxMinSizeProperty()); } ReflowInput childRI(pc, *rs, aChild, aAvailableSize, &aCBSize, riFlags); ReflowOutput childSize(childRI); @@ -3738,7 +3738,7 @@ MeasuringReflow(nsIFrame* aChild, parent->FinishReflowChild(aChild, pc, childSize, &childRI, wm, LogicalPoint(wm), nsSize(), flags); #ifdef DEBUG - parent->Properties().Delete(nsContainerFrame::DebugReflowingWithInfiniteISize()); + parent->DeleteProperty(nsContainerFrame::DebugReflowingWithInfiniteISize()); #endif return childSize.BSize(wm); } @@ -5253,9 +5253,9 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, baselineAdjust = -baselineAdjust; } if (baselineAdjust != nscoord(0)) { - aChild->Properties().Set(aProp, baselineAdjust); + aChild->SetProperty(aProp, baselineAdjust); } else { - aChild->Properties().Delete(aProp); + aChild->DeleteProperty(aProp); } }; SetProp(eLogicalAxisBlock, isOrthogonal ? IBaselinePadProperty() : @@ -5292,10 +5292,10 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, auto childBAxis = GetOrthogonalAxis(childIAxis); if (aGridItemInfo->mState[childBAxis] & ItemState::eClampMarginBoxMinSize) { flags |= ReflowInput::B_CLAMP_MARGIN_BOX_MIN_SIZE; - aChild->Properties().Set(BClampMarginBoxMinSizeProperty(), - childCBSize.BSize(childWM)); + aChild->SetProperty(BClampMarginBoxMinSizeProperty(), + childCBSize.BSize(childWM)); } else { - aChild->Properties().Delete(BClampMarginBoxMinSizeProperty()); + aChild->DeleteProperty(BClampMarginBoxMinSizeProperty()); } if ((aGridItemInfo->mState[childIAxis] & ItemState::eApplyAutoMinSize)) { flags |= ReflowInput::I_APPLY_AUTO_MIN_SIZE; @@ -5313,11 +5313,11 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, // A table-wrapper needs to propagate the CB size we give it to its // inner table frame later. @see nsTableWrapperFrame::InitChildReflowInput. if (childType == nsGkAtoms::tableWrapperFrame) { - const auto& props = aChild->Properties(); - LogicalSize* cb = props.Get(nsTableWrapperFrame::GridItemCBSizeProperty()); + LogicalSize* cb = + aChild->GetProperty(nsTableWrapperFrame::GridItemCBSizeProperty()); if (!cb) { cb = new LogicalSize(childWM); - props.Set(nsTableWrapperFrame::GridItemCBSizeProperty(), cb); + aChild->SetProperty(nsTableWrapperFrame::GridItemCBSizeProperty(), cb); } *cb = percentBasis; } @@ -5337,9 +5337,9 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, } } if (stretch) { - aChild->Properties().Set(FragStretchBSizeProperty(), *aStretchBSize); + aChild->SetProperty(FragStretchBSizeProperty(), *aStretchBSize); } else { - aChild->Properties().Delete(FragStretchBSizeProperty()); + aChild->DeleteProperty(FragStretchBSizeProperty()); } } @@ -5951,10 +5951,10 @@ nsGridContainerFrame::ReflowChildren(GridReflowInput& aState, LogicalRect itemCB = aState.ContainingBlockForAbsPos(area, gridOrigin, gridCB); // nsAbsoluteContainingBlock::Reflow uses physical coordinates. - nsRect* cb = child->Properties().Get(GridItemContainingBlockRect()); + nsRect* cb = child->GetProperty(GridItemContainingBlockRect()); if (!cb) { cb = new nsRect; - child->Properties().Set(GridItemContainingBlockRect(), cb); + child->SetProperty(GridItemContainingBlockRect(), cb); } *cb = itemCB.GetPhysicalRect(wm, gridCBPhysicalSize); } @@ -6044,7 +6044,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, f = next; } if (overflowContainers->IsEmpty()) { - Properties().Delete(OverflowContainersProperty()); + DeleteProperty(OverflowContainersProperty()); } MergeSortedExcessOverflowContainers(moveToEOC); } @@ -6355,7 +6355,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(colTrackStates), Move(colRemovedRepeatTracks), gridReflowInput.mColFunctions.mRepeatAutoStart); - Properties().Set(GridColTrackInfo(), colInfo); + SetProperty(GridColTrackInfo(), colInfo); uint32_t rowTrackCount = gridReflowInput.mRows.mSizes.Length(); nsTArray rowTrackPositions(rowTrackCount); @@ -6390,7 +6390,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(rowTrackStates), Move(rowRemovedRepeatTracks), gridReflowInput.mRowFunctions.mRepeatAutoStart); - Properties().Set(GridRowTrackInfo(), rowInfo); + SetProperty(GridRowTrackInfo(), rowInfo); if (prevInFlow) { // This frame is fragmenting rows from a previous frame, so patch up @@ -6399,7 +6399,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, // FIXME: This can be streamlined and/or removed when bug 1151204 lands. ComputedGridTrackInfo* priorRowInfo = - prevInFlow->Properties().Get(GridRowTrackInfo()); + prevInFlow->GetProperty(GridRowTrackInfo()); // Adjust track positions based on the first track in this fragment. if (priorRowInfo->mPositions.Length() > @@ -6421,7 +6421,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(priorRowInfo->mStates), Move(priorRowInfo->mRemovedRepeatTracks), priorRowInfo->mRepeatFirstTrack); - prevInFlow->Properties().Set(GridRowTrackInfo(), revisedPriorRowInfo); + prevInFlow->SetProperty(GridRowTrackInfo(), revisedPriorRowInfo); } // Generate the line info properties. We need to provide the number of @@ -6448,7 +6448,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(columnLineNames), gridColTemplate.mRepeatAutoLineNameListBefore, gridColTemplate.mRepeatAutoLineNameListAfter); - Properties().Set(GridColumnLineInfo(), columnLineInfo); + SetProperty(GridColumnLineInfo(), columnLineInfo); // Generate row lines next. capacity = gridReflowInput.mRows.mSizes.Length(); @@ -6469,25 +6469,25 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(rowLineNames), gridRowTemplate.mRepeatAutoLineNameListBefore, gridRowTemplate.mRepeatAutoLineNameListAfter); - Properties().Set(GridRowLineInfo(), rowLineInfo); + SetProperty(GridRowLineInfo(), rowLineInfo); // Generate area info for explicit areas. Implicit areas are handled // elsewhere. if (gridReflowInput.mGridStyle->mGridTemplateAreas) { nsTArray* areas = new nsTArray( gridReflowInput.mGridStyle->mGridTemplateAreas->mNamedAreas); - Properties().Set(ExplicitNamedAreasProperty(), areas); + SetProperty(ExplicitNamedAreasProperty(), areas); } else { - Properties().Delete(ExplicitNamedAreasProperty()); + DeleteProperty(ExplicitNamedAreasProperty()); } } if (!prevInFlow) { - SharedGridData* sharedGridData = Properties().Get(SharedGridData::Prop()); + SharedGridData* sharedGridData = GetProperty(SharedGridData::Prop()); if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) { if (!sharedGridData) { sharedGridData = new SharedGridData; - Properties().Set(SharedGridData::Prop(), sharedGridData); + SetProperty(SharedGridData::Prop(), sharedGridData); } sharedGridData->mCols.mSizes.Clear(); sharedGridData->mCols.mSizes.SwapElements(gridReflowInput.mCols.mSizes); @@ -6522,7 +6522,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, sharedGridData->mGenerateComputedGridInfo = HasAnyStateBits(NS_STATE_GRID_GENERATE_COMPUTED_VALUES); } else if (sharedGridData && !GetNextInFlow()) { - Properties().Delete(SharedGridData::Prop()); + DeleteProperty(SharedGridData::Prop()); } } @@ -7142,10 +7142,10 @@ nsGridContainerFrame::GetGridFrameWithComputedInfo(nsIFrame* aFrame) nsGridContainerFrame* gridFrame = GetGridContainerFrame(aFrame); if (gridFrame) { // if any of our properties are missing, generate them - bool reflowNeeded = (!gridFrame->Properties().Has(GridColTrackInfo()) || - !gridFrame->Properties().Has(GridRowTrackInfo()) || - !gridFrame->Properties().Has(GridColumnLineInfo()) || - !gridFrame->Properties().Has(GridRowLineInfo())); + bool reflowNeeded = (!gridFrame->HasProperty(GridColTrackInfo()) || + !gridFrame->HasProperty(GridRowTrackInfo()) || + !gridFrame->HasProperty(GridColumnLineInfo()) || + !gridFrame->HasProperty(GridRowLineInfo())); if (reflowNeeded) { // Trigger a reflow that generates additional grid property data. @@ -7161,13 +7161,13 @@ nsGridContainerFrame::GetGridFrameWithComputedInfo(nsIFrame* aFrame) // Assert the grid properties are present MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridColTrackInfo())); + gridFrame->HasProperty(GridColTrackInfo())); MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridRowTrackInfo())); + gridFrame->HasProperty(GridRowTrackInfo())); MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridColumnLineInfo())); + gridFrame->HasProperty(GridColumnLineInfo())); MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridRowLineInfo())); + gridFrame->HasProperty(GridRowLineInfo())); } } diff --git a/layout/generic/nsGridContainerFrame.h b/layout/generic/nsGridContainerFrame.h index e610dfa0b..960558421 100644 --- a/layout/generic/nsGridContainerFrame.h +++ b/layout/generic/nsGridContainerFrame.h @@ -164,7 +164,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridColTrackInfo, ComputedGridTrackInfo) const ComputedGridTrackInfo* GetComputedTemplateColumns() { - const ComputedGridTrackInfo* info = Properties().Get(GridColTrackInfo()); + const ComputedGridTrackInfo* info = GetProperty(GridColTrackInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -172,7 +172,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridRowTrackInfo, ComputedGridTrackInfo) const ComputedGridTrackInfo* GetComputedTemplateRows() { - const ComputedGridTrackInfo* info = Properties().Get(GridRowTrackInfo()); + const ComputedGridTrackInfo* info = GetProperty(GridRowTrackInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -180,7 +180,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridColumnLineInfo, ComputedGridLineInfo) const ComputedGridLineInfo* GetComputedTemplateColumnLines() { - const ComputedGridLineInfo* info = Properties().Get(GridColumnLineInfo()); + const ComputedGridLineInfo* info = GetProperty(GridColumnLineInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -188,7 +188,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridRowLineInfo, ComputedGridLineInfo) const ComputedGridLineInfo* GetComputedTemplateRowLines() { - const ComputedGridLineInfo* info = Properties().Get(GridRowLineInfo()); + const ComputedGridLineInfo* info = GetProperty(GridRowLineInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -199,14 +199,14 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(ImplicitNamedAreasProperty, ImplicitNamedAreas) ImplicitNamedAreas* GetImplicitNamedAreas() const { - return Properties().Get(ImplicitNamedAreasProperty()); + return GetProperty(ImplicitNamedAreasProperty()); } typedef nsTArray ExplicitNamedAreas; NS_DECLARE_FRAME_PROPERTY_DELETABLE(ExplicitNamedAreasProperty, ExplicitNamedAreas) ExplicitNamedAreas* GetExplicitNamedAreas() const { - return Properties().Get(ExplicitNamedAreasProperty()); + return GetProperty(ExplicitNamedAreasProperty()); } /** diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 2acafa882..37a4e3749 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -24,7 +24,7 @@ #include #include "CaretAssociationHint.h" -#include "FramePropertyTable.h" +#include "FrameProperties.h" #include "mozilla/layout/FrameChildList.h" #include "mozilla/Maybe.h" #include "mozilla/WritingModes.h" @@ -1005,8 +1005,8 @@ public: #define NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(prop, type) \ NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(prop, mozilla::SmallValueHolder) - NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitSibling, nsIFrame) - NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitPrevSibling, nsIFrame) + NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitSibling, nsContainerFrame) + NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitPrevSibling, nsContainerFrame) NS_DECLARE_FRAME_PROPERTY_DELETABLE(NormalPositionProperty, nsPoint) NS_DECLARE_FRAME_PROPERTY_DELETABLE(ComputedOffsetProperty, nsMargin) @@ -1059,7 +1059,7 @@ public: mozilla::FrameBidiData GetBidiData() { - return Properties().Get(BidiDataProperty()); + return GetProperty(BidiDataProperty()); } nsBidiLevel GetBaseLevel() @@ -1073,7 +1073,7 @@ public: } nsTArray* GetGenConPseudos() { - return Properties().Get(GenConProperty()); + return GetProperty(GenConProperty()); } /** @@ -1534,7 +1534,7 @@ public: bool RefusedAsyncAnimation() const { - return Properties().Get(RefusedAsyncAnimationProperty()); + return GetProperty(RefusedAsyncAnimationProperty()); } /** @@ -3061,9 +3061,53 @@ public: return mContent == aParentContent; } - FrameProperties Properties() const { - return FrameProperties(PresContext()->PropertyTable(), this); - } +/** + * Support for reading and writing properties on the frame. + * These call through to the frame's FrameProperties object, if it + * exists, but avoid creating it if no property is ever set. + */ +template +FrameProperties::PropertyType +GetProperty(FrameProperties::Descriptor aProperty, + bool* aFoundResult = nullptr) const +{ + return mProperties.Get(aProperty, aFoundResult); +} + +template +bool HasProperty(FrameProperties::Descriptor aProperty) const +{ + return mProperties.Has(aProperty); +} + +template +void SetProperty(FrameProperties::Descriptor aProperty, + FrameProperties::PropertyType aValue) +{ + mProperties.Set(aProperty, aValue, this); +} + +template +FrameProperties::PropertyType +RemoveProperty(FrameProperties::Descriptor aProperty, + bool* aFoundResult = nullptr) +{ + return mProperties.Remove(aProperty, aFoundResult); +} + +template +void DeleteProperty(FrameProperties::Descriptor aProperty) +{ + mProperties.Delete(aProperty, this); +} + +void DeleteAllProperties() +{ + mProperties.DeleteAll(this); +} + +// Reports size of the FrameProperties for this frame and its descendants +size_t SizeOfFramePropertiesForTree(mozilla::MallocSizeOf aMallocSizeOf) const; /** * Return true if and only if this frame obeys visibility:hidden. @@ -3423,7 +3467,7 @@ public: */ bool FrameIsNonFirstInIBSplit() const { return (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) && - FirstContinuation()->Properties().Get(nsIFrame::IBSplitPrevSibling()); + FirstContinuation()->GetProperty(nsIFrame::IBSplitPrevSibling()); } /** @@ -3432,7 +3476,7 @@ public: */ bool FrameIsNonLastInIBSplit() const { return (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) && - FirstContinuation()->Properties().Get(nsIFrame::IBSplitSibling()); + FirstContinuation()->GetProperty(nsIFrame::IBSplitSibling()); } /** @@ -3514,11 +3558,11 @@ private: DestroyPaintedPresShellList) nsTArray* PaintedPresShellList() { - nsTArray* list = Properties().Get(PaintedPresShellsProperty()); + nsTArray* list = GetProperty(PaintedPresShellsProperty()); if (!list) { list = new nsTArray(); - Properties().Set(PaintedPresShellsProperty(), list); + SetProperty(PaintedPresShellsProperty(), list); } return list; @@ -3535,6 +3579,11 @@ protected: nsFrameState mState; + /** + * List of properties attached to the frame. + */ + FrameProperties mProperties; + // When there is an overflow area only slightly larger than mRect, // we store a set of four 1-byte deltas from the edges of mRect // rather than allocating a whole separate rectangle property. diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 138d0b871..6a15a9cfa 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -819,11 +819,11 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, #endif if (mCurrentSpan == mRootSpan) { - pfd->mFrame->Properties().Remove(nsIFrame::LineBaselineOffset()); + pfd->mFrame->RemoveProperty(nsIFrame::LineBaselineOffset()); } else { #ifdef DEBUG bool hasLineOffset; - pfd->mFrame->Properties().Get(nsIFrame::LineBaselineOffset(), &hasLineOffset); + pfd->mFrame->GetProperty(nsIFrame::LineBaselineOffset(), &hasLineOffset); NS_ASSERTION(!hasLineOffset, "LineBaselineOffset was set but was not expected"); #endif } diff --git a/layout/generic/nsPlaceholderFrame.cpp b/layout/generic/nsPlaceholderFrame.cpp index 2b6799f48..bd380a2d9 100644 --- a/layout/generic/nsPlaceholderFrame.cpp +++ b/layout/generic/nsPlaceholderFrame.cpp @@ -128,7 +128,7 @@ nsPlaceholderFrame::Reflow(nsPresContext* aPresContext, nsIFrame* ancestor = this; while ((ancestor = ancestor->GetParent())) { if (ancestor->GetPrevContinuation() || - ancestor->Properties().Get(IBSplitPrevSibling())) { + ancestor->GetProperty(IBSplitPrevSibling())) { isInContinuationOrIBSplit = true; break; } diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 3288d3f2e..0641c7439 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -2838,9 +2838,9 @@ nsTextFrame::EnsureTextRun(TextRunType aWhichTextRun, return gfxSkipCharsIterator(gfxPlatform:: GetPlatform()->EmptySkipChars(), 0); } - TabWidthStore* tabWidths = Properties().Get(TabWidthProperty()); + TabWidthStore* tabWidths = GetProperty(TabWidthProperty()); if (tabWidths && tabWidths->mValidForContentOffset != GetContentOffset()) { - Properties().Delete(TabWidthProperty()); + DeleteProperty(TabWidthProperty()); } } @@ -3478,7 +3478,7 @@ PropertyProvider::CalcTabWidths(Range aRange) return; } if (!mReflowing) { - mTabWidths = mFrame->Properties().Get(TabWidthProperty()); + mTabWidths = mFrame->GetProperty(TabWidthProperty()); #ifdef DEBUG // If we're not reflowing, we should have already computed the // tab widths; check that they're available as far as the last @@ -3524,7 +3524,7 @@ PropertyProvider::CalcTabWidths(Range aRange) } else { if (!mTabWidths) { mTabWidths = new TabWidthStore(mFrame->GetContentOffset()); - mFrame->Properties().Set(TabWidthProperty(), mTabWidths); + mFrame->SetProperty(TabWidthProperty(), mTabWidths); } double nextTab = AdvanceToNextTab(mOffsetFromBlockOriginForTabs, mFrame, mTextRun, &tabWidth); @@ -3543,7 +3543,7 @@ PropertyProvider::CalcTabWidths(Range aRange) if (!mTabWidths) { // Delete any stale property that may be left on the frame - mFrame->Properties().Delete(TabWidthProperty()); + mFrame->DeleteProperty(TabWidthProperty()); mTabWidthsAnalyzedLimit = std::max(mTabWidthsAnalyzedLimit, aRange.end - startOffset); } @@ -4249,7 +4249,7 @@ nsTextFrame::ClearFrameOffsetCache() // just destroys the frames in order, which means that the primary frame is already // dead if we're a continuing text frame, in which case, all of its properties are // gone, and we don't need to worry about deleting this property here. - primaryFrame->Properties().Delete(OffsetToFrameProperty()); + primaryFrame->DeleteProperty(OffsetToFrameProperty()); } RemoveStateBits(TEXT_IN_OFFSET_CACHE); } @@ -4358,7 +4358,7 @@ nsContinuingTextFrame::Init(nsIContent* aContent, if (aPrevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) { FrameBidiData bidiData = aPrevInFlow->GetBidiData(); bidiData.precedingControl = kBidiLevelNone; - Properties().Set(BidiDataProperty(), bidiData); + SetProperty(BidiDataProperty(), bidiData); if (nextContinuation) { SetNextContinuation(nextContinuation); @@ -4622,7 +4622,7 @@ nsTextFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemK gfxTextRun* nsTextFrame::GetUninflatedTextRun() { - return Properties().Get(UninflatedTextRunProperty()); + return GetProperty(UninflatedTextRunProperty()); } void @@ -4648,7 +4648,7 @@ nsTextFrame::SetTextRun(gfxTextRun* aTextRun, TextRunType aWhichTextRun, // Setting the property will not automatically increment the textrun's // reference count, so we need to do it here. aTextRun->AddRef(); - Properties().Set(UninflatedTextRunProperty(), aTextRun); + SetProperty(UninflatedTextRunProperty(), aTextRun); return; } // fall through to setting mTextRun @@ -4668,10 +4668,9 @@ nsTextFrame::RemoveTextRun(gfxTextRun* aTextRun) mTextRun = nullptr; return true; } - FrameProperties props = Properties(); if ((GetStateBits() & TEXT_HAS_FONT_INFLATION) && - props.Get(UninflatedTextRunProperty()) == aTextRun) { - props.Delete(UninflatedTextRunProperty()); + GetProperty(UninflatedTextRunProperty()) == aTextRun) { + DeleteProperty(UninflatedTextRunProperty()); return true; } return false; @@ -4689,7 +4688,7 @@ nsTextFrame::ClearTextRun(nsTextFrame* aStartContinuation, DebugOnly checkmTextrun = textRun == mTextRun; UnhookTextRunFromFrames(textRun, aStartContinuation); MOZ_ASSERT(checkmTextrun ? !mTextRun - : !Properties().Get(UninflatedTextRunProperty())); + : !GetProperty(UninflatedTextRunProperty())); } void @@ -4699,7 +4698,7 @@ nsTextFrame::DisconnectTextRuns() "Textrun mentions this frame in its user data so we can't just disconnect"); mTextRun = nullptr; if ((GetStateBits() & TEXT_HAS_FONT_INFLATION)) { - Properties().Delete(UninflatedTextRunProperty()); + DeleteProperty(UninflatedTextRunProperty()); } } @@ -4929,7 +4928,7 @@ NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(TextCombineScaleFactorProperty, float) static float GetTextCombineScaleFactor(nsTextFrame* aFrame) { - float factor = aFrame->Properties().Get(TextCombineScaleFactorProperty()); + float factor = aFrame->GetProperty(TextCombineScaleFactorProperty()); return factor ? factor : 1.0f; } @@ -5105,7 +5104,7 @@ static nscoord LazyGetLineBaselineOffset(nsIFrame* aChildFrame, nsBlockFrame* aBlockFrame) { bool offsetFound; - nscoord offset = aChildFrame->Properties().Get( + nscoord offset = aChildFrame->GetProperty( nsIFrame::LineBaselineOffset(), &offsetFound); if (!offsetFound) { @@ -5118,11 +5117,11 @@ LazyGetLineBaselineOffset(nsIFrame* aChildFrame, nsBlockFrame* aBlockFrame) for (nsIFrame* lineFrame = line->mFirstChild; n > 0; lineFrame = lineFrame->GetNextSibling(), --n) { offset = lineBaseline - lineFrame->GetNormalPosition().y; - lineFrame->Properties().Set(nsIFrame::LineBaselineOffset(), offset); + lineFrame->SetProperty(nsIFrame::LineBaselineOffset(), offset); } } } - return aChildFrame->Properties().Get( + return aChildFrame->GetProperty( nsIFrame::LineBaselineOffset(), &offsetFound); } else { return offset; @@ -5367,7 +5366,7 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider) { const nsStyleText* styleText = StyleText(); if (!styleText->HasTextEmphasis()) { - Properties().Delete(EmphasisMarkProperty()); + DeleteProperty(EmphasisMarkProperty()); return nsRect(); } @@ -5419,7 +5418,7 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider) overflowRect.BStart(aWM) += gap * (side == eLogicalSideBStart ? -1 : 1); } - Properties().Set(EmphasisMarkProperty(), info); + SetProperty(EmphasisMarkProperty(), info); return overflowRect.GetPhysicalRect(aWM, frameSize.GetPhysicalSize(aWM)); } @@ -6432,7 +6431,7 @@ nsTextFrame::DrawEmphasisMarks(gfxContext* aContext, WritingMode aWM, const nscolor* aDecorationOverrideColor, PropertyProvider* aProvider) { - const EmphasisMarkInfo* info = Properties().Get(EmphasisMarkProperty()); + const EmphasisMarkInfo* info = GetProperty(EmphasisMarkProperty()); if (!info) { return; } @@ -7584,7 +7583,7 @@ nsTextFrame::GetChildFrameContainingOffset(int32_t aContentOffset, int32_t offset = mContentOffset; // Try to look up the offset to frame property - nsTextFrame* cachedFrame = Properties().Get(OffsetToFrameProperty()); + nsTextFrame* cachedFrame = GetProperty(OffsetToFrameProperty()); if (cachedFrame) { f = cachedFrame; @@ -7632,7 +7631,7 @@ nsTextFrame::GetChildFrameContainingOffset(int32_t aContentOffset, *aOutFrame = f; // cache the frame we found - Properties().Set(OffsetToFrameProperty(), f); + SetProperty(OffsetToFrameProperty(), f); f->AddStateBits(TEXT_IN_OFFSET_CACHE); return NS_OK; @@ -8169,7 +8168,7 @@ nsTextFrame::GetFontSizeInflation() const if (!HasFontSizeInflation()) { return 1.0f; } - return Properties().Get(FontSizeInflationProperty()); + return GetProperty(FontSizeInflationProperty()); } void @@ -8178,13 +8177,13 @@ nsTextFrame::SetFontSizeInflation(float aInflation) if (aInflation == 1.0f) { if (HasFontSizeInflation()) { RemoveStateBits(TEXT_HAS_FONT_INFLATION); - Properties().Delete(FontSizeInflationProperty()); + DeleteProperty(FontSizeInflationProperty()); } return; } AddStateBits(TEXT_HAS_FONT_INFLATION); - Properties().Set(FontSizeInflationProperty(), aInflation); + SetProperty(FontSizeInflationProperty(), aInflation); } /* virtual */ @@ -9319,9 +9318,9 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, gfxFloat em = fm->EmHeight(); // Compress the characters in horizontal axis if necessary. if (width <= em) { - Properties().Remove(TextCombineScaleFactorProperty()); + RemoveProperty(TextCombineScaleFactorProperty()); } else { - Properties().Set(TextCombineScaleFactorProperty(), em / width); + SetProperty(TextCombineScaleFactorProperty(), em / width); finalSize.ISize(wm) = em; } // Make the characters be in an 1em square. @@ -10049,13 +10048,13 @@ nsTextFrame::AssignJustificationGaps( static_assert(sizeof(aAssign) == 1, "The encoding might be broken if JustificationAssignment " "is larger than 1 byte"); - Properties().Set(JustificationAssignmentProperty(), encoded); + SetProperty(JustificationAssignmentProperty(), encoded); } mozilla::JustificationAssignment nsTextFrame::GetJustificationAssignment() const { - int32_t encoded = Properties().Get(JustificationAssignmentProperty()); + int32_t encoded = GetProperty(JustificationAssignmentProperty()); mozilla::JustificationAssignment result; result.mGapsAtStart = encoded >> 8; result.mGapsAtEnd = encoded & 0xFF; diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp index ad1b13efd..93b631c9d 100644 --- a/layout/mathml/nsMathMLContainerFrame.cpp +++ b/layout/mathml/nsMathMLContainerFrame.cpp @@ -134,7 +134,7 @@ nsMathMLContainerFrame::SaveReflowAndBoundingMetricsFor(nsIFrame* { ReflowOutput* reflowOutput = new ReflowOutput(aReflowOutput); reflowOutput->mBoundingMetrics = aBoundingMetrics; - aFrame->Properties().Set(HTMLReflowOutputProperty(), reflowOutput); + aFrame->SetProperty(HTMLReflowOutputProperty(), reflowOutput); } // helper method to facilitate getting the reflow and bounding metrics @@ -147,7 +147,7 @@ nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor(nsIFrame* aFra NS_PRECONDITION(aFrame, "null arg"); ReflowOutput* reflowOutput = - aFrame->Properties().Get(HTMLReflowOutputProperty()); + aFrame->GetProperty(HTMLReflowOutputProperty()); // IMPORTANT: This function is only meant to be called in Place() methods // where it is assumed that SaveReflowAndBoundingMetricsFor has recorded the @@ -175,9 +175,8 @@ void nsMathMLContainerFrame::ClearSavedChildMetrics() { nsIFrame* childFrame = mFrames.FirstChild(); - FramePropertyTable* props = PresContext()->PropertyTable(); while (childFrame) { - props->Delete(childFrame, HTMLReflowOutputProperty()); + childFrame->DeleteProperty(HTMLReflowOutputProperty()); childFrame = childFrame->GetNextSibling(); } } diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index a706fb483..fd184e637 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -167,8 +167,7 @@ FindCellProperty(const nsIFrame* aCellFrame, nsTArray* propertyData = nullptr; while (currentFrame) { - FrameProperties props = currentFrame->Properties(); - propertyData = props.Get(aFrameProperty); + propertyData = currentFrame->GetProperty(aFrameProperty); bool frameIsTable = (currentFrame->GetType() == nsGkAtoms::tableFrame); if (propertyData || frameIsTable) @@ -361,8 +360,7 @@ ParseFrameAttribute(nsIFrame* aFrame, if (valueList) { // The code reading the property assumes that this list is nonempty. NS_ASSERTION(valueList->Length() >= 1, "valueList should not be empty!"); - FrameProperties props = aFrame->Properties(); - props.Set(AttributeToProperty(aAttribute), valueList); + aFrame->SetProperty(AttributeToProperty(aAttribute), valueList); } else { ReportParseError(aFrame, aAttribute->GetUTF16String(), attrValue.get()); } @@ -769,8 +767,7 @@ nsMathMLmtableWrapperFrame::AttributeChanged(int32_t aNameSpaceID, aAttribute == nsGkAtoms::columnalign_ || aAttribute == nsGkAtoms::columnlines_) { // clear any cached property list for this table - presContext->PropertyTable()-> - Delete(tableFrame, AttributeToProperty(aAttribute)); + tableFrame->DeleteProperty(AttributeToProperty(aAttribute)); // Reparse the new attribute on the table. ParseFrameAttribute(tableFrame, aAttribute, true); } else { @@ -1120,7 +1117,7 @@ nsMathMLmtrFrame::AttributeChanged(int32_t aNameSpaceID, return NS_OK; } - presContext->PropertyTable()->Delete(this, AttributeToProperty(aAttribute)); + DeleteProperty(AttributeToProperty(aAttribute)); bool allowMultiValues = (aAttribute == nsGkAtoms::columnalign_); @@ -1219,8 +1216,7 @@ nsMathMLmtdFrame::AttributeChanged(int32_t aNameSpaceID, if (aAttribute == nsGkAtoms::rowalign_ || aAttribute == nsGkAtoms::columnalign_) { - nsPresContext* presContext = PresContext(); - presContext->PropertyTable()->Delete(this, AttributeToProperty(aAttribute)); + DeleteProperty(AttributeToProperty(aAttribute)); // Reparse the attribute. ParseFrameAttribute(this, aAttribute, false); diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index e5a03333f..6ba267ee8 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -1328,7 +1328,7 @@ NS_DECLARE_FRAME_PROPERTY_DELETABLE(TextNodeCorrespondenceProperty, static uint32_t GetUndisplayedCharactersBeforeFrame(nsTextFrame* aFrame) { - void* value = aFrame->Properties().Get(TextNodeCorrespondenceProperty()); + void* value = aFrame->GetProperty(TextNodeCorrespondenceProperty()); TextNodeCorrespondence* correspondence = static_cast(value); if (!correspondence) { @@ -1517,8 +1517,8 @@ TextNodeCorrespondenceRecorder::TraverseAndRecord(nsIFrame* aFrame) } // Set the frame property. - frame->Properties().Set(TextNodeCorrespondenceProperty(), - new TextNodeCorrespondence(undisplayed)); + frame->SetProperty(TextNodeCorrespondenceProperty(), + new TextNodeCorrespondence(undisplayed)); // Remember how far into the current nsTextNode we are. mNodeCharIndex = frame->GetContentEnd(); @@ -3391,7 +3391,7 @@ SVGTextFrame::HandleAttributeChangeInDescendant(Element* aElement, // Blow away our reference, if any nsIFrame* childElementFrame = aElement->GetPrimaryFrame(); if (childElementFrame) { - childElementFrame->Properties().Delete( + childElementFrame->DeleteProperty( nsSVGEffects::HrefAsTextPathProperty()); NotifyGlyphMetricsChange(); } @@ -4817,7 +4817,7 @@ SVGPathElement* SVGTextFrame::GetTextPathPathElement(nsIFrame* aTextPathFrame) { nsSVGTextPathProperty *property = - aTextPathFrame->Properties().Get(nsSVGEffects::HrefAsTextPathProperty()); + aTextPathFrame->GetProperty(nsSVGEffects::HrefAsTextPathProperty()); if (!property) { nsIContent* content = aTextPathFrame->GetContent(); diff --git a/layout/svg/nsSVGEffects.cpp b/layout/svg/nsSVGEffects.cpp index e75c973c8..ca4c5778c 100644 --- a/layout/svg/nsSVGEffects.cpp +++ b/layout/svg/nsSVGEffects.cpp @@ -480,27 +480,26 @@ GetOrCreateFilterProperty(nsIFrame* aFrame) if (!effects->HasFilters()) return nullptr; - FrameProperties props = aFrame->Properties(); - nsSVGFilterProperty *prop = props.Get(nsSVGEffects::FilterProperty()); + nsSVGFilterProperty *prop = + aFrame->GetProperty(nsSVGEffects::FilterProperty()); if (prop) return prop; prop = new nsSVGFilterProperty(effects->mFilters, aFrame); NS_ADDREF(prop); - props.Set(nsSVGEffects::FilterProperty(), prop); + aFrame->SetProperty(nsSVGEffects::FilterProperty(), prop); return prop; } static nsSVGMaskProperty* GetOrCreateMaskProperty(nsIFrame* aFrame) { - FrameProperties props = aFrame->Properties(); - nsSVGMaskProperty *prop = props.Get(nsSVGEffects::MaskProperty()); + nsSVGMaskProperty *prop = aFrame->GetProperty(nsSVGEffects::MaskProperty()); if (prop) return prop; prop = new nsSVGMaskProperty(aFrame); NS_ADDREF(prop); - props.Set(nsSVGEffects::MaskProperty(), prop); + aFrame->SetProperty(nsSVGEffects::MaskProperty(), prop); return prop; } @@ -512,13 +511,12 @@ GetEffectProperty(nsIURI* aURI, nsIFrame* aFrame, if (!aURI) return nullptr; - FrameProperties props = aFrame->Properties(); - T* prop = props.Get(aProperty); + T* prop = aFrame->GetProperty(aProperty); if (prop) return prop; prop = new T(aURI, aFrame, false); NS_ADDREF(prop); - props.Set(aProperty, prop); + aFrame->SetProperty(aProperty, prop); return prop; } @@ -553,11 +551,11 @@ nsSVGEffects::GetPaintingPropertyForURI(nsIURI* aURI, nsIFrame* aFrame, if (!aURI) return nullptr; - FrameProperties props = aFrame->Properties(); - nsSVGEffects::URIObserverHashtable *hashtable = props.Get(aProperty); + nsSVGEffects::URIObserverHashtable *hashtable = + aFrame->GetProperty(aProperty); if (!hashtable) { hashtable = new nsSVGEffects::URIObserverHashtable(); - props.Set(aProperty, hashtable); + aFrame->SetProperty(aProperty, hashtable); } nsSVGPaintingProperty* prop = static_cast(hashtable->GetWeak(aURI)); @@ -689,16 +687,15 @@ nsSVGEffects::UpdateEffects(nsIFrame* aFrame) NS_ASSERTION(aFrame->GetContent()->IsElement(), "aFrame's content should be an element"); - FrameProperties props = aFrame->Properties(); - props.Delete(FilterProperty()); - props.Delete(MaskProperty()); - props.Delete(ClipPathProperty()); - props.Delete(MarkerBeginProperty()); - props.Delete(MarkerMiddleProperty()); - props.Delete(MarkerEndProperty()); - props.Delete(FillProperty()); - props.Delete(StrokeProperty()); - props.Delete(BackgroundImageProperty()); + aFrame->DeleteProperty(FilterProperty()); + aFrame->DeleteProperty(MaskProperty()); + aFrame->DeleteProperty(ClipPathProperty()); + aFrame->DeleteProperty(MarkerBeginProperty()); + aFrame->DeleteProperty(MarkerMiddleProperty()); + aFrame->DeleteProperty(MarkerEndProperty()); + aFrame->DeleteProperty(FillProperty()); + aFrame->DeleteProperty(StrokeProperty()); + aFrame->DeleteProperty(BackgroundImageProperty()); // Ensure that the filter is repainted correctly // We can't do that in DoUpdate as the referenced frame may not be valid @@ -725,7 +722,7 @@ nsSVGEffects::GetFilterProperty(nsIFrame* aFrame) if (!aFrame->StyleEffects()->HasFilters()) return nullptr; - return aFrame->Properties().Get(FilterProperty()); + return aFrame->GetProperty(FilterProperty()); } void @@ -835,7 +832,7 @@ nsSVGEffects::InvalidateRenderingObservers(nsIFrame* aFrame) return; // If the rendering has changed, the bounds may well have changed too: - aFrame->Properties().Delete(nsSVGUtils::ObjectBoundingBoxProperty()); + aFrame->DeleteProperty(nsSVGUtils::ObjectBoundingBoxProperty()); nsSVGRenderingObserverList *observerList = GetObserverList(content->AsElement()); @@ -864,7 +861,7 @@ nsSVGEffects::InvalidateDirectRenderingObservers(Element* aElement, uint32_t aFl nsIFrame* frame = aElement->GetPrimaryFrame(); if (frame) { // If the rendering has changed, the bounds may well have changed too: - frame->Properties().Delete(nsSVGUtils::ObjectBoundingBoxProperty()); + frame->DeleteProperty(nsSVGUtils::ObjectBoundingBoxProperty()); } if (aElement->HasRenderingObservers()) { diff --git a/layout/svg/nsSVGEffects.h b/layout/svg/nsSVGEffects.h index 0cf9b1500..b8b2e53c1 100644 --- a/layout/svg/nsSVGEffects.h +++ b/layout/svg/nsSVGEffects.h @@ -7,7 +7,7 @@ #define NSSVGEFFECTS_H_ #include "mozilla/Attributes.h" -#include "FramePropertyTable.h" +#include "FrameProperties.h" #include "mozilla/dom/Element.h" #include "nsHashKeys.h" #include "nsID.h" diff --git a/layout/svg/nsSVGFilterFrame.cpp b/layout/svg/nsSVGFilterFrame.cpp index 13ce16993..3b99f413e 100644 --- a/layout/svg/nsSVGFilterFrame.cpp +++ b/layout/svg/nsSVGFilterFrame.cpp @@ -107,7 +107,7 @@ nsSVGFilterFrame::GetReferencedFilter() return nullptr; nsSVGPaintingProperty *property = - Properties().Get(nsSVGEffects::HrefAsPaintingProperty()); + GetProperty(nsSVGEffects::HrefAsPaintingProperty()); if (!property) { // Fetch our Filter element's href or xlink:href attribute @@ -183,7 +183,7 @@ nsSVGFilterFrame::AttributeChanged(int32_t aNameSpaceID, aNameSpaceID == kNameSpaceID_None) && aAttribute == nsGkAtoms::href) { // Blow away our reference, if any - Properties().Delete(nsSVGEffects::HrefAsPaintingProperty()); + DeleteProperty(nsSVGEffects::HrefAsPaintingProperty()); mNoHRefURI = false; // And update whoever references us nsSVGEffects::InvalidateDirectRenderingObservers(this); diff --git a/layout/svg/nsSVGGradientFrame.cpp b/layout/svg/nsSVGGradientFrame.cpp index 2d7684f5a..340cfa881 100644 --- a/layout/svg/nsSVGGradientFrame.cpp +++ b/layout/svg/nsSVGGradientFrame.cpp @@ -72,7 +72,7 @@ nsSVGGradientFrame::AttributeChanged(int32_t aNameSpaceID, aNameSpaceID == kNameSpaceID_None) && aAttribute == nsGkAtoms::href) { // Blow away our reference, if any - Properties().Delete(nsSVGEffects::HrefAsPaintingProperty()); + DeleteProperty(nsSVGEffects::HrefAsPaintingProperty()); mNoHRefURI = false; // And update whoever references us nsSVGEffects::InvalidateDirectRenderingObservers(this); @@ -316,7 +316,7 @@ nsSVGGradientFrame::GetReferencedGradient() return nullptr; nsSVGPaintingProperty *property = - Properties().Get(nsSVGEffects::HrefAsPaintingProperty()); + GetProperty(nsSVGEffects::HrefAsPaintingProperty()); if (!property) { // Fetch our gradient element's href or xlink:href attribute diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index 0003e1a73..4ce2941d4 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -75,7 +75,7 @@ public: private: static nsRect GetPreEffectsVisualOverflowRect(nsIFrame* aFrame) { - nsRect* r = aFrame->Properties().Get(nsIFrame::PreEffectsBBoxProperty()); + nsRect* r = aFrame->GetProperty(nsIFrame::PreEffectsBBoxProperty()); if (r) { return *r; } @@ -113,8 +113,7 @@ private: NS_ASSERTION(aFrame->GetParent()->StyleContext()->GetPseudo() == nsCSSAnonBoxes::mozAnonymousBlock, "How did we getting here, then?"); - NS_ASSERTION(!aFrame->Properties().Get( - aFrame->PreTransformOverflowAreasProperty()), + NS_ASSERTION(!aFrame->GetProperty(aFrame->PreTransformOverflowAreasProperty()), "GetVisualOverflowRect() won't return the pre-effects rect!"); return aFrame->GetVisualOverflowRect(); } diff --git a/layout/svg/nsSVGPatternFrame.cpp b/layout/svg/nsSVGPatternFrame.cpp index 198163d7f..2cd7eeaad 100644 --- a/layout/svg/nsSVGPatternFrame.cpp +++ b/layout/svg/nsSVGPatternFrame.cpp @@ -89,7 +89,7 @@ nsSVGPatternFrame::AttributeChanged(int32_t aNameSpaceID, aNameSpaceID == kNameSpaceID_None) && aAttribute == nsGkAtoms::href) { // Blow away our reference, if any - Properties().Delete(nsSVGEffects::HrefAsPaintingProperty()); + DeleteProperty(nsSVGEffects::HrefAsPaintingProperty()); mNoHRefURI = false; // And update whoever references us nsSVGEffects::InvalidateDirectRenderingObservers(this); @@ -548,7 +548,7 @@ nsSVGPatternFrame::GetReferencedPattern() return nullptr; nsSVGPaintingProperty *property = - Properties().Get(nsSVGEffects::HrefAsPaintingProperty()); + GetProperty(nsSVGEffects::HrefAsPaintingProperty()); if (!property) { // Fetch our pattern element's href or xlink:href attribute diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index 98e5f9b5f..c3394e292 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -1060,10 +1060,9 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags) return bbox; } - FrameProperties props = aFrame->Properties(); if (aFlags == eBBoxIncludeFillGeometry) { - gfxRect* prop = props.Get(ObjectBoundingBoxProperty()); + gfxRect* prop = aFrame->GetProperty(ObjectBoundingBoxProperty()); if (prop) { return *prop; } @@ -1139,7 +1138,7 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags) if (aFlags == eBBoxIncludeFillGeometry) { // Obtaining the bbox for objectBoundingBox calculations is common so we // cache the result for future calls, since calculation can be expensive: - props.Set(ObjectBoundingBoxProperty(), new gfxRect(bbox)); + aFrame->SetProperty(ObjectBoundingBoxProperty(), new gfxRect(bbox)); } return bbox; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 4c11d2704..b9b6ca5fe 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -272,13 +272,12 @@ nsTableFrame::RegisterPositionedTablePart(nsIFrame* aFrame) tableFrame = static_cast(tableFrame->FirstContinuation()); // Retrieve the positioned parts array for this table. - FrameProperties props = tableFrame->Properties(); - FrameTArray* positionedParts = props.Get(PositionedTablePartArray()); + FrameTArray* positionedParts = tableFrame->GetProperty(PositionedTablePartArray()); // Lazily create the array if it doesn't exist yet. if (!positionedParts) { positionedParts = new FrameTArray; - props.Set(PositionedTablePartArray(), positionedParts); + tableFrame->SetProperty(PositionedTablePartArray(), positionedParts); } // Add this frame to the list. @@ -302,8 +301,7 @@ nsTableFrame::UnregisterPositionedTablePart(nsIFrame* aFrame, tableFrame = static_cast(tableFrame->FirstContinuation()); // Retrieve the positioned parts array for this table. - FrameProperties props = tableFrame->Properties(); - FrameTArray* positionedParts = props.Get(PositionedTablePartArray()); + FrameTArray* positionedParts = tableFrame->GetProperty(PositionedTablePartArray()); // Remove the frame. MOZ_ASSERT(positionedParts && positionedParts->Contains(aFrame), @@ -1992,7 +1990,7 @@ nsTableFrame::FixupPositionedTableParts(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, const ReflowInput& aReflowInput) { - FrameTArray* positionedParts = Properties().Get(PositionedTablePartArray()); + FrameTArray* positionedParts = GetProperty(PositionedTablePartArray()); if (!positionedParts) { return; } @@ -2653,13 +2651,18 @@ nsTableFrame::GetUsedMargin() const NS_DECLARE_FRAME_PROPERTY_DELETABLE(TableBCProperty, BCPropertyData) BCPropertyData* -nsTableFrame::GetBCProperty(bool aCreateIfNecessary) const +nsTableFrame::GetBCProperty() const { - FrameProperties props = Properties(); - BCPropertyData* value = props.Get(TableBCProperty()); - if (!value && aCreateIfNecessary) { + return GetProperty(TableBCProperty()); +} + +BCPropertyData* +nsTableFrame::GetOrCreateBCProperty() +{ + BCPropertyData* value = GetProperty(TableBCProperty()); + if (!value) { value = new BCPropertyData(); - props.Set(TableBCProperty(), value); + SetProperty(TableBCProperty(), value); } return value; @@ -4103,7 +4106,7 @@ nsTableFrame::AddBCDamageArea(const TableArea& aValue) SetNeedToCalcBCBorders(true); // Get the property - BCPropertyData* value = GetBCProperty(true); + BCPropertyData* value = GetOrCreateBCProperty(); if (value) { #ifdef DEBUG VerifyNonNegativeDamageRect(value->mDamageArea); @@ -4143,7 +4146,7 @@ nsTableFrame::SetFullBCDamageArea() SetNeedToCalcBCBorders(true); - BCPropertyData* value = GetBCProperty(true); + BCPropertyData* value = GetOrCreateBCProperty(); if (value) { value->mDamageArea = TableArea(0, 0, GetColCount(), GetRowCount()); } @@ -4310,7 +4313,7 @@ BCMapCellInfo::BCMapCellInfo(nsTableFrame* aTableFrame) : mTableFrame(aTableFrame) , mNumTableRows(aTableFrame->GetRowCount()) , mNumTableCols(aTableFrame->GetColCount()) - , mTableBCData(mTableFrame->Properties().Get(TableBCProperty())) + , mTableBCData(mTableFrame->GetProperty(TableBCProperty())) , mTableWM(aTableFrame->StyleContext()) { ResetCellInfo(); diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index a78625339..7e56c28c1 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -809,7 +809,8 @@ protected: void SetBorderCollapse(bool aValue); - BCPropertyData* GetBCProperty(bool aCreateIfNecessary = false) const; + BCPropertyData* GetBCProperty() const; + BCPropertyData* GetOrCreateBCProperty(); void SetFullBCDamageArea(); void CalcBCBorders(); diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 81b5d6699..1b6051ef2 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -978,7 +978,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, // MovePositionBy does internally. (This codepath should really // be merged into the else below if we can.) nsMargin* computedOffsetProp = - kidFrame->Properties().Get(nsIFrame::ComputedOffsetProperty()); + kidFrame->GetProperty(nsIFrame::ComputedOffsetProperty()); // Bug 975644: a position:sticky kid can end up with a null // property value here. LogicalMargin computedOffsets(wm, computedOffsetProp ? @@ -1417,16 +1417,14 @@ nsTableRowFrame::SetUnpaginatedBSize(nsPresContext* aPresContext, nscoord aValue) { NS_ASSERTION(!GetPrevInFlow(), "program error"); - // Get the property - aPresContext->PropertyTable()-> - Set(this, RowUnpaginatedHeightProperty(), aValue); + // Set the property + SetProperty(RowUnpaginatedHeightProperty(), aValue); } nscoord nsTableRowFrame::GetUnpaginatedBSize() { - FrameProperties props = FirstInFlow()->Properties(); - return props.Get(RowUnpaginatedHeightProperty()); + return GetProperty(RowUnpaginatedHeightProperty()); } void nsTableRowFrame::SetContinuousBCBorderWidth(LogicalSide aForSide, diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 60596f12b..8f014b204 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -1910,7 +1910,7 @@ nsTableRowGroupFrame::ClearRowCursor() } RemoveStateBits(NS_ROWGROUP_HAS_ROW_CURSOR); - Properties().Delete(RowCursorProperty()); + DeleteProperty(RowCursorProperty()); } nsTableRowGroupFrame::FrameCursorData* @@ -1934,7 +1934,7 @@ nsTableRowGroupFrame::SetupRowCursor() FrameCursorData* data = new FrameCursorData(); if (!data) return nullptr; - Properties().Set(RowCursorProperty(), data); + SetProperty(RowCursorProperty(), data); AddStateBits(NS_ROWGROUP_HAS_ROW_CURSOR); return data; } @@ -1946,7 +1946,7 @@ nsTableRowGroupFrame::GetFirstRowContaining(nscoord aY, nscoord* aOverflowAbove) return nullptr; } - FrameCursorData* property = Properties().Get(RowCursorProperty()); + FrameCursorData* property = GetProperty(RowCursorProperty()); uint32_t cursorIndex = property->mCursorIndex; uint32_t frameCount = property->mFrames.Length(); if (cursorIndex >= frameCount) diff --git a/layout/tables/nsTableWrapperFrame.cpp b/layout/tables/nsTableWrapperFrame.cpp index e44652a73..f0b6d1512 100644 --- a/layout/tables/nsTableWrapperFrame.cpp +++ b/layout/tables/nsTableWrapperFrame.cpp @@ -246,7 +246,7 @@ nsTableWrapperFrame::InitChildReflowInput(nsPresContext& aPresContext, } // Propagate our stored CB size if present, minus any margins. if (!HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { - LogicalSize* cb = Properties().Get(GridItemCBSizeProperty()); + LogicalSize* cb = GetProperty(GridItemCBSizeProperty()); if (cb) { cbSize.emplace(*cb); *cbSize -= aReflowInput.ComputedLogicalMargin().Size(wm); @@ -953,7 +953,7 @@ nsTableWrapperFrame::Reflow(nsPresContext* aPresContext, // for the table frame if we are bsize constrained and the caption is above // or below the inner table. Also reduce the CB size that we store for // our children in case we're a grid item, by the same amount. - LogicalSize* cbSize = Properties().Get(GridItemCBSizeProperty()); + LogicalSize* cbSize = GetProperty(GridItemCBSizeProperty()); if (NS_UNCONSTRAINEDSIZE != aOuterRI.AvailableBSize() || cbSize) { nscoord captionBSize = 0; nscoord captionISize = 0; diff --git a/layout/xul/nsBox.cpp b/layout/xul/nsBox.cpp index f7ec5fead..787758b15 100644 --- a/layout/xul/nsBox.cpp +++ b/layout/xul/nsBox.cpp @@ -144,10 +144,9 @@ nsBox::BeginXULLayout(nsBoxLayoutState& aState) // Another copy-over from ReflowInput. // Since we are in reflow, we don't need to store these properties anymore. - FrameProperties props = Properties(); - props.Delete(UsedBorderProperty()); - props.Delete(UsedPaddingProperty()); - props.Delete(UsedMarginProperty()); + DeleteProperty(UsedBorderProperty()); + DeleteProperty(UsedPaddingProperty()); + DeleteProperty(UsedMarginProperty()); #ifdef DEBUG_LAYOUT PropagateDebug(aState); diff --git a/layout/xul/nsMenuFrame.cpp b/layout/xul/nsMenuFrame.cpp index ea968fab5..67fcdbe43 100644 --- a/layout/xul/nsMenuFrame.cpp +++ b/layout/xul/nsMenuFrame.cpp @@ -273,7 +273,7 @@ nsMenuFrame::GetPopupList() const if (!HasPopup()) { return nullptr; } - nsFrameList* prop = Properties().Get(PopupListProperty()); + nsFrameList* prop = GetProperty(PopupListProperty()); NS_ASSERTION(prop && prop->GetLength() == 1 && prop->FirstChild()->GetType() == nsGkAtoms::menuPopupFrame, "popup list should have exactly one nsMenuPopupFrame"); @@ -284,7 +284,7 @@ void nsMenuFrame::DestroyPopupList() { NS_ASSERTION(HasPopup(), "huh?"); - nsFrameList* prop = Properties().Remove(PopupListProperty()); + nsFrameList* prop = RemoveProperty(PopupListProperty()); NS_ASSERTION(prop && prop->IsEmpty(), "popup list must exist and be empty when destroying"); RemoveStateBits(NS_STATE_MENU_HAS_POPUP_LIST); @@ -300,7 +300,7 @@ nsMenuFrame::SetPopupFrame(nsFrameList& aFrameList) // Remove the frame from the list and store it in a nsFrameList* property. aFrameList.RemoveFrame(popupFrame); nsFrameList* popupList = new (PresContext()->PresShell()) nsFrameList(popupFrame, popupFrame); - Properties().Set(PopupListProperty(), popupList); + SetProperty(PopupListProperty(), popupList); AddStateBits(NS_STATE_MENU_HAS_POPUP_LIST); break; } -- cgit v1.2.3 From a61cca1c15b807225423fd991792b00ef82e36fe Mon Sep 17 00:00:00 2001 From: Kevin Bhasi <37286461+kbhasi@users.noreply.github.com> Date: Mon, 1 Jul 2019 13:14:14 +0800 Subject: Issue #1148 - Part 1: Add StartupWMClass to .desktop for unofficial --- application/palemoon/branding/unofficial/newmoon.desktop | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/palemoon/branding/unofficial/newmoon.desktop b/application/palemoon/branding/unofficial/newmoon.desktop index 6dcf32477..3b337fdd4 100644 --- a/application/palemoon/branding/unofficial/newmoon.desktop +++ b/application/palemoon/branding/unofficial/newmoon.desktop @@ -87,8 +87,9 @@ Type=Application Icon=palemoon Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp; -StartupNotify=true +StartupNotify=false Actions=NewTab;NewWindow;NewPrivateWindow; +StartupWMClass="new moon" [Desktop Action NewTab] Name=Open new tab -- cgit v1.2.3 From 4f3ec55dd6a709b9273e32689f53c873291721a8 Mon Sep 17 00:00:00 2001 From: Kevin Bhasi <37286461+kbhasi@users.noreply.github.com> Date: Mon, 1 Jul 2019 13:24:01 +0800 Subject: Issue #1148 - Part 2: Add StartupWMClass to .desktop for official --- application/palemoon/branding/official/palemoon.desktop | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/palemoon/branding/official/palemoon.desktop b/application/palemoon/branding/official/palemoon.desktop index 3f678e1bf..440092b33 100644 --- a/application/palemoon/branding/official/palemoon.desktop +++ b/application/palemoon/branding/official/palemoon.desktop @@ -87,8 +87,9 @@ Type=Application Icon=palemoon Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp; -StartupNotify=true +StartupNotify=false Actions=NewTab;NewWindow;NewPrivateWindow; +StartupWMClass="pale moon" [Desktop Action NewTab] Name=Open new tab -- cgit v1.2.3 From c794a79d87a64425c3c23af78f4234833fb9bd79 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 2 Jul 2019 16:07:31 +0200 Subject: New cycle version bump. --- application/palemoon/config/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/palemoon/config/version.txt b/application/palemoon/config/version.txt index bcbf0fd12..ff225a990 100644 --- a/application/palemoon/config/version.txt +++ b/application/palemoon/config/version.txt @@ -1 +1 @@ -28.6.0a1 \ No newline at end of file +28.7.0a1 \ No newline at end of file -- cgit v1.2.3 From f46e7a46cc16260d9c346016db43cf920cc6706a Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 3 Jul 2019 00:05:41 +0200 Subject: Update SSUAO for web.whatsapp.com. This resolves #1152 --- application/palemoon/branding/shared/pref/uaoverrides.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/palemoon/branding/shared/pref/uaoverrides.inc b/application/palemoon/branding/shared/pref/uaoverrides.inc index 36a0ae145..487d083a9 100644 --- a/application/palemoon/branding/shared/pref/uaoverrides.inc +++ b/application/palemoon/branding/shared/pref/uaoverrides.inc @@ -76,7 +76,7 @@ pref("@GUAO_PREF@.netflix.com","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ Fire pref("@GUAO_PREF@.netflximg.net","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ Firefox/45.9"); // UA-sniffing domains that are "app/vendor-specific" and do not like Pale Moon -pref("@GUAO_PREF@.web.whatsapp.com","Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"); +pref("@GUAO_PREF@.web.whatsapp.com","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"); // The following domains do not like the Goanna slice pref("@GUAO_PREF@.hitbox.tv","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@"); -- cgit v1.2.3 From 893de15c27912cd96649e56597d25b1ecb2ee6d9 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 3 Jul 2019 12:01:25 +0200 Subject: Update 16x16 branding images/icons for improved contrast on grey backgrounds. --- .../palemoon/branding/official/default16.png | Bin 767 -> 836 bytes .../palemoon/branding/official/firefox.icns | Bin 251912 -> 251915 bytes application/palemoon/branding/official/firefox.ico | Bin 101320 -> 101320 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/application/palemoon/branding/official/default16.png b/application/palemoon/branding/official/default16.png index a2e8b1a01..d76bb6fad 100644 Binary files a/application/palemoon/branding/official/default16.png and b/application/palemoon/branding/official/default16.png differ diff --git a/application/palemoon/branding/official/firefox.icns b/application/palemoon/branding/official/firefox.icns index 64f17ff62..d63c656c7 100644 Binary files a/application/palemoon/branding/official/firefox.icns and b/application/palemoon/branding/official/firefox.icns differ diff --git a/application/palemoon/branding/official/firefox.ico b/application/palemoon/branding/official/firefox.ico index 0d142c5f1..43c5d9343 100644 Binary files a/application/palemoon/branding/official/firefox.ico and b/application/palemoon/branding/official/firefox.ico differ -- cgit v1.2.3 From 8ea1f38f9c55a076dade47eaf0daaea27590d179 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 3 Jul 2019 15:01:34 +0200 Subject: Change softoken password rounds to a more conservative number still within industry standard security, considering our db hashing is more CPU intensive than anticipated. --- security/nss/lib/softoken/sftkpwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/nss/lib/softoken/sftkpwd.c b/security/nss/lib/softoken/sftkpwd.c index 745e724f0..b6d098a07 100644 --- a/security/nss/lib/softoken/sftkpwd.c +++ b/security/nss/lib/softoken/sftkpwd.c @@ -36,9 +36,9 @@ const int NSS_DEFAULT_ITERATION_COUNT = #ifdef DEBUG - 1000 + 25 #else - 60000 + 500 #endif ; -- cgit v1.2.3 From 6fce24e0e85934061d95f6ad1ee64919d325ae5c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 4 Jul 2019 13:47:47 +0200 Subject: Remove FT's polyfill.io SSUAO now they have fixed their detection. See also: https://github.com/Financial-Times/polyfill-useragent-normaliser/pull/12 --- application/palemoon/branding/shared/pref/uaoverrides.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/application/palemoon/branding/shared/pref/uaoverrides.inc b/application/palemoon/branding/shared/pref/uaoverrides.inc index 487d083a9..028b29b41 100644 --- a/application/palemoon/branding/shared/pref/uaoverrides.inc +++ b/application/palemoon/branding/shared/pref/uaoverrides.inc @@ -57,8 +57,6 @@ pref("@GUAO_PREF@.www.amazon.com","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ F pref("@GUAO_PREF@.soundcloud.com","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); // Daily motion only likes strict Firefox UAs pref("@GUAO_PREF@.dailymotion.com","Mozilla/5.0 (@OS_SLICE@ rv:52.0) @GK_SLICE@ Firefox/52.0"); -// Financial Times' polyfill.io breaks horribly on a Pale Moon UA. Send a strict Firefox UA instead. -pref("@GUAO_PREF@.polyfill.io","Mozilla/5.0 (@OS_SLICE@ rv:60.9) @GK_SLICE@ Firefox/60.9"); // The following requires native mode. Or it blocks.. "too old firefox", breakage, etc. -- cgit v1.2.3 From 8096258c0ca2e96d0d3641165f408b231980e859 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 4 Jul 2019 18:50:29 +0200 Subject: Add adjusted icon for 2k/XP classic grey toolbar backgrounds. (because otherwise we won't hear the end of it) --- application/palemoon/branding/official/firefox.ico | Bin 101320 -> 94683 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/application/palemoon/branding/official/firefox.ico b/application/palemoon/branding/official/firefox.ico index 43c5d9343..ea25fd887 100644 Binary files a/application/palemoon/branding/official/firefox.ico and b/application/palemoon/branding/official/firefox.ico differ -- cgit v1.2.3 From 15e8d1c9195400727079716b4cfc65afe08511e5 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 4 Jul 2019 19:38:41 +0200 Subject: Give Mac an Linux (small sizes) the same treatment --- .../palemoon/branding/official/default16.png | Bin 836 -> 811 bytes .../palemoon/branding/official/default22.png | Bin 1198 -> 1377 bytes .../palemoon/branding/official/default24.png | Bin 1372 -> 1534 bytes .../palemoon/branding/official/default32.png | Bin 2079 -> 2273 bytes .../palemoon/branding/official/firefox.icns | Bin 251915 -> 253858 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/application/palemoon/branding/official/default16.png b/application/palemoon/branding/official/default16.png index d76bb6fad..b840a3acf 100644 Binary files a/application/palemoon/branding/official/default16.png and b/application/palemoon/branding/official/default16.png differ diff --git a/application/palemoon/branding/official/default22.png b/application/palemoon/branding/official/default22.png index 6508e7b84..4e290f84b 100644 Binary files a/application/palemoon/branding/official/default22.png and b/application/palemoon/branding/official/default22.png differ diff --git a/application/palemoon/branding/official/default24.png b/application/palemoon/branding/official/default24.png index 1d4e66a27..f47d3ef23 100644 Binary files a/application/palemoon/branding/official/default24.png and b/application/palemoon/branding/official/default24.png differ diff --git a/application/palemoon/branding/official/default32.png b/application/palemoon/branding/official/default32.png index ce9630745..fde9707d8 100644 Binary files a/application/palemoon/branding/official/default32.png and b/application/palemoon/branding/official/default32.png differ diff --git a/application/palemoon/branding/official/firefox.icns b/application/palemoon/branding/official/firefox.icns index d63c656c7..87f9ac751 100644 Binary files a/application/palemoon/branding/official/firefox.icns and b/application/palemoon/branding/official/firefox.icns differ -- cgit v1.2.3 From 281b66c7a2899380e03a0399a0d5f1ab51b3f3a0 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 5 Jul 2019 17:32:17 +0800 Subject: Issue #1158 - Remove extraneous closing brace - This also adjusts code indentation --- application/basilisk/base/content/tabbrowser.xml | 27 ++++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/application/basilisk/base/content/tabbrowser.xml b/application/basilisk/base/content/tabbrowser.xml index 0e819a3ed..e64ebb1e6 100644 --- a/application/basilisk/base/content/tabbrowser.xml +++ b/application/basilisk/base/content/tabbrowser.xml @@ -6906,21 +6906,20 @@ -- cgit v1.2.3 From 51bf4b3df415e4f7993da8f5f8499e9b029202ec Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 5 Jul 2019 17:50:00 +0800 Subject: Issue #1158 - Reinstate `tabcontainer` variable - This was erroneously removed in commit 1f5194b5f1deb0f36b36ed886d94ce5f8b62ca9d because it is still being used by surrounding code. --- application/basilisk/base/content/tabbrowser.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/basilisk/base/content/tabbrowser.xml b/application/basilisk/base/content/tabbrowser.xml index e64ebb1e6..85f923923 100644 --- a/application/basilisk/base/content/tabbrowser.xml +++ b/application/basilisk/base/content/tabbrowser.xml @@ -6909,6 +6909,8 @@ document.getElementById("alltabs_undoCloseTab").disabled = SessionStore.getClosedTabCount(window) == 0; + var tabcontainer = gBrowser.tabContainer; + // Listen for changes in the tab bar. tabcontainer.addEventListener("TabAttrModified", this, false); tabcontainer.addEventListener("TabClose", this, false); -- cgit v1.2.3 From 7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 5 Jul 2019 21:58:21 +0300 Subject: Introduce a new non-heap-allocated type for holding nsStringBuffer* in the HTML parser. An innerHTML setter profile shows about 10% of the time being spent under nsHtml5HtmlAttributes::clear, mostly deleting nsStrings. --- parser/html/moz.build | 2 + parser/html/nsHtml5ArrayCopy.h | 7 +- parser/html/nsHtml5AttributeName.cpp | 2 +- parser/html/nsHtml5AttributeName.h | 2 +- parser/html/nsHtml5ElementName.cpp | 2 +- parser/html/nsHtml5ElementName.h | 2 +- parser/html/nsHtml5Highlighter.cpp | 16 +- parser/html/nsHtml5Highlighter.h | 6 +- parser/html/nsHtml5HtmlAttributes.cpp | 27 +-- parser/html/nsHtml5HtmlAttributes.h | 12 +- parser/html/nsHtml5MetaScanner.cpp | 15 +- parser/html/nsHtml5MetaScanner.h | 8 +- parser/html/nsHtml5MetaScannerCppSupplement.h | 6 +- parser/html/nsHtml5PlainTextUtils.cpp | 15 +- parser/html/nsHtml5Portability.cpp | 99 ++++------- parser/html/nsHtml5Portability.h | 29 ++-- parser/html/nsHtml5SpeculativeLoad.h | 106 ++++++------ parser/html/nsHtml5StackNode.cpp | 2 +- parser/html/nsHtml5StackNode.h | 2 +- parser/html/nsHtml5StateSnapshot.cpp | 2 +- parser/html/nsHtml5StateSnapshot.h | 2 +- parser/html/nsHtml5StreamParser.cpp | 7 +- parser/html/nsHtml5StreamParser.h | 2 +- parser/html/nsHtml5String.cpp | 226 ++++++++++++++++++++++++++ parser/html/nsHtml5String.h | 95 +++++++++++ parser/html/nsHtml5Tokenizer.cpp | 34 ++-- parser/html/nsHtml5Tokenizer.h | 16 +- parser/html/nsHtml5TreeBuilder.cpp | 49 ++++-- parser/html/nsHtml5TreeBuilder.h | 27 ++- parser/html/nsHtml5TreeBuilderCppSupplement.h | 206 +++++++++++------------ parser/html/nsHtml5TreeOperation.cpp | 14 +- parser/html/nsHtml5UTF16Buffer.cpp | 2 +- parser/html/nsHtml5UTF16Buffer.h | 2 +- parser/html/nsHtml5ViewSourceUtils.cpp | 33 ++-- 34 files changed, 719 insertions(+), 358 deletions(-) create mode 100644 parser/html/nsHtml5String.cpp create mode 100644 parser/html/nsHtml5String.h diff --git a/parser/html/moz.build b/parser/html/moz.build index 4a2da8a79..cd6031abe 100644 --- a/parser/html/moz.build +++ b/parser/html/moz.build @@ -39,6 +39,7 @@ EXPORTS += [ 'nsHtml5SpeculativeLoad.h', 'nsHtml5StreamListener.h', 'nsHtml5StreamParser.h', + 'nsHtml5String.h', 'nsHtml5StringParser.h', 'nsHtml5SVGLoadDispatcher.h', 'nsHtml5TreeOperation.h', @@ -78,6 +79,7 @@ UNIFIED_SOURCES += [ 'nsHtml5StateSnapshot.cpp', 'nsHtml5StreamListener.cpp', 'nsHtml5StreamParser.cpp', + 'nsHtml5String.cpp', 'nsHtml5StringParser.cpp', 'nsHtml5SVGLoadDispatcher.cpp', 'nsHtml5Tokenizer.cpp', diff --git a/parser/html/nsHtml5ArrayCopy.h b/parser/html/nsHtml5ArrayCopy.h index 78ed65568..594a801ab 100644 --- a/parser/html/nsHtml5ArrayCopy.h +++ b/parser/html/nsHtml5ArrayCopy.h @@ -51,10 +51,11 @@ class nsHtml5ArrayCopy { memcpy(target, source, size_t(length) * sizeof(int32_t)); } - static inline void - arraycopy(nsString** source, nsString** target, int32_t length) + static inline void arraycopy(nsHtml5String* source, + nsHtml5String* target, + int32_t length) { - memcpy(target, source, size_t(length) * sizeof(nsString*)); + memcpy(target, source, size_t(length) * sizeof(nsHtml5String)); } static inline void diff --git a/parser/html/nsHtml5AttributeName.cpp b/parser/html/nsHtml5AttributeName.cpp index fc7745adc..dc546c111 100644 --- a/parser/html/nsHtml5AttributeName.cpp +++ b/parser/html/nsHtml5AttributeName.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5AttributeName.h b/parser/html/nsHtml5AttributeName.h index 748dcf3c9..d0b93341b 100644 --- a/parser/html/nsHtml5AttributeName.h +++ b/parser/html/nsHtml5AttributeName.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp index 1aa6f11ce..fb523e7ef 100644 --- a/parser/html/nsHtml5ElementName.cpp +++ b/parser/html/nsHtml5ElementName.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h index b4df323a6..b5f0e4b9b 100644 --- a/parser/html/nsHtml5ElementName.h +++ b/parser/html/nsHtml5ElementName.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5Highlighter.cpp b/parser/html/nsHtml5Highlighter.cpp index 259803ee1..23cdf7d84 100644 --- a/parser/html/nsHtml5Highlighter.cpp +++ b/parser/html/nsHtml5Highlighter.cpp @@ -91,7 +91,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle) if (length > INT32_MAX) { length = INT32_MAX; } - AppendCharacters(aTitle.get(), 0, (int32_t)length); + AppendCharacters(aTitle.BeginReading(), 0, (int32_t)length); Pop(); // title Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes()); @@ -105,7 +105,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle) Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes()); nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0); - nsString* preId = new nsString(NS_LITERAL_STRING("line1")); + nsHtml5String preId = nsHtml5Portability::newStringFromLiteral("line1"); preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId, -1); Push(nsGkAtoms::pre, preAttrs); @@ -618,7 +618,7 @@ nsHtml5Highlighter::FlushOps() void nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName, - nsString* aValue) + nsHtml5String aValue) { if (!(nsHtml5AttributeName::ATTR_HREF == aName || nsHtml5AttributeName::ATTR_SRC == aName || @@ -630,7 +630,7 @@ nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName, nsHtml5AttributeName::ATTR_DEFINITIONURL == aName)) { return; } - AddViewSourceHref(*aValue); + AddViewSourceHref(aValue); } void @@ -717,10 +717,10 @@ nsHtml5Highlighter::AddClass(const char16_t* aClass) } void -nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue) +nsHtml5Highlighter::AddViewSourceHref(nsHtml5String aValue) { char16_t* bufferCopy = new char16_t[aValue.Length() + 1]; - memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t)); + aValue.CopyToBuffer(bufferCopy); bufferCopy[aValue.Length()] = 0; mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceHref, @@ -730,14 +730,14 @@ nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue) } void -nsHtml5Highlighter::AddBase(const nsString& aValue) +nsHtml5Highlighter::AddBase(nsHtml5String aValue) { if(mSeenBase) { return; } mSeenBase = true; char16_t* bufferCopy = new char16_t[aValue.Length() + 1]; - memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t)); + aValue.CopyToBuffer(bufferCopy); bufferCopy[aValue.Length()] = 0; mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceBase, diff --git a/parser/html/nsHtml5Highlighter.h b/parser/html/nsHtml5Highlighter.h index e9474869e..366f11582 100644 --- a/parser/html/nsHtml5Highlighter.h +++ b/parser/html/nsHtml5Highlighter.h @@ -78,7 +78,7 @@ class nsHtml5Highlighter * @param aValue the value of the attribute */ void MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName, - nsString* aValue); + nsHtml5String aValue); /** * Inform the highlighter that the tokenizer successfully completed a @@ -147,7 +147,7 @@ class nsHtml5Highlighter * * @param aValue the base URL to add */ - void AddBase(const nsString& aValue); + void AddBase(nsHtml5String aValue); private: @@ -272,7 +272,7 @@ class nsHtml5Highlighter * * @param aValue the (potentially relative) URL to link to */ - void AddViewSourceHref(const nsString& aValue); + void AddViewSourceHref(nsHtml5String aValue); /** * The state we are transitioning away from. diff --git a/parser/html/nsHtml5HtmlAttributes.cpp b/parser/html/nsHtml5HtmlAttributes.cpp index d515f381d..62b9ae2b2 100644 --- a/parser/html/nsHtml5HtmlAttributes.cpp +++ b/parser/html/nsHtml5HtmlAttributes.cpp @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -58,11 +58,11 @@ nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nullptr; nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode) - : mode(mode), - length(0), - names(jArray::newJArray(8)), - values(jArray::newJArray(8)), - lines(jArray::newJArray(8)) + : mode(mode) + , length(0) + , names(jArray::newJArray(8)) + , values(jArray::newJArray(8)) + , lines(jArray::newJArray(8)) { MOZ_COUNT_CTOR(nsHtml5HtmlAttributes); } @@ -85,7 +85,7 @@ nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* name) return -1; } -nsString* +nsHtml5String nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* name) { int32_t index = getIndex(name); @@ -123,7 +123,7 @@ nsHtml5HtmlAttributes::getPrefixNoBoundsCheck(int32_t index) return names[index]->getPrefix(mode); } -nsString* +nsHtml5String nsHtml5HtmlAttributes::getValueNoBoundsCheck(int32_t index) { MOZ_ASSERT(index < length && index >= 0, "Index out of bounds"); @@ -145,14 +145,17 @@ nsHtml5HtmlAttributes::getLineNoBoundsCheck(int32_t index) } void -nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value, int32_t line) +nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, + nsHtml5String value, + int32_t line) { if (names.length == length) { int32_t newLen = length << 1; jArray newNames = jArray::newJArray(newLen); nsHtml5ArrayCopy::arraycopy(names, newNames, names.length); names = newNames; - jArray newValues = jArray::newJArray(newLen); + jArray newValues = + jArray::newJArray(newLen); nsHtml5ArrayCopy::arraycopy(values, newValues, values.length); values = newValues; jArray newLines = jArray::newJArray(newLen); @@ -171,7 +174,7 @@ nsHtml5HtmlAttributes::clear(int32_t m) for (int32_t i = 0; i < length; i++) { names[i]->release(); names[i] = nullptr; - nsHtml5Portability::releaseString(values[i]); + values[i].Release(); values[i] = nullptr; } length = 0; @@ -181,7 +184,7 @@ nsHtml5HtmlAttributes::clear(int32_t m) void nsHtml5HtmlAttributes::releaseValue(int32_t i) { - nsHtml5Portability::releaseString(values[i]); + values[i].Release(); } void diff --git a/parser/html/nsHtml5HtmlAttributes.h b/parser/html/nsHtml5HtmlAttributes.h index c02d0a08c..12149a0b5 100644 --- a/parser/html/nsHtml5HtmlAttributes.h +++ b/parser/html/nsHtml5HtmlAttributes.h @@ -31,7 +31,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -64,21 +64,23 @@ class nsHtml5HtmlAttributes int32_t mode; int32_t length; autoJArray names; - autoJArray values; + autoJArray values; autoJArray lines; public: explicit nsHtml5HtmlAttributes(int32_t mode); ~nsHtml5HtmlAttributes(); int32_t getIndex(nsHtml5AttributeName* name); - nsString* getValue(nsHtml5AttributeName* name); + nsHtml5String getValue(nsHtml5AttributeName* name); int32_t getLength(); nsIAtom* getLocalNameNoBoundsCheck(int32_t index); int32_t getURINoBoundsCheck(int32_t index); nsIAtom* getPrefixNoBoundsCheck(int32_t index); - nsString* getValueNoBoundsCheck(int32_t index); + nsHtml5String getValueNoBoundsCheck(int32_t index); nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index); int32_t getLineNoBoundsCheck(int32_t index); - void addAttribute(nsHtml5AttributeName* name, nsString* value, int32_t line); + void addAttribute(nsHtml5AttributeName* name, + nsHtml5String value, + int32_t line); void clear(int32_t m); void releaseValue(int32_t i); void clearWithoutReleasingContents(); diff --git a/parser/html/nsHtml5MetaScanner.cpp b/parser/html/nsHtml5MetaScanner.cpp index d39eacd9b..24f17b02b 100644 --- a/parser/html/nsHtml5MetaScanner.cpp +++ b/parser/html/nsHtml5MetaScanner.cpp @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -86,8 +86,8 @@ nsHtml5MetaScanner::nsHtml5MetaScanner(nsHtml5TreeBuilder* tb) nsHtml5MetaScanner::~nsHtml5MetaScanner() { MOZ_COUNT_DTOR(nsHtml5MetaScanner); - nsHtml5Portability::releaseString(content); - nsHtml5Portability::releaseString(charset); + content.Release(); + charset.Release(); } void @@ -771,9 +771,9 @@ bool nsHtml5MetaScanner::handleTag() { bool stop = handleTagInner(); - nsHtml5Portability::releaseString(content); + content.Release(); content = nullptr; - nsHtml5Portability::releaseString(charset); + charset.Release(); charset = nullptr; httpEquivState = NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN; return stop; @@ -786,12 +786,13 @@ nsHtml5MetaScanner::handleTagInner() return true; } if (!!content && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE) { - nsString* extract = nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder); + nsHtml5String extract = + nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder); if (!extract) { return false; } bool success = tryCharset(extract); - nsHtml5Portability::releaseString(extract); + extract.Release(); return success; } return false; diff --git a/parser/html/nsHtml5MetaScanner.h b/parser/html/nsHtml5MetaScanner.h index 4e0ad7647..a4d308147 100644 --- a/parser/html/nsHtml5MetaScanner.h +++ b/parser/html/nsHtml5MetaScanner.h @@ -31,7 +31,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -76,8 +76,8 @@ class nsHtml5MetaScanner private: int32_t strBufLen; autoJArray strBuf; - nsString* content; - nsString* charset; + nsHtml5String content; + nsHtml5String charset; int32_t httpEquivState; nsHtml5TreeBuilder* treeBuilder; public: @@ -100,7 +100,7 @@ class nsHtml5MetaScanner bool handleTag(); bool handleTagInner(); protected: - bool tryCharset(nsString* encoding); + bool tryCharset(nsHtml5String encoding); public: static void initializeStatics(); static void releaseStatics(); diff --git a/parser/html/nsHtml5MetaScannerCppSupplement.h b/parser/html/nsHtml5MetaScannerCppSupplement.h index 5e7033777..9d2496361 100644 --- a/parser/html/nsHtml5MetaScannerCppSupplement.h +++ b/parser/html/nsHtml5MetaScannerCppSupplement.h @@ -19,13 +19,15 @@ nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsACString& charset) } bool -nsHtml5MetaScanner::tryCharset(nsString* charset) +nsHtml5MetaScanner::tryCharset(nsHtml5String charset) { // This code needs to stay in sync with // nsHtml5StreamParser::internalEncodingDeclaration. Unfortunately, the // trickery with member fields here leads to some copy-paste reuse. :-( nsAutoCString label; - CopyUTF16toUTF8(*charset, label); + nsString charset16; // Not Auto, because using it to hold nsStringBuffer* + charset.ToString(charset16); + CopyUTF16toUTF8(charset16, label); nsAutoCString encoding; if (!EncodingUtils::FindEncodingForLabel(label, encoding)) { return false; diff --git a/parser/html/nsHtml5PlainTextUtils.cpp b/parser/html/nsHtml5PlainTextUtils.cpp index 4f0eab81b..0d2933150 100644 --- a/parser/html/nsHtml5PlainTextUtils.cpp +++ b/parser/html/nsHtml5PlainTextUtils.cpp @@ -5,21 +5,24 @@ #include "nsHtml5PlainTextUtils.h" #include "nsHtml5AttributeName.h" +#include "nsHtml5Portability.h" #include "nsIServiceManager.h" #include "nsIStringBundle.h" #include "mozilla/Preferences.h" +#include "nsHtml5String.h" // static nsHtml5HtmlAttributes* nsHtml5PlainTextUtils::NewLinkAttributes() { nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); - nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet")); + nsHtml5String rel = + nsHtml5Portability::newStringFromLiteral("alternate stylesheet"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1); - nsString* type = new nsString(NS_LITERAL_STRING("text/css")); + nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1); - nsString* href = new nsString( - NS_LITERAL_STRING("resource://gre-resources/plaintext.css")); + nsHtml5String href = nsHtml5Portability::newStringFromLiteral( + "resource://gre-resources/plaintext.css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1); nsresult rv; @@ -34,7 +37,7 @@ nsHtml5PlainTextUtils::NewLinkAttributes() bundle->GetStringFromName(u"plainText.wordWrap", getter_Copies(title)); } - nsString* titleCopy = new nsString(title); - linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy, -1); + linkAttrs->addAttribute( + nsHtml5AttributeName::ATTR_TITLE, nsHtml5String::FromString(title), -1); return linkAttrs; } diff --git a/parser/html/nsHtml5Portability.cpp b/parser/html/nsHtml5Portability.cpp index 0a7c6f845..5a76b3c56 100644 --- a/parser/html/nsHtml5Portability.cpp +++ b/parser/html/nsHtml5Portability.cpp @@ -16,37 +16,31 @@ nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_ return interner->GetAtom(nsDependentSubstring(buf, buf + length)); } -nsString* -nsHtml5Portability::newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder) +nsHtml5String +nsHtml5Portability::newStringFromBuffer(char16_t* buf, + int32_t offset, + int32_t length, + nsHtml5TreeBuilder* treeBuilder) { - nsString* str = new nsString(); - bool succeeded = str->Append(buf + offset, length, mozilla::fallible); - if (!succeeded) { - str->Assign(char16_t(0xFFFD)); - treeBuilder->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY); - } - return str; + return nsHtml5String::FromBuffer(buf + offset, length, treeBuilder); } -nsString* +nsHtml5String nsHtml5Portability::newEmptyString() { - return new nsString(); + return nsHtml5String::EmptyString(); } -nsString* +nsHtml5String nsHtml5Portability::newStringFromLiteral(const char* literal) { - nsString* str = new nsString(); - str->AssignASCII(literal); - return str; + return nsHtml5String::FromLiteral(literal); } -nsString* -nsHtml5Portability::newStringFromString(nsString* string) { - nsString* newStr = new nsString(); - newStr->Assign(*string); - return newStr; +nsHtml5String +nsHtml5Portability::newStringFromString(nsHtml5String string) +{ + return string.Clone(); } jArray @@ -60,12 +54,14 @@ nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local) return arr; } -jArray -nsHtml5Portability::newCharArrayFromString(nsString* string) +jArray +nsHtml5Portability::newCharArrayFromString(nsHtml5String string) { - int32_t len = string->Length(); + MOZ_RELEASE_ASSERT(string); + uint32_t len = string.Length(); + MOZ_RELEASE_ASSERT(len < INT32_MAX); jArray arr = jArray::newJArray(len); - memcpy(arr, string->BeginReading(), len * sizeof(char16_t)); + string.CopyToBuffer(arr); return arr; } @@ -82,12 +78,6 @@ nsHtml5Portability::newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner return local; } -void -nsHtml5Portability::releaseString(nsString* str) -{ - delete str; -} - bool nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length) { @@ -95,55 +85,32 @@ nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t off } bool -nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string) +nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string) { - if (!string) { - return false; - } - const char* litPtr = lowerCaseLiteral; - const char16_t* strPtr = string->BeginReading(); - const char16_t* end = string->EndReading(); - char16_t litChar; - while ((litChar = *litPtr)) { - NS_ASSERTION(!(litChar >= 'A' && litChar <= 'Z'), "Literal isn't in lower case."); - if (strPtr == end) { - return false; - } - char16_t strChar = *strPtr; - if (strChar >= 'A' && strChar <= 'Z') { - strChar += 0x20; - } - if (litChar != strChar) { - return false; - } - ++litPtr; - ++strPtr; - } - return true; + return string.LowerCaseStartsWithASCII(lowerCaseLiteral); } bool -nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string) +nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string) { - if (!string) { - return false; - } - return string->LowerCaseEqualsASCII(lowerCaseLiteral); + return string.LowerCaseEqualsASCII(lowerCaseLiteral); } bool -nsHtml5Portability::literalEqualsString(const char* literal, nsString* string) +nsHtml5Portability::literalEqualsString(const char* literal, + nsHtml5String string) { - if (!string) { - return false; - } - return string->EqualsASCII(literal); + return string.EqualsASCII(literal); } bool -nsHtml5Portability::stringEqualsString(nsString* one, nsString* other) +nsHtml5Portability::stringEqualsString(nsHtml5String one, nsHtml5String other) { - return one->Equals(*other); + return one.Equals(other); } void diff --git a/parser/html/nsHtml5Portability.h b/parser/html/nsHtml5Portability.h index bd85ccbdb..a3214dd2f 100644 --- a/parser/html/nsHtml5Portability.h +++ b/parser/html/nsHtml5Portability.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -59,19 +59,26 @@ class nsHtml5Portability { public: static nsIAtom* newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner); - static nsString* newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder); - static nsString* newEmptyString(); - static nsString* newStringFromLiteral(const char* literal); - static nsString* newStringFromString(nsString* string); + static nsHtml5String newStringFromBuffer(char16_t* buf, + int32_t offset, + int32_t length, + nsHtml5TreeBuilder* treeBuilder); + static nsHtml5String newEmptyString(); + static nsHtml5String newStringFromLiteral(const char* literal); + static nsHtml5String newStringFromString(nsHtml5String string); static jArray newCharArrayFromLocal(nsIAtom* local); - static jArray newCharArrayFromString(nsString* string); + static jArray newCharArrayFromString( + nsHtml5String string); static nsIAtom* newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner); - static void releaseString(nsString* str); static bool localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length); - static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string); - static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string); - static bool literalEqualsString(const char* literal, nsString* string); - static bool stringEqualsString(nsString* one, nsString* other); + static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string); + static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string); + static bool literalEqualsString(const char* literal, nsHtml5String string); + static bool stringEqualsString(nsHtml5String one, nsHtml5String other); static void initializeStatics(); static void releaseStatics(); }; diff --git a/parser/html/nsHtml5SpeculativeLoad.h b/parser/html/nsHtml5SpeculativeLoad.h index 575f6186d..6f1365bcf 100644 --- a/parser/html/nsHtml5SpeculativeLoad.h +++ b/parser/html/nsHtml5SpeculativeLoad.h @@ -35,45 +35,57 @@ class nsHtml5SpeculativeLoad { nsHtml5SpeculativeLoad(); ~nsHtml5SpeculativeLoad(); - inline void InitBase(const nsAString& aUrl) + inline void InitBase(nsHtml5String aUrl) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadBase; - mUrl.Assign(aUrl); + aUrl.ToString(mUrl); } - inline void InitMetaCSP(const nsAString& aCSP) { + inline void InitMetaCSP(nsHtml5String aCSP) + { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadCSP; + nsString csp; // Not Auto, because using it to hold nsStringBuffer* + aCSP.ToString(csp); mMetaCSP.Assign( - nsContentUtils::TrimWhitespace(aCSP)); + nsContentUtils::TrimWhitespace(csp)); } - inline void InitMetaReferrerPolicy(const nsAString& aReferrerPolicy) { + inline void InitMetaReferrerPolicy(nsHtml5String aReferrerPolicy) + { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadMetaReferrer; + nsString + referrerPolicy; // Not Auto, because using it to hold nsStringBuffer* + aReferrerPolicy.ToString(referrerPolicy); mReferrerPolicy.Assign( - nsContentUtils::TrimWhitespace(aReferrerPolicy)); + nsContentUtils::TrimWhitespace( + referrerPolicy)); } - inline void InitImage(const nsAString& aUrl, - const nsAString& aCrossOrigin, - const nsAString& aReferrerPolicy, - const nsAString& aSrcset, - const nsAString& aSizes) + inline void InitImage(nsHtml5String aUrl, + nsHtml5String aCrossOrigin, + nsHtml5String aReferrerPolicy, + nsHtml5String aSrcset, + nsHtml5String aSizes) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadImage; - mUrl.Assign(aUrl); - mCrossOrigin.Assign(aCrossOrigin); + aUrl.ToString(mUrl); + aCrossOrigin.ToString(mCrossOrigin); + nsString + referrerPolicy; // Not Auto, because using it to hold nsStringBuffer* + aReferrerPolicy.ToString(referrerPolicy); mReferrerPolicy.Assign( - nsContentUtils::TrimWhitespace(aReferrerPolicy)); - mSrcset.Assign(aSrcset); - mSizes.Assign(aSizes); + nsContentUtils::TrimWhitespace( + referrerPolicy)); + aSrcset.ToString(mSrcset); + aSizes.ToString(mSizes); } // elements have multiple nodes followed by an , @@ -97,49 +109,50 @@ class nsHtml5SpeculativeLoad { mOpCode = eSpeculativeLoadEndPicture; } - inline void InitPictureSource(const nsAString& aSrcset, - const nsAString& aSizes, - const nsAString& aType, - const nsAString& aMedia) + inline void InitPictureSource(nsHtml5String aSrcset, + nsHtml5String aSizes, + nsHtml5String aType, + nsHtml5String aMedia) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadPictureSource; - mSrcset.Assign(aSrcset); - mSizes.Assign(aSizes); - mTypeOrCharsetSourceOrDocumentMode.Assign(aType); - mMedia.Assign(aMedia); + aSrcset.ToString(mSrcset); + aSizes.ToString(mSizes); + aType.ToString(mTypeOrCharsetSourceOrDocumentMode); + aMedia.ToString(mMedia); } - inline void InitScript(const nsAString& aUrl, - const nsAString& aCharset, - const nsAString& aType, - const nsAString& aCrossOrigin, - const nsAString& aIntegrity, + inline void InitScript(nsHtml5String aUrl, + nsHtml5String aCharset, + nsHtml5String aType, + nsHtml5String aCrossOrigin, + nsHtml5String aIntegrity, bool aParserInHead) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = aParserInHead ? eSpeculativeLoadScriptFromHead : eSpeculativeLoadScript; - mUrl.Assign(aUrl); - mCharset.Assign(aCharset); - mTypeOrCharsetSourceOrDocumentMode.Assign(aType); - mCrossOrigin.Assign(aCrossOrigin); - mIntegrity.Assign(aIntegrity); + aUrl.ToString(mUrl); + aCharset.ToString(mCharset); + aType.ToString(mTypeOrCharsetSourceOrDocumentMode); + aCrossOrigin.ToString(mCrossOrigin); + aIntegrity.ToString(mIntegrity); } - inline void InitStyle(const nsAString& aUrl, const nsAString& aCharset, - const nsAString& aCrossOrigin, - const nsAString& aIntegrity) + inline void InitStyle(nsHtml5String aUrl, + nsHtml5String aCharset, + nsHtml5String aCrossOrigin, + nsHtml5String aIntegrity) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadStyle; - mUrl.Assign(aUrl); - mCharset.Assign(aCharset); - mCrossOrigin.Assign(aCrossOrigin); - mIntegrity.Assign(aIntegrity); + aUrl.ToString(mUrl); + aCharset.ToString(mCharset); + aCrossOrigin.ToString(mCrossOrigin); + aIntegrity.ToString(mIntegrity); } /** @@ -153,12 +166,12 @@ class nsHtml5SpeculativeLoad { * manifests seen by the parser thread have to maintain the queue order * relative to true speculative loads. See bug 541079. */ - inline void InitManifest(const nsAString& aUrl) + inline void InitManifest(nsHtml5String aUrl) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadManifest; - mUrl.Assign(aUrl); + aUrl.ToString(mUrl); } /** @@ -195,14 +208,13 @@ class nsHtml5SpeculativeLoad { mTypeOrCharsetSourceOrDocumentMode.Assign((char16_t)aMode); } - inline void InitPreconnect(const nsAString& aUrl, - const nsAString& aCrossOrigin) + inline void InitPreconnect(nsHtml5String aUrl, nsHtml5String aCrossOrigin) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadPreconnect; - mUrl.Assign(aUrl); - mCrossOrigin.Assign(aCrossOrigin); + aUrl.ToString(mUrl); + aCrossOrigin.ToString(mCrossOrigin); } void Perform(nsHtml5TreeOpExecutor* aExecutor); diff --git a/parser/html/nsHtml5StackNode.cpp b/parser/html/nsHtml5StackNode.cpp index ac5f0b2a3..41163ae40 100644 --- a/parser/html/nsHtml5StackNode.cpp +++ b/parser/html/nsHtml5StackNode.cpp @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StackNode.h b/parser/html/nsHtml5StackNode.h index 57909ca9c..1677ec571 100644 --- a/parser/html/nsHtml5StackNode.h +++ b/parser/html/nsHtml5StackNode.h @@ -31,7 +31,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StateSnapshot.cpp b/parser/html/nsHtml5StateSnapshot.cpp index e8e3debf0..90780738b 100644 --- a/parser/html/nsHtml5StateSnapshot.cpp +++ b/parser/html/nsHtml5StateSnapshot.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StateSnapshot.h b/parser/html/nsHtml5StateSnapshot.h index 141b34340..119570499 100644 --- a/parser/html/nsHtml5StateSnapshot.h +++ b/parser/html/nsHtml5StateSnapshot.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index 83bf4d8b6..ab4548125 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -1261,7 +1261,7 @@ nsHtml5StreamParser::PreferredForInternalEncodingDecl(nsACString& aEncoding) } bool -nsHtml5StreamParser::internalEncodingDeclaration(nsString* aEncoding) +nsHtml5StreamParser::internalEncodingDeclaration(nsHtml5String aEncoding) { // This code needs to stay in sync with // nsHtml5MetaScanner::tryCharset. Unfortunately, the @@ -1270,9 +1270,10 @@ nsHtml5StreamParser::internalEncodingDeclaration(nsString* aEncoding) if (mCharsetSource >= kCharsetFromMetaTag) { // this threshold corresponds to "confident" in the HTML5 spec return false; } - + nsString newEncoding16; // Not Auto, because using it to hold nsStringBuffer* + aEncoding.ToString(newEncoding16); nsAutoCString newEncoding; - CopyUTF16toUTF8(*aEncoding, newEncoding); + CopyUTF16toUTF8(newEncoding16, newEncoding); if (!PreferredForInternalEncodingDecl(newEncoding)) { return false; diff --git a/parser/html/nsHtml5StreamParser.h b/parser/html/nsHtml5StreamParser.h index 9a38ba067..2560f84ab 100644 --- a/parser/html/nsHtml5StreamParser.h +++ b/parser/html/nsHtml5StreamParser.h @@ -145,7 +145,7 @@ class nsHtml5StreamParser : public nsICharsetDetectionObserver { /** * Tree builder uses this to report a late */ - bool internalEncodingDeclaration(nsString* aEncoding); + bool internalEncodingDeclaration(nsHtml5String aEncoding); // Not from an external interface diff --git a/parser/html/nsHtml5String.cpp b/parser/html/nsHtml5String.cpp new file mode 100644 index 000000000..d26eeaede --- /dev/null +++ b/parser/html/nsHtml5String.cpp @@ -0,0 +1,226 @@ +/* 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 "nsHtml5String.h" +#include "nsCharTraits.h" +#include "nsUTF8Utils.h" +#include "nsHtml5TreeBuilder.h" + +nsHtml5String::nsHtml5String(already_AddRefed aBuffer, + uint32_t aLength) + : mBuffer(aBuffer.take()) + , mLength(aLength) +{ + if (mBuffer) { + MOZ_ASSERT(aLength); + } else { + MOZ_ASSERT(!aLength || aLength == UINT32_MAX); + } +} + +void +nsHtml5String::ToString(nsAString& aString) +{ + if (mBuffer) { + mBuffer->ToString(mLength, aString); + } else { + aString.Truncate(); + if (mLength) { + aString.SetIsVoid(true); + } + } +} + +void +nsHtml5String::CopyToBuffer(char16_t* aBuffer) +{ + if (mBuffer) { + memcpy(aBuffer, mBuffer->Data(), mLength * sizeof(char16_t)); + } +} + +bool +nsHtml5String::LowerCaseEqualsASCII(const char* aLowerCaseLiteral) +{ + if (!mBuffer) { + if (mLength) { + // This string is null + return false; + } + // this string is empty + return !(*aLowerCaseLiteral); + } + return !nsCharTraits::compareLowerCaseToASCIINullTerminated( + reinterpret_cast(mBuffer->Data()), Length(), aLowerCaseLiteral); +} + +bool +nsHtml5String::EqualsASCII(const char* aLiteral) +{ + if (!mBuffer) { + if (mLength) { + // This string is null + return false; + } + // this string is empty + return !(*aLiteral); + } + return !nsCharTraits::compareASCIINullTerminated( + reinterpret_cast(mBuffer->Data()), Length(), aLiteral); +} + +bool +nsHtml5String::LowerCaseStartsWithASCII(const char* aLowerCaseLiteral) +{ + if (!mBuffer) { + if (mLength) { + // This string is null + return false; + } + // this string is empty + return !(*aLowerCaseLiteral); + } + const char* litPtr = aLowerCaseLiteral; + const char16_t* strPtr = reinterpret_cast(mBuffer->Data()); + const char16_t* end = strPtr + Length(); + char16_t litChar; + while ((litChar = *litPtr) && (strPtr != end)) { + MOZ_ASSERT(!(litChar >= 'A' && litChar <= 'Z'), + "Literal isn't in lower case."); + char16_t strChar = *strPtr; + if (strChar >= 'A' && strChar <= 'Z') { + strChar += 0x20; + } + if (litChar != strChar) { + return false; + } + ++litPtr; + ++strPtr; + } + return true; +} + +bool +nsHtml5String::Equals(nsHtml5String aOther) +{ + MOZ_ASSERT(operator bool()); + MOZ_ASSERT(aOther); + if (mLength != aOther.mLength) { + return false; + } + if (!mBuffer) { + return true; + } + MOZ_ASSERT(aOther.mBuffer); + return !memcmp( + mBuffer->Data(), aOther.mBuffer->Data(), Length() * sizeof(char16_t)); +} + +nsHtml5String +nsHtml5String::Clone() +{ + MOZ_ASSERT(operator bool()); + RefPtr ref(mBuffer); + return nsHtml5String(ref.forget(), mLength); +} + +void +nsHtml5String::Release() +{ + if (mBuffer) { + mBuffer->Release(); + mBuffer = nullptr; + } + mLength = UINT32_MAX; +} + +// static +nsHtml5String +nsHtml5String::FromBuffer(char16_t* aBuffer, + int32_t aLength, + nsHtml5TreeBuilder* aTreeBuilder) +{ + if (!aLength) { + return nsHtml5String(nullptr, 0U); + } + // Work with nsStringBuffer directly to make sure that storage is actually + // nsStringBuffer and to make sure the allocation strategy matches + // nsAttrValue::GetStringBuffer, so that it doesn't need to reallocate and + // copy. + RefPtr buffer( + nsStringBuffer::Alloc((aLength + 1) * sizeof(char16_t))); + if (!buffer) { + if (!aTreeBuilder) { + MOZ_CRASH("Out of memory."); + } + aTreeBuilder->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY); + buffer = nsStringBuffer::Alloc(2 * sizeof(char16_t)); + if (!buffer) { + MOZ_CRASH( + "Out of memory so badly that couldn't even allocate placeholder."); + } + char16_t* data = reinterpret_cast(buffer->Data()); + data[0] = 0xFFFD; + data[1] = 0; + return nsHtml5String(buffer.forget(), 1); + } + char16_t* data = reinterpret_cast(buffer->Data()); + memcpy(data, aBuffer, aLength * sizeof(char16_t)); + data[aLength] = 0; + return nsHtml5String(buffer.forget(), aLength); +} + +// static +nsHtml5String +nsHtml5String::FromLiteral(const char* aLiteral) +{ + size_t length = std::strlen(aLiteral); + if (!length) { + return nsHtml5String(nullptr, 0U); + } + // Work with nsStringBuffer directly to make sure that storage is actually + // nsStringBuffer and to make sure the allocation strategy matches + // nsAttrValue::GetStringBuffer, so that it doesn't need to reallocate and + // copy. + RefPtr buffer( + nsStringBuffer::Alloc((length + 1) * sizeof(char16_t))); + if (!buffer) { + MOZ_CRASH("Out of memory."); + } + char16_t* data = reinterpret_cast(buffer->Data()); + LossyConvertEncoding8to16 converter(data); + converter.write(aLiteral, length); + data[length] = 0; + return nsHtml5String(buffer.forget(), length); +} + +// static +nsHtml5String +nsHtml5String::FromString(const nsAString& aString) +{ + auto length = aString.Length(); + if (!length) { + return nsHtml5String(nullptr, 0U); + } + RefPtr buffer = nsStringBuffer::FromString(aString); + if (buffer) { + return nsHtml5String(buffer.forget(), length); + } + buffer = nsStringBuffer::Alloc((length + 1) * sizeof(char16_t)); + if (!buffer) { + MOZ_CRASH("Out of memory."); + } + char16_t* data = reinterpret_cast(buffer->Data()); + memcpy(data, aString.BeginReading(), length * sizeof(char16_t)); + data[length] = 0; + return nsHtml5String(buffer.forget(), length); +} + +// static +nsHtml5String +nsHtml5String::EmptyString() +{ + return nsHtml5String(nullptr, 0U); + +} \ No newline at end of file diff --git a/parser/html/nsHtml5String.h b/parser/html/nsHtml5String.h new file mode 100644 index 000000000..191bf6be8 --- /dev/null +++ b/parser/html/nsHtml5String.h @@ -0,0 +1,95 @@ +/* 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/. */ + +#ifndef nsHtml5String_h +#define nsHtml5String_h + +#include "nsString.h" + +class nsHtml5TreeBuilder; + +/** + * A pass-by-value type that combines an unsafe `nsStringBuffer*` with its + * logical length (`uint32_t`). (`nsStringBuffer` knows its capacity but not + * its logical length, i.e. how much of the capacity is in use.) + * + * Holding or passing this type is as unsafe as holding or passing + * `nsStringBuffer*`. + * + * Empty strings and null strings are distinct. Since an empty nsString does + * not have a an `nsStringBuffer`, both empty and null `nsHtml5String` have + * `nullptr` as `mBuffer`. If `mBuffer` is `nullptr`, the empty case is marked + * with `mLength` being zero and the null case with `mLength` being non-zero. + */ +class nsHtml5String final +{ +public: + /** + * Default constructor. + */ + inline nsHtml5String() + : nsHtml5String(nullptr) + { + } + + /** + * Constructor from nullptr. + */ + inline MOZ_IMPLICIT nsHtml5String(decltype(nullptr)) + : mBuffer(nullptr) + , mLength(UINT32_MAX) + { + } + + inline uint32_t Length() const { return mBuffer ? mLength : 0; } + + /** + * False iff the string is logically null + */ + inline MOZ_IMPLICIT operator bool() const { return !(!mBuffer && mLength); } + + void ToString(nsAString& aString); + + void CopyToBuffer(char16_t* aBuffer); + + bool LowerCaseEqualsASCII(const char* aLowerCaseLiteral); + + bool EqualsASCII(const char* aLiteral); + + bool LowerCaseStartsWithASCII(const char* aLowerCaseLiteral); + + bool Equals(nsHtml5String aOther); + + nsHtml5String Clone(); + + void Release(); + + static nsHtml5String FromBuffer(char16_t* aBuffer, + int32_t aLength, + nsHtml5TreeBuilder* aTreeBuilder); + + static nsHtml5String FromLiteral(const char* aLiteral); + + static nsHtml5String FromString(const nsAString& aString); + + static nsHtml5String EmptyString(); + +private: + /** + * Constructor from raw parts. + */ + nsHtml5String(already_AddRefed aBuffer, uint32_t aLength); + + /** + * nullptr if the string is logically null or logically empty + */ + nsStringBuffer* mBuffer; + + /** + * The length of the string. non-zero if the string is logically null. + */ + uint32_t mLength; +}; + +#endif // nsHtml5String_h \ No newline at end of file diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp index 2838d74aa..a9db8d0c1 100644 --- a/parser/html/nsHtml5Tokenizer.cpp +++ b/parser/html/nsHtml5Tokenizer.cpp @@ -32,7 +32,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" #include "jArray.h" @@ -113,7 +113,8 @@ nsHtml5Tokenizer::setInterner(nsHtml5AtomTable* interner) } void -nsHtml5Tokenizer::initLocation(nsString* newPublicId, nsString* newSystemId) +nsHtml5Tokenizer::initLocation(nsHtml5String newPublicId, + nsHtml5String newSystemId) { this->systemId = newSystemId; this->publicId = newPublicId; @@ -222,10 +223,11 @@ nsHtml5Tokenizer::emitOrAppendCharRefBuf(int32_t returnState) } } -nsString* +nsHtml5String nsHtml5Tokenizer::strBufToString() { - nsString* str = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler); + nsHtml5String str = + nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler); clearStrBufAfterUse(); return str; } @@ -350,7 +352,7 @@ void nsHtml5Tokenizer::addAttributeWithValue() { if (attributeName) { - nsString* val = strBufToString(); + nsHtml5String val = strBufToString(); if (mViewSource) { mViewSource->MaybeLinkifyAttributeValue(attributeName, val); } @@ -3496,11 +3498,11 @@ nsHtml5Tokenizer::initDoctypeFields() clearStrBufAfterUse(); doctypeName = nsHtml5Atoms::emptystring; if (systemIdentifier) { - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } if (publicIdentifier) { - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; } forceQuirks = false; @@ -3662,11 +3664,11 @@ nsHtml5Tokenizer::eof() errEofInDoctype(); doctypeName = nsHtml5Atoms::emptystring; if (systemIdentifier) { - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } if (publicIdentifier) { - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; } forceQuirks = true; @@ -3896,14 +3898,14 @@ nsHtml5Tokenizer::emitDoctypeToken(int32_t pos) cstart = pos + 1; tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks); doctypeName = nullptr; - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } bool -nsHtml5Tokenizer::internalEncodingDeclaration(nsString* internalCharset) +nsHtml5Tokenizer::internalEncodingDeclaration(nsHtml5String internalCharset) { if (encodingDeclarationHandler) { return encodingDeclarationHandler->internalEncodingDeclaration(internalCharset); @@ -3938,11 +3940,11 @@ nsHtml5Tokenizer::end() strBuf = nullptr; doctypeName = nullptr; if (systemIdentifier) { - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } if (publicIdentifier) { - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; } if (tagName) { @@ -4041,13 +4043,13 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other) } else { doctypeName = nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner); } - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); if (!other->systemIdentifier) { systemIdentifier = nullptr; } else { systemIdentifier = nsHtml5Portability::newStringFromString(other->systemIdentifier); } - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); if (!other->publicIdentifier) { publicIdentifier = nullptr; } else { diff --git a/parser/html/nsHtml5Tokenizer.h b/parser/html/nsHtml5Tokenizer.h index da509b69b..00cca9a9c 100644 --- a/parser/html/nsHtml5Tokenizer.h +++ b/parser/html/nsHtml5Tokenizer.h @@ -33,7 +33,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" #include "jArray.h" @@ -106,8 +106,8 @@ class nsHtml5Tokenizer protected: int32_t cstart; private: - nsString* publicId; - nsString* systemId; + nsHtml5String publicId; + nsHtml5String systemId; autoJArray strBuf; int32_t strBufLen; autoJArray charRefBuf; @@ -126,8 +126,8 @@ class nsHtml5Tokenizer nsHtml5AttributeName* attributeName; private: nsIAtom* doctypeName; - nsString* publicIdentifier; - nsString* systemIdentifier; + nsHtml5String publicIdentifier; + nsHtml5String systemIdentifier; nsHtml5HtmlAttributes* attributes; bool newAttributesEachTime; bool shouldSuspend; @@ -141,7 +141,7 @@ class nsHtml5Tokenizer public: nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource); void setInterner(nsHtml5AtomTable* interner); - void initLocation(nsString* newPublicId, nsString* newSystemId); + void initLocation(nsHtml5String newPublicId, nsHtml5String newSystemId); bool isViewingXmlSource(); void setStateAndEndTagExpectation(int32_t specialTokenizerState, nsIAtom* endTagExpectation); void setStateAndEndTagExpectation(int32_t specialTokenizerState, nsHtml5ElementName* endTagExpectation); @@ -193,7 +193,7 @@ class nsHtml5Tokenizer } protected: - nsString* strBufToString(); + nsHtml5String strBufToString(); private: void strBufToDoctypeName(); void emitStrBuf(); @@ -285,7 +285,7 @@ class nsHtml5Tokenizer } public: - bool internalEncodingDeclaration(nsString* internalCharset); + bool internalEncodingDeclaration(nsHtml5String internalCharset); private: void emitOrAppendTwo(const char16_t* val, int32_t returnState); void emitOrAppendOne(const char16_t* val, int32_t returnState); diff --git a/parser/html/nsHtml5TreeBuilder.cpp b/parser/html/nsHtml5TreeBuilder.cpp index f694116ba..457c7deb1 100644 --- a/parser/html/nsHtml5TreeBuilder.cpp +++ b/parser/html/nsHtml5TreeBuilder.cpp @@ -34,7 +34,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" #include "nsITimer.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -154,13 +154,16 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self) } void -nsHtml5TreeBuilder::doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks) +nsHtml5TreeBuilder::doctype(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks) { needToDropLF = false; if (!isInForeign() && mode == NS_HTML5TREE_BUILDER_INITIAL) { - nsString* emptyString = nsHtml5Portability::newEmptyString(); + nsHtml5String emptyString = nsHtml5Portability::newEmptyString(); appendDoctypeToDocument(!name ? nsHtml5Atoms::emptystring : name, !publicIdentifier ? emptyString : publicIdentifier, !systemIdentifier ? emptyString : systemIdentifier); - nsHtml5Portability::releaseString(emptyString); + emptyString.Release(); if (isQuirky(name, publicIdentifier, systemIdentifier, forceQuirks)) { errQuirkyDoctype(); documentModeInternal(QUIRKS_MODE, publicIdentifier, systemIdentifier, false); @@ -1990,8 +1993,9 @@ nsHtml5TreeBuilder::isSpecialParentInForeign(nsHtml5StackNode* stackNode) return (kNameSpaceID_XHTML == ns) || (stackNode->isHtmlIntegrationPoint()) || ((kNameSpaceID_MathML == ns) && (stackNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT)); } -nsString* -nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue, nsHtml5TreeBuilder* tb) +nsHtml5String +nsHtml5TreeBuilder::extractCharsetFromContent(nsHtml5String attributeValue, + nsHtml5TreeBuilder* tb) { int32_t charsetState = NS_HTML5TREE_BUILDER_CHARSET_INITIAL; int32_t start = -1; @@ -2175,12 +2179,13 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue, nsHtml5T } } charsetloop_end: ; - nsString* charset = nullptr; + nsHtml5String charset = nullptr; if (start != -1) { if (end == -1) { end = buffer.length; } - charset = nsHtml5Portability::newStringFromBuffer(buffer, start, end - start, tb); + charset = + nsHtml5Portability::newStringFromBuffer(buffer, start, end - start, tb); } return charset; } @@ -2188,7 +2193,8 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue, nsHtml5T void nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes) { - nsString* charset = attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); + nsHtml5String charset = + attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); if (charset) { if (tokenizer->internalEncodingDeclaration(charset)) { requestSuspension(); @@ -2199,15 +2205,17 @@ nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes) if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("content-type", attributes->getValue(nsHtml5AttributeName::ATTR_HTTP_EQUIV))) { return; } - nsString* content = attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); + nsHtml5String content = + attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); if (content) { - nsString* extract = nsHtml5TreeBuilder::extractCharsetFromContent(content, this); + nsHtml5String extract = + nsHtml5TreeBuilder::extractCharsetFromContent(content, this); if (extract) { if (tokenizer->internalEncodingDeclaration(extract)) { requestSuspension(); } } - nsHtml5Portability::releaseString(extract); + extract.Release(); } } @@ -3208,7 +3216,11 @@ nsHtml5TreeBuilder::isSecondOnStackBody() } void -nsHtml5TreeBuilder::documentModeInternal(nsHtml5DocumentMode m, nsString* publicIdentifier, nsString* systemIdentifier, bool html4SpecificAdditionalErrorChecks) +nsHtml5TreeBuilder::documentModeInternal( + nsHtml5DocumentMode m, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool html4SpecificAdditionalErrorChecks) { if (isSrcdocDocument) { quirks = false; @@ -3220,7 +3232,8 @@ nsHtml5TreeBuilder::documentModeInternal(nsHtml5DocumentMode m, nsString* public } bool -nsHtml5TreeBuilder::isAlmostStandards(nsString* publicIdentifier, nsString* systemIdentifier) +nsHtml5TreeBuilder::isAlmostStandards(nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier) { if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("-//w3c//dtd xhtml 1.0 transitional//en", publicIdentifier)) { return true; @@ -3240,7 +3253,10 @@ nsHtml5TreeBuilder::isAlmostStandards(nsString* publicIdentifier, nsString* syst } bool -nsHtml5TreeBuilder::isQuirky(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks) +nsHtml5TreeBuilder::isQuirky(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks) { if (forceQuirks) { return true; @@ -4051,7 +4067,8 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5Elem bool nsHtml5TreeBuilder::annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes) { - nsString* encoding = attributes->getValue(nsHtml5AttributeName::ATTR_ENCODING); + nsHtml5String encoding = + attributes->getValue(nsHtml5AttributeName::ATTR_ENCODING); if (!encoding) { return false; } diff --git a/parser/html/nsHtml5TreeBuilder.h b/parser/html/nsHtml5TreeBuilder.h index a66b168be..67f5010c5 100644 --- a/parser/html/nsHtml5TreeBuilder.h +++ b/parser/html/nsHtml5TreeBuilder.h @@ -35,7 +35,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" #include "nsITimer.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -103,7 +103,10 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState bool isSrcdocDocument; public: void startTokenization(nsHtml5Tokenizer* self); - void doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks); + void doctype(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks); void comment(char16_t* buf, int32_t start, int32_t length); void characters(const char16_t* buf, int32_t start, int32_t length); void zeroOriginatingReplacementCharacter(); @@ -119,7 +122,8 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState bool isTemplateModeStackEmpty(); bool isSpecialParentInForeign(nsHtml5StackNode* stackNode); public: - static nsString* extractCharsetFromContent(nsString* attributeValue, nsHtml5TreeBuilder* tb); + static nsHtml5String extractCharsetFromContent(nsHtml5String attributeValue, + nsHtml5TreeBuilder* tb); private: void checkMetaCharset(nsHtml5HtmlAttributes* attributes); public: @@ -136,9 +140,16 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState void generateImpliedEndTagsExceptFor(nsIAtom* name); void generateImpliedEndTags(); bool isSecondOnStackBody(); - void documentModeInternal(nsHtml5DocumentMode m, nsString* publicIdentifier, nsString* systemIdentifier, bool html4SpecificAdditionalErrorChecks); - bool isAlmostStandards(nsString* publicIdentifier, nsString* systemIdentifier); - bool isQuirky(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks); + void documentModeInternal(nsHtml5DocumentMode m, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool html4SpecificAdditionalErrorChecks); + bool isAlmostStandards(nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier); + bool isQuirky(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks); void closeTheCell(int32_t eltPos); int32_t findLastInTableScopeTdTh(); void clearStackBackTo(int32_t eltPos); @@ -224,7 +235,9 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState void markMalformedIfScript(nsIContentHandle* elt); void start(bool fragmentMode); void end(); - void appendDoctypeToDocument(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier); + void appendDoctypeToDocument(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier); void elementPushed(int32_t ns, nsIAtom* name, nsIContentHandle* node); void elementPopped(int32_t ns, nsIAtom* name, nsIContentHandle* node); public: diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index ff17c326e..aacc5a3e0 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -123,181 +123,178 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, switch (aNamespace) { case kNameSpaceID_XHTML: if (nsHtml5Atoms::img == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); - nsString* srcset = + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); + nsHtml5String srcset = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET); - nsString* crossOrigin = + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* referrerPolicy = + nsHtml5String referrerPolicy = aAttributes->getValue(nsHtml5AttributeName::ATTR_REFERRERPOLICY); - nsString* sizes = + nsHtml5String sizes = aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES); - mSpeculativeLoadQueue.AppendElement()-> - InitImage(url ? *url : NullString(), - crossOrigin ? *crossOrigin : NullString(), - referrerPolicy ? *referrerPolicy : NullString(), - srcset ? *srcset : NullString(), - sizes ? *sizes : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitImage( + url, crossOrigin, referrerPolicy, srcset, sizes); } else if (nsHtml5Atoms::source == aName) { - nsString* srcset = + nsHtml5String srcset = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET); // Sources without srcset cannot be selected. The source could also be // for a media element, but in that context doesn't use srcset. See // comments in nsHtml5SpeculativeLoad.h about preloading if (srcset) { - nsString* sizes = + nsHtml5String sizes = aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES); - nsString* type = + nsHtml5String type = aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); - nsString* media = + nsHtml5String media = aAttributes->getValue(nsHtml5AttributeName::ATTR_MEDIA); - mSpeculativeLoadQueue.AppendElement()-> - InitPictureSource(*srcset, - sizes ? *sizes : NullString(), - type ? *type : NullString(), - media ? *media : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitPictureSource( + srcset, sizes, type, media); } } else if (nsHtml5Atoms::script == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetScriptLineNumberAndFreeze, content, tokenizer->getLineNumber()); - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); if (url) { - nsString* charset = aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); - nsString* type = aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); - nsString* crossOrigin = + nsHtml5String charset = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); + nsHtml5String type = + aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitScript(*url, - (charset) ? *charset : EmptyString(), - (type) ? *type : EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString(), - mode == NS_HTML5TREE_BUILDER_IN_HEAD); + mSpeculativeLoadQueue.AppendElement()->InitScript( + url, + charset, + type, + crossOrigin, + integrity, + mode == NS_HTML5TREE_BUILDER_IN_HEAD); mCurrentHtmlScriptIsAsyncOrDefer = aAttributes->contains(nsHtml5AttributeName::ATTR_ASYNC) || aAttributes->contains(nsHtml5AttributeName::ATTR_DEFER); } } else if (nsHtml5Atoms::link == aName) { - nsString* rel = aAttributes->getValue(nsHtml5AttributeName::ATTR_REL); + nsHtml5String rel = + aAttributes->getValue(nsHtml5AttributeName::ATTR_REL); // Not splitting on space here is bogus but the old parser didn't even // do a case-insensitive check. if (rel) { - if (rel->LowerCaseEqualsASCII("stylesheet")) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + if (rel.LowerCaseEqualsASCII("stylesheet")) { + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - nsString* charset = aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); - nsString* crossOrigin = + nsHtml5String charset = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitStyle(*url, - (charset) ? *charset : EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitStyle( + url, charset, crossOrigin, integrity); } - } else if (rel->LowerCaseEqualsASCII("preconnect")) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + } else if (rel.LowerCaseEqualsASCII("preconnect")) { + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - nsString* crossOrigin = + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - mSpeculativeLoadQueue.AppendElement()-> - InitPreconnect(*url, (crossOrigin) ? *crossOrigin : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitPreconnect( + url, crossOrigin); } } } } else if (nsHtml5Atoms::video == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_POSTER); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_POSTER); if (url) { - mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString(), - NullString(), - NullString(), - NullString()); + mSpeculativeLoadQueue.AppendElement()->InitImage( + url, nullptr, nullptr, nullptr, nullptr); } } else if (nsHtml5Atoms::style == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetStyleLineNumber, content, tokenizer->getLineNumber()); } else if (nsHtml5Atoms::html == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); - if (url) { - mSpeculativeLoadQueue.AppendElement()->InitManifest(*url); - } else { - mSpeculativeLoadQueue.AppendElement()->InitManifest(EmptyString()); - } + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); + mSpeculativeLoadQueue.AppendElement()->InitManifest(url); } else if (nsHtml5Atoms::base == aName) { - nsString* url = - aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - mSpeculativeLoadQueue.AppendElement()->InitBase(*url); + mSpeculativeLoadQueue.AppendElement()->InitBase(url); } } else if (nsHtml5Atoms::meta == aName) { if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString( "content-security-policy", aAttributes->getValue(nsHtml5AttributeName::ATTR_HTTP_EQUIV))) { - nsString* csp = aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); + nsHtml5String csp = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); if (csp) { - mSpeculativeLoadQueue.AppendElement()->InitMetaCSP(*csp); + mSpeculativeLoadQueue.AppendElement()->InitMetaCSP(csp); } } else if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString( "referrer", aAttributes->getValue(nsHtml5AttributeName::ATTR_NAME))) { - nsString* referrerPolicy = aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); + nsHtml5String referrerPolicy = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); if (referrerPolicy) { - mSpeculativeLoadQueue.AppendElement()->InitMetaReferrerPolicy(*referrerPolicy); + mSpeculativeLoadQueue.AppendElement()->InitMetaReferrerPolicy( + referrerPolicy); } } } break; case kNameSpaceID_SVG: if (nsHtml5Atoms::image == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); if (url) { - mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString(), - NullString(), - NullString(), - NullString()); + mSpeculativeLoadQueue.AppendElement()->InitImage( + url, nullptr, nullptr, nullptr, nullptr); } } else if (nsHtml5Atoms::script == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetScriptLineNumberAndFreeze, content, tokenizer->getLineNumber()); - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); if (url) { - nsString* type = aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); - nsString* crossOrigin = + nsHtml5String type = + aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitScript(*url, - EmptyString(), - (type) ? *type : EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString(), - mode == NS_HTML5TREE_BUILDER_IN_HEAD); + mSpeculativeLoadQueue.AppendElement()->InitScript( + url, + nullptr, + type, + crossOrigin, + integrity, + mode == NS_HTML5TREE_BUILDER_IN_HEAD); } } else if (nsHtml5Atoms::style == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetStyleLineNumber, content, tokenizer->getLineNumber()); - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); if (url) { - nsString* crossOrigin = + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitStyle(*url, EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitStyle( + url, nullptr, crossOrigin, integrity); } } break; @@ -320,18 +317,23 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, } } else if (aNamespace == kNameSpaceID_XHTML) { if (nsHtml5Atoms::html == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); if (url) { - treeOp->Init(eTreeOpProcessOfflineManifest, *url); + nsString + urlString; // Not Auto, because using it to hold nsStringBuffer* + url.ToString(urlString); + treeOp->Init(eTreeOpProcessOfflineManifest, urlString); } else { treeOp->Init(eTreeOpProcessOfflineManifest, EmptyString()); } } else if (nsHtml5Atoms::base == aName && mViewSource) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - mViewSource->AddBase(*url); + mViewSource->AddBase(url); } } } @@ -743,17 +745,19 @@ nsHtml5TreeBuilder::end() } void -nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, nsString* aPublicId, nsString* aSystemId) +nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, + nsHtml5String aPublicId, + nsHtml5String aSystemId) { NS_PRECONDITION(aName, "Null name"); - + nsString publicId; // Not Auto, because using it to hold nsStringBuffer* + nsString systemId; // Not Auto, because using it to hold nsStringBuffer* + aPublicId.ToString(publicId); + aSystemId.ToString(systemId); if (mBuilder) { nsCOMPtr name = nsHtml5TreeOperation::Reget(aName); - nsresult rv = - nsHtml5TreeOperation::AppendDoctypeToDocument(name, - *aPublicId, - *aSystemId, - mBuilder); + nsresult rv = nsHtml5TreeOperation::AppendDoctypeToDocument( + name, publicId, systemId, mBuilder); if (NS_FAILED(rv)) { MarkAsBrokenAndRequestSuspension(rv); } @@ -762,7 +766,7 @@ nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, nsString* aPublicId, nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); - treeOp->Init(aName, *aPublicId, *aSystemId); + treeOp->Init(aName, publicId, systemId); // nsXMLContentSink can flush here, but what's the point? // It can also interrupt here, but we can't. } diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index af246a253..3877e01b8 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -319,11 +319,10 @@ nsHtml5TreeOperation::AddAttributes(nsIContent* aNode, if (!node->HasAttr(nsuri, localName)) { // prefix doesn't need regetting. it is always null or a static atom // local name is never null - node->SetAttr(nsuri, - localName, - aAttributes->getPrefixNoBoundsCheck(i), - *(aAttributes->getValueNoBoundsCheck(i)), - true); + nsString value; // Not Auto, because using it to hold nsStringBuffer* + aAttributes->getValueNoBoundsCheck(i).ToString(value); + node->SetAttr( + nsuri, localName, aAttributes->getPrefixNoBoundsCheck(i), value, true); // XXX what to do with nsresult? } } @@ -418,12 +417,14 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs, nsCOMPtr prefix = aAttributes->getPrefixNoBoundsCheck(i); int32_t nsuri = aAttributes->getURINoBoundsCheck(i); + nsString value; // Not Auto, because using it to hold nsStringBuffer* + aAttributes->getValueNoBoundsCheck(i).ToString(value); if (aNs == kNameSpaceID_XHTML && nsHtml5Atoms::a == aName && nsHtml5Atoms::name == localName) { // This is an HTML5-incompliant Geckoism. // Remove when fixing bug 582361 - NS_ConvertUTF16toUTF8 cname(*(aAttributes->getValueNoBoundsCheck(i))); + NS_ConvertUTF16toUTF8 cname(value); NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting())); newContent->SetAttr(nsuri, localName, @@ -431,7 +432,6 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs, uv, false); } else { - nsString& value = *(aAttributes->getValueNoBoundsCheck(i)); newContent->SetAttr(nsuri, localName, prefix, diff --git a/parser/html/nsHtml5UTF16Buffer.cpp b/parser/html/nsHtml5UTF16Buffer.cpp index f70365ce4..0d6870bc4 100644 --- a/parser/html/nsHtml5UTF16Buffer.cpp +++ b/parser/html/nsHtml5UTF16Buffer.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5UTF16Buffer.h b/parser/html/nsHtml5UTF16Buffer.h index cf810e124..c94245f74 100644 --- a/parser/html/nsHtml5UTF16Buffer.h +++ b/parser/html/nsHtml5UTF16Buffer.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5ViewSourceUtils.cpp b/parser/html/nsHtml5ViewSourceUtils.cpp index 4dd33fc05..b2f635bff 100644 --- a/parser/html/nsHtml5ViewSourceUtils.cpp +++ b/parser/html/nsHtml5ViewSourceUtils.cpp @@ -6,32 +6,35 @@ #include "nsHtml5ViewSourceUtils.h" #include "nsHtml5AttributeName.h" #include "mozilla/Preferences.h" -#include "mozilla/UniquePtr.h" +#include "nsHtml5String.h" // static nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewBodyAttributes() { nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0); - auto id = MakeUnique(NS_LITERAL_STRING("viewsource")); - bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id.release(), -1); + nsHtml5String id = nsHtml5Portability::newStringFromLiteral("viewsource"); + bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id, -1); - auto klass = MakeUnique(); + nsString klass; if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) { - klass->Append(NS_LITERAL_STRING("wrap ")); + klass.Append(NS_LITERAL_STRING("wrap ")); } if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) { - klass->Append(NS_LITERAL_STRING("highlight")); + klass.Append(NS_LITERAL_STRING("highlight")); } - if (!klass->IsEmpty()) { - bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass.release(), -1); + if (!klass.IsEmpty()) { + bodyAttrs->addAttribute( + nsHtml5AttributeName::ATTR_CLASS, nsHtml5String::FromString(klass), -1); } int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4); if (tabSize > 0) { - auto style = MakeUnique(NS_LITERAL_STRING("-moz-tab-size: ")); - style->AppendInt(tabSize); - bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_STYLE, style.release(), -1); + nsString style; + style.AssignASCII("-moz-tab-size: "); + style.AppendInt(tabSize); + bodyAttrs->addAttribute( + nsHtml5AttributeName::ATTR_STYLE, nsHtml5String::FromString(style), -1); } return bodyAttrs; @@ -42,12 +45,12 @@ nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewLinkAttributes() { nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); - nsString* rel = new nsString(NS_LITERAL_STRING("stylesheet")); + nsHtml5String rel = nsHtml5Portability::newStringFromLiteral("stylesheet"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1); - nsString* type = new nsString(NS_LITERAL_STRING("text/css")); + nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1); - nsString* href = new nsString( - NS_LITERAL_STRING("resource://gre-resources/viewsource.css")); + nsHtml5String href = nsHtml5Portability::newStringFromLiteral( + "resource://gre-resources/viewsource.css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1); return linkAttrs; } -- cgit v1.2.3 From 6741666a9b9d8a61346b9828e4eab851b39b5d6a Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 5 Jul 2019 11:52:56 -0400 Subject: Issue #1160 - [Basilisk] Remove unused HotFix preferences --- application/basilisk/app/profile/basilisk.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/application/basilisk/app/profile/basilisk.js b/application/basilisk/app/profile/basilisk.js index c229f3523..aa2df6d40 100644 --- a/application/basilisk/app/profile/basilisk.js +++ b/application/basilisk/app/profile/basilisk.js @@ -53,12 +53,6 @@ pref("extensions.getAddons.recommended.browseURL", "https://@AM_DOMAIN@/?compone pref("extensions.update.autoUpdateDefault", true); -// Leave these for the moment... -pref("extensions.hotfix.id", "firefox-hotfix@mozilla.org"); -pref("extensions.hotfix.cert.checkAttributes", true); -pref("extensions.hotfix.certs.1.sha1Fingerprint", "91:53:98:0C:C1:86:DF:47:8F:35:22:9E:11:C9:A7:31:04:49:A1:AA"); -pref("extensions.hotfix.certs.2.sha1Fingerprint", "39:E7:2B:7A:5B:CF:37:78:F9:5D:4A:E0:53:2D:2F:3D:68:53:C5:60"); - // Also, leave this for the moment... // Check AUS for system add-on updates. pref("extensions.systemAddon.update.url", "https://aus5.mozilla.org/update/3/SystemAddons/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml"); -- cgit v1.2.3 From 48060d3484c9a8bf6c3b29e26591ab956d6061de Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 5 Jul 2019 21:17:46 -0400 Subject: Issue #1160 - Remove HotFix preferences from testing --- testing/profiles/prefs_general.js | 1 - testing/talos/talos/config.py | 2 -- testing/talos/tests/test_talosconfig_browser_config.json | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js index 35680ca43..3ec41b385 100644 --- a/testing/profiles/prefs_general.js +++ b/testing/profiles/prefs_general.js @@ -108,7 +108,6 @@ user_pref("extensions.update.background.url", "http://%(server)s/extensions-dumm user_pref("extensions.blocklist.detailsURL", "http://%(server)s/extensions-dummy/blocklistDetailsURL"); user_pref("extensions.blocklist.itemURL", "http://%(server)s/extensions-dummy/blocklistItemURL"); user_pref("extensions.blocklist.url", "http://%(server)s/extensions-dummy/blocklistURL"); -user_pref("extensions.hotfix.url", "http://%(server)s/extensions-dummy/hotfixURL"); user_pref("extensions.systemAddon.update.url", "http://%(server)s/dummy-system-addons.xml"); // Turn off extension updates so they don't bother tests user_pref("extensions.update.enabled", false); diff --git a/testing/talos/talos/config.py b/testing/talos/talos/config.py index 828e68a15..872bb3543 100644 --- a/testing/talos/talos/config.py +++ b/testing/talos/talos/config.py @@ -123,8 +123,6 @@ DEFAULTS = dict( 'extensions.blocklist.enabled': False, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', - 'extensions.hotfix.url': - 'http://127.0.0.1/extensions-dummy/hotfixURL', 'extensions.update.enabled': False, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL', diff --git a/testing/talos/tests/test_talosconfig_browser_config.json b/testing/talos/tests/test_talosconfig_browser_config.json index 7e7226c9f..b0ba17ad7 100644 --- a/testing/talos/tests/test_talosconfig_browser_config.json +++ b/testing/talos/tests/test_talosconfig_browser_config.json @@ -1 +1 @@ -{'deviceroot': '', 'dirs': {}, 'repository': 'http://hg.mozilla.org/releases/mozilla-release', 'buildid': '20131205075310', 'results_log': 'pathtoresults_log', 'symbols_path': None, 'bcontroller_config': 'pathtobcontroller', 'host': '', 'browser_name': 'Firefox', 'sourcestamp': '39faf812aaec', 'remote': False, 'child_process': 'plugin-container', 'branch_name': '', 'browser_version': '26.0', 'extra_args': '', 'develop': True, 'preferences': {'browser.display.overlaynavbuttons': False, 'extensions.getAddons.get.url': 'http://127.0.0.1/extensions-dummy/repositoryGetURL', 'dom.max_chrome_script_run_time': 0, 'network.proxy.type': 1, 'extensions.update.background.url': 'http://127.0.0.1/extensions-dummy/updateBackgroundURL', 'network.proxy.http': 'localhost', 'plugins.update.url': 'http://127.0.0.1/plugins-dummy/updateCheckURL', 'dom.max_script_run_time': 0, 'extensions.update.enabled': False, 'browser.safebrowsing.keyURL': 'http://127.0.0.1/safebrowsing-dummy/newkey', 'media.navigator.permission.disabled': True, 'app.update.enabled': False, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', 'browser.EULA.override': True, 'extensions.checkCompatibility': False, 'talos.logfile': 'pathtofile', 'browser.safebrowsing.gethashURL': 'http://127.0.0.1/safebrowsing-dummy/gethash', 'extensions.hotfix.url': 'http://127.0.0.1/extensions-dummy/hotfixURL', 'dom.disable_window_move_resize': True, 'network.proxy.http_port': 80, 'browser.dom.window.dump.enabled': True, 'extensions.update.url': 'http://127.0.0.1/extensions-dummy/updateURL', 'browser.chrome.dynamictoolbar': False, 'browser.link.open_newwindow': 2, 'extensions.getAddons.search.url': 'http://127.0.0.1/extensions-dummy/repositorySearchURL', 'browser.cache.disk.smart_size.first_run': False, 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True, 'dom.disable_open_during_load': False, 'extensions.getAddons.search.browseURL': 'http://127.0.0.1/extensions-dummy/repositoryBrowseURL', 'browser.cache.disk.smart_size.enabled': False, 'extensions.getAddons.getWithPerformance.url': 'http://127.0.0.1/extensions-dummy/repositoryGetWithPerformanceURL', 'hangmonitor.timeout': 0, 'extensions.getAddons.maxResults': 0, 'dom.send_after_paint_to_content': True, 'security.fileuri.strict_origin_policy': False, 'media.capturestream_hints.enabled': True, 'extensions.update.notifyUser': False, 'extensions.blocklist.enabled': False, 'browser.bookmarks.max_backups': 0, 'browser.shell.checkDefaultBrowser': False, 'media.peerconnection.enabled': True, 'dom.disable_window_flip': True, 'security.enable_java': False, 'browser.warnOnQuit': False, 'media.navigator.enabled': True, 'browser.safebrowsing.updateURL': 'http://127.0.0.1/safebrowsing-dummy/update', 'dom.allow_scripts_to_close_windows': True, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL'}, 'test_timeout': 1200, 'title': 'qm-pxp01', 'error_filename': 'pathtoerrorfile', 'webserver': 'localhost:15707', 'browser_path':ffox_path, 'port': 20701, 'browser_log': 'browser_output.txt', 'process': 'firefox.exe', 'xperf_path': 'C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe', 'extensions': ['pathtopageloader'], 'fennecIDs': '', 'env': {'NO_EM_RESTART': '1'}, 'init_url': 'http://localhost:15707/getInfo.html', 'browser_wait': 5} \ No newline at end of file +{'deviceroot': '', 'dirs': {}, 'repository': 'http://hg.mozilla.org/releases/mozilla-release', 'buildid': '20131205075310', 'results_log': 'pathtoresults_log', 'symbols_path': None, 'bcontroller_config': 'pathtobcontroller', 'host': '', 'browser_name': 'Firefox', 'sourcestamp': '39faf812aaec', 'remote': False, 'child_process': 'plugin-container', 'branch_name': '', 'browser_version': '26.0', 'extra_args': '', 'develop': True, 'preferences': {'browser.display.overlaynavbuttons': False, 'extensions.getAddons.get.url': 'http://127.0.0.1/extensions-dummy/repositoryGetURL', 'dom.max_chrome_script_run_time': 0, 'network.proxy.type': 1, 'extensions.update.background.url': 'http://127.0.0.1/extensions-dummy/updateBackgroundURL', 'network.proxy.http': 'localhost', 'plugins.update.url': 'http://127.0.0.1/plugins-dummy/updateCheckURL', 'dom.max_script_run_time': 0, 'extensions.update.enabled': False, 'browser.safebrowsing.keyURL': 'http://127.0.0.1/safebrowsing-dummy/newkey', 'media.navigator.permission.disabled': True, 'app.update.enabled': False, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', 'browser.EULA.override': True, 'extensions.checkCompatibility': False, 'talos.logfile': 'pathtofile', 'browser.safebrowsing.gethashURL': 'http://127.0.0.1/safebrowsing-dummy/gethash', 'dom.disable_window_move_resize': True, 'network.proxy.http_port': 80, 'browser.dom.window.dump.enabled': True, 'extensions.update.url': 'http://127.0.0.1/extensions-dummy/updateURL', 'browser.chrome.dynamictoolbar': False, 'browser.link.open_newwindow': 2, 'extensions.getAddons.search.url': 'http://127.0.0.1/extensions-dummy/repositorySearchURL', 'browser.cache.disk.smart_size.first_run': False, 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True, 'dom.disable_open_during_load': False, 'extensions.getAddons.search.browseURL': 'http://127.0.0.1/extensions-dummy/repositoryBrowseURL', 'browser.cache.disk.smart_size.enabled': False, 'extensions.getAddons.getWithPerformance.url': 'http://127.0.0.1/extensions-dummy/repositoryGetWithPerformanceURL', 'hangmonitor.timeout': 0, 'extensions.getAddons.maxResults': 0, 'dom.send_after_paint_to_content': True, 'security.fileuri.strict_origin_policy': False, 'media.capturestream_hints.enabled': True, 'extensions.update.notifyUser': False, 'extensions.blocklist.enabled': False, 'browser.bookmarks.max_backups': 0, 'browser.shell.checkDefaultBrowser': False, 'media.peerconnection.enabled': True, 'dom.disable_window_flip': True, 'security.enable_java': False, 'browser.warnOnQuit': False, 'media.navigator.enabled': True, 'browser.safebrowsing.updateURL': 'http://127.0.0.1/safebrowsing-dummy/update', 'dom.allow_scripts_to_close_windows': True, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL'}, 'test_timeout': 1200, 'title': 'qm-pxp01', 'error_filename': 'pathtoerrorfile', 'webserver': 'localhost:15707', 'browser_path':ffox_path, 'port': 20701, 'browser_log': 'browser_output.txt', 'process': 'firefox.exe', 'xperf_path': 'C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe', 'extensions': ['pathtopageloader'], 'fennecIDs': '', 'env': {'NO_EM_RESTART': '1'}, 'init_url': 'http://localhost:15707/getInfo.html', 'browser_wait': 5} -- cgit v1.2.3 From 24ad244d47034b36e433797914718baaffa5dada Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 5 Jul 2019 21:18:04 -0400 Subject: Issue #1160 - Remove HotFix Preferences from Telemetry --- toolkit/components/telemetry/TelemetryEnvironment.jsm | 2 -- toolkit/components/telemetry/docs/data/environment.rst | 1 - .../components/telemetry/tests/unit/test_TelemetryEnvironment.js | 8 +------- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/toolkit/components/telemetry/TelemetryEnvironment.jsm b/toolkit/components/telemetry/TelemetryEnvironment.jsm index 295679ca4..391ea4bb4 100644 --- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -196,7 +196,6 @@ const PREF_DISTRIBUTION_ID = "distribution.id"; const PREF_DISTRIBUTION_VERSION = "distribution.version"; const PREF_DISTRIBUTOR = "app.distributor"; const PREF_DISTRIBUTOR_CHANNEL = "app.distributor.channel"; -const PREF_HOTFIX_LASTVERSION = "extensions.hotfix.lastVersion"; const PREF_APP_PARTNER_BRANCH = "app.partner."; const PREF_PARTNER_ID = "mozilla.partner.id"; const PREF_UPDATE_ENABLED = "app.update.enabled"; @@ -1050,7 +1049,6 @@ EnvironmentCache.prototype = { vendor: Services.appinfo.vendor || null, platformVersion: Services.appinfo.platformVersion || null, xpcomAbi: Services.appinfo.XPCOMABI, - hotfixVersion: Preferences.get(PREF_HOTFIX_LASTVERSION, null), }; // Add |architecturesInBinary| only for Mac Universal builds. diff --git a/toolkit/components/telemetry/docs/data/environment.rst b/toolkit/components/telemetry/docs/data/environment.rst index ff0d204a4..0c259fa85 100644 --- a/toolkit/components/telemetry/docs/data/environment.rst +++ b/toolkit/components/telemetry/docs/data/environment.rst @@ -31,7 +31,6 @@ Structure: vendor: , // e.g. "Mozilla" platformVersion: , // e.g. "35.0" xpcomAbi: , // e.g. "x86-msvc" - hotfixVersion: , // e.g. "20141211.01" }, settings: { addonCompatibilityCheckEnabled: , // Whether application compatibility is respected for add-ons diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js index 35181272a..2518a80ba 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js @@ -33,7 +33,6 @@ const PLATFORM_VERSION = "1.9.2"; const APP_VERSION = "1"; const APP_ID = "xpcshell@tests.mozilla.org"; const APP_NAME = "XPCShell"; -const APP_HOTFIX_VERSION = "2.3.4a"; const DISTRIBUTION_ID = "distributor-id"; const DISTRIBUTION_VERSION = "4.5.6b"; @@ -385,10 +384,8 @@ function checkBuildSection(data) { Assert.equal(data.build[f], expectedInfo[f], f + " must have the correct value."); } - // Make sure architecture and hotfixVersion are in the environment. + // Make sure architecture is in the environment. Assert.ok(checkString(data.build.architecture)); - Assert.ok(checkString(data.build.hotfixVersion)); - Assert.equal(data.build.hotfixVersion, APP_HOTFIX_VERSION); if (gIsMac) { let macUtils = Cc["@mozilla.org/xpcom/mac-utils;1"].getService(Ci.nsIMacUtils); @@ -830,9 +827,6 @@ add_task(function* setup() { gHttpServer.registerDirectory("/data/", do_get_cwd()); do_register_cleanup(() => gHttpServer.stop(() => {})); - // Spoof the the hotfixVersion - Preferences.set("extensions.hotfix.lastVersion", APP_HOTFIX_VERSION); - // Create the attribution data file, so that settings.attribution will exist. // The attribution functionality only exists in Firefox. if (AppConstants.MOZ_BUILD_APP == "browser") { -- cgit v1.2.3 From e0598b0ae2c748f1b38759d66e7a759aec04a6b9 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Sun, 7 Jul 2019 20:02:35 +0300 Subject: Avoid multiple hashtable lookups in DisplayItemData destructor UXP has: MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas && sAliveDisplayItemDatas >Contains(this)); sAliveDisplayItemDatas->RemoveEntry(this); and this gets hit during frame destruction. Combine these checks. --- layout/base/FrameLayerBuilder.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index e87d9dc09..934d108e0 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -272,8 +272,13 @@ FrameLayerBuilder::DisplayItemData::~DisplayItemData() array->RemoveElement(this); } - MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas && sAliveDisplayItemDatas->Contains(this)); - sAliveDisplayItemDatas->RemoveEntry(this); + MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas); + nsPtrHashKey* entry + = sAliveDisplayItemDatas->GetEntry(this); + MOZ_RELEASE_ASSERT(entry); + + sAliveDisplayItemDatas->RemoveEntry(entry); + if (sAliveDisplayItemDatas->Count() == 0) { delete sAliveDisplayItemDatas; sAliveDisplayItemDatas = nullptr; -- cgit v1.2.3 From 20e3587ef5a97f190da7a4e674e988d7189c795c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 8 Jul 2019 02:17:07 +0200 Subject: Avoid type confusion in ArrayJoinDenseKernel --- js/src/jsarray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index ec65bce64..ff581beec 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -1048,7 +1048,7 @@ struct StringSeparatorOp template static bool -ArrayJoinDenseKernel(JSContext* cx, SeparatorOp sepOp, HandleNativeObject obj, uint64_t length, +ArrayJoinDenseKernel(JSContext* cx, SeparatorOp sepOp, HandleNativeObject obj, uint32_t length, StringBuffer& sb, uint32_t* numProcessed) { // This loop handles all elements up to initializedLength. If -- cgit v1.2.3 From 570cad82795beeb1eb7011c09be295afa11373ce Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 8 Jul 2019 19:19:56 +0300 Subject: Iterate the frame property list once to collect which child list properties we have Look into optimizing out the hashtable lookups from nsContainerFrame --- layout/base/FrameProperties.h | 27 +++++++++++ layout/generic/nsContainerFrame.cpp | 89 ++++++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 36 deletions(-) diff --git a/layout/base/FrameProperties.h b/layout/base/FrameProperties.h index bba3ee06b..71a79138a 100644 --- a/layout/base/FrameProperties.h +++ b/layout/base/FrameProperties.h @@ -160,6 +160,11 @@ public: MOZ_ASSERT(mProperties.Length() == 0, "forgot to delete properties"); } + /** + * Return true if we have no properties, otherwise return false. + */ + bool IsEmpty() const { return mProperties.IsEmpty(); } + /** * Set a property value. This requires a linear search through * the properties of the frame. Any existing value for the property @@ -241,6 +246,28 @@ public: { DeleteInternal(aProperty, aFrame); } + + /** + * Call @aFunction for each property or until @aFunction returns false. + */ + template + void ForEach(F aFunction) const + { +#ifdef DEBUG + size_t len = mProperties.Length(); +#endif + for (const auto& prop : mProperties) { + bool shouldContinue = aFunction(prop.mProperty, prop.mValue); +#ifdef DEBUG + MOZ_ASSERT(len == mProperties.Length(), + "frame property list was modified by ForEach callback!"); +#endif + if (!shouldContinue) { + return; + } + } + } + /** * Remove and destroy all property values for the frame. */ diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 2933ac4cf..abf687c9b 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -219,24 +219,49 @@ nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot) // Destroy frames on the principal child list. mFrames.DestroyFramesFrom(aDestructRoot); + + if (MOZ_UNLIKELY(!mProperties.IsEmpty())) { + using T = mozilla::FrameProperties::UntypedDescriptor; + bool hasO = false, hasOC = false, hasEOC = false, hasBackdrop = false; + mProperties.ForEach([&] (const T& aProp, void*) { + if (aProp == OverflowProperty()) { + hasO = true; + } else if (aProp == OverflowContainersProperty()) { + hasOC = true; + } else if (aProp == ExcessOverflowContainersProperty()) { + hasEOC = true; + } else if (aProp == BackdropProperty()) { + hasBackdrop = true; + } + return true; + }); + // Destroy frames on the auxiliary frame lists and delete the lists. nsPresContext* pc = PresContext(); nsIPresShell* shell = pc->PresShell(); - SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); + if (hasO) { + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); + } - MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers) || - !(GetProperty(nsContainerFrame::OverflowContainersProperty()) || - GetProperty(nsContainerFrame::ExcessOverflowContainersProperty())), - "this type of frame should't have overflow containers"); - SafelyDestroyFrameListProp(aDestructRoot, shell, - OverflowContainersProperty()); - SafelyDestroyFrameListProp(aDestructRoot, shell, - ExcessOverflowContainersProperty()); + MOZ_ASSERT(IsFrameOfType(eCanContainOverflowContainers) || + !(hasOC || hasEOC), + "this type of frame shouldn't have overflow containers"); + if (hasOC) { + SafelyDestroyFrameListProp(aDestructRoot, shell, + OverflowContainersProperty()); + } + if (hasEOC) { + SafelyDestroyFrameListProp(aDestructRoot, shell, + ExcessOverflowContainersProperty()); + } MOZ_ASSERT(!GetProperty(BackdropProperty()) || StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE, "only top layer frame may have backdrop"); - SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); + if (hasBackdrop) { + SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); + } +} nsSplittableFrame::DestroyFrom(aDestructRoot); } @@ -274,36 +299,28 @@ nsContainerFrame::GetChildList(ChildListID aListID) const } } -static void -AppendIfNonempty(const nsIFrame* aFrame, - nsContainerFrame::FrameListPropertyDescriptor aProperty, - nsTArray* aLists, - nsIFrame::ChildListID aListID) -{ - if (nsFrameList* list = aFrame->GetProperty(aProperty)) { - list->AppendIfNonempty(aLists, aListID); - } -} - void nsContainerFrame::GetChildLists(nsTArray* aLists) const { mFrames.AppendIfNonempty(aLists, kPrincipalList); - ::AppendIfNonempty(this, OverflowProperty(), - aLists, kOverflowList); - if (IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) { - ::AppendIfNonempty(this, OverflowContainersProperty(), - aLists, kOverflowContainersList); - ::AppendIfNonempty(this, ExcessOverflowContainersProperty(), - aLists, kExcessOverflowContainersList); - } - // Bypass BackdropProperty hashtable lookup for any in-flow frames - // since frames in the top layer (only which can have backdrop) are - // definitely out-of-flow. - if (GetStateBits() & NS_FRAME_OUT_OF_FLOW) { - ::AppendIfNonempty(this, BackdropProperty(), - aLists, kBackdropList); - } + using T = mozilla::FrameProperties::UntypedDescriptor; + mProperties.ForEach([this, aLists] (const T& aProp, void* aValue) { + typedef const nsFrameList* L; + if (aProp == OverflowProperty()) { + L(aValue)->AppendIfNonempty(aLists, kOverflowList); + } else if (aProp == OverflowContainersProperty()) { + MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers), + "found unexpected OverflowContainersProperty"); + L(aValue)->AppendIfNonempty(aLists, kOverflowContainersList); + } else if (aProp == ExcessOverflowContainersProperty()) { + MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers), + "found unexpected ExcessOverflowContainersProperty"); + L(aValue)->AppendIfNonempty(aLists, kExcessOverflowContainersList); + } else if (aProp == BackdropProperty()) { + L(aValue)->AppendIfNonempty(aLists, kBackdropList); + } + return true; + }); nsSplittableFrame::GetChildLists(aLists); } -- cgit v1.2.3 From f7f7224dedd63809fbf5532b7ac843cea22d9499 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 8 Jul 2019 21:46:44 +0200 Subject: Remove e10s info from about:support tag #953 --- toolkit/content/aboutSupport.js | 22 ---------------------- toolkit/content/aboutSupport.xhtml | 9 --------- .../locales/en-US/chrome/global/aboutSupport.dtd | 2 -- .../en-US/chrome/global/aboutSupport.properties | 17 ----------------- toolkit/modules/Troubleshoot.jsm | 12 ------------ .../modules/tests/browser/browser_Troubleshoot.js | 7 ------- 6 files changed, 69 deletions(-) diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 8908a0f80..06470f966 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -53,28 +53,6 @@ var snapshotFormatters = { if (data.updateChannel) $("updatechannel-box").textContent = data.updateChannel; - let statusText = stringBundle().GetStringFromName("multiProcessStatus.unknown"); - - // Whitelist of known values with string descriptions: - switch (data.autoStartStatus) { - case 0: - case 1: - case 2: - case 4: - case 6: - case 7: - case 8: - statusText = stringBundle().GetStringFromName("multiProcessStatus." + data.autoStartStatus); - break; - - case 10: - statusText = (Services.appinfo.OS == "Darwin" ? "OS X 10.6 - 10.8" : "Windows XP"); - break; - } - - $("multiprocess-box").textContent = stringBundle().formatStringFromName("multiProcessWindows", - [data.numRemoteWindows, data.numTotalWindows, statusText], 3); - $("safemode-box").textContent = data.safeMode; }, diff --git a/toolkit/content/aboutSupport.xhtml b/toolkit/content/aboutSupport.xhtml index 5e6319182..fff86dff6 100644 --- a/toolkit/content/aboutSupport.xhtml +++ b/toolkit/content/aboutSupport.xhtml @@ -234,15 +234,6 @@ - - - &aboutSupport.appBasicsMultiProcessSupport; - - - - - - &aboutSupport.appBasicsSafeMode; diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd index a2477fb2e..34db4e4c4 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd @@ -64,8 +64,6 @@ Windows/Mac use the term "Folder" instead of "Directory" --> - - diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.properties b/toolkit/locales/en-US/chrome/global/aboutSupport.properties index 564292e3d..be9ce5f33 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties @@ -99,23 +99,6 @@ gpuProcessKillButton = Terminate GPU Process minLibVersions = Expected minimum version loadedLibVersions = Version in use -# LOCALIZATION NOTE %1$S and %2$S will be replaced with the number of remote and the total number -# of windows, respectively, while %3$S will be replaced with one of the status strings below, -# which contains a description of the multi-process preference and status. -# Note: multiProcessStatus.3 doesn't exist because status=3 was deprecated. -multiProcessWindows = %1$S/%2$S (%3$S) -multiProcessStatus.0 = Enabled by user -multiProcessStatus.1 = Enabled by default -multiProcessStatus.2 = Disabled -multiProcessStatus.4 = Disabled by accessibility tools -multiProcessStatus.5 = Disabled by lack of graphics hardware acceleration on Mac OS X -multiProcessStatus.6 = Disabled by unsupported text input -multiProcessStatus.7 = Disabled by add-ons -multiProcessStatus.8 = Disabled forcibly -# No longer in use (bug 1296353) but we might bring this back. -multiProcessStatus.9 = Disabled by graphics hardware acceleration on Windows XP -multiProcessStatus.unknown = Unknown status - asyncPanZoom = Asynchronous Pan/Zoom apzNone = none wheelEnabled = wheel input enabled diff --git a/toolkit/modules/Troubleshoot.jsm b/toolkit/modules/Troubleshoot.jsm index 8d84eec8c..6ee6cb54e 100644 --- a/toolkit/modules/Troubleshoot.jsm +++ b/toolkit/modules/Troubleshoot.jsm @@ -220,18 +220,6 @@ var dataProviders = { } } - data.remoteAutoStart = Services.appinfo.browserTabsRemoteAutostart; - - try { - let e10sStatus = Cc["@mozilla.org/supports-PRUint64;1"] - .createInstance(Ci.nsISupportsPRUint64); - let appinfo = Services.appinfo.QueryInterface(Ci.nsIObserver); - appinfo.observe(e10sStatus, "getE10SBlocked", ""); - data.autoStartStatus = e10sStatus.data; - } catch (e) { - data.autoStartStatus = -1; - } - done(data); }, diff --git a/toolkit/modules/tests/browser/browser_Troubleshoot.js b/toolkit/modules/tests/browser/browser_Troubleshoot.js index 4124be1fb..ebc4de1f9 100644 --- a/toolkit/modules/tests/browser/browser_Troubleshoot.js +++ b/toolkit/modules/tests/browser/browser_Troubleshoot.js @@ -126,13 +126,6 @@ const SNAPSHOT_SCHEMA = { supportURL: { type: "string", }, - remoteAutoStart: { - type: "boolean", - required: true, - }, - autoStartStatus: { - type: "number", - }, numTotalWindows: { type: "number", }, -- cgit v1.2.3 From 18f9b185b67120ba88f5e643b7413ca06c497383 Mon Sep 17 00:00:00 2001 From: Jeroen Vreeken Date: Wed, 10 Jul 2019 11:05:38 +0200 Subject: Allow matroska mime types for video element and MSE Allow avc (h.264) content in matroska/webm containers --- dom/media/fmp4/MP4Decoder.cpp | 3 ++- dom/media/mediasource/ContainerParser.cpp | 3 +++ dom/media/mediasource/MediaSource.cpp | 3 ++- dom/media/mediasource/TrackBuffersManager.cpp | 1 + dom/media/webm/WebMDecoder.cpp | 7 ++++++- dom/media/webm/WebMDemuxer.cpp | 24 +++++++++++++++++++++++- media/libnestegg/include/nestegg.h | 1 + media/libnestegg/src/nestegg.c | 7 ++++++- 8 files changed, 44 insertions(+), 5 deletions(-) diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index 6954e9757..b293c251b 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -172,7 +172,8 @@ bool MP4Decoder::IsH264(const nsACString& aMimeType) { return aMimeType.EqualsLiteral("video/mp4") || - aMimeType.EqualsLiteral("video/avc"); + aMimeType.EqualsLiteral("video/avc") || + aMimeType.EqualsLiteral("video/webm; codecs=avc1"); } /* static */ diff --git a/dom/media/mediasource/ContainerParser.cpp b/dom/media/mediasource/ContainerParser.cpp index 4ae37d7e9..46f2e9557 100644 --- a/dom/media/mediasource/ContainerParser.cpp +++ b/dom/media/mediasource/ContainerParser.cpp @@ -697,6 +697,9 @@ ContainerParser::CreateForMIMEType(const nsACString& aType) if (aType.LowerCaseEqualsLiteral("video/webm") || aType.LowerCaseEqualsLiteral("audio/webm")) { return new WebMContainerParser(aType); } + if (aType.LowerCaseEqualsLiteral("video/x-matroska")) { + return new WebMContainerParser(aType); + } #ifdef MOZ_FMP4 if (aType.LowerCaseEqualsLiteral("video/mp4") || aType.LowerCaseEqualsLiteral("audio/mp4")) { diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index 152c0085a..a262ff52c 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -110,7 +110,8 @@ MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* a } return NS_OK; } - if (mimeType.EqualsASCII("video/webm")) { + if (mimeType.EqualsASCII("video/webm") || + mimeType.EqualsASCII("video/x-matroska")) { if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) || IsWebMForced(aDiagnostics))) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index ac6d82411..3a6f2a5c8 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -814,6 +814,7 @@ TrackBuffersManager::CreateDemuxerforMIMEType() ShutdownDemuxers(); if (mType.LowerCaseEqualsLiteral("video/webm") || + mType.LowerCaseEqualsLiteral("video/x-matroska") || mType.LowerCaseEqualsLiteral("audio/webm")) { mInputDemuxer = new WebMDemuxer(mCurrentInputBuffer, true /* IsMediaSource*/ ); return; diff --git a/dom/media/webm/WebMDecoder.cpp b/dom/media/webm/WebMDecoder.cpp index 9575d6e42..37e1e4a33 100644 --- a/dom/media/webm/WebMDecoder.cpp +++ b/dom/media/webm/WebMDecoder.cpp @@ -41,7 +41,7 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, } const bool isWebMAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/webm"); - const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm"); + const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm") || aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ; if (!isWebMAudio && !isWebMVideo) { return false; } @@ -74,6 +74,11 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, continue; } #endif + + if (IsH264CodecString(codec)) { + continue; + } + // Some unsupported codec. return false; } diff --git a/dom/media/webm/WebMDemuxer.cpp b/dom/media/webm/WebMDemuxer.cpp index 013da9b2c..2b6d46186 100644 --- a/dom/media/webm/WebMDemuxer.cpp +++ b/dom/media/webm/WebMDemuxer.cpp @@ -326,6 +326,20 @@ WebMDemuxer::ReadMetadata() case NESTEGG_CODEC_AV1: mInfo.mVideo.mMimeType = "video/webm; codecs=av1"; break; + case NESTEGG_CODEC_AVC1: { + mInfo.mVideo.mMimeType = "video/webm; codecs=avc1"; + + unsigned char* data = 0; + size_t length = 0; + r = nestegg_track_codec_data(context, track, 0, &data, &length); + if (r == -1) { + return NS_ERROR_FAILURE; + } + + mInfo.mVideo.mExtraData = new MediaByteBuffer(length); + mInfo.mVideo.mExtraData->AppendElements(data, length); + break; + } default: NS_WARNING("Unknown WebM video codec"); return NS_ERROR_FAILURE; @@ -662,6 +676,9 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl isKeyframe = AOMDecoder::IsKeyframe(sample); break; #endif + case NESTEGG_CODEC_AVC1: + isKeyframe = nestegg_packet_has_keyframe(holder->Packet()); + break; default: NS_WARNING("Cannot detect keyframes in unknown WebM video codec"); return NS_ERROR_FAILURE; @@ -682,7 +699,7 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl dimensions = AOMDecoder::GetFrameSize(sample); break; #endif - } + } if (mLastSeenFrameSize.isSome() && (dimensions != mLastSeenFrameSize.value())) { mInfo.mVideo.mDisplay = dimensions; @@ -749,6 +766,11 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl if (aType == TrackInfo::kVideoTrack) { sample->mTrackInfo = mSharedVideoTrackInfo; } + + if (mVideoCodec == NESTEGG_CODEC_AVC1) { + sample->mExtraData = mInfo.mVideo.mExtraData; + } + aSamples->Push(sample); } return NS_OK; diff --git a/media/libnestegg/include/nestegg.h b/media/libnestegg/include/nestegg.h index 2baa50bc5..777555f7b 100644 --- a/media/libnestegg/include/nestegg.h +++ b/media/libnestegg/include/nestegg.h @@ -72,6 +72,7 @@ extern "C" { #define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */ #define NESTEGG_CODEC_OPUS 3 /**< Track uses Xiph Opus codec. */ #define NESTEGG_CODEC_AV1 4 /**< Track uses AOMedia AV1 codec. */ +#define NESTEGG_CODEC_AVC1 5 /**< Track uses AVC1 'h264' */ #define NESTEGG_CODEC_UNKNOWN INT_MAX /**< Track uses unknown codec. */ #define NESTEGG_VIDEO_MONO 0 /**< Track is mono video. */ diff --git a/media/libnestegg/src/nestegg.c b/media/libnestegg/src/nestegg.c index 61c30ec6b..6f0d55b46 100644 --- a/media/libnestegg/src/nestegg.c +++ b/media/libnestegg/src/nestegg.c @@ -157,6 +157,7 @@ enum ebml_type_enum { #define TRACK_ID_AV1 "V_AV1" #define TRACK_ID_VORBIS "A_VORBIS" #define TRACK_ID_OPUS "A_OPUS" +#define TRACK_ID_AVC1 "V_MPEG4/ISO/AVC" /* Track Encryption */ #define CONTENT_ENC_ALGO_AES 5 @@ -2401,6 +2402,9 @@ nestegg_track_codec_id(nestegg * ctx, unsigned int track) if (strcmp(codec_id, TRACK_ID_OPUS) == 0) return NESTEGG_CODEC_OPUS; + if (strcmp(codec_id, TRACK_ID_AVC1) == 0) + return NESTEGG_CODEC_AVC1; + return NESTEGG_CODEC_UNKNOWN; } @@ -2459,7 +2463,8 @@ nestegg_track_codec_data(nestegg * ctx, unsigned int track, unsigned int item, return -1; if (nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_VORBIS && - nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS) + nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS && + nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_AVC1) return -1; if (ne_get_binary(entry->codec_private, &codec_private) != 0) -- cgit v1.2.3 From 31addeaac8841867008699478ef55e1c1b3d68a7 Mon Sep 17 00:00:00 2001 From: Jeroen Vreeken Date: Thu, 11 Jul 2019 16:36:22 +0200 Subject: Make matroska mime type checking more consistent. --- dom/media/mediasource/ContainerParser.cpp | 2 +- dom/media/mediasource/MediaSource.cpp | 3 ++- dom/media/mediasource/TrackBuffersManager.cpp | 1 + dom/media/webm/WebMDecoder.cpp | 9 ++++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dom/media/mediasource/ContainerParser.cpp b/dom/media/mediasource/ContainerParser.cpp index 46f2e9557..b4dcfde8a 100644 --- a/dom/media/mediasource/ContainerParser.cpp +++ b/dom/media/mediasource/ContainerParser.cpp @@ -697,7 +697,7 @@ ContainerParser::CreateForMIMEType(const nsACString& aType) if (aType.LowerCaseEqualsLiteral("video/webm") || aType.LowerCaseEqualsLiteral("audio/webm")) { return new WebMContainerParser(aType); } - if (aType.LowerCaseEqualsLiteral("video/x-matroska")) { + if (aType.LowerCaseEqualsLiteral("video/x-matroska") || aType.LowerCaseEqualsLiteral("audio/x-matroska")) { return new WebMContainerParser(aType); } diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index a262ff52c..1c276cdc1 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -118,7 +118,8 @@ MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* a } return NS_OK; } - if (mimeType.EqualsASCII("audio/webm")) { + if (mimeType.EqualsASCII("audio/webm") || + mimeType.EqualsASCII("audio/x-matroska")) { if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) || Preferences::GetBool("media.mediasource.webm.audio.enabled", true))) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index 3a6f2a5c8..21fb158b5 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -815,6 +815,7 @@ TrackBuffersManager::CreateDemuxerforMIMEType() if (mType.LowerCaseEqualsLiteral("video/webm") || mType.LowerCaseEqualsLiteral("video/x-matroska") || + mType.LowerCaseEqualsLiteral("audio/x-matroska") || mType.LowerCaseEqualsLiteral("audio/webm")) { mInputDemuxer = new WebMDemuxer(mCurrentInputBuffer, true /* IsMediaSource*/ ); return; diff --git a/dom/media/webm/WebMDecoder.cpp b/dom/media/webm/WebMDecoder.cpp index 37e1e4a33..5cb943742 100644 --- a/dom/media/webm/WebMDecoder.cpp +++ b/dom/media/webm/WebMDecoder.cpp @@ -41,8 +41,11 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, } const bool isWebMAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/webm"); - const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm") || aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ; - if (!isWebMAudio && !isWebMVideo) { + const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm"); + const bool isMatroskaAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/x-matroska") ; + const bool isMatroskaVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ; + + if (!isWebMAudio && !isWebMVideo && !isMatroskaAudio && !isMatroskaVideo) { return false; } @@ -63,7 +66,7 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, } // Note: Only accept VP8/VP9 in a video content type, not in an audio // content type. - if (isWebMVideo && + if ((isWebMVideo || isMatroskaVideo) && (codec.EqualsLiteral("vp8") || codec.EqualsLiteral("vp8.0") || codec.EqualsLiteral("vp9") || codec.EqualsLiteral("vp9.0"))) { -- cgit v1.2.3 From a059b0688b82ca1fc51eae621916eb6dd008d873 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 12 Jul 2019 00:30:22 +0300 Subject: Fix comments for Frameproperties https://bugzilla.mozilla.org/show_bug.cgi?id=1373884 Fixes comments for Frameproperties. These comments went unnoticed earlier. No code changes. --- layout/base/FrameProperties.h | 2 +- layout/generic/nsIFrame.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/base/FrameProperties.h b/layout/base/FrameProperties.h index 71a79138a..74513abac 100644 --- a/layout/base/FrameProperties.h +++ b/layout/base/FrameProperties.h @@ -62,7 +62,7 @@ protected: * * To use this class, declare a global (i.e., file, class or function-scope * static member) FramePropertyDescriptor and pass its address as - * aProperty in the FramePropertyTable methods. + * aProperty in the FrameProperties methods. */ template struct FramePropertyDescriptor : public FramePropertyDescriptorUntyped diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 37a4e3749..ec3568483 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -997,7 +997,7 @@ public: #define NS_DECLARE_FRAME_PROPERTY_WITH_DTOR_NEVER_CALLED(prop, type) \ static void AssertOnDestroyingProperty##prop(type*) { \ MOZ_ASSERT_UNREACHABLE("Frame property " #prop " should never " \ - "be destroyed by the FramePropertyTable"); \ + "be destroyed by the FrameProperties class"); \ } \ NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(prop, type, \ AssertOnDestroyingProperty##prop) -- cgit v1.2.3 From fdd8d6347e611ef2e045d098f8cc8840deb00355 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 12 Jul 2019 16:37:23 +0200 Subject: Stop building /caps unified and fix deprot. Tag #80 --- caps/moz.build | 5 ----- caps/nsJSPrincipals.cpp | 2 ++ caps/nsNullPrincipal.cpp | 2 ++ caps/nsNullPrincipalURI.cpp | 6 ++++++ caps/nsPrincipal.cpp | 2 ++ caps/nsScriptSecurityManager.cpp | 2 ++ 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/caps/moz.build b/caps/moz.build index 58b45e360..dc47ecbba 100644 --- a/caps/moz.build +++ b/caps/moz.build @@ -34,12 +34,7 @@ EXPORTS.mozilla = [ ] SOURCES += [ - # Compile this separately since nsExceptionHandler.h conflicts - # with something from nsNullPrincipal.cpp. 'BasePrincipal.cpp', -] - -UNIFIED_SOURCES += [ 'DomainPolicy.cpp', 'nsJSPrincipals.cpp', 'nsNullPrincipal.cpp', diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp index 0f3afa14e..8349aed53 100644 --- a/caps/nsJSPrincipals.cpp +++ b/caps/nsJSPrincipals.cpp @@ -15,6 +15,7 @@ #include "nsMemory.h" #include "nsStringBuffer.h" +#include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/dom/StructuredCloneTags.h" // for mozilla::dom::workers::kJSPrincipalsDebugToken #include "mozilla/dom/workers/Workers.h" @@ -22,6 +23,7 @@ using namespace mozilla; using namespace mozilla::ipc; +using namespace mozilla::dom; NS_IMETHODIMP_(MozExternalRefCountType) nsJSPrincipals::AddRef() diff --git a/caps/nsNullPrincipal.cpp b/caps/nsNullPrincipal.cpp index 6ebf0f129..386344e37 100644 --- a/caps/nsNullPrincipal.cpp +++ b/caps/nsNullPrincipal.cpp @@ -20,6 +20,8 @@ #include "nsIClassInfoImpl.h" #include "nsNetCID.h" #include "nsError.h" +#include "nsIObjectInputStream.h" +#include "nsIObjectOutputStream.h" #include "nsIScriptSecurityManager.h" #include "nsPrincipal.h" #include "nsScriptSecurityManager.h" diff --git a/caps/nsNullPrincipalURI.cpp b/caps/nsNullPrincipalURI.cpp index f8b867160..159928ba6 100644 --- a/caps/nsNullPrincipalURI.cpp +++ b/caps/nsNullPrincipalURI.cpp @@ -6,8 +6,12 @@ #include "nsNullPrincipalURI.h" +#include "mozilla/ArrayUtils.h" + #include "mozilla/DebugOnly.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/Services.h" +#include "mozilla/Unused.h" #include "mozilla/ipc/URIParams.h" @@ -15,6 +19,8 @@ #include "nsCRT.h" #include "nsIUUIDGenerator.h" +using namespace mozilla; + //////////////////////////////////////////////////////////////////////////////// //// nsNullPrincipalURI diff --git a/caps/nsPrincipal.cpp b/caps/nsPrincipal.cpp index 129cdf9a0..d111042c1 100644 --- a/caps/nsPrincipal.cpp +++ b/caps/nsPrincipal.cpp @@ -19,6 +19,8 @@ #include "nsJSPrincipals.h" #include "nsIEffectiveTLDService.h" #include "nsIClassInfoImpl.h" +#include "nsIObjectInputStream.h" +#include "nsIObjectOutputStream.h" #include "nsIProtocolHandler.h" #include "nsError.h" #include "nsIContentSecurityPolicy.h" diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 129a4d0da..bf5f33599 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -59,6 +59,7 @@ #include "mozIApplication.h" #include "mozilla/Preferences.h" #include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/ContentParent.h" #include #include "mozilla/dom/ScriptSettings.h" #include "mozilla/ClearOnShutdown.h" @@ -70,6 +71,7 @@ using namespace mozilla; using namespace mozilla::dom; +using namespace mozilla::ipc; nsIIOService *nsScriptSecurityManager::sIOService = nullptr; nsIStringBundle *nsScriptSecurityManager::sStrBundle = nullptr; -- cgit v1.2.3 From dd5d075b1a2651ea020a34e9c54e1959fc9bf29b Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 12 Jul 2019 23:30:59 +0200 Subject: Stop building /chrome unified and fix deprot. Tag #80 --- chrome/moz.build | 2 +- chrome/nsChromeRegistry.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/moz.build b/chrome/moz.build index b75e9435d..15439356a 100644 --- a/chrome/moz.build +++ b/chrome/moz.build @@ -17,7 +17,7 @@ EXPORTS.mozilla.chrome += [ 'RegistryMessageUtils.h', ] -UNIFIED_SOURCES += [ +SOURCES += [ 'nsChromeProtocolHandler.cpp', 'nsChromeRegistry.cpp', 'nsChromeRegistryChrome.cpp', diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 485ca002c..4bd8b4dca 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -14,6 +14,7 @@ #include "nsError.h" #include "nsEscape.h" #include "nsNetUtil.h" +#include "nsIURL.h" #include "nsString.h" #include "nsQueryObject.h" -- cgit v1.2.3 From 197f4cbaa47e5e8b9b1fb578b10046914eb6486e Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 13 Jul 2019 02:41:46 +0200 Subject: Remove WebIDE devtools component. This resolves #1123 --- .../components/customizableui/CustomizableUI.jsm | 5 - devtools/client/framework/devtools-browser.js | 17 - devtools/client/framework/gDevTools.jsm | 11 - devtools/client/locales/en-US/menus.properties | 5 - devtools/client/locales/en-US/webide.dtd | 222 ---- devtools/client/locales/en-US/webide.properties | 92 -- devtools/client/menus.js | 11 - devtools/client/moz.build | 1 - devtools/client/preferences/devtools.js | 3 - .../lib/plugins/app-manager/app-project-editor.js | 56 - .../lib/plugins/app-manager/moz.build | 10 - .../lib/plugins/app-manager/plugin.js | 77 -- .../client/projecteditor/lib/plugins/moz.build | 1 - devtools/client/projecteditor/lib/projecteditor.js | 1 - devtools/client/shared/telemetry.js | 17 - devtools/client/webide/components/moz.build | 10 - devtools/client/webide/components/webideCli.js | 58 - .../webide/components/webideComponents.manifest | 4 - devtools/client/webide/content/addons.js | 135 --- devtools/client/webide/content/addons.xhtml | 31 - devtools/client/webide/content/details.js | 139 --- devtools/client/webide/content/details.xhtml | 54 - .../client/webide/content/devicepreferences.js | 81 -- .../client/webide/content/devicepreferences.xhtml | 49 - devtools/client/webide/content/devicesettings.js | 81 -- .../client/webide/content/devicesettings.xhtml | 50 - devtools/client/webide/content/jar.mn | 38 - devtools/client/webide/content/logs.js | 70 -- devtools/client/webide/content/logs.xhtml | 33 - devtools/client/webide/content/monitor.js | 741 ------------- devtools/client/webide/content/monitor.xhtml | 31 - devtools/client/webide/content/moz.build | 7 - devtools/client/webide/content/newapp.js | 175 --- devtools/client/webide/content/newapp.xul | 33 - devtools/client/webide/content/permissionstable.js | 78 -- .../client/webide/content/permissionstable.xhtml | 36 - devtools/client/webide/content/prefs.js | 108 -- devtools/client/webide/content/prefs.xhtml | 112 -- devtools/client/webide/content/project-listing.js | 42 - .../client/webide/content/project-listing.xhtml | 35 - devtools/client/webide/content/project-panel.js | 11 - devtools/client/webide/content/runtime-listing.js | 66 -- .../client/webide/content/runtime-listing.xhtml | 45 - devtools/client/webide/content/runtime-panel.js | 11 - devtools/client/webide/content/runtimedetails.js | 153 --- .../client/webide/content/runtimedetails.xhtml | 46 - devtools/client/webide/content/simulator.js | 352 ------ devtools/client/webide/content/simulator.xhtml | 99 -- devtools/client/webide/content/webide.js | 1157 -------------------- devtools/client/webide/content/webide.xul | 178 --- devtools/client/webide/content/wifi-auth.js | 44 - devtools/client/webide/content/wifi-auth.xhtml | 45 - devtools/client/webide/modules/addons.js | 197 ---- devtools/client/webide/modules/app-manager.js | 850 -------------- devtools/client/webide/modules/app-projects.js | 235 ---- devtools/client/webide/modules/app-validator.js | 292 ----- devtools/client/webide/modules/build.js | 199 ---- devtools/client/webide/modules/config-view.js | 373 ------- devtools/client/webide/modules/moz.build | 21 - devtools/client/webide/modules/project-list.js | 375 ------- devtools/client/webide/modules/runtime-list.js | 207 ---- devtools/client/webide/modules/runtimes.js | 673 ------------ .../client/webide/modules/simulator-process.js | 325 ------ devtools/client/webide/modules/simulators.js | 368 ------- devtools/client/webide/modules/tab-store.js | 178 --- devtools/client/webide/modules/utils.js | 68 -- devtools/client/webide/moz.build | 23 - devtools/client/webide/test/.eslintrc.js | 6 - .../client/webide/test/addons/adbhelper-linux.xpi | Bin 1293 -> 0 bytes .../webide/test/addons/adbhelper-linux64.xpi | Bin 1293 -> 0 bytes .../client/webide/test/addons/adbhelper-mac64.xpi | Bin 1293 -> 0 bytes .../client/webide/test/addons/adbhelper-win32.xpi | Bin 1293 -> 0 bytes .../webide/test/addons/fxdt-adapters-linux32.xpi | Bin 1156 -> 0 bytes .../webide/test/addons/fxdt-adapters-linux64.xpi | Bin 1156 -> 0 bytes .../webide/test/addons/fxdt-adapters-mac64.xpi | Bin 1156 -> 0 bytes .../webide/test/addons/fxdt-adapters-win32.xpi | Bin 1156 -> 0 bytes .../test/addons/fxos_1_0_simulator-linux.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_1_0_simulator-linux64.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_1_0_simulator-mac64.xpi | Bin 5044 -> 0 bytes .../test/addons/fxos_1_0_simulator-win32.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_2_0_simulator-linux.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_2_0_simulator-linux64.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_2_0_simulator-mac64.xpi | Bin 5043 -> 0 bytes .../test/addons/fxos_2_0_simulator-win32.xpi | Bin 5045 -> 0 bytes .../test/addons/fxos_3_0_simulator-linux.xpi | Bin 5045 -> 0 bytes .../test/addons/fxos_3_0_simulator-linux64.xpi | Bin 5048 -> 0 bytes .../test/addons/fxos_3_0_simulator-mac64.xpi | Bin 5048 -> 0 bytes .../test/addons/fxos_3_0_simulator-win32.xpi | Bin 5044 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-linux.xpi | Bin 5052 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-linux64.xpi | Bin 5055 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-mac64.xpi | Bin 5051 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-win32.xpi | Bin 5051 -> 0 bytes devtools/client/webide/test/addons/simulators.json | 4 - devtools/client/webide/test/app.zip | Bin 480 -> 0 bytes devtools/client/webide/test/app/index.html | 6 - devtools/client/webide/test/app/manifest.webapp | 5 - devtools/client/webide/test/browser.ini | 12 - devtools/client/webide/test/browser_tabs.js | 84 -- devtools/client/webide/test/browser_widget.js | 15 - .../client/webide/test/build_app1/package.json | 5 - .../client/webide/test/build_app2/manifest.webapp | 1 - .../client/webide/test/build_app2/package.json | 10 - .../webide/test/build_app2/stage/empty-directory | 0 .../webide/test/build_app_windows1/package.json | 5 - .../webide/test/build_app_windows2/manifest.webapp | 1 - .../webide/test/build_app_windows2/package.json | 10 - .../test/build_app_windows2/stage/empty-directory | 0 devtools/client/webide/test/chrome.ini | 71 -- devtools/client/webide/test/device_front_shared.js | 219 ---- devtools/client/webide/test/doc_tabs.html | 15 - devtools/client/webide/test/head.js | 248 ----- devtools/client/webide/test/hosted_app.manifest | 3 - devtools/client/webide/test/templates.json | 14 - devtools/client/webide/test/test_addons.html | 176 --- .../client/webide/test/test_app_validator.html | 205 ---- .../webide/test/test_autoconnect_runtime.html | 94 -- .../webide/test/test_autoselect_project.html | 110 -- devtools/client/webide/test/test_basic.html | 55 - devtools/client/webide/test/test_build.html | 128 --- .../webide/test/test_device_permissions.html | 81 -- .../webide/test/test_device_preferences.html | 87 -- .../client/webide/test/test_device_runtime.html | 81 -- .../client/webide/test/test_device_settings.html | 87 -- .../client/webide/test/test_duplicate_import.html | 77 -- .../client/webide/test/test_fullscreenToolbox.html | 67 -- devtools/client/webide/test/test_import.html | 82 -- .../client/webide/test/test_manifestUpdate.html | 98 -- devtools/client/webide/test/test_newapp.html | 46 - devtools/client/webide/test/test_runtime.html | 203 ---- devtools/client/webide/test/test_simulators.html | 426 ------- devtools/client/webide/test/test_telemetry.html | 325 ------ devtools/client/webide/test/test_toolbox.html | 93 -- devtools/client/webide/test/test_zoom.html | 77 -- .../test/validator/no-name-or-icon/home.html | 0 .../test/validator/no-name-or-icon/manifest.webapp | 3 - .../validator/non-absolute-path/manifest.webapp | 7 - .../test/validator/valid/alsoValid/manifest.webapp | 7 - .../client/webide/test/validator/valid/home.html | 0 .../client/webide/test/validator/valid/icon.png | 0 .../webide/test/validator/valid/manifest.webapp | 7 - .../test/validator/wrong-launch-path/icon.png | 0 .../validator/wrong-launch-path/manifest.webapp | 7 - devtools/client/webide/themes/addons.css | 79 -- devtools/client/webide/themes/config-view.css | 80 -- devtools/client/webide/themes/deck.css | 91 -- devtools/client/webide/themes/default-app-icon.png | Bin 5208 -> 0 bytes devtools/client/webide/themes/details.css | 138 --- devtools/client/webide/themes/icons.png | Bin 35353 -> 0 bytes devtools/client/webide/themes/jar.mn | 24 - devtools/client/webide/themes/logs.css | 18 - devtools/client/webide/themes/monitor.css | 86 -- devtools/client/webide/themes/moz.build | 7 - devtools/client/webide/themes/newapp.css | 54 - devtools/client/webide/themes/noise.png | Bin 6216 -> 0 bytes devtools/client/webide/themes/panel-listing.css | 150 --- devtools/client/webide/themes/permissionstable.css | 23 - devtools/client/webide/themes/rocket.svg | 12 - devtools/client/webide/themes/runtimedetails.css | 25 - devtools/client/webide/themes/simulator.css | 41 - devtools/client/webide/themes/throbber.svg | 22 - devtools/client/webide/themes/webide.css | 149 --- devtools/client/webide/themes/wifi-auth.css | 64 -- devtools/client/webide/webide-prefs.js | 35 - 163 files changed, 13812 deletions(-) delete mode 100644 devtools/client/locales/en-US/webide.dtd delete mode 100644 devtools/client/locales/en-US/webide.properties delete mode 100644 devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js delete mode 100644 devtools/client/projecteditor/lib/plugins/app-manager/moz.build delete mode 100644 devtools/client/projecteditor/lib/plugins/app-manager/plugin.js delete mode 100644 devtools/client/webide/components/moz.build delete mode 100644 devtools/client/webide/components/webideCli.js delete mode 100644 devtools/client/webide/components/webideComponents.manifest delete mode 100644 devtools/client/webide/content/addons.js delete mode 100644 devtools/client/webide/content/addons.xhtml delete mode 100644 devtools/client/webide/content/details.js delete mode 100644 devtools/client/webide/content/details.xhtml delete mode 100644 devtools/client/webide/content/devicepreferences.js delete mode 100644 devtools/client/webide/content/devicepreferences.xhtml delete mode 100644 devtools/client/webide/content/devicesettings.js delete mode 100644 devtools/client/webide/content/devicesettings.xhtml delete mode 100644 devtools/client/webide/content/jar.mn delete mode 100644 devtools/client/webide/content/logs.js delete mode 100644 devtools/client/webide/content/logs.xhtml delete mode 100644 devtools/client/webide/content/monitor.js delete mode 100644 devtools/client/webide/content/monitor.xhtml delete mode 100644 devtools/client/webide/content/moz.build delete mode 100644 devtools/client/webide/content/newapp.js delete mode 100644 devtools/client/webide/content/newapp.xul delete mode 100644 devtools/client/webide/content/permissionstable.js delete mode 100644 devtools/client/webide/content/permissionstable.xhtml delete mode 100644 devtools/client/webide/content/prefs.js delete mode 100644 devtools/client/webide/content/prefs.xhtml delete mode 100644 devtools/client/webide/content/project-listing.js delete mode 100644 devtools/client/webide/content/project-listing.xhtml delete mode 100644 devtools/client/webide/content/project-panel.js delete mode 100644 devtools/client/webide/content/runtime-listing.js delete mode 100644 devtools/client/webide/content/runtime-listing.xhtml delete mode 100644 devtools/client/webide/content/runtime-panel.js delete mode 100644 devtools/client/webide/content/runtimedetails.js delete mode 100644 devtools/client/webide/content/runtimedetails.xhtml delete mode 100644 devtools/client/webide/content/simulator.js delete mode 100644 devtools/client/webide/content/simulator.xhtml delete mode 100644 devtools/client/webide/content/webide.js delete mode 100644 devtools/client/webide/content/webide.xul delete mode 100644 devtools/client/webide/content/wifi-auth.js delete mode 100644 devtools/client/webide/content/wifi-auth.xhtml delete mode 100644 devtools/client/webide/modules/addons.js delete mode 100644 devtools/client/webide/modules/app-manager.js delete mode 100644 devtools/client/webide/modules/app-projects.js delete mode 100644 devtools/client/webide/modules/app-validator.js delete mode 100644 devtools/client/webide/modules/build.js delete mode 100644 devtools/client/webide/modules/config-view.js delete mode 100644 devtools/client/webide/modules/moz.build delete mode 100644 devtools/client/webide/modules/project-list.js delete mode 100644 devtools/client/webide/modules/runtime-list.js delete mode 100644 devtools/client/webide/modules/runtimes.js delete mode 100644 devtools/client/webide/modules/simulator-process.js delete mode 100644 devtools/client/webide/modules/simulators.js delete mode 100644 devtools/client/webide/modules/tab-store.js delete mode 100644 devtools/client/webide/modules/utils.js delete mode 100644 devtools/client/webide/moz.build delete mode 100644 devtools/client/webide/test/.eslintrc.js delete mode 100644 devtools/client/webide/test/addons/adbhelper-linux.xpi delete mode 100644 devtools/client/webide/test/addons/adbhelper-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/adbhelper-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/adbhelper-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-linux32.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/simulators.json delete mode 100644 devtools/client/webide/test/app.zip delete mode 100644 devtools/client/webide/test/app/index.html delete mode 100644 devtools/client/webide/test/app/manifest.webapp delete mode 100644 devtools/client/webide/test/browser.ini delete mode 100644 devtools/client/webide/test/browser_tabs.js delete mode 100644 devtools/client/webide/test/browser_widget.js delete mode 100644 devtools/client/webide/test/build_app1/package.json delete mode 100644 devtools/client/webide/test/build_app2/manifest.webapp delete mode 100644 devtools/client/webide/test/build_app2/package.json delete mode 100644 devtools/client/webide/test/build_app2/stage/empty-directory delete mode 100644 devtools/client/webide/test/build_app_windows1/package.json delete mode 100644 devtools/client/webide/test/build_app_windows2/manifest.webapp delete mode 100644 devtools/client/webide/test/build_app_windows2/package.json delete mode 100644 devtools/client/webide/test/build_app_windows2/stage/empty-directory delete mode 100644 devtools/client/webide/test/chrome.ini delete mode 100644 devtools/client/webide/test/device_front_shared.js delete mode 100644 devtools/client/webide/test/doc_tabs.html delete mode 100644 devtools/client/webide/test/head.js delete mode 100644 devtools/client/webide/test/hosted_app.manifest delete mode 100644 devtools/client/webide/test/templates.json delete mode 100644 devtools/client/webide/test/test_addons.html delete mode 100644 devtools/client/webide/test/test_app_validator.html delete mode 100644 devtools/client/webide/test/test_autoconnect_runtime.html delete mode 100644 devtools/client/webide/test/test_autoselect_project.html delete mode 100644 devtools/client/webide/test/test_basic.html delete mode 100644 devtools/client/webide/test/test_build.html delete mode 100644 devtools/client/webide/test/test_device_permissions.html delete mode 100644 devtools/client/webide/test/test_device_preferences.html delete mode 100644 devtools/client/webide/test/test_device_runtime.html delete mode 100644 devtools/client/webide/test/test_device_settings.html delete mode 100644 devtools/client/webide/test/test_duplicate_import.html delete mode 100644 devtools/client/webide/test/test_fullscreenToolbox.html delete mode 100644 devtools/client/webide/test/test_import.html delete mode 100644 devtools/client/webide/test/test_manifestUpdate.html delete mode 100644 devtools/client/webide/test/test_newapp.html delete mode 100644 devtools/client/webide/test/test_runtime.html delete mode 100644 devtools/client/webide/test/test_simulators.html delete mode 100644 devtools/client/webide/test/test_telemetry.html delete mode 100644 devtools/client/webide/test/test_toolbox.html delete mode 100644 devtools/client/webide/test/test_zoom.html delete mode 100644 devtools/client/webide/test/validator/no-name-or-icon/home.html delete mode 100644 devtools/client/webide/test/validator/no-name-or-icon/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/non-absolute-path/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/valid/alsoValid/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/valid/home.html delete mode 100644 devtools/client/webide/test/validator/valid/icon.png delete mode 100644 devtools/client/webide/test/validator/valid/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/wrong-launch-path/icon.png delete mode 100644 devtools/client/webide/test/validator/wrong-launch-path/manifest.webapp delete mode 100644 devtools/client/webide/themes/addons.css delete mode 100644 devtools/client/webide/themes/config-view.css delete mode 100644 devtools/client/webide/themes/deck.css delete mode 100644 devtools/client/webide/themes/default-app-icon.png delete mode 100644 devtools/client/webide/themes/details.css delete mode 100644 devtools/client/webide/themes/icons.png delete mode 100644 devtools/client/webide/themes/jar.mn delete mode 100644 devtools/client/webide/themes/logs.css delete mode 100644 devtools/client/webide/themes/monitor.css delete mode 100644 devtools/client/webide/themes/moz.build delete mode 100644 devtools/client/webide/themes/newapp.css delete mode 100644 devtools/client/webide/themes/noise.png delete mode 100644 devtools/client/webide/themes/panel-listing.css delete mode 100644 devtools/client/webide/themes/permissionstable.css delete mode 100644 devtools/client/webide/themes/rocket.svg delete mode 100644 devtools/client/webide/themes/runtimedetails.css delete mode 100644 devtools/client/webide/themes/simulator.css delete mode 100644 devtools/client/webide/themes/throbber.svg delete mode 100644 devtools/client/webide/themes/webide.css delete mode 100644 devtools/client/webide/themes/wifi-auth.css delete mode 100644 devtools/client/webide/webide-prefs.js diff --git a/application/basilisk/components/customizableui/CustomizableUI.jsm b/application/basilisk/components/customizableui/CustomizableUI.jsm index d56d63d99..a58d33a6d 100644 --- a/application/basilisk/components/customizableui/CustomizableUI.jsm +++ b/application/basilisk/components/customizableui/CustomizableUI.jsm @@ -38,7 +38,6 @@ const kPrefCustomizationState = "browser.uiCustomization.state"; const kPrefCustomizationAutoAdd = "browser.uiCustomization.autoAdd"; const kPrefCustomizationDebug = "browser.uiCustomization.debug"; const kPrefDrawInTitlebar = "browser.tabs.drawInTitlebar"; -const kPrefWebIDEInNavbar = "devtools.webide.widget.inNavbarByDefault"; const kExpectedWindowURL = "chrome://browser/content/browser.xul"; @@ -230,10 +229,6 @@ var CustomizableUIInternal = { navbarPlacements.splice(2, 0, "developer-button"); } - if (Services.prefs.getBoolPref(kPrefWebIDEInNavbar)) { - navbarPlacements.push("webide-button"); - } - // Place this last, when createWidget is called for pocket, it will // append to the toolbar. if (Services.prefs.getPrefType("extensions.pocket.enabled") != Services.prefs.PREF_INVALID && diff --git a/devtools/client/framework/devtools-browser.js b/devtools/client/framework/devtools-browser.js index 4d7176b4c..1b34e44e0 100644 --- a/devtools/client/framework/devtools-browser.js +++ b/devtools/client/framework/devtools-browser.js @@ -123,23 +123,6 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = { win.DeveloperToolbar.show(false).catch(console.error); } - // Enable WebIDE? - let webIDEEnabled = Services.prefs.getBoolPref("devtools.webide.enabled"); - idEls = [ - "appmenu_webide", - "menu_webide" - ]; - idEls.forEach(function (idEl) { - toggleMenuItem(idEl, webIDEEnabled); - }); - - let showWebIDEWidget = Services.prefs.getBoolPref("devtools.webide.widget.enabled"); - if (webIDEEnabled && showWebIDEWidget) { - gDevToolsBrowser.installWebIDEWidget(); - } else { - gDevToolsBrowser.uninstallWebIDEWidget(); - } - // Enable Browser Toolbox? let chromeEnabled = Services.prefs.getBoolPref("devtools.chrome.enabled"); let devtoolsRemoteEnabled = Services.prefs.getBoolPref("devtools.debugger.remote-enabled"); diff --git a/devtools/client/framework/gDevTools.jsm b/devtools/client/framework/gDevTools.jsm index d825c0eaa..6e0dc5e83 100644 --- a/devtools/client/framework/gDevTools.jsm +++ b/devtools/client/framework/gDevTools.jsm @@ -126,16 +126,9 @@ let gDevToolsBrowserMethods = [ // Used by browser-sets.inc, command "openConnectScreen", - // Used by browser-sets.inc, command - // itself, webide widget - "openWebIDE", - // Used by browser-sets.inc, command "openContentProcessToolbox", - // Used by webide.js - "moveWebIDEWidgetInNavbar", - // Used by browser.js "registerBrowserWindow", @@ -146,10 +139,6 @@ let gDevToolsBrowserMethods = [ "forgetBrowserWindow" ]; this.gDevToolsBrowser = { - // Used by webide.js - get isWebIDEInitialized() { - return browser.isWebIDEInitialized; - }, // Used by a test (should be removed) get _trackedBrowserWindows() { return browser._trackedBrowserWindows; diff --git a/devtools/client/locales/en-US/menus.properties b/devtools/client/locales/en-US/menus.properties index 66e158cbd..7030fe17d 100644 --- a/devtools/client/locales/en-US/menus.properties +++ b/devtools/client/locales/en-US/menus.properties @@ -54,11 +54,6 @@ devToolbarMenu.accesskey = v devToolbarMenu.key = VK_F2 devToolbarMenu.keytext = F2 -webide.label = WebIDE -webide.accesskey = W -webide.key = VK_F8 -webide.keytext = F8 - devToolboxMenuItem.label = Toggle Tools devToolboxMenuItem.accesskey = T devToolboxMenuItem.key = I diff --git a/devtools/client/locales/en-US/webide.dtd b/devtools/client/locales/en-US/webide.dtd deleted file mode 100644 index 554488f6d..000000000 --- a/devtools/client/locales/en-US/webide.dtd +++ /dev/null @@ -1,222 +0,0 @@ - - - - %brandDTD; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/devtools/client/locales/en-US/webide.properties b/devtools/client/locales/en-US/webide.properties deleted file mode 100644 index 154094906..000000000 --- a/devtools/client/locales/en-US/webide.properties +++ /dev/null @@ -1,92 +0,0 @@ -# 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/. - -title_noApp=WebIDE -title_app=WebIDE: %S - -runtimeButton_label=Select Runtime -projectButton_label=Open App - -mainProcess_label=Main Process - -local_runtime=Local Runtime -remote_runtime=Remote Runtime -remote_runtime_promptTitle=Remote Runtime -remote_runtime_promptMessage=hostname:port - -importPackagedApp_title=Select Directory -importHostedApp_title=Open Hosted App -importHostedApp_header=Enter Manifest URL - -selectCustomBinary_title=Select custom B2G binary -selectCustomProfile_title=Select custom Gaia profile - -notification_showTroubleShooting_label=Troubleshooting -notification_showTroubleShooting_accesskey=T - -# LOCALIZATION NOTE (project_tab_loading): This is shown as a temporary tab -# title for browser tab projects when the tab is still loading. -project_tab_loading=Loading… - -# These messages appear in a notification box when an error occur. - -error_cantInstallNotFullyConnected=Can’t install project. Not fully connected. -error_cantInstallValidationErrors=Can’t install project. Validation errors. -error_listRunningApps=Can’t get app list from device - -# Variable: name of the operation (in english) -error_operationTimeout=Operation timed out: %1$S -error_operationFail=Operation failed: %1$S - -# Variable: app name -error_cantConnectToApp=Can’t connect to app: %1$S - -# Variable: error message (in english) -error_cantFetchAddonsJSON=Can’t fetch the add-on list: %S - -error_appProjectsLoadFailed=Unable to load project list. This can occur if you’ve used this profile with a newer version of the browser. -error_folderCreationFailed=Unable to create project folder in the selected directory. - -# Variable: runtime app build ID (looks like this %Y%M%D format) and firefox build ID (same format) -error_runtimeVersionTooRecent=The connected runtime has a more recent build date (%1$S) than your desktop browser (%2$S) does. This is an unsupported setup and may cause DevTools to fail. Please update the browser. - -addons_stable=stable -addons_unstable=unstable -# LOCALIZATION NOTE (addons_simulator_label): This label is shown as the name of -# a given simulator version in the "Manage Simulators" pane. %1$S: Firefox OS -# version in the simulator, ex. 1.3. %2$S: Simulator stability label, ex. -# "stable" or "unstable". -addons_simulator_label=Firefox OS %1$S Simulator (%2$S) -addons_install_button=install -addons_uninstall_button=uninstall -addons_adb_label=ADB Helper Add-on -addons_adapters_label=Tools Adapters Add-on -addons_adb_warning=USB devices won’t be detected without this add-on -addons_status_unknown=? -addons_status_installed=Installed -addons_status_uninstalled=Not Installed -addons_status_preparing=preparing -addons_status_downloading=downloading -addons_status_installing=installing - -runtimedetails_checkno=no -runtimedetails_checkyes=yes -runtimedetails_checkunknown=unknown (requires ADB Helper 0.4.0 or later) -runtimedetails_notUSBDevice=Not a USB device - -# Validation status -status_tooltip=Validation status: %1$S -status_valid=VALID -status_warning=WARNINGS -status_error=ERRORS -status_unknown=UNKNOWN - -# Device preferences and settings -device_reset_default=Reset to default - -# Simulator options -simulator_custom_device=Custom -simulator_custom_binary=Custom B2G binary… -simulator_custom_profile=Custom Gaia profile… -simulator_default_profile=Use default diff --git a/devtools/client/menus.js b/devtools/client/menus.js index dbacb367d..23f024f04 100644 --- a/devtools/client/menus.js +++ b/devtools/client/menus.js @@ -86,17 +86,6 @@ exports.menuitems = [ }, checkbox: true }, - { id: "menu_webide", - l10nKey: "webide", - disabled: true, - oncommand() { - gDevToolsBrowser.openWebIDE(); - }, - key: { - id: "webide", - modifiers: "shift" - } - }, { id: "menu_browserToolbox", l10nKey: "browserToolboxMenu", disabled: true, diff --git a/devtools/client/moz.build b/devtools/client/moz.build index b55aa5380..9699ec726 100644 --- a/devtools/client/moz.build +++ b/devtools/client/moz.build @@ -34,7 +34,6 @@ DIRS += [ 'themes', 'webaudioeditor', 'webconsole', - 'webide', ] # Shim old theme paths used by DevTools add-ons diff --git a/devtools/client/preferences/devtools.js b/devtools/client/preferences/devtools.js index 2f6ca2104..dea61e37f 100644 --- a/devtools/client/preferences/devtools.js +++ b/devtools/client/preferences/devtools.js @@ -21,9 +21,6 @@ pref("devtools.loader.hotreload", false); pref("devtools.toolbar.enabled", true); pref("devtools.toolbar.visible", false); -// Enable DevTools WebIDE by default -pref("devtools.webide.enabled", true); - // Toolbox preferences pref("devtools.toolbox.footer.height", 250); pref("devtools.toolbox.sidebar.width", 500); diff --git a/devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js b/devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js deleted file mode 100644 index 9a66770b0..000000000 --- a/devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set ft=javascript 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/. */ - -const { Cu } = require("chrome"); -const { Class } = require("sdk/core/heritage"); -const promise = require("promise"); -const { ItchEditor } = require("devtools/client/projecteditor/lib/editors"); - -var AppProjectEditor = Class({ - extends: ItchEditor, - - hidesToolbar: true, - - initialize: function (host) { - ItchEditor.prototype.initialize.apply(this, arguments); - this.appended = promise.resolve(); - this.host = host; - this.label = "app-manager"; - }, - - destroy: function () { - this.elt.remove(); - this.elt = null; - }, - - load: function (resource) { - let {appManagerOpts} = this.host.project; - - // Only load the frame the first time it is selected - if (!this.iframe || this.iframe.getAttribute("src") !== appManagerOpts.projectOverviewURL) { - - this.elt.textContent = ""; - let iframe = this.iframe = this.elt.ownerDocument.createElement("iframe"); - let iframeLoaded = this.iframeLoaded = promise.defer(); - - iframe.addEventListener("load", function onLoad() { - iframe.removeEventListener("load", onLoad); - iframeLoaded.resolve(); - }); - - iframe.setAttribute("flex", "1"); - iframe.setAttribute("src", appManagerOpts.projectOverviewURL); - this.elt.appendChild(iframe); - - } - - promise.all([this.iframeLoaded.promise, this.appended]).then(() => { - this.emit("load"); - }); - } -}); - -exports.AppProjectEditor = AppProjectEditor; diff --git a/devtools/client/projecteditor/lib/plugins/app-manager/moz.build b/devtools/client/projecteditor/lib/plugins/app-manager/moz.build deleted file mode 100644 index 8aae52725..000000000 --- a/devtools/client/projecteditor/lib/plugins/app-manager/moz.build +++ /dev/null @@ -1,10 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -DevToolsModules( - 'app-project-editor.js', - 'plugin.js', -) diff --git a/devtools/client/projecteditor/lib/plugins/app-manager/plugin.js b/devtools/client/projecteditor/lib/plugins/app-manager/plugin.js deleted file mode 100644 index 82bbab34b..000000000 --- a/devtools/client/projecteditor/lib/plugins/app-manager/plugin.js +++ /dev/null @@ -1,77 +0,0 @@ -const { Cu } = require("chrome"); -const { Class } = require("sdk/core/heritage"); -const { EventTarget } = require("sdk/event/target"); -const { emit } = require("sdk/event/core"); -const promise = require("promise"); -var { registerPlugin, Plugin } = require("devtools/client/projecteditor/lib/plugins/core"); -const { AppProjectEditor } = require("./app-project-editor"); -const OPTION_URL = "chrome://devtools/skin/images/tool-options.svg"; -const Services = require("Services"); -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -var AppManagerRenderer = Class({ - extends: Plugin, - - isAppManagerProject: function () { - return !!this.host.project.appManagerOpts; - }, - editorForResource: function (resource) { - if (!resource.parent && this.isAppManagerProject()) { - return AppProjectEditor; - } - }, - getUI: function (parent) { - let doc = parent.ownerDocument; - if (parent.childElementCount == 0) { - let image = doc.createElement("image"); - let optionImage = doc.createElement("image"); - let flexElement = doc.createElement("div"); - let nameLabel = doc.createElement("span"); - let statusElement = doc.createElement("div"); - - image.className = "project-image"; - optionImage.className = "project-options"; - optionImage.setAttribute("src", OPTION_URL); - nameLabel.className = "project-name-label"; - statusElement.className = "project-status"; - flexElement.className = "project-flex"; - - parent.appendChild(image); - parent.appendChild(nameLabel); - parent.appendChild(flexElement); - parent.appendChild(statusElement); - parent.appendChild(optionImage); - } - - return { - image: parent.querySelector(".project-image"), - nameLabel: parent.querySelector(".project-name-label"), - statusElement: parent.querySelector(".project-status") - }; - }, - onAnnotate: function (resource, editor, elt) { - if (resource.parent || !this.isAppManagerProject()) { - return; - } - - let {appManagerOpts} = this.host.project; - let doc = elt.ownerDocument; - - let {image, nameLabel, statusElement} = this.getUI(elt); - let name = appManagerOpts.name || resource.basename; - let url = appManagerOpts.iconUrl || "icon-sample.png"; - let status = appManagerOpts.validationStatus || "unknown"; - let tooltip = Strings.formatStringFromName("status_tooltip", - [Strings.GetStringFromName("status_" + status)], 1); - - nameLabel.textContent = name; - image.setAttribute("src", url); - statusElement.setAttribute("status", status); - statusElement.setAttribute("tooltiptext", tooltip); - - return true; - } -}); - -exports.AppManagerRenderer = AppManagerRenderer; -registerPlugin(AppManagerRenderer); diff --git a/devtools/client/projecteditor/lib/plugins/moz.build b/devtools/client/projecteditor/lib/plugins/moz.build index 17bff7ce0..99d864e13 100644 --- a/devtools/client/projecteditor/lib/plugins/moz.build +++ b/devtools/client/projecteditor/lib/plugins/moz.build @@ -5,7 +5,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += [ - 'app-manager', 'delete', 'dirty', 'image-view', diff --git a/devtools/client/projecteditor/lib/projecteditor.js b/devtools/client/projecteditor/lib/projecteditor.js index a3ef06249..27127b0a0 100644 --- a/devtools/client/projecteditor/lib/projecteditor.js +++ b/devtools/client/projecteditor/lib/projecteditor.js @@ -31,7 +31,6 @@ require("devtools/client/projecteditor/lib/plugins/new/new"); require("devtools/client/projecteditor/lib/plugins/rename/rename"); require("devtools/client/projecteditor/lib/plugins/save/save"); require("devtools/client/projecteditor/lib/plugins/image-view/plugin"); -require("devtools/client/projecteditor/lib/plugins/app-manager/plugin"); require("devtools/client/projecteditor/lib/plugins/status-bar/plugin"); // Uncomment to enable logging. diff --git a/devtools/client/shared/telemetry.js b/devtools/client/shared/telemetry.js index 38a21cef6..547b1c07f 100644 --- a/devtools/client/shared/telemetry.js +++ b/devtools/client/shared/telemetry.js @@ -177,23 +177,6 @@ Telemetry.prototype = { histogram: "DEVTOOLS_ABOUTDEBUGGING_OPENED_COUNT", timerHistogram: "DEVTOOLS_ABOUTDEBUGGING_TIME_ACTIVE_SECONDS" }, - webide: { - histogram: "DEVTOOLS_WEBIDE_OPENED_COUNT", - timerHistogram: "DEVTOOLS_WEBIDE_TIME_ACTIVE_SECONDS" - }, - webideProjectEditor: { - histogram: "DEVTOOLS_WEBIDE_PROJECT_EDITOR_OPENED_COUNT", - timerHistogram: "DEVTOOLS_WEBIDE_PROJECT_EDITOR_TIME_ACTIVE_SECONDS" - }, - webideProjectEditorSave: { - histogram: "DEVTOOLS_WEBIDE_PROJECT_EDITOR_SAVE_COUNT", - }, - webideNewProject: { - histogram: "DEVTOOLS_WEBIDE_NEW_PROJECT_COUNT", - }, - webideImportProject: { - histogram: "DEVTOOLS_WEBIDE_IMPORT_PROJECT_COUNT", - }, custom: { histogram: "DEVTOOLS_CUSTOM_OPENED_COUNT", timerHistogram: "DEVTOOLS_CUSTOM_TIME_ACTIVE_SECONDS" diff --git a/devtools/client/webide/components/moz.build b/devtools/client/webide/components/moz.build deleted file mode 100644 index d4047c295..000000000 --- a/devtools/client/webide/components/moz.build +++ /dev/null @@ -1,10 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -EXTRA_COMPONENTS += [ - 'webideCli.js', - 'webideComponents.manifest', -] diff --git a/devtools/client/webide/components/webideCli.js b/devtools/client/webide/components/webideCli.js deleted file mode 100644 index 0f75da2c4..000000000 --- a/devtools/client/webide/components/webideCli.js +++ /dev/null @@ -1,58 +0,0 @@ -/* 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/. */ - -"use strict"; - -const Ci = Components.interfaces; -const Cu = Components.utils; - -const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); - -XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); - -/** - * Handles --webide command line option. - */ - -function webideCli() { } - -webideCli.prototype = { - handle: function (cmdLine) { - if (!cmdLine.handleFlag("webide", false)) { - return; - } - - // If --webide is used remotely, we don't want to open - // a new tab. - // - // If --webide is used for a new Firefox instance, we - // want to open webide only. - cmdLine.preventDefault = true; - - let win = Services.wm.getMostRecentWindow("devtools:webide"); - if (win) { - win.focus(); - } else { - win = Services.ww.openWindow(null, - "chrome://webide/content/", - "webide", - "chrome,centerscreen,resizable,dialog=no", - null); - } - - if (cmdLine.state == Ci.nsICommandLine.STATE_INITIAL_LAUNCH) { - // If this is a new Firefox instance, and because we will only start - // webide, we need to notify "sessionstore-windows-restored" to trigger - // addons registration (for simulators and adb helper). - Services.obs.notifyObservers(null, "sessionstore-windows-restored", ""); - } - }, - - helpInfo: "", - - classID: Components.ID("{79b7b44e-de5e-4e4c-b7a2-044003c615d9}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([webideCli]); diff --git a/devtools/client/webide/components/webideComponents.manifest b/devtools/client/webide/components/webideComponents.manifest deleted file mode 100644 index 03af9758c..000000000 --- a/devtools/client/webide/components/webideComponents.manifest +++ /dev/null @@ -1,4 +0,0 @@ -# webide components -component {79b7b44e-de5e-4e4c-b7a2-044003c615d9} webideCli.js -contract @mozilla.org/browser/webide-clh;1 {79b7b44e-de5e-4e4c-b7a2-044003c615d9} -category command-line-handler a-webide @mozilla.org/browser/webide-clh;1 diff --git a/devtools/client/webide/content/addons.js b/devtools/client/webide/content/addons.js deleted file mode 100644 index 3948b040f..000000000 --- a/devtools/client/webide/content/addons.js +++ /dev/null @@ -1,135 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {gDevTools} = require("devtools/client/framework/devtools"); -const {GetAvailableAddons, ForgetAddonsList} = require("devtools/client/webide/modules/addons"); -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.querySelector("#aboutaddons").onclick = function () { - let browserWin = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType); - if (browserWin && browserWin.BrowserOpenAddonsMgr) { - browserWin.BrowserOpenAddonsMgr("addons://list/extension"); - } - }; - document.querySelector("#close").onclick = CloseUI; - GetAvailableAddons().then(BuildUI, (e) => { - console.error(e); - window.alert(Strings.formatStringFromName("error_cantFetchAddonsJSON", [e], 1)); - }); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - ForgetAddonsList(); -}, true); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function BuildUI(addons) { - BuildItem(addons.adb, "adb"); - BuildItem(addons.adapters, "adapters"); - for (let addon of addons.simulators) { - BuildItem(addon, "simulator"); - } -} - -function BuildItem(addon, type) { - - function onAddonUpdate(event, arg) { - switch (event) { - case "update": - progress.removeAttribute("value"); - li.setAttribute("status", addon.status); - status.textContent = Strings.GetStringFromName("addons_status_" + addon.status); - break; - case "failure": - window.parent.UI.reportError("error_operationFail", arg); - break; - case "progress": - if (arg == -1) { - progress.removeAttribute("value"); - } else { - progress.value = arg; - } - break; - } - } - - let events = ["update", "failure", "progress"]; - for (let e of events) { - addon.on(e, onAddonUpdate); - } - window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - for (let e of events) { - addon.off(e, onAddonUpdate); - } - }); - - let li = document.createElement("li"); - li.setAttribute("status", addon.status); - - let name = document.createElement("span"); - name.className = "name"; - - switch (type) { - case "adb": - li.setAttribute("addon", type); - name.textContent = Strings.GetStringFromName("addons_adb_label"); - break; - case "adapters": - li.setAttribute("addon", type); - try { - name.textContent = Strings.GetStringFromName("addons_adapters_label"); - } catch (e) { - // This code (bug 1081093) will be backported to Aurora, which doesn't - // contain this string. - name.textContent = "Tools Adapters Add-on"; - } - break; - case "simulator": - li.setAttribute("addon", "simulator-" + addon.version); - let stability = Strings.GetStringFromName("addons_" + addon.stability); - name.textContent = Strings.formatStringFromName("addons_simulator_label", [addon.version, stability], 2); - break; - } - - li.appendChild(name); - - let status = document.createElement("span"); - status.className = "status"; - status.textContent = Strings.GetStringFromName("addons_status_" + addon.status); - li.appendChild(status); - - let installButton = document.createElement("button"); - installButton.className = "install-button"; - installButton.onclick = () => addon.install(); - installButton.textContent = Strings.GetStringFromName("addons_install_button"); - li.appendChild(installButton); - - let uninstallButton = document.createElement("button"); - uninstallButton.className = "uninstall-button"; - uninstallButton.onclick = () => addon.uninstall(); - uninstallButton.textContent = Strings.GetStringFromName("addons_uninstall_button"); - li.appendChild(uninstallButton); - - let progress = document.createElement("progress"); - li.appendChild(progress); - - if (type == "adb") { - let warning = document.createElement("p"); - warning.textContent = Strings.GetStringFromName("addons_adb_warning"); - warning.className = "warning"; - li.appendChild(warning); - } - - document.querySelector("ul").appendChild(li); -} diff --git a/devtools/client/webide/content/addons.xhtml b/devtools/client/webide/content/addons.xhtml deleted file mode 100644 index 6f3bc1e7c..000000000 --- a/devtools/client/webide/content/addons.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - -

&addons_title;

- -
    - - - diff --git a/devtools/client/webide/content/details.js b/devtools/client/webide/content/details.js deleted file mode 100644 index 9097cd8c5..000000000 --- a/devtools/client/webide/content/details.js +++ /dev/null @@ -1,139 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {ProjectBuilding} = require("devtools/client/webide/modules/build"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.addEventListener("visibilitychange", updateUI, true); - AppManager.on("app-manager-update", onAppManagerUpdate); - updateUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", onAppManagerUpdate); -}, true); - -function onAppManagerUpdate(event, what, details) { - if (what == "project" || - what == "project-validated") { - updateUI(); - } -} - -function resetUI() { - document.querySelector("#toolbar").classList.add("hidden"); - document.querySelector("#type").classList.add("hidden"); - document.querySelector("#descriptionHeader").classList.add("hidden"); - document.querySelector("#manifestURLHeader").classList.add("hidden"); - document.querySelector("#locationHeader").classList.add("hidden"); - - document.body.className = ""; - document.querySelector("#icon").src = ""; - document.querySelector("h1").textContent = ""; - document.querySelector("#description").textContent = ""; - document.querySelector("#type").textContent = ""; - document.querySelector("#manifestURL").textContent = ""; - document.querySelector("#location").textContent = ""; - - document.querySelector("#prePackageLog").hidden = true; - - document.querySelector("#errorslist").innerHTML = ""; - document.querySelector("#warningslist").innerHTML = ""; - -} - -function updateUI() { - resetUI(); - - let project = AppManager.selectedProject; - if (!project) { - return; - } - - if (project.type != "runtimeApp" && project.type != "mainProcess") { - document.querySelector("#toolbar").classList.remove("hidden"); - document.querySelector("#locationHeader").classList.remove("hidden"); - document.querySelector("#location").textContent = project.location; - } - - document.body.className = project.validationStatus; - document.querySelector("#icon").src = project.icon; - document.querySelector("h1").textContent = project.name; - - let manifest; - if (project.type == "runtimeApp") { - manifest = project.app.manifest; - } else { - manifest = project.manifest; - } - - if (manifest) { - if (manifest.description) { - document.querySelector("#descriptionHeader").classList.remove("hidden"); - document.querySelector("#description").textContent = manifest.description; - } - - document.querySelector("#type").classList.remove("hidden"); - - if (project.type == "runtimeApp") { - let manifestURL = AppManager.getProjectManifestURL(project); - document.querySelector("#type").textContent = manifest.type || "web"; - document.querySelector("#manifestURLHeader").classList.remove("hidden"); - document.querySelector("#manifestURL").textContent = manifestURL; - } else if (project.type == "mainProcess") { - document.querySelector("#type").textContent = project.name; - } else { - document.querySelector("#type").textContent = project.type + " " + (manifest.type || "web"); - } - - if (project.type == "packaged") { - let manifestURL = AppManager.getProjectManifestURL(project); - if (manifestURL) { - document.querySelector("#manifestURLHeader").classList.remove("hidden"); - document.querySelector("#manifestURL").textContent = manifestURL; - } - } - } - - if (project.type != "runtimeApp" && project.type != "mainProcess") { - ProjectBuilding.hasPrepackage(project).then(hasPrepackage => { - document.querySelector("#prePackageLog").hidden = !hasPrepackage; - }); - } - - let errorsNode = document.querySelector("#errorslist"); - let warningsNode = document.querySelector("#warningslist"); - - if (project.errors) { - for (let e of project.errors) { - let li = document.createElement("li"); - li.textContent = e; - errorsNode.appendChild(li); - } - } - - if (project.warnings) { - for (let w of project.warnings) { - let li = document.createElement("li"); - li.textContent = w; - warningsNode.appendChild(li); - } - } - - AppManager.update("details"); -} - -function showPrepackageLog() { - window.top.UI.selectDeckPanel("logs"); -} - -function removeProject() { - AppManager.removeSelectedProject(); -} diff --git a/devtools/client/webide/content/details.xhtml b/devtools/client/webide/content/details.xhtml deleted file mode 100644 index a04c37b0c..000000000 --- a/devtools/client/webide/content/details.xhtml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - -
    - -

    - &details_valid_header; - &details_warning_header; - &details_error_header; -

    -
    - -
    - -
    -

    -

    -
    -
    - -
    -

    &details_description;

    -

    - -

    &details_location;

    -

    - -

    &details_manifestURL;

    -

    - - -
    - -
      -
        - - - diff --git a/devtools/client/webide/content/devicepreferences.js b/devtools/client/webide/content/devicepreferences.js deleted file mode 100644 index 14c020f12..000000000 --- a/devtools/client/webide/content/devicepreferences.js +++ /dev/null @@ -1,81 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const ConfigView = require("devtools/client/webide/modules/config-view"); - -var configView = new ConfigView(window); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - AppManager.on("app-manager-update", OnAppManagerUpdate); - document.getElementById("close").onclick = CloseUI; - document.getElementById("device-fields").onchange = UpdateField; - document.getElementById("device-fields").onclick = CheckReset; - document.getElementById("search-bar").onkeyup = document.getElementById("search-bar").onclick = SearchField; - document.getElementById("custom-value").onclick = UpdateNewField; - document.getElementById("custom-value-type").onchange = ClearNewFields; - document.getElementById("add-custom-field").onkeyup = CheckNewFieldSubmit; - BuildUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - } -} - -function CheckNewFieldSubmit(event) { - configView.checkNewFieldSubmit(event); -} - -function UpdateNewField() { - configView.updateNewField(); -} - -function ClearNewFields() { - configView.clearNewFields(); -} - -function CheckReset(event) { - configView.checkReset(event); -} - -function UpdateField(event) { - configView.updateField(event); -} - -function SearchField(event) { - configView.search(event); -} - -var getAllPrefs; // Used by tests -function BuildUI() { - configView.resetTable(); - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.preferenceFront) { - configView.front = AppManager.preferenceFront; - configView.kind = "Pref"; - configView.includeTypeName = true; - - getAllPrefs = AppManager.preferenceFront.getAllPrefs() - .then(json => configView.generateDisplay(json)); - } else { - CloseUI(); - } -} diff --git a/devtools/client/webide/content/devicepreferences.xhtml b/devtools/client/webide/content/devicepreferences.xhtml deleted file mode 100644 index dafb6f15f..000000000 --- a/devtools/client/webide/content/devicepreferences.xhtml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - -
        - -

        &devicepreference_title;

        - -
        - - - - - - -
        - - - - - - -
        - - diff --git a/devtools/client/webide/content/devicesettings.js b/devtools/client/webide/content/devicesettings.js deleted file mode 100644 index 987df5995..000000000 --- a/devtools/client/webide/content/devicesettings.js +++ /dev/null @@ -1,81 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const ConfigView = require("devtools/client/webide/modules/config-view"); - -var configView = new ConfigView(window); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - AppManager.on("app-manager-update", OnAppManagerUpdate); - document.getElementById("close").onclick = CloseUI; - document.getElementById("device-fields").onchange = UpdateField; - document.getElementById("device-fields").onclick = CheckReset; - document.getElementById("search-bar").onkeyup = document.getElementById("search-bar").onclick = SearchField; - document.getElementById("custom-value").onclick = UpdateNewField; - document.getElementById("custom-value-type").onchange = ClearNewFields; - document.getElementById("add-custom-field").onkeyup = CheckNewFieldSubmit; - BuildUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - } -} - -function CheckNewFieldSubmit(event) { - configView.checkNewFieldSubmit(event); -} - -function UpdateNewField() { - configView.updateNewField(); -} - -function ClearNewFields() { - configView.clearNewFields(); -} - -function CheckReset(event) { - configView.checkReset(event); -} - -function UpdateField(event) { - configView.updateField(event); -} - -function SearchField(event) { - configView.search(event); -} - -var getAllSettings; // Used by tests -function BuildUI() { - configView.resetTable(); - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.settingsFront) { - configView.front = AppManager.settingsFront; - configView.kind = "Setting"; - configView.includeTypeName = false; - - getAllSettings = AppManager.settingsFront.getAllSettings() - .then(json => configView.generateDisplay(json)); - } else { - CloseUI(); - } -} diff --git a/devtools/client/webide/content/devicesettings.xhtml b/devtools/client/webide/content/devicesettings.xhtml deleted file mode 100644 index 0406c6f07..000000000 --- a/devtools/client/webide/content/devicesettings.xhtml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - -
        - -

        &devicesetting_title;

        - -
        - - - - - - -
        - - - - - - -
        - - diff --git a/devtools/client/webide/content/jar.mn b/devtools/client/webide/content/jar.mn deleted file mode 100644 index db79fdb51..000000000 --- a/devtools/client/webide/content/jar.mn +++ /dev/null @@ -1,38 +0,0 @@ -# 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/. - -webide.jar: -% content webide %content/ - content/webide.xul (webide.xul) - content/webide.js (webide.js) - content/newapp.xul (newapp.xul) - content/newapp.js (newapp.js) - content/details.xhtml (details.xhtml) - content/details.js (details.js) - content/addons.js (addons.js) - content/addons.xhtml (addons.xhtml) - content/permissionstable.js (permissionstable.js) - content/permissionstable.xhtml (permissionstable.xhtml) - content/runtimedetails.js (runtimedetails.js) - content/runtimedetails.xhtml (runtimedetails.xhtml) - content/prefs.js (prefs.js) - content/prefs.xhtml (prefs.xhtml) - content/monitor.xhtml (monitor.xhtml) - content/monitor.js (monitor.js) - content/devicepreferences.js (devicepreferences.js) - content/devicepreferences.xhtml (devicepreferences.xhtml) - content/devicesettings.js (devicesettings.js) - content/devicesettings.xhtml (devicesettings.xhtml) - content/wifi-auth.js (wifi-auth.js) - content/wifi-auth.xhtml (wifi-auth.xhtml) - content/logs.xhtml (logs.xhtml) - content/logs.js (logs.js) - content/project-listing.xhtml (project-listing.xhtml) - content/project-listing.js (project-listing.js) - content/project-panel.js (project-panel.js) - content/runtime-panel.js (runtime-panel.js) - content/runtime-listing.xhtml (runtime-listing.xhtml) - content/runtime-listing.js (runtime-listing.js) - content/simulator.js (simulator.js) - content/simulator.xhtml (simulator.xhtml) diff --git a/devtools/client/webide/content/logs.js b/devtools/client/webide/content/logs.js deleted file mode 100644 index 157d83b67..000000000 --- a/devtools/client/webide/content/logs.js +++ /dev/null @@ -1,70 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - - Logs.init(); -}); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - - Logs.uninit(); -}); - -const Logs = { - init: function () { - this.list = document.getElementById("logs"); - - Logs.onAppManagerUpdate = Logs.onAppManagerUpdate.bind(this); - AppManager.on("app-manager-update", Logs.onAppManagerUpdate); - - document.getElementById("close").onclick = Logs.close.bind(this); - }, - - uninit: function () { - AppManager.off("app-manager-update", Logs.onAppManagerUpdate); - }, - - onAppManagerUpdate: function (event, what, details) { - switch (what) { - case "pre-package": - this.prePackageLog(details); - break; - } - }, - - close: function () { - window.parent.UI.openProject(); - }, - - prePackageLog: function (msg, details) { - if (msg == "start") { - this.clear(); - } else if (msg == "succeed") { - setTimeout(function () { - Logs.close(); - }, 1000); - } else if (msg == "failed") { - this.log(details); - } else { - this.log(msg); - } - }, - - clear: function () { - this.list.innerHTML = ""; - }, - - log: function (msg) { - let line = document.createElement("li"); - line.textContent = msg; - this.list.appendChild(line); - } -}; diff --git a/devtools/client/webide/content/logs.xhtml b/devtools/client/webide/content/logs.xhtml deleted file mode 100644 index 8d003e509..000000000 --- a/devtools/client/webide/content/logs.xhtml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - - - -

        &logs_title;

        - -
          -
        - - - diff --git a/devtools/client/webide/content/monitor.js b/devtools/client/webide/content/monitor.js deleted file mode 100644 index a5d80d460..000000000 --- a/devtools/client/webide/content/monitor.js +++ /dev/null @@ -1,741 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {AppActorFront} = require("devtools/shared/apps/app-actor-front"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const EventEmitter = require("devtools/shared/event-emitter"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - window.addEventListener("resize", Monitor.resize); - window.addEventListener("unload", Monitor.unload); - - document.querySelector("#close").onclick = () => { - window.parent.UI.openProject(); - }; - - Monitor.load(); -}); - - -/** - * The Monitor is a WebIDE tool used to display any kind of time-based data in - * the form of graphs. - * - * The data can come from a Firefox OS device, simulator, or from a WebSockets - * server running locally. - * - * The format of a data update is typically an object like: - * - * { graph: 'mygraph', curve: 'mycurve', value: 42, time: 1234 } - * - * or an array of such objects. For more details on the data format, see the - * `Graph.update(data)` method. - */ -var Monitor = { - - apps: new Map(), - graphs: new Map(), - front: null, - socket: null, - wstimeout: null, - b2ginfo: false, - b2gtimeout: null, - - /** - * Add new data to the graphs, create a new graph if necessary. - */ - update: function (data, fallback) { - if (Array.isArray(data)) { - data.forEach(d => Monitor.update(d, fallback)); - return; - } - - if (Monitor.b2ginfo && data.graph === "USS") { - // If we're polling b2g-info, ignore USS updates from the device's - // USSAgents (see Monitor.pollB2GInfo()). - return; - } - - if (fallback) { - for (let key in fallback) { - if (!data[key]) { - data[key] = fallback[key]; - } - } - } - - let graph = Monitor.graphs.get(data.graph); - if (!graph) { - let element = document.createElement("div"); - element.classList.add("graph"); - document.body.appendChild(element); - - graph = new Graph(data.graph, element); - Monitor.resize(); // a scrollbar might have dis/reappeared - Monitor.graphs.set(data.graph, graph); - } - graph.update(data); - }, - - /** - * Initialize the Monitor. - */ - load: function () { - AppManager.on("app-manager-update", Monitor.onAppManagerUpdate); - Monitor.connectToRuntime(); - Monitor.connectToWebSocket(); - }, - - /** - * Clean up the Monitor. - */ - unload: function () { - AppManager.off("app-manager-update", Monitor.onAppManagerUpdate); - Monitor.disconnectFromRuntime(); - Monitor.disconnectFromWebSocket(); - }, - - /** - * Resize all the graphs. - */ - resize: function () { - for (let graph of Monitor.graphs.values()) { - graph.resize(); - } - }, - - /** - * When WebIDE connects to a new runtime, start its data forwarders. - */ - onAppManagerUpdate: function (event, what, details) { - switch (what) { - case "runtime-global-actors": - Monitor.connectToRuntime(); - break; - case "connection": - if (AppManager.connection.status == Connection.Status.DISCONNECTED) { - Monitor.disconnectFromRuntime(); - } - break; - } - }, - - /** - * Use an AppActorFront on a runtime to watch track its apps. - */ - connectToRuntime: function () { - Monitor.pollB2GInfo(); - let client = AppManager.connection && AppManager.connection.client; - let resp = AppManager._listTabsResponse; - if (client && resp && !Monitor.front) { - Monitor.front = new AppActorFront(client, resp); - Monitor.front.watchApps(Monitor.onRuntimeAppEvent); - } - }, - - /** - * Destroy our AppActorFront. - */ - disconnectFromRuntime: function () { - Monitor.unpollB2GInfo(); - if (Monitor.front) { - Monitor.front.unwatchApps(Monitor.onRuntimeAppEvent); - Monitor.front = null; - } - }, - - /** - * Try connecting to a local websockets server and accept updates from it. - */ - connectToWebSocket: function () { - let webSocketURL = Services.prefs.getCharPref("devtools.webide.monitorWebSocketURL"); - try { - Monitor.socket = new WebSocket(webSocketURL); - Monitor.socket.onmessage = function (event) { - Monitor.update(JSON.parse(event.data)); - }; - Monitor.socket.onclose = function () { - Monitor.wstimeout = setTimeout(Monitor.connectToWebsocket, 1000); - }; - } catch (e) { - Monitor.wstimeout = setTimeout(Monitor.connectToWebsocket, 1000); - } - }, - - /** - * Used when cleaning up. - */ - disconnectFromWebSocket: function () { - clearTimeout(Monitor.wstimeout); - if (Monitor.socket) { - Monitor.socket.onclose = () => {}; - Monitor.socket.close(); - } - }, - - /** - * When an app starts on the runtime, start a monitor actor for its process. - */ - onRuntimeAppEvent: function (type, app) { - if (type !== "appOpen" && type !== "appClose") { - return; - } - - let client = AppManager.connection.client; - app.getForm().then(form => { - if (type === "appOpen") { - app.monitorClient = new MonitorClient(client, form); - app.monitorClient.start(); - app.monitorClient.on("update", Monitor.onRuntimeUpdate); - Monitor.apps.set(form.monitorActor, app); - } else { - let app = Monitor.apps.get(form.monitorActor); - if (app) { - app.monitorClient.stop(() => app.monitorClient.destroy()); - Monitor.apps.delete(form.monitorActor); - } - } - }); - }, - - /** - * Accept data updates from the monitor actors of a runtime. - */ - onRuntimeUpdate: function (type, packet) { - let fallback = {}, app = Monitor.apps.get(packet.from); - if (app) { - fallback.curve = app.manifest.name; - } - Monitor.update(packet.data, fallback); - }, - - /** - * Bug 1047355: If possible, parsing the output of `b2g-info` has several - * benefits over bug 1037465's multi-process USSAgent approach, notably: - * - Works for older Firefox OS devices (pre-2.1), - * - Doesn't need certified-apps debugging, - * - Polling time is synchronized for all processes. - * TODO: After bug 1043324 lands, consider removing this hack. - */ - pollB2GInfo: function () { - if (AppManager.selectedRuntime) { - let device = AppManager.selectedRuntime.device; - if (device && device.shell) { - device.shell("b2g-info").then(s => { - let lines = s.split("\n"); - let line = ""; - - // Find the header row to locate NAME and USS, looks like: - // ' NAME PID NICE USS PSS RSS VSIZE OOM_ADJ USER '. - while (line.indexOf("NAME") < 0) { - if (lines.length < 1) { - // Something is wrong with this output, don't trust b2g-info. - Monitor.unpollB2GInfo(); - return; - } - line = lines.shift(); - } - let namelength = line.indexOf("NAME") + "NAME".length; - let ussindex = line.slice(namelength).split(/\s+/).indexOf("USS"); - - // Get the NAME and USS in each following line, looks like: - // 'Homescreen 375 18 12.6 16.3 27.1 67.8 4 app_375'. - while (lines.length > 0 && lines[0].length > namelength) { - line = lines.shift(); - let name = line.slice(0, namelength); - let uss = line.slice(namelength).split(/\s+/)[ussindex]; - Monitor.update({ - curve: name.trim(), - value: 1024 * 1024 * parseFloat(uss) // Convert MB to bytes. - }, { - // Note: We use the fallback object to set the graph name to 'USS' - // so that Monitor.update() can ignore USSAgent updates. - graph: "USS" - }); - } - }); - } - } - Monitor.b2ginfo = true; - Monitor.b2gtimeout = setTimeout(Monitor.pollB2GInfo, 350); - }, - - /** - * Polling b2g-info doesn't work or is no longer needed. - */ - unpollB2GInfo: function () { - clearTimeout(Monitor.b2gtimeout); - Monitor.b2ginfo = false; - } - -}; - - -/** - * A MonitorClient is used as an actor client of a runtime's monitor actors, - * receiving its updates. - */ -function MonitorClient(client, form) { - this.client = client; - this.actor = form.monitorActor; - this.events = ["update"]; - - EventEmitter.decorate(this); - this.client.registerClient(this); -} -MonitorClient.prototype.destroy = function () { - this.client.unregisterClient(this); -}; -MonitorClient.prototype.start = function () { - this.client.request({ - to: this.actor, - type: "start" - }); -}; -MonitorClient.prototype.stop = function (callback) { - this.client.request({ - to: this.actor, - type: "stop" - }, callback); -}; - - -/** - * A Graph populates a container DOM element with an SVG graph and a legend. - */ -function Graph(name, element) { - this.name = name; - this.element = element; - this.curves = new Map(); - this.events = new Map(); - this.ignored = new Set(); - this.enabled = true; - this.request = null; - - this.x = d3.time.scale(); - this.y = d3.scale.linear(); - - this.xaxis = d3.svg.axis().scale(this.x).orient("bottom"); - this.yaxis = d3.svg.axis().scale(this.y).orient("left"); - - this.xformat = d3.time.format("%I:%M:%S"); - this.yformat = this.formatter(1); - this.yaxis.tickFormat(this.formatter(0)); - - this.line = d3.svg.line().interpolate("linear") - .x(function (d) { return this.x(d.time); }) - .y(function (d) { return this.y(d.value); }); - - this.color = d3.scale.category10(); - - this.svg = d3.select(element).append("svg").append("g") - .attr("transform", "translate(" + this.margin.left + "," + this.margin.top + ")"); - - this.xelement = this.svg.append("g").attr("class", "x axis").call(this.xaxis); - this.yelement = this.svg.append("g").attr("class", "y axis").call(this.yaxis); - - // RULERS on axes - let xruler = this.xruler = this.svg.select(".x.axis").append("g").attr("class", "x ruler"); - xruler.append("line").attr("y2", 6); - xruler.append("line").attr("stroke-dasharray", "1,1"); - xruler.append("text").attr("y", 9).attr("dy", ".71em"); - - let yruler = this.yruler = this.svg.select(".y.axis").append("g").attr("class", "y ruler"); - yruler.append("line").attr("x2", -6); - yruler.append("line").attr("stroke-dasharray", "1,1"); - yruler.append("text").attr("x", -9).attr("dy", ".32em"); - - let self = this; - - d3.select(element).select("svg") - .on("mousemove", function () { - let mouse = d3.mouse(this); - self.mousex = mouse[0] - self.margin.left, - self.mousey = mouse[1] - self.margin.top; - - xruler.attr("transform", "translate(" + self.mousex + ",0)"); - yruler.attr("transform", "translate(0," + self.mousey + ")"); - }); - /* .on('mouseout', function() { - self.xruler.attr('transform', 'translate(-500,0)'); - self.yruler.attr('transform', 'translate(0,-500)'); - });*/ - this.mousex = this.mousey = -500; - - let sidebar = d3.select(this.element).append("div").attr("class", "sidebar"); - let title = sidebar.append("label").attr("class", "graph-title"); - - title.append("input") - .attr("type", "checkbox") - .attr("checked", "true") - .on("click", function () { self.toggle(); }); - title.append("span").text(this.name); - - this.legend = sidebar.append("div").attr("class", "legend"); - - this.resize = this.resize.bind(this); - this.render = this.render.bind(this); - this.averages = this.averages.bind(this); - - setInterval(this.averages, 1000); - - this.resize(); -} - -Graph.prototype = { - - /** - * These margin are used to properly position the SVG graph items inside the - * container element. - */ - margin: { - top: 10, - right: 150, - bottom: 20, - left: 50 - }, - - /** - * A Graph can be collapsed by the user. - */ - toggle: function () { - if (this.enabled) { - this.element.classList.add("disabled"); - this.enabled = false; - } else { - this.element.classList.remove("disabled"); - this.enabled = true; - } - Monitor.resize(); - }, - - /** - * If the container element is resized (e.g. because the window was resized or - * a scrollbar dis/appeared), the graph needs to be resized as well. - */ - resize: function () { - let style = getComputedStyle(this.element), - height = parseFloat(style.height) - this.margin.top - this.margin.bottom, - width = parseFloat(style.width) - this.margin.left - this.margin.right; - - d3.select(this.element).select("svg") - .attr("width", width + this.margin.left) - .attr("height", height + this.margin.top + this.margin.bottom); - - this.x.range([0, width]); - this.y.range([height, 0]); - - this.xelement.attr("transform", "translate(0," + height + ")"); - this.xruler.select("line[stroke-dasharray]").attr("y2", -height); - this.yruler.select("line[stroke-dasharray]").attr("x2", width); - }, - - /** - * If the domain of the Graph's data changes (on the time axis and/or on the - * value axis), the axes' domains need to be updated and the graph items need - * to be rescaled in order to represent all the data. - */ - rescale: function () { - let gettime = v => { return v.time; }, - getvalue = v => { return v.value; }, - ignored = c => { return this.ignored.has(c.id); }; - - let xmin = null, xmax = null, ymin = null, ymax = null; - for (let curve of this.curves.values()) { - if (ignored(curve)) { - continue; - } - if (xmax == null || curve.xmax > xmax) { - xmax = curve.xmax; - } - if (xmin == null || curve.xmin < xmin) { - xmin = curve.xmin; - } - if (ymax == null || curve.ymax > ymax) { - ymax = curve.ymax; - } - if (ymin == null || curve.ymin < ymin) { - ymin = curve.ymin; - } - } - for (let event of this.events.values()) { - if (ignored(event)) { - continue; - } - if (xmax == null || event.xmax > xmax) { - xmax = event.xmax; - } - if (xmin == null || event.xmin < xmin) { - xmin = event.xmin; - } - } - - let oldxdomain = this.x.domain(); - if (xmin != null && xmax != null) { - this.x.domain([xmin, xmax]); - let newxdomain = this.x.domain(); - if (newxdomain[0] !== oldxdomain[0] || newxdomain[1] !== oldxdomain[1]) { - this.xelement.call(this.xaxis); - } - } - - let oldydomain = this.y.domain(); - if (ymin != null && ymax != null) { - this.y.domain([ymin, ymax]).nice(); - let newydomain = this.y.domain(); - if (newydomain[0] !== oldydomain[0] || newydomain[1] !== oldydomain[1]) { - this.yelement.call(this.yaxis); - } - } - }, - - /** - * Add new values to the graph. - */ - update: function (data) { - delete data.graph; - - let time = data.time || Date.now(); - delete data.time; - - let curve = data.curve; - delete data.curve; - - // Single curve value, e.g. { curve: 'memory', value: 42, time: 1234 }. - if ("value" in data) { - this.push(this.curves, curve, [{time: time, value: data.value}]); - delete data.value; - } - - // Several curve values, e.g. { curve: 'memory', values: [{value: 42, time: 1234}] }. - if ("values" in data) { - this.push(this.curves, curve, data.values); - delete data.values; - } - - // Punctual event, e.g. { event: 'gc', time: 1234 }, - // event with duration, e.g. { event: 'jank', duration: 425, time: 1234 }. - if ("event" in data) { - this.push(this.events, data.event, [{time: time, value: data.duration}]); - delete data.event; - delete data.duration; - } - - // Remaining keys are curves, e.g. { time: 1234, memory: 42, battery: 13, temperature: 45 }. - for (let key in data) { - this.push(this.curves, key, [{time: time, value: data[key]}]); - } - - // If no render is currently pending, request one. - if (this.enabled && !this.request) { - this.request = requestAnimationFrame(this.render); - } - }, - - /** - * Insert new data into the graph's data structures. - */ - push: function (collection, id, values) { - - // Note: collection is either `this.curves` or `this.events`. - let item = collection.get(id); - if (!item) { - item = { id: id, values: [], xmin: null, xmax: null, ymin: 0, ymax: null, average: 0 }; - collection.set(id, item); - } - - for (let v of values) { - let time = new Date(v.time), value = +v.value; - // Update the curve/event's domain values. - if (item.xmax == null || time > item.xmax) { - item.xmax = time; - } - if (item.xmin == null || time < item.xmin) { - item.xmin = time; - } - if (item.ymax == null || value > item.ymax) { - item.ymax = value; - } - if (item.ymin == null || value < item.ymin) { - item.ymin = value; - } - // Note: A curve's average is not computed here. Call `graph.averages()`. - item.values.push({ time: time, value: value }); - } - }, - - /** - * Render the SVG graph with curves, events, crosshair and legend. - */ - render: function () { - this.request = null; - this.rescale(); - - - // DATA - - let self = this, - getid = d => { return d.id; }, - gettime = d => { return d.time.getTime(); }, - getline = d => { return self.line(d.values); }, - getcolor = d => { return self.color(d.id); }, - getvalues = d => { return d.values; }, - ignored = d => { return self.ignored.has(d.id); }; - - // Convert our maps to arrays for d3. - let curvedata = [...this.curves.values()], - eventdata = [...this.events.values()], - data = curvedata.concat(eventdata); - - - // CURVES - - // Map curve data to curve elements. - let curves = this.svg.selectAll(".curve").data(curvedata, getid); - - // Create new curves (no element corresponding to the data). - curves.enter().append("g").attr("class", "curve").append("path") - .style("stroke", getcolor); - - // Delete old curves (elements corresponding to data not present anymore). - curves.exit().remove(); - - // Update all curves from data. - this.svg.selectAll(".curve").select("path") - .attr("d", d => { return ignored(d) ? "" : getline(d); }); - - let height = parseFloat(getComputedStyle(this.element).height) - this.margin.top - this.margin.bottom; - - - // EVENTS - - // Map event data to event elements. - let events = this.svg.selectAll(".event-slot").data(eventdata, getid); - - // Create new events. - events.enter().append("g").attr("class", "event-slot"); - - // Remove old events. - events.exit().remove(); - - // Get all occurences of an event, and map its data to them. - let lines = this.svg.selectAll(".event-slot") - .style("stroke", d => { return ignored(d) ? "none" : getcolor(d); }) - .selectAll(".event") - .data(getvalues, gettime); - - // Create new event occurrence. - lines.enter().append("line").attr("class", "event").attr("y2", height); - - // Delete old event occurrence. - lines.exit().remove(); - - // Update all event occurrences from data. - this.svg.selectAll(".event") - .attr("transform", d => { return "translate(" + self.x(d.time) + ",0)"; }); - - - // CROSSHAIR - - // TODO select curves and events, intersect with curves and show values/hovers - // e.g. look like http://code.shutterstock.com/rickshaw/examples/lines.html - - // Update crosshair labels on each axis. - this.xruler.select("text").text(self.xformat(self.x.invert(self.mousex))); - this.yruler.select("text").text(self.yformat(self.y.invert(self.mousey))); - - - // LEGEND - - // Map data to legend elements. - let legends = this.legend.selectAll("label").data(data, getid); - - // Update averages. - legends.attr("title", c => { return "Average: " + self.yformat(c.average); }); - - // Create new legends. - let newlegend = legends.enter().append("label"); - newlegend.append("input").attr("type", "checkbox").attr("checked", "true").on("click", function (c) { - if (ignored(c)) { - this.parentElement.classList.remove("disabled"); - self.ignored.delete(c.id); - } else { - this.parentElement.classList.add("disabled"); - self.ignored.add(c.id); - } - self.update({}); // if no re-render is pending, request one. - }); - newlegend.append("span").attr("class", "legend-color").style("background-color", getcolor); - newlegend.append("span").attr("class", "legend-id").text(getid); - - // Delete old legends. - legends.exit().remove(); - }, - - /** - * Returns a SI value formatter with a given precision. - */ - formatter: function (decimals) { - return value => { - // Don't use sub-unit SI prefixes (milli, micro, etc.). - if (Math.abs(value) < 1) return value.toFixed(decimals); - // SI prefix, e.g. 1234567 will give '1.2M' at precision 1. - let prefix = d3.formatPrefix(value); - return prefix.scale(value).toFixed(decimals) + prefix.symbol; - }; - }, - - /** - * Compute the average of each time series. - */ - averages: function () { - for (let c of this.curves.values()) { - let length = c.values.length; - if (length > 0) { - let total = 0; - c.values.forEach(v => total += v.value); - c.average = (total / length); - } - } - }, - - /** - * Bisect a time serie to find the data point immediately left of `time`. - */ - bisectTime: d3.bisector(d => d.time).left, - - /** - * Get all curve values at a given time. - */ - valuesAt: function (time) { - let values = { time: time }; - - for (let id of this.curves.keys()) { - let curve = this.curves.get(id); - - // Find the closest value just before `time`. - let i = this.bisectTime(curve.values, time); - if (i < 0) { - // Curve starts after `time`, use first value. - values[id] = curve.values[0].value; - } else if (i > curve.values.length - 2) { - // Curve ends before `time`, use last value. - values[id] = curve.values[curve.values.length - 1].value; - } else { - // Curve has two values around `time`, interpolate. - let v1 = curve.values[i], - v2 = curve.values[i + 1], - delta = (time - v1.time) / (v2.time - v1.time); - values[id] = v1.value + (v2.value - v1.time) * delta; - } - } - return values; - } - -}; diff --git a/devtools/client/webide/content/monitor.xhtml b/devtools/client/webide/content/monitor.xhtml deleted file mode 100644 index 552f3826c..000000000 --- a/devtools/client/webide/content/monitor.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - - - -

        &monitor_title;

        - - - diff --git a/devtools/client/webide/content/moz.build b/devtools/client/webide/content/moz.build deleted file mode 100644 index aac3a838c..000000000 --- a/devtools/client/webide/content/moz.build +++ /dev/null @@ -1,7 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -JAR_MANIFESTS += ['jar.mn'] diff --git a/devtools/client/webide/content/newapp.js b/devtools/client/webide/content/newapp.js deleted file mode 100644 index d47bfabec..000000000 --- a/devtools/client/webide/content/newapp.js +++ /dev/null @@ -1,175 +0,0 @@ -/* 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/. */ - -"use strict"; - -var Cc = Components.classes; -var Cu = Components.utils; -var Ci = Components.interfaces; - -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); -const Services = require("Services"); -const {FileUtils} = require("resource://gre/modules/FileUtils.jsm"); -const {AppProjects} = require("devtools/client/webide/modules/app-projects"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {getJSON} = require("devtools/client/shared/getjson"); - -XPCOMUtils.defineLazyModuleGetter(this, "ZipUtils", "resource://gre/modules/ZipUtils.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Downloads", "resource://gre/modules/Downloads.jsm"); - -const TEMPLATES_URL = "devtools.webide.templatesURL"; - -var gTemplateList = null; - -// See bug 989619 -console.log = console.log.bind(console); -console.warn = console.warn.bind(console); -console.error = console.error.bind(console); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - let projectNameNode = document.querySelector("#project-name"); - projectNameNode.addEventListener("input", canValidate, true); - getTemplatesJSON(); -}, true); - -function getTemplatesJSON() { - getJSON(TEMPLATES_URL).then(list => { - if (!Array.isArray(list)) { - throw new Error("JSON response not an array"); - } - if (list.length == 0) { - throw new Error("JSON response is an empty array"); - } - gTemplateList = list; - let templatelistNode = document.querySelector("#templatelist"); - templatelistNode.innerHTML = ""; - for (let template of list) { - let richlistitemNode = document.createElement("richlistitem"); - let imageNode = document.createElement("image"); - imageNode.setAttribute("src", template.icon); - let labelNode = document.createElement("label"); - labelNode.setAttribute("value", template.name); - let descriptionNode = document.createElement("description"); - descriptionNode.textContent = template.description; - let vboxNode = document.createElement("vbox"); - vboxNode.setAttribute("flex", "1"); - richlistitemNode.appendChild(imageNode); - vboxNode.appendChild(labelNode); - vboxNode.appendChild(descriptionNode); - richlistitemNode.appendChild(vboxNode); - templatelistNode.appendChild(richlistitemNode); - } - templatelistNode.selectedIndex = 0; - - /* Chrome mochitest support */ - let testOptions = window.arguments[0].testOptions; - if (testOptions) { - templatelistNode.selectedIndex = testOptions.index; - document.querySelector("#project-name").value = testOptions.name; - doOK(); - } - }, (e) => { - failAndBail("Can't download app templates: " + e); - }); -} - -function failAndBail(msg) { - let promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService); - promptService.alert(window, "error", msg); - window.close(); -} - -function canValidate() { - let projectNameNode = document.querySelector("#project-name"); - let dialogNode = document.querySelector("dialog"); - if (projectNameNode.value.length > 0) { - dialogNode.removeAttribute("buttondisabledaccept"); - } else { - dialogNode.setAttribute("buttondisabledaccept", "true"); - } -} - -function doOK() { - let projectName = document.querySelector("#project-name").value; - - if (!projectName) { - console.error("No project name"); - return false; - } - - if (!gTemplateList) { - console.error("No template index"); - return false; - } - - let templatelistNode = document.querySelector("#templatelist"); - if (templatelistNode.selectedIndex < 0) { - console.error("No template selected"); - return false; - } - - let folder; - - /* Chrome mochitest support */ - let testOptions = window.arguments[0].testOptions; - if (testOptions) { - folder = testOptions.folder; - } else { - let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); - fp.init(window, "Select directory where to create app directory", Ci.nsIFilePicker.modeGetFolder); - let res = fp.show(); - if (res == Ci.nsIFilePicker.returnCancel) { - console.error("No directory selected"); - return false; - } - folder = fp.file; - } - - // Create subfolder with fs-friendly name of project - let subfolder = projectName.replace(/[\\/:*?"<>|]/g, "").toLowerCase(); - let win = Services.wm.getMostRecentWindow("devtools:webide"); - folder.append(subfolder); - - try { - folder.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); - } catch (e) { - win.UI.reportError("error_folderCreationFailed"); - window.close(); - return false; - } - - // Download boilerplate zip - let template = gTemplateList[templatelistNode.selectedIndex]; - let source = template.file; - let target = folder.clone(); - target.append(subfolder + ".zip"); - - let bail = (e) => { - console.error(e); - window.close(); - }; - - Downloads.fetch(source, target).then(() => { - ZipUtils.extractFiles(target, folder); - target.remove(false); - AppProjects.addPackaged(folder).then((project) => { - window.arguments[0].location = project.location; - AppManager.validateAndUpdateProject(project).then(() => { - if (project.manifest) { - project.manifest.name = projectName; - AppManager.writeManifest(project).then(() => { - AppManager.validateAndUpdateProject(project).then( - () => {window.close();}, bail); - }, bail); - } else { - bail("Manifest not found"); - } - }, bail); - }, bail); - }, bail); - - return false; -} diff --git a/devtools/client/webide/content/newapp.xul b/devtools/client/webide/content/newapp.xul deleted file mode 100644 index 7ff083519..000000000 --- a/devtools/client/webide/content/newapp.xul +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - diff --git a/devtools/client/webide/content/permissionstable.js b/devtools/client/webide/content/permissionstable.js deleted file mode 100644 index 22c74bd0d..000000000 --- a/devtools/client/webide/content/permissionstable.js +++ /dev/null @@ -1,78 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.querySelector("#close").onclick = CloseUI; - AppManager.on("app-manager-update", OnAppManagerUpdate); - BuildUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - } -} - -function generateFields(json) { - let table = document.querySelector("table"); - let permissionsTable = json.rawPermissionsTable; - for (let name in permissionsTable) { - let tr = document.createElement("tr"); - tr.className = "line"; - let td = document.createElement("td"); - td.textContent = name; - tr.appendChild(td); - for (let type of ["app", "privileged", "certified"]) { - let td = document.createElement("td"); - if (permissionsTable[name][type] == json.ALLOW_ACTION) { - td.textContent = "✓"; - td.className = "permallow"; - } - if (permissionsTable[name][type] == json.PROMPT_ACTION) { - td.textContent = "!"; - td.className = "permprompt"; - } - if (permissionsTable[name][type] == json.DENY_ACTION) { - td.textContent = "✕"; - td.className = "permdeny"; - } - tr.appendChild(td); - } - table.appendChild(tr); - } -} - -var getRawPermissionsTablePromise; // Used by tests -function BuildUI() { - let table = document.querySelector("table"); - let lines = table.querySelectorAll(".line"); - for (let line of lines) { - line.remove(); - } - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.deviceFront) { - getRawPermissionsTablePromise = AppManager.deviceFront.getRawPermissionsTable() - .then(json => generateFields(json)); - } else { - CloseUI(); - } -} diff --git a/devtools/client/webide/content/permissionstable.xhtml b/devtools/client/webide/content/permissionstable.xhtml deleted file mode 100644 index 361cfece8..000000000 --- a/devtools/client/webide/content/permissionstable.xhtml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - -

        &permissionstable_title;

        - - - - - - - - -
        &permissionstable_name_header;type:webtype:privilegedtype:certified
        - - diff --git a/devtools/client/webide/content/prefs.js b/devtools/client/webide/content/prefs.js deleted file mode 100644 index 75f6233ba..000000000 --- a/devtools/client/webide/content/prefs.js +++ /dev/null @@ -1,108 +0,0 @@ -/* 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/. */ - -"use strict"; - -const Cu = Components.utils; -const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - - // Listen to preference changes - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - Services.prefs.addObserver(pref, FillForm, false); - i.addEventListener("change", SaveForm, false); - } - - // Buttons - document.querySelector("#close").onclick = CloseUI; - document.querySelector("#restore").onclick = RestoreDefaults; - document.querySelector("#manageComponents").onclick = ShowAddons; - - // Initialize the controls - FillForm(); - -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - i.removeEventListener("change", SaveForm, false); - Services.prefs.removeObserver(pref, FillForm, false); - } -}, true); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function ShowAddons() { - window.parent.Cmds.showAddons(); -} - -function FillForm() { - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - let val = GetPref(pref); - if (i.type == "checkbox") { - i.checked = val; - } else { - i.value = val; - } - } -} - -function SaveForm(e) { - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - if (i.type == "checkbox") { - SetPref(pref, i.checked); - } else { - SetPref(pref, i.value); - } - } -} - -function GetPref(name) { - let type = Services.prefs.getPrefType(name); - switch (type) { - case Services.prefs.PREF_STRING: - return Services.prefs.getCharPref(name); - case Services.prefs.PREF_INT: - return Services.prefs.getIntPref(name); - case Services.prefs.PREF_BOOL: - return Services.prefs.getBoolPref(name); - default: - throw new Error("Unknown type"); - } -} - -function SetPref(name, value) { - let type = Services.prefs.getPrefType(name); - switch (type) { - case Services.prefs.PREF_STRING: - return Services.prefs.setCharPref(name, value); - case Services.prefs.PREF_INT: - return Services.prefs.setIntPref(name, value); - case Services.prefs.PREF_BOOL: - return Services.prefs.setBoolPref(name, value); - default: - throw new Error("Unknown type"); - } -} - -function RestoreDefaults() { - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - Services.prefs.clearUserPref(pref); - } -} diff --git a/devtools/client/webide/content/prefs.xhtml b/devtools/client/webide/content/prefs.xhtml deleted file mode 100644 index 726ca772c..000000000 --- a/devtools/client/webide/content/prefs.xhtml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - -

        &prefs_title;

        - -

        &prefs_general_title;

        - -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        - -

        &prefs_editor_title;

        - -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        - - - diff --git a/devtools/client/webide/content/project-listing.js b/devtools/client/webide/content/project-listing.js deleted file mode 100644 index 5641f6c0c..000000000 --- a/devtools/client/webide/content/project-listing.js +++ /dev/null @@ -1,42 +0,0 @@ -/* 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/. */ - -/* eslint-env browser */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const ProjectList = require("devtools/client/webide/modules/project-list"); - -var projectList = new ProjectList(window, window.parent); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad, true); - document.getElementById("new-app").onclick = CreateNewApp; - document.getElementById("hosted-app").onclick = ImportHostedApp; - document.getElementById("packaged-app").onclick = ImportPackagedApp; - document.getElementById("refresh-tabs").onclick = RefreshTabs; - projectList.update(); - projectList.updateCommands(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - projectList.destroy(); -}); - -function RefreshTabs() { - projectList.refreshTabs(); -} - -function CreateNewApp() { - projectList.newApp(); -} - -function ImportHostedApp() { - projectList.importHostedApp(); -} - -function ImportPackagedApp() { - projectList.importPackagedApp(); -} diff --git a/devtools/client/webide/content/project-listing.xhtml b/devtools/client/webide/content/project-listing.xhtml deleted file mode 100644 index 337befe5d..000000000 --- a/devtools/client/webide/content/project-listing.xhtml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - -
        -
        - - - - -
        - -
        - -
        -
        -
        - - diff --git a/devtools/client/webide/content/project-panel.js b/devtools/client/webide/content/project-panel.js deleted file mode 100644 index 54eab8251..000000000 --- a/devtools/client/webide/content/project-panel.js +++ /dev/null @@ -1,11 +0,0 @@ -/* 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/. */ - -var ProjectPanel = { - // TODO: Expand function to save toggle state. - toggleSidebar: function () { - document.querySelector("#project-listing-panel").setAttribute("sidebar-displayed", true); - document.querySelector("#project-listing-splitter").setAttribute("sidebar-displayed", true); - } -}; diff --git a/devtools/client/webide/content/runtime-listing.js b/devtools/client/webide/content/runtime-listing.js deleted file mode 100644 index 0a1a40a2a..000000000 --- a/devtools/client/webide/content/runtime-listing.js +++ /dev/null @@ -1,66 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const RuntimeList = require("devtools/client/webide/modules/runtime-list"); - -var runtimeList = new RuntimeList(window, window.parent); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad, true); - document.getElementById("runtime-screenshot").onclick = TakeScreenshot; - document.getElementById("runtime-permissions").onclick = ShowPermissionsTable; - document.getElementById("runtime-details").onclick = ShowRuntimeDetails; - document.getElementById("runtime-disconnect").onclick = DisconnectRuntime; - document.getElementById("runtime-preferences").onclick = ShowDevicePreferences; - document.getElementById("runtime-settings").onclick = ShowSettings; - document.getElementById("runtime-panel-installsimulator").onclick = ShowAddons; - document.getElementById("runtime-panel-noadbhelper").onclick = ShowAddons; - document.getElementById("runtime-panel-nousbdevice").onclick = ShowTroubleShooting; - document.getElementById("refresh-devices").onclick = RefreshScanners; - runtimeList.update(); - runtimeList.updateCommands(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - runtimeList.destroy(); -}); - -function TakeScreenshot() { - runtimeList.takeScreenshot(); -} - -function ShowRuntimeDetails() { - runtimeList.showRuntimeDetails(); -} - -function ShowPermissionsTable() { - runtimeList.showPermissionsTable(); -} - -function ShowDevicePreferences() { - runtimeList.showDevicePreferences(); -} - -function ShowSettings() { - runtimeList.showSettings(); -} - -function RefreshScanners() { - runtimeList.refreshScanners(); -} - -function DisconnectRuntime() { - window.parent.Cmds.disconnectRuntime(); -} - -function ShowAddons() { - runtimeList.showAddons(); -} - -function ShowTroubleShooting() { - runtimeList.showTroubleShooting(); -} diff --git a/devtools/client/webide/content/runtime-listing.xhtml b/devtools/client/webide/content/runtime-listing.xhtml deleted file mode 100644 index f648fac12..000000000 --- a/devtools/client/webide/content/runtime-listing.xhtml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - -
        -
        - - - -
        - -
        - -
        - - -
        -
        - - - - - - -
        -
        -
        - - diff --git a/devtools/client/webide/content/runtime-panel.js b/devtools/client/webide/content/runtime-panel.js deleted file mode 100644 index 3646fa15c..000000000 --- a/devtools/client/webide/content/runtime-panel.js +++ /dev/null @@ -1,11 +0,0 @@ -/* 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/. */ - -var RuntimePanel = { - // TODO: Expand function to save toggle state. - toggleSidebar: function () { - document.querySelector("#runtime-listing-panel").setAttribute("sidebar-displayed", true); - document.querySelector("#runtime-listing-splitter").setAttribute("sidebar-displayed", true); - } -}; diff --git a/devtools/client/webide/content/runtimedetails.js b/devtools/client/webide/content/runtimedetails.js deleted file mode 100644 index dea423e81..000000000 --- a/devtools/client/webide/content/runtimedetails.js +++ /dev/null @@ -1,153 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const {RuntimeTypes} = require("devtools/client/webide/modules/runtimes"); -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -const UNRESTRICTED_HELP_URL = "https://developer.mozilla.org/docs/Tools/WebIDE/Running_and_debugging_apps#Unrestricted_app_debugging_%28including_certified_apps_main_process_etc.%29"; - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.querySelector("#close").onclick = CloseUI; - document.querySelector("#devtools-check button").onclick = EnableCertApps; - document.querySelector("#adb-check button").onclick = RootADB; - document.querySelector("#unrestricted-privileges").onclick = function () { - window.parent.UI.openInBrowser(UNRESTRICTED_HELP_URL); - }; - AppManager.on("app-manager-update", OnAppManagerUpdate); - BuildUI(); - CheckLockState(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - CheckLockState(); - } -} - -function generateFields(json) { - let table = document.querySelector("table"); - for (let name in json) { - let tr = document.createElement("tr"); - let td = document.createElement("td"); - td.textContent = name; - tr.appendChild(td); - td = document.createElement("td"); - td.textContent = json[name]; - tr.appendChild(td); - table.appendChild(tr); - } -} - -var getDescriptionPromise; // Used by tests -function BuildUI() { - let table = document.querySelector("table"); - table.innerHTML = ""; - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.deviceFront) { - getDescriptionPromise = AppManager.deviceFront.getDescription() - .then(json => generateFields(json)); - } else { - CloseUI(); - } -} - -function CheckLockState() { - let adbCheckResult = document.querySelector("#adb-check > .yesno"); - let devtoolsCheckResult = document.querySelector("#devtools-check > .yesno"); - let flipCertPerfButton = document.querySelector("#devtools-check button"); - let adbRootButton = document.querySelector("#adb-check button"); - let flipCertPerfAction = document.querySelector("#devtools-check > .action"); - let adbRootAction = document.querySelector("#adb-check > .action"); - - let sYes = Strings.GetStringFromName("runtimedetails_checkyes"); - let sNo = Strings.GetStringFromName("runtimedetails_checkno"); - let sUnknown = Strings.GetStringFromName("runtimedetails_checkunknown"); - let sNotUSB = Strings.GetStringFromName("runtimedetails_notUSBDevice"); - - flipCertPerfButton.setAttribute("disabled", "true"); - flipCertPerfAction.setAttribute("hidden", "true"); - adbRootAction.setAttribute("hidden", "true"); - - adbCheckResult.textContent = sUnknown; - devtoolsCheckResult.textContent = sUnknown; - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED) { - - // ADB check - if (AppManager.selectedRuntime.type === RuntimeTypes.USB) { - let device = AppManager.selectedRuntime.device; - if (device && device.summonRoot) { - device.isRoot().then(isRoot => { - if (isRoot) { - adbCheckResult.textContent = sYes; - flipCertPerfButton.removeAttribute("disabled"); - } else { - adbCheckResult.textContent = sNo; - adbRootAction.removeAttribute("hidden"); - } - }, e => console.error(e)); - } else { - adbCheckResult.textContent = sUnknown; - } - } else { - adbCheckResult.textContent = sNotUSB; - } - - // forbid-certified-apps check - try { - let prefFront = AppManager.preferenceFront; - prefFront.getBoolPref("devtools.debugger.forbid-certified-apps").then(isForbidden => { - if (isForbidden) { - devtoolsCheckResult.textContent = sNo; - flipCertPerfAction.removeAttribute("hidden"); - } else { - devtoolsCheckResult.textContent = sYes; - } - }, e => console.error(e)); - } catch (e) { - // Exception. pref actor is only accessible if forbird-certified-apps is false - devtoolsCheckResult.textContent = sNo; - flipCertPerfAction.removeAttribute("hidden"); - } - - } - -} - -function EnableCertApps() { - let device = AppManager.selectedRuntime.device; - // TODO: Remove `network.disable.ipc.security` once bug 1125916 is fixed. - device.shell( - "stop b2g && " + - "cd /data/b2g/mozilla/*.default/ && " + - "echo 'user_pref(\"devtools.debugger.forbid-certified-apps\", false);' >> prefs.js && " + - "echo 'user_pref(\"dom.apps.developer_mode\", true);' >> prefs.js && " + - "echo 'user_pref(\"network.disable.ipc.security\", true);' >> prefs.js && " + - "echo 'user_pref(\"dom.webcomponents.enabled\", true);' >> prefs.js && " + - "start b2g" - ); -} - -function RootADB() { - let device = AppManager.selectedRuntime.device; - device.summonRoot().then(CheckLockState, (e) => console.error(e)); -} diff --git a/devtools/client/webide/content/runtimedetails.xhtml b/devtools/client/webide/content/runtimedetails.xhtml deleted file mode 100644 index b2f74728a..000000000 --- a/devtools/client/webide/content/runtimedetails.xhtml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - -

        &runtimedetails_title;

        - -
        -

        - &runtimedetails_adbIsRoot; -

        - - &runtimedetails_ADBRootWarning; -
        -

        -

        - &runtimedetails_unrestrictedPrivileges; -

        - - &runtimedetails_privilegesWarning; -
        -

        -
        - -
        - - diff --git a/devtools/client/webide/content/simulator.js b/devtools/client/webide/content/simulator.js deleted file mode 100644 index ddc1cbed1..000000000 --- a/devtools/client/webide/content/simulator.js +++ /dev/null @@ -1,352 +0,0 @@ -/* 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/. */ - -var Cu = Components.utils; -var Ci = Components.interfaces; - -const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const { getDevices, getDeviceString } = require("devtools/client/shared/devices"); -const { Simulators, Simulator } = require("devtools/client/webide/modules/simulators"); -const Services = require("Services"); -const EventEmitter = require("devtools/shared/event-emitter"); -const promise = require("promise"); -const utils = require("devtools/client/webide/modules/utils"); - -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -var SimulatorEditor = { - - // Available Firefox OS Simulator addons (key: `addon.id`). - _addons: {}, - - // Available device simulation profiles (key: `device.name`). - _devices: {}, - - // The names of supported simulation options. - _deviceOptions: [], - - // The
        element used to edit Simulator options. - _form: null, - - // The Simulator object being edited. - _simulator: null, - - // Generate the dynamic form elements. - init() { - let promises = []; - - // Grab the element. - let form = this._form; - if (!form) { - // This is the first time we run `init()`, bootstrap some things. - form = this._form = document.querySelector("#simulator-editor"); - form.addEventListener("change", this.update.bind(this)); - Simulators.on("configure", (e, simulator) => { this.edit(simulator); }); - // Extract the list of device simulation options we'll support. - let deviceFields = form.querySelectorAll("*[data-device]"); - this._deviceOptions = Array.map(deviceFields, field => field.name); - } - - // Append a new
        - - - diff --git a/devtools/client/webide/content/webide.js b/devtools/client/webide/content/webide.js deleted file mode 100644 index c222332e3..000000000 --- a/devtools/client/webide/content/webide.js +++ /dev/null @@ -1,1157 +0,0 @@ -/* 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/. */ - -var Cc = Components.classes; -var Cu = Components.utils; -var Ci = Components.interfaces; - -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {gDevTools} = require("devtools/client/framework/devtools"); -const {gDevToolsBrowser} = require("devtools/client/framework/devtools-browser"); -const {Toolbox} = require("devtools/client/framework/toolbox"); -const Services = require("Services"); -const {AppProjects} = require("devtools/client/webide/modules/app-projects"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const EventEmitter = require("devtools/shared/event-emitter"); -const promise = require("promise"); -const ProjectEditor = require("devtools/client/projecteditor/lib/projecteditor"); -const {GetAvailableAddons} = require("devtools/client/webide/modules/addons"); -const {getJSON} = require("devtools/client/shared/getjson"); -const utils = require("devtools/client/webide/modules/utils"); -const Telemetry = require("devtools/client/shared/telemetry"); -const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes"); -const {showDoorhanger} = require("devtools/client/shared/doorhanger"); -const {Simulators} = require("devtools/client/webide/modules/simulators"); -const {Task} = require("devtools/shared/task"); - -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -const HTML = "http://www.w3.org/1999/xhtml"; -const HELP_URL = "https://developer.mozilla.org/docs/Tools/WebIDE/Troubleshooting"; - -const MAX_ZOOM = 1.4; -const MIN_ZOOM = 0.6; - -const MS_PER_DAY = 86400000; - -[["AppManager", AppManager], - ["AppProjects", AppProjects], - ["Connection", Connection]].forEach(([key, value]) => { - Object.defineProperty(this, key, { - value: value, - enumerable: true, - writable: false - }); - }); - -// Download remote resources early -getJSON("devtools.webide.addonsURL"); -getJSON("devtools.webide.templatesURL"); -getJSON("devtools.devices.url"); - -// See bug 989619 -console.log = console.log.bind(console); -console.warn = console.warn.bind(console); -console.error = console.error.bind(console); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - UI.init(); -}); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - UI.destroy(); -}); - -var UI = { - init: function () { - this._telemetry = new Telemetry(); - this._telemetry.toolOpened("webide"); - - AppManager.init(); - - this.appManagerUpdate = this.appManagerUpdate.bind(this); - AppManager.on("app-manager-update", this.appManagerUpdate); - - Cmds.showProjectPanel(); - Cmds.showRuntimePanel(); - - this.updateCommands(); - - this.onfocus = this.onfocus.bind(this); - window.addEventListener("focus", this.onfocus, true); - - AppProjects.load().then(() => { - this.autoSelectProject(); - }, e => { - console.error(e); - this.reportError("error_appProjectsLoadFailed"); - }); - - // Auto install the ADB Addon Helper and Tools Adapters. Only once. - // If the user decides to uninstall any of this addon, we won't install it again. - let autoinstallADBHelper = Services.prefs.getBoolPref("devtools.webide.autoinstallADBHelper"); - let autoinstallFxdtAdapters = Services.prefs.getBoolPref("devtools.webide.autoinstallFxdtAdapters"); - if (autoinstallADBHelper) { - GetAvailableAddons().then(addons => { - addons.adb.install(); - }, console.error); - } - if (autoinstallFxdtAdapters) { - GetAvailableAddons().then(addons => { - addons.adapters.install(); - }, console.error); - } - Services.prefs.setBoolPref("devtools.webide.autoinstallADBHelper", false); - Services.prefs.setBoolPref("devtools.webide.autoinstallFxdtAdapters", false); - - if (Services.prefs.getBoolPref("devtools.webide.widget.autoinstall") && - !Services.prefs.getBoolPref("devtools.webide.widget.enabled")) { - Services.prefs.setBoolPref("devtools.webide.widget.enabled", true); - gDevToolsBrowser.moveWebIDEWidgetInNavbar(); - } - - this.setupDeck(); - - this.contentViewer = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .contentViewer; - this.contentViewer.fullZoom = Services.prefs.getCharPref("devtools.webide.zoom"); - - gDevToolsBrowser.isWebIDEInitialized.resolve(); - - this.configureSimulator = this.configureSimulator.bind(this); - Simulators.on("configure", this.configureSimulator); - }, - - destroy: function () { - window.removeEventListener("focus", this.onfocus, true); - AppManager.off("app-manager-update", this.appManagerUpdate); - AppManager.destroy(); - Simulators.off("configure", this.configureSimulator); - this.updateConnectionTelemetry(); - this._telemetry.toolClosed("webide"); - this._telemetry.toolClosed("webideProjectEditor"); - this._telemetry.destroy(); - }, - - canCloseProject: function () { - if (this.projecteditor) { - return this.projecteditor.confirmUnsaved(); - } - return true; - }, - - onfocus: function () { - // Because we can't track the activity in the folder project, - // we need to validate the project regularly. Let's assume that - // if a modification happened, it happened when the window was - // not focused. - if (AppManager.selectedProject && - AppManager.selectedProject.type != "mainProcess" && - AppManager.selectedProject.type != "runtimeApp" && - AppManager.selectedProject.type != "tab") { - AppManager.validateAndUpdateProject(AppManager.selectedProject); - } - - // Hook to display promotional Developer Edition doorhanger. Only displayed once. - // Hooked into the `onfocus` event because sometimes does not work - // when run at the end of `init`. ¯\(°_o)/¯ - showDoorhanger({ window, type: "deveditionpromo", anchor: document.querySelector("#deck") }); - }, - - appManagerUpdate: function (event, what, details) { - // Got a message from app-manager.js - // See AppManager.update() for descriptions of what these events mean. - switch (what) { - case "runtime-list": - this.autoConnectRuntime(); - break; - case "connection": - this.updateRuntimeButton(); - this.updateCommands(); - this.updateConnectionTelemetry(); - break; - case "before-project": - if (!this.canCloseProject()) { - details.cancel(); - } - break; - case "project": - this._updatePromise = Task.spawn(function* () { - UI.updateTitle(); - yield UI.destroyToolbox(); - UI.updateCommands(); - UI.openProject(); - yield UI.autoStartProject(); - UI.autoOpenToolbox(); - UI.saveLastSelectedProject(); - UI.updateRemoveProjectButton(); - }); - return; - case "project-started": - this.updateCommands(); - UI.autoOpenToolbox(); - break; - case "project-stopped": - UI.destroyToolbox(); - this.updateCommands(); - break; - case "runtime-global-actors": - // Check runtime version only on runtime-global-actors, - // as we expect to use device actor - this.checkRuntimeVersion(); - this.updateCommands(); - break; - case "runtime-details": - this.updateRuntimeButton(); - break; - case "runtime": - this.updateRuntimeButton(); - this.saveLastConnectedRuntime(); - break; - case "project-validated": - this.updateTitle(); - this.updateCommands(); - this.updateProjectEditorHeader(); - break; - case "install-progress": - this.updateProgress(Math.round(100 * details.bytesSent / details.totalBytes)); - break; - case "runtime-targets": - this.autoSelectProject(); - break; - case "pre-package": - this.prePackageLog(details); - break; - } - this._updatePromise = promise.resolve(); - }, - - configureSimulator: function (event, simulator) { - UI.selectDeckPanel("simulator"); - }, - - openInBrowser: function (url) { - // Open a URL in a Firefox window - let mainWindow = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType); - if (mainWindow) { - mainWindow.openUILinkIn(url, "tab"); - mainWindow.focus() - } else { - window.open(url); - } - }, - - updateTitle: function () { - let project = AppManager.selectedProject; - if (project) { - window.document.title = Strings.formatStringFromName("title_app", [project.name], 1); - } else { - window.document.title = Strings.GetStringFromName("title_noApp"); - } - }, - - /** ******** BUSY UI **********/ - - _busyTimeout: null, - _busyOperationDescription: null, - _busyPromise: null, - - updateProgress: function (percent) { - let progress = document.querySelector("#action-busy-determined"); - progress.mode = "determined"; - progress.value = percent; - this.setupBusyTimeout(); - }, - - busy: function () { - let win = document.querySelector("window"); - win.classList.add("busy"); - win.classList.add("busy-undetermined"); - this.updateCommands(); - this.update("busy"); - }, - - unbusy: function () { - let win = document.querySelector("window"); - win.classList.remove("busy"); - win.classList.remove("busy-determined"); - win.classList.remove("busy-undetermined"); - this.updateCommands(); - this.update("unbusy"); - this._busyPromise = null; - }, - - setupBusyTimeout: function () { - this.cancelBusyTimeout(); - this._busyTimeout = setTimeout(() => { - this.unbusy(); - UI.reportError("error_operationTimeout", this._busyOperationDescription); - }, Services.prefs.getIntPref("devtools.webide.busyTimeout")); - }, - - cancelBusyTimeout: function () { - clearTimeout(this._busyTimeout); - }, - - busyWithProgressUntil: function (promise, operationDescription) { - let busy = this.busyUntil(promise, operationDescription); - let win = document.querySelector("window"); - let progress = document.querySelector("#action-busy-determined"); - progress.mode = "undetermined"; - win.classList.add("busy-determined"); - win.classList.remove("busy-undetermined"); - return busy; - }, - - busyUntil: function (promise, operationDescription) { - // Freeze the UI until the promise is resolved. A timeout will unfreeze the - // UI, just in case the promise never gets resolved. - this._busyPromise = promise; - this._busyOperationDescription = operationDescription; - this.setupBusyTimeout(); - this.busy(); - promise.then(() => { - this.cancelBusyTimeout(); - this.unbusy(); - }, (e) => { - let message; - if (e && e.error && e.message) { - // Some errors come from fronts that are not based on protocol.js. - // Errors are not translated to strings. - message = operationDescription + " (" + e.error + "): " + e.message; - } else { - message = operationDescription + (e ? (": " + e) : ""); - } - this.cancelBusyTimeout(); - let operationCanceled = e && e.canceled; - if (!operationCanceled) { - UI.reportError("error_operationFail", message); - if (e) { - console.error(e); - } - } - this.unbusy(); - }); - return promise; - }, - - reportError: function (l10nProperty, ...l10nArgs) { - let text; - - if (l10nArgs.length > 0) { - text = Strings.formatStringFromName(l10nProperty, l10nArgs, l10nArgs.length); - } else { - text = Strings.GetStringFromName(l10nProperty); - } - - console.error(text); - - let buttons = [{ - label: Strings.GetStringFromName("notification_showTroubleShooting_label"), - accessKey: Strings.GetStringFromName("notification_showTroubleShooting_accesskey"), - callback: function () { - Cmds.showTroubleShooting(); - } - }]; - - let nbox = document.querySelector("#notificationbox"); - nbox.removeAllNotifications(true); - nbox.appendNotification(text, "webide:errornotification", null, - nbox.PRIORITY_WARNING_LOW, buttons); - }, - - dismissErrorNotification: function () { - let nbox = document.querySelector("#notificationbox"); - nbox.removeAllNotifications(true); - }, - - /** ******** COMMANDS **********/ - - /** - * This module emits various events when state changes occur. - * - * The events this module may emit include: - * busy: - * The window is currently busy and certain UI functions may be disabled. - * unbusy: - * The window is not busy and certain UI functions may be re-enabled. - */ - update: function (what, details) { - this.emit("webide-update", what, details); - }, - - updateCommands: function () { - // Action commands - let playCmd = document.querySelector("#cmd_play"); - let stopCmd = document.querySelector("#cmd_stop"); - let debugCmd = document.querySelector("#cmd_toggleToolbox"); - let playButton = document.querySelector("#action-button-play"); - let projectPanelCmd = document.querySelector("#cmd_showProjectPanel"); - - if (document.querySelector("window").classList.contains("busy")) { - playCmd.setAttribute("disabled", "true"); - stopCmd.setAttribute("disabled", "true"); - debugCmd.setAttribute("disabled", "true"); - projectPanelCmd.setAttribute("disabled", "true"); - return; - } - - if (!AppManager.selectedProject || !AppManager.connected) { - playCmd.setAttribute("disabled", "true"); - stopCmd.setAttribute("disabled", "true"); - debugCmd.setAttribute("disabled", "true"); - } else { - let isProjectRunning = AppManager.isProjectRunning(); - if (isProjectRunning) { - playButton.classList.add("reload"); - stopCmd.removeAttribute("disabled"); - debugCmd.removeAttribute("disabled"); - } else { - playButton.classList.remove("reload"); - stopCmd.setAttribute("disabled", "true"); - debugCmd.setAttribute("disabled", "true"); - } - - // If connected and a project is selected - if (AppManager.selectedProject.type == "runtimeApp") { - playCmd.removeAttribute("disabled"); - } else if (AppManager.selectedProject.type == "tab") { - playCmd.removeAttribute("disabled"); - stopCmd.setAttribute("disabled", "true"); - } else if (AppManager.selectedProject.type == "mainProcess") { - playCmd.setAttribute("disabled", "true"); - stopCmd.setAttribute("disabled", "true"); - } else { - if (AppManager.selectedProject.errorsCount == 0 && - AppManager.runtimeCanHandleApps()) { - playCmd.removeAttribute("disabled"); - } else { - playCmd.setAttribute("disabled", "true"); - } - } - } - - // Runtime commands - let monitorCmd = document.querySelector("#cmd_showMonitor"); - let screenshotCmd = document.querySelector("#cmd_takeScreenshot"); - let permissionsCmd = document.querySelector("#cmd_showPermissionsTable"); - let detailsCmd = document.querySelector("#cmd_showRuntimeDetails"); - let disconnectCmd = document.querySelector("#cmd_disconnectRuntime"); - let devicePrefsCmd = document.querySelector("#cmd_showDevicePrefs"); - let settingsCmd = document.querySelector("#cmd_showSettings"); - - if (AppManager.connected) { - if (AppManager.deviceFront) { - monitorCmd.removeAttribute("disabled"); - detailsCmd.removeAttribute("disabled"); - permissionsCmd.removeAttribute("disabled"); - screenshotCmd.removeAttribute("disabled"); - } - if (AppManager.preferenceFront) { - devicePrefsCmd.removeAttribute("disabled"); - } - if (AppManager.settingsFront) { - settingsCmd.removeAttribute("disabled"); - } - disconnectCmd.removeAttribute("disabled"); - } else { - monitorCmd.setAttribute("disabled", "true"); - detailsCmd.setAttribute("disabled", "true"); - permissionsCmd.setAttribute("disabled", "true"); - screenshotCmd.setAttribute("disabled", "true"); - disconnectCmd.setAttribute("disabled", "true"); - devicePrefsCmd.setAttribute("disabled", "true"); - settingsCmd.setAttribute("disabled", "true"); - } - - let runtimePanelButton = document.querySelector("#runtime-panel-button"); - - if (AppManager.connected) { - runtimePanelButton.setAttribute("active", "true"); - runtimePanelButton.removeAttribute("hidden"); - } else { - runtimePanelButton.removeAttribute("active"); - runtimePanelButton.setAttribute("hidden", "true"); - } - - projectPanelCmd.removeAttribute("disabled"); - }, - - updateRemoveProjectButton: function () { - // Remove command - let removeCmdNode = document.querySelector("#cmd_removeProject"); - if (AppManager.selectedProject) { - removeCmdNode.removeAttribute("disabled"); - } else { - removeCmdNode.setAttribute("disabled", "true"); - } - }, - - /** ******** RUNTIME **********/ - - get lastConnectedRuntime() { - return Services.prefs.getCharPref("devtools.webide.lastConnectedRuntime"); - }, - - set lastConnectedRuntime(runtime) { - Services.prefs.setCharPref("devtools.webide.lastConnectedRuntime", runtime); - }, - - autoConnectRuntime: function () { - // Automatically reconnect to the previously selected runtime, - // if available and has an ID and feature is enabled - if (AppManager.selectedRuntime || - !Services.prefs.getBoolPref("devtools.webide.autoConnectRuntime") || - !this.lastConnectedRuntime) { - return; - } - let [_, type, id] = this.lastConnectedRuntime.match(/^(\w+):(.+)$/); - - type = type.toLowerCase(); - - // Local connection is mapped to AppManager.runtimeList.other array - if (type == "local") { - type = "other"; - } - - // We support most runtimes except simulator, that needs to be manually - // launched - if (type == "usb" || type == "wifi" || type == "other") { - for (let runtime of AppManager.runtimeList[type]) { - // Some runtimes do not expose an id and don't support autoconnect (like - // remote connection) - if (runtime.id == id) { - // Only want one auto-connect attempt, so clear last runtime value - this.lastConnectedRuntime = ""; - this.connectToRuntime(runtime); - } - } - } - }, - - connectToRuntime: function (runtime) { - let name = runtime.name; - let promise = AppManager.connectToRuntime(runtime); - promise.then(() => this.initConnectionTelemetry()) - .catch(() => { - // Empty rejection handler to silence uncaught rejection warnings - // |busyUntil| will listen for rejections. - // Bug 1121100 may find a better way to silence these. - }); - promise = this.busyUntil(promise, "Connecting to " + name); - // Stop busy timeout for runtimes that take unknown or long amounts of time - // to connect. - if (runtime.prolongedConnection) { - this.cancelBusyTimeout(); - } - return promise; - }, - - updateRuntimeButton: function () { - let labelNode = document.querySelector("#runtime-panel-button > .panel-button-label"); - if (!AppManager.selectedRuntime) { - labelNode.setAttribute("value", Strings.GetStringFromName("runtimeButton_label")); - } else { - let name = AppManager.selectedRuntime.name; - labelNode.setAttribute("value", name); - } - }, - - saveLastConnectedRuntime: function () { - if (AppManager.selectedRuntime && - AppManager.selectedRuntime.id !== undefined) { - this.lastConnectedRuntime = AppManager.selectedRuntime.type + ":" + - AppManager.selectedRuntime.id; - } else { - this.lastConnectedRuntime = ""; - } - }, - - /** ******** ACTIONS **********/ - - _actionsToLog: new Set(), - - /** - * For each new connection, track whether play and debug were ever used. Only - * one value is collected for each button, even if they are used multiple - * times during a connection. - */ - initConnectionTelemetry: function () { - this._actionsToLog.add("play"); - this._actionsToLog.add("debug"); - }, - - /** - * Action occurred. Log that it happened, and remove it from the loggable - * set. - */ - onAction: function (action) { - if (!this._actionsToLog.has(action)) { - return; - } - this.logActionState(action, true); - this._actionsToLog.delete(action); - }, - - /** - * Connection status changed or we are shutting down. Record any loggable - * actions as having not occurred. - */ - updateConnectionTelemetry: function () { - for (let action of this._actionsToLog.values()) { - this.logActionState(action, false); - } - this._actionsToLog.clear(); - }, - - logActionState: function (action, state) { - let histogramId = "DEVTOOLS_WEBIDE_CONNECTION_" + - action.toUpperCase() + "_USED"; - this._telemetry.log(histogramId, state); - }, - - /** ******** PROJECTS **********/ - - // ProjectEditor & details screen - - destroyProjectEditor: function () { - if (this.projecteditor) { - this.projecteditor.destroy(); - this.projecteditor = null; - } - }, - - /** - * Called when selecting or deselecting the project editor panel. - */ - onChangeProjectEditorSelected: function () { - if (this.projecteditor) { - let panel = document.querySelector("#deck").selectedPanel; - if (panel && panel.id == "deck-panel-projecteditor") { - this.projecteditor.menuEnabled = true; - this._telemetry.toolOpened("webideProjectEditor"); - } else { - this.projecteditor.menuEnabled = false; - this._telemetry.toolClosed("webideProjectEditor"); - } - } - }, - - getProjectEditor: function () { - if (this.projecteditor) { - return this.projecteditor.loaded; - } - - let projecteditorIframe = document.querySelector("#deck-panel-projecteditor"); - this.projecteditor = ProjectEditor.ProjectEditor(projecteditorIframe, { - menubar: document.querySelector("#main-menubar"), - menuindex: 1 - }); - this.projecteditor.on("onEditorSave", () => { - AppManager.validateAndUpdateProject(AppManager.selectedProject); - this._telemetry.actionOccurred("webideProjectEditorSave"); - }); - return this.projecteditor.loaded; - }, - - updateProjectEditorHeader: function () { - let project = AppManager.selectedProject; - if (!project || !this.projecteditor) { - return; - } - let status = project.validationStatus || "unknown"; - if (status == "error warning") { - status = "error"; - } - this.getProjectEditor().then((projecteditor) => { - projecteditor.setProjectToAppPath(project.location, { - name: project.name, - iconUrl: project.icon, - projectOverviewURL: "chrome://webide/content/details.xhtml", - validationStatus: status - }).then(null, console.error); - }, console.error); - }, - - isProjectEditorEnabled: function () { - return Services.prefs.getBoolPref("devtools.webide.showProjectEditor"); - }, - - openProject: function () { - let project = AppManager.selectedProject; - - // Nothing to show - - if (!project) { - this.resetDeck(); - return; - } - - // Make sure the directory exist before we show Project Editor - - let forceDetailsOnly = false; - if (project.type == "packaged") { - forceDetailsOnly = !utils.doesFileExist(project.location); - } - - // Show only the details screen - - if (project.type != "packaged" || - !this.isProjectEditorEnabled() || - forceDetailsOnly) { - this.selectDeckPanel("details"); - return; - } - - // Show ProjectEditor - - this.getProjectEditor().then(() => { - this.updateProjectEditorHeader(); - }, console.error); - - this.selectDeckPanel("projecteditor"); - }, - - autoStartProject: Task.async(function* () { - let project = AppManager.selectedProject; - - if (!project) { - return; - } - if (!(project.type == "runtimeApp" || - project.type == "mainProcess" || - project.type == "tab")) { - return; // For something that is not an editable app, we're done. - } - - // Do not force opening apps that are already running, as they may have - // some activity being opened and don't want to dismiss them. - if (project.type == "runtimeApp" && !AppManager.isProjectRunning()) { - yield UI.busyUntil(AppManager.launchRuntimeApp(), "running app"); - } - }), - - autoOpenToolbox: Task.async(function* () { - let project = AppManager.selectedProject; - - if (!project) { - return; - } - if (!(project.type == "runtimeApp" || - project.type == "mainProcess" || - project.type == "tab")) { - return; // For something that is not an editable app, we're done. - } - - yield UI.createToolbox(); - }), - - importAndSelectApp: Task.async(function* (source) { - let isPackaged = !!source.path; - let project; - try { - project = yield AppProjects[isPackaged ? "addPackaged" : "addHosted"](source); - } catch (e) { - if (e === "Already added") { - // Select project that's already been added, - // and allow it to be revalidated and selected - project = AppProjects.get(isPackaged ? source.path : source); - } else { - throw e; - } - } - - // Select project - AppManager.selectedProject = project; - - this._telemetry.actionOccurred("webideImportProject"); - }), - - // Remember the last selected project on the runtime - saveLastSelectedProject: function () { - let shouldRestore = Services.prefs.getBoolPref("devtools.webide.restoreLastProject"); - if (!shouldRestore) { - return; - } - - // Ignore unselection of project on runtime disconnection - if (!AppManager.connected) { - return; - } - - let project = "", type = ""; - let selected = AppManager.selectedProject; - if (selected) { - if (selected.type == "runtimeApp") { - type = "runtimeApp"; - project = selected.app.manifestURL; - } else if (selected.type == "mainProcess") { - type = "mainProcess"; - } else if (selected.type == "packaged" || - selected.type == "hosted") { - type = "local"; - project = selected.location; - } - } - if (type) { - Services.prefs.setCharPref("devtools.webide.lastSelectedProject", - type + ":" + project); - } else { - Services.prefs.clearUserPref("devtools.webide.lastSelectedProject"); - } - }, - - autoSelectProject: function () { - if (AppManager.selectedProject) { - return; - } - let shouldRestore = Services.prefs.getBoolPref("devtools.webide.restoreLastProject"); - if (!shouldRestore) { - return; - } - let pref = Services.prefs.getCharPref("devtools.webide.lastSelectedProject"); - if (!pref) { - return; - } - let m = pref.match(/^(\w+):(.*)$/); - if (!m) { - return; - } - let [_, type, project] = m; - - if (type == "local") { - let lastProject = AppProjects.get(project); - if (lastProject) { - AppManager.selectedProject = lastProject; - } - } - - // For other project types, we need to be connected to the runtime - if (!AppManager.connected) { - return; - } - - if (type == "mainProcess" && AppManager.isMainProcessDebuggable()) { - AppManager.selectedProject = { - type: "mainProcess", - name: Strings.GetStringFromName("mainProcess_label"), - icon: AppManager.DEFAULT_PROJECT_ICON - }; - } else if (type == "runtimeApp") { - let app = AppManager.apps.get(project); - if (app) { - AppManager.selectedProject = { - type: "runtimeApp", - app: app.manifest, - icon: app.iconURL, - name: app.manifest.name - }; - } - } - }, - - /** ******** DECK **********/ - - setupDeck: function () { - let iframes = document.querySelectorAll("#deck > iframe"); - for (let iframe of iframes) { - iframe.tooltip = "aHTMLTooltip"; - } - }, - - resetFocus: function () { - document.commandDispatcher.focusedElement = document.documentElement; - }, - - selectDeckPanel: function (id) { - let deck = document.querySelector("#deck"); - if (deck.selectedPanel && deck.selectedPanel.id === "deck-panel-" + id) { - // This panel is already displayed. - return; - } - this.resetFocus(); - let panel = deck.querySelector("#deck-panel-" + id); - let lazysrc = panel.getAttribute("lazysrc"); - if (lazysrc) { - panel.removeAttribute("lazysrc"); - panel.setAttribute("src", lazysrc); - } - deck.selectedPanel = panel; - this.onChangeProjectEditorSelected(); - }, - - resetDeck: function () { - this.resetFocus(); - let deck = document.querySelector("#deck"); - deck.selectedPanel = null; - this.onChangeProjectEditorSelected(); - }, - - buildIDToDate(buildID) { - let fields = buildID.match(/(\d{4})(\d{2})(\d{2})/); - // Date expects 0 - 11 for months - return new Date(fields[1], Number.parseInt(fields[2]) - 1, fields[3]); - }, - - checkRuntimeVersion: Task.async(function* () { - if (AppManager.connected && AppManager.deviceFront) { - let desc = yield AppManager.deviceFront.getDescription(); - // Compare device and firefox build IDs - // and only compare by day (strip hours/minutes) to prevent - // warning against builds of the same day. - let deviceID = desc.appbuildid.substr(0, 8); - let localID = Services.appinfo.appBuildID.substr(0, 8); - let deviceDate = this.buildIDToDate(deviceID); - let localDate = this.buildIDToDate(localID); - // Allow device to be newer by up to a week. This accommodates those with - // local device builds, since their devices will almost always be newer - // than the client. - if (deviceDate - localDate > 7 * MS_PER_DAY) { - this.reportError("error_runtimeVersionTooRecent", deviceID, localID); - } - } - }), - - /** ******** TOOLBOX **********/ - - /** - * There are many ways to close a toolbox: - * * Close button inside the toolbox - * * Toggle toolbox wrench in WebIDE - * * Disconnect the current runtime gracefully - * * Yank cord out of device - * * Close or crash the app/tab - * We can't know for sure which one was used here, so reset the - * |toolboxPromise| since someone must be destroying it to reach here, - * and call our own close method. - */ - _onToolboxClosed: function (promise, iframe) { - // Only save toolbox size, disable wrench button, workaround focus issue... - // if we are closing the last toolbox: - // - toolboxPromise is nullified by destroyToolbox and is still null here - // if no other toolbox has been opened in between, - // - having two distinct promise means we are receiving closed event - // for a previous, non-current, toolbox. - if (!this.toolboxPromise || this.toolboxPromise === promise) { - this.toolboxPromise = null; - this.resetFocus(); - Services.prefs.setIntPref("devtools.toolbox.footer.height", iframe.height); - - let splitter = document.querySelector(".devtools-horizontal-splitter"); - splitter.setAttribute("hidden", "true"); - document.querySelector("#action-button-debug").removeAttribute("active"); - } - // We have to destroy the iframe, otherwise, the keybindings of webide don't work - // properly anymore. - iframe.remove(); - }, - - destroyToolbox: function () { - // Only have a live toolbox if |this.toolboxPromise| exists - if (this.toolboxPromise) { - let toolboxPromise = this.toolboxPromise; - this.toolboxPromise = null; - return toolboxPromise.then(toolbox => toolbox.destroy()); - } - return promise.resolve(); - }, - - createToolbox: function () { - // If |this.toolboxPromise| exists, there is already a live toolbox - if (this.toolboxPromise) { - return this.toolboxPromise; - } - - let iframe = document.createElement("iframe"); - iframe.id = "toolbox"; - - // Compute a uid on the iframe in order to identify toolbox iframe - // when receiving toolbox-close event - iframe.uid = new Date().getTime(); - - let height = Services.prefs.getIntPref("devtools.toolbox.footer.height"); - iframe.height = height; - - let promise = this.toolboxPromise = AppManager.getTarget().then(target => { - return this._showToolbox(target, iframe); - }).then(toolbox => { - // Destroy the toolbox on WebIDE side before - // toolbox.destroy's promise resolves. - toolbox.once("destroyed", this._onToolboxClosed.bind(this, promise, iframe)); - return toolbox; - }, console.error); - - return this.busyUntil(this.toolboxPromise, "opening toolbox"); - }, - - _showToolbox: function (target, iframe) { - let splitter = document.querySelector(".devtools-horizontal-splitter"); - splitter.removeAttribute("hidden"); - - document.querySelector("notificationbox").insertBefore(iframe, splitter.nextSibling); - let host = Toolbox.HostType.CUSTOM; - let options = { customIframe: iframe, zoom: false, uid: iframe.uid }; - - document.querySelector("#action-button-debug").setAttribute("active", "true"); - - return gDevTools.showToolbox(target, null, host, options); - }, - - prePackageLog: function (msg) { - if (msg == "start") { - UI.selectDeckPanel("logs"); - } - } -}; - -EventEmitter.decorate(UI); - -var Cmds = { - quit: function () { - if (UI.canCloseProject()) { - window.close(); - } - }, - - showProjectPanel: function () { - ProjectPanel.toggleSidebar(); - return promise.resolve(); - }, - - showRuntimePanel: function () { - RuntimeScanners.scan(); - RuntimePanel.toggleSidebar(); - }, - - disconnectRuntime: function () { - let disconnecting = Task.spawn(function* () { - yield UI.destroyToolbox(); - yield AppManager.disconnectRuntime(); - }); - return UI.busyUntil(disconnecting, "disconnecting from runtime"); - }, - - takeScreenshot: function () { - let url = AppManager.deviceFront.screenshotToDataURL(); - return UI.busyUntil(url.then(longstr => { - return longstr.string().then(dataURL => { - longstr.release().then(null, console.error); - UI.openInBrowser(dataURL); - }); - }), "taking screenshot"); - }, - - showPermissionsTable: function () { - UI.selectDeckPanel("permissionstable"); - }, - - showRuntimeDetails: function () { - UI.selectDeckPanel("runtimedetails"); - }, - - showDevicePrefs: function () { - UI.selectDeckPanel("devicepreferences"); - }, - - showSettings: function () { - UI.selectDeckPanel("devicesettings"); - }, - - showMonitor: function () { - UI.selectDeckPanel("monitor"); - }, - - play: Task.async(function* () { - let busy; - switch (AppManager.selectedProject.type) { - case "packaged": - let autosave = - Services.prefs.getBoolPref("devtools.webide.autosaveFiles"); - if (autosave && UI.projecteditor) { - yield UI.projecteditor.saveAllFiles(); - } - busy = UI.busyWithProgressUntil(AppManager.installAndRunProject(), - "installing and running app"); - break; - case "hosted": - busy = UI.busyUntil(AppManager.installAndRunProject(), - "installing and running app"); - break; - case "runtimeApp": - busy = UI.busyUntil(AppManager.launchOrReloadRuntimeApp(), "launching / reloading app"); - break; - case "tab": - busy = UI.busyUntil(AppManager.reloadTab(), "reloading tab"); - break; - } - if (!busy) { - return promise.reject(); - } - UI.onAction("play"); - return busy; - }), - - stop: function () { - return UI.busyUntil(AppManager.stopRunningApp(), "stopping app"); - }, - - toggleToolbox: function () { - UI.onAction("debug"); - if (UI.toolboxPromise) { - UI.destroyToolbox(); - return promise.resolve(); - } else { - return UI.createToolbox(); - } - }, - - removeProject: function () { - AppManager.removeSelectedProject(); - }, - - toggleEditors: function () { - let isNowEnabled = !UI.isProjectEditorEnabled(); - Services.prefs.setBoolPref("devtools.webide.showProjectEditor", isNowEnabled); - if (!isNowEnabled) { - UI.destroyProjectEditor(); - } - UI.openProject(); - }, - - showTroubleShooting: function () { - UI.openInBrowser(HELP_URL); - }, - - showAddons: function () { - UI.selectDeckPanel("addons"); - }, - - showPrefs: function () { - UI.selectDeckPanel("prefs"); - }, - - zoomIn: function () { - if (UI.contentViewer.fullZoom < MAX_ZOOM) { - UI.contentViewer.fullZoom += 0.1; - Services.prefs.setCharPref("devtools.webide.zoom", UI.contentViewer.fullZoom); - } - }, - - zoomOut: function () { - if (UI.contentViewer.fullZoom > MIN_ZOOM) { - UI.contentViewer.fullZoom -= 0.1; - Services.prefs.setCharPref("devtools.webide.zoom", UI.contentViewer.fullZoom); - } - }, - - resetZoom: function () { - UI.contentViewer.fullZoom = 1; - Services.prefs.setCharPref("devtools.webide.zoom", 1); - } -}; diff --git a/devtools/client/webide/content/webide.xul b/devtools/client/webide/content/webide.xul deleted file mode 100644 index a3e4355b9..000000000 --- a/devtools/client/webide/content/webide.xul +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        -