import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

614
layout/xul/BoxObject.cpp Normal file
View file

@ -0,0 +1,614 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/BoxObject.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsContainerFrame.h"
#include "nsIDocShell.h"
#include "nsReadableUtils.h"
#include "nsDOMClassInfoID.h"
#include "nsView.h"
#ifdef MOZ_XUL
#include "nsIDOMXULElement.h"
#else
#include "nsIDOMElement.h"
#endif
#include "nsLayoutUtils.h"
#include "nsISupportsPrimitives.h"
#include "nsSupportsPrimitives.h"
#include "mozilla/dom/Element.h"
#include "nsComponentManagerUtils.h"
#include "mozilla/dom/BoxObjectBinding.h"
// Implementation /////////////////////////////////////////////////////////////////
namespace mozilla {
namespace dom {
// Static member variable initialization
// Implement our nsISupports methods
NS_IMPL_CYCLE_COLLECTION_CLASS(BoxObject)
NS_IMPL_CYCLE_COLLECTING_ADDREF(BoxObject)
NS_IMPL_CYCLE_COLLECTING_RELEASE(BoxObject)
// QueryInterface implementation for BoxObject
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BoxObject)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIBoxObject)
NS_INTERFACE_MAP_ENTRY(nsPIBoxObject)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(BoxObject)
// XXX jmorton: why aren't we unlinking mPropertyTable?
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(BoxObject)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
if (tmp->mPropertyTable) {
for (auto iter = tmp->mPropertyTable->Iter(); !iter.Done(); iter.Next()) {
cb.NoteXPCOMChild(iter.UserData());
}
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(BoxObject)
// Constructors/Destructors
BoxObject::BoxObject()
: mContent(nullptr)
{
}
BoxObject::~BoxObject()
{
}
NS_IMETHODIMP
BoxObject::GetElement(nsIDOMElement** aResult)
{
if (mContent) {
return CallQueryInterface(mContent, aResult);
}
*aResult = nullptr;
return NS_OK;
}
// nsPIBoxObject //////////////////////////////////////////////////////////////////////////
nsresult
BoxObject::Init(nsIContent* aContent)
{
mContent = aContent;
return NS_OK;
}
void
BoxObject::Clear()
{
mPropertyTable = nullptr;
mContent = nullptr;
}
void
BoxObject::ClearCachedValues()
{
}
nsIFrame*
BoxObject::GetFrame(bool aFlushLayout)
{
nsIPresShell* shell = GetPresShell(aFlushLayout);
if (!shell)
return nullptr;
if (!aFlushLayout) {
// If we didn't flush layout when getting the presshell, we should at least
// flush to make sure our frame model is up to date.
// XXXbz should flush on document, no? Except people call this from
// frame code, maybe?
shell->FlushPendingNotifications(Flush_Frames);
}
// The flush might have killed mContent.
if (!mContent) {
return nullptr;
}
return mContent->GetPrimaryFrame();
}
nsIPresShell*
BoxObject::GetPresShell(bool aFlushLayout)
{
if (!mContent) {
return nullptr;
}
nsCOMPtr<nsIDocument> doc = mContent->GetUncomposedDoc();
if (!doc) {
return nullptr;
}
if (aFlushLayout) {
doc->FlushPendingNotifications(Flush_Layout);
}
return doc->GetShell();
}
nsresult
BoxObject::GetOffsetRect(nsIntRect& aRect)
{
aRect.SetRect(0, 0, 0, 0);
if (!mContent)
return NS_ERROR_NOT_INITIALIZED;
// Get the Frame for our content
nsIFrame* frame = GetFrame(true);
if (frame) {
// Get its origin
nsPoint origin = frame->GetPositionIgnoringScrolling();
// Find the frame parent whose content is the document element.
Element* docElement = mContent->GetComposedDoc()->GetRootElement();
nsIFrame* parent = frame->GetParent();
for (;;) {
// If we've hit the document element, break here
if (parent->GetContent() == docElement) {
break;
}
nsIFrame* next = parent->GetParent();
if (!next) {
NS_WARNING("We should have hit the document element...");
origin += parent->GetPosition();
break;
}
// Add the parent's origin to our own to get to the
// right coordinate system
origin += next->GetPositionOfChildIgnoringScrolling(parent);
parent = next;
}
// For the origin, add in the border for the frame
const nsStyleBorder* border = frame->StyleBorder();
origin.x += border->GetComputedBorderWidth(NS_SIDE_LEFT);
origin.y += border->GetComputedBorderWidth(NS_SIDE_TOP);
// And subtract out the border for the parent
const nsStyleBorder* parentBorder = parent->StyleBorder();
origin.x -= parentBorder->GetComputedBorderWidth(NS_SIDE_LEFT);
origin.y -= parentBorder->GetComputedBorderWidth(NS_SIDE_TOP);
aRect.x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
aRect.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
// Get the union of all rectangles in this and continuation frames.
// It doesn't really matter what we use as aRelativeTo here, since
// we only care about the size. Using 'parent' might make things
// a bit faster by speeding up the internal GetOffsetTo operations.
nsRect rcFrame = nsLayoutUtils::GetAllInFlowRectsUnion(frame, parent);
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.width);
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.height);
}
return NS_OK;
}
nsresult
BoxObject::GetScreenPosition(nsIntPoint& aPoint)
{
aPoint.x = aPoint.y = 0;
if (!mContent)
return NS_ERROR_NOT_INITIALIZED;
nsIFrame* frame = GetFrame(true);
if (frame) {
nsIntRect rect = frame->GetScreenRect();
aPoint.x = rect.x;
aPoint.y = rect.y;
}
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetX(int32_t* aResult)
{
nsIntRect rect;
GetOffsetRect(rect);
*aResult = rect.x;
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetY(int32_t* aResult)
{
nsIntRect rect;
GetOffsetRect(rect);
*aResult = rect.y;
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetWidth(int32_t* aResult)
{
nsIntRect rect;
GetOffsetRect(rect);
*aResult = rect.width;
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetHeight(int32_t* aResult)
{
nsIntRect rect;
GetOffsetRect(rect);
*aResult = rect.height;
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetScreenX(int32_t *_retval)
{
nsIntPoint position;
nsresult rv = GetScreenPosition(position);
if (NS_FAILED(rv)) return rv;
*_retval = position.x;
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetScreenY(int32_t *_retval)
{
nsIntPoint position;
nsresult rv = GetScreenPosition(position);
if (NS_FAILED(rv)) return rv;
*_retval = position.y;
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetPropertyAsSupports(const char16_t* aPropertyName, nsISupports** aResult)
{
NS_ENSURE_ARG(aPropertyName && *aPropertyName);
if (!mPropertyTable) {
*aResult = nullptr;
return NS_OK;
}
nsDependentString propertyName(aPropertyName);
mPropertyTable->Get(propertyName, aResult); // Addref here.
return NS_OK;
}
NS_IMETHODIMP
BoxObject::SetPropertyAsSupports(const char16_t* aPropertyName, nsISupports* aValue)
{
NS_ENSURE_ARG(aPropertyName && *aPropertyName);
if (!mPropertyTable) {
mPropertyTable = new nsInterfaceHashtable<nsStringHashKey,nsISupports>(4);
}
nsDependentString propertyName(aPropertyName);
mPropertyTable->Put(propertyName, aValue);
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetProperty(const char16_t* aPropertyName, char16_t** aResult)
{
nsCOMPtr<nsISupports> data;
nsresult rv = GetPropertyAsSupports(aPropertyName,getter_AddRefs(data));
NS_ENSURE_SUCCESS(rv, rv);
if (!data) {
*aResult = nullptr;
return NS_OK;
}
nsCOMPtr<nsISupportsString> supportsStr = do_QueryInterface(data);
if (!supportsStr) {
return NS_ERROR_FAILURE;
}
return supportsStr->ToString(aResult);
}
NS_IMETHODIMP
BoxObject::SetProperty(const char16_t* aPropertyName, const char16_t* aPropertyValue)
{
NS_ENSURE_ARG(aPropertyName && *aPropertyName);
nsDependentString propertyName(aPropertyName);
nsDependentString propertyValue;
if (aPropertyValue) {
propertyValue.Rebind(aPropertyValue);
} else {
propertyValue.SetIsVoid(true);
}
nsCOMPtr<nsISupportsString> supportsStr(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY);
supportsStr->SetData(propertyValue);
return SetPropertyAsSupports(aPropertyName,supportsStr);
}
NS_IMETHODIMP
BoxObject::RemoveProperty(const char16_t* aPropertyName)
{
NS_ENSURE_ARG(aPropertyName && *aPropertyName);
if (!mPropertyTable) return NS_OK;
nsDependentString propertyName(aPropertyName);
mPropertyTable->Remove(propertyName);
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetParentBox(nsIDOMElement * *aParentBox)
{
*aParentBox = nullptr;
nsIFrame* frame = GetFrame(false);
if (!frame) return NS_OK;
nsIFrame* parent = frame->GetParent();
if (!parent) return NS_OK;
nsCOMPtr<nsIDOMElement> el = do_QueryInterface(parent->GetContent());
*aParentBox = el;
NS_IF_ADDREF(*aParentBox);
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetFirstChild(nsIDOMElement * *aFirstVisibleChild)
{
*aFirstVisibleChild = nullptr;
nsIFrame* frame = GetFrame(false);
if (!frame) return NS_OK;
nsIFrame* firstFrame = frame->PrincipalChildList().FirstChild();
if (!firstFrame) return NS_OK;
// get the content for the box and query to a dom element
nsCOMPtr<nsIDOMElement> el = do_QueryInterface(firstFrame->GetContent());
el.swap(*aFirstVisibleChild);
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetLastChild(nsIDOMElement * *aLastVisibleChild)
{
*aLastVisibleChild = nullptr;
nsIFrame* frame = GetFrame(false);
if (!frame) return NS_OK;
return GetPreviousSibling(frame, nullptr, aLastVisibleChild);
}
NS_IMETHODIMP
BoxObject::GetNextSibling(nsIDOMElement **aNextOrdinalSibling)
{
*aNextOrdinalSibling = nullptr;
nsIFrame* frame = GetFrame(false);
if (!frame) return NS_OK;
nsIFrame* nextFrame = frame->GetNextSibling();
if (!nextFrame) return NS_OK;
// get the content for the box and query to a dom element
nsCOMPtr<nsIDOMElement> el = do_QueryInterface(nextFrame->GetContent());
el.swap(*aNextOrdinalSibling);
return NS_OK;
}
NS_IMETHODIMP
BoxObject::GetPreviousSibling(nsIDOMElement **aPreviousOrdinalSibling)
{
*aPreviousOrdinalSibling = nullptr;
nsIFrame* frame = GetFrame(false);
if (!frame) return NS_OK;
nsIFrame* parentFrame = frame->GetParent();
if (!parentFrame) return NS_OK;
return GetPreviousSibling(parentFrame, frame, aPreviousOrdinalSibling);
}
nsresult
BoxObject::GetPreviousSibling(nsIFrame* aParentFrame, nsIFrame* aFrame,
nsIDOMElement** aResult)
{
*aResult = nullptr;
nsIFrame* nextFrame = aParentFrame->PrincipalChildList().FirstChild();
nsIFrame* prevFrame = nullptr;
while (nextFrame) {
if (nextFrame == aFrame)
break;
prevFrame = nextFrame;
nextFrame = nextFrame->GetNextSibling();
}
if (!prevFrame) return NS_OK;
// get the content for the box and query to a dom element
nsCOMPtr<nsIDOMElement> el = do_QueryInterface(prevFrame->GetContent());
el.swap(*aResult);
return NS_OK;
}
nsIContent*
BoxObject::GetParentObject() const
{
return mContent;
}
JSObject*
BoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return BoxObjectBinding::Wrap(aCx, this, aGivenProto);
}
Element*
BoxObject::GetElement() const
{
return mContent && mContent->IsElement() ? mContent->AsElement() : nullptr;
}
int32_t
BoxObject::X()
{
int32_t ret = 0;
GetX(&ret);
return ret;
}
int32_t
BoxObject::Y()
{
int32_t ret = 0;
GetY(&ret);
return ret;
}
int32_t
BoxObject::GetScreenX(ErrorResult& aRv)
{
int32_t ret = 0;
aRv = GetScreenX(&ret);
return ret;
}
int32_t
BoxObject::GetScreenY(ErrorResult& aRv)
{
int32_t ret = 0;
aRv = GetScreenY(&ret);
return ret;
}
int32_t
BoxObject::Width()
{
int32_t ret = 0;
GetWidth(&ret);
return ret;
}
int32_t
BoxObject::Height()
{
int32_t ret = 0;
GetHeight(&ret);
return ret;
}
already_AddRefed<nsISupports>
BoxObject::GetPropertyAsSupports(const nsAString& propertyName)
{
nsCOMPtr<nsISupports> ret;
GetPropertyAsSupports(PromiseFlatString(propertyName).get(), getter_AddRefs(ret));
return ret.forget();
}
void
BoxObject::SetPropertyAsSupports(const nsAString& propertyName, nsISupports* value)
{
SetPropertyAsSupports(PromiseFlatString(propertyName).get(), value);
}
void
BoxObject::GetProperty(const nsAString& propertyName, nsString& aRetVal, ErrorResult& aRv)
{
nsCOMPtr<nsISupports> data(GetPropertyAsSupports(propertyName));
if (!data) {
return;
}
nsCOMPtr<nsISupportsString> supportsStr(do_QueryInterface(data));
if (!supportsStr) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
supportsStr->GetData(aRetVal);
}
void
BoxObject::SetProperty(const nsAString& propertyName, const nsAString& propertyValue)
{
SetProperty(PromiseFlatString(propertyName).get(), PromiseFlatString(propertyValue).get());
}
void
BoxObject::RemoveProperty(const nsAString& propertyName)
{
RemoveProperty(PromiseFlatString(propertyName).get());
}
already_AddRefed<Element>
BoxObject::GetParentBox()
{
nsCOMPtr<nsIDOMElement> el;
GetParentBox(getter_AddRefs(el));
nsCOMPtr<Element> ret(do_QueryInterface(el));
return ret.forget();
}
already_AddRefed<Element>
BoxObject::GetFirstChild()
{
nsCOMPtr<nsIDOMElement> el;
GetFirstChild(getter_AddRefs(el));
nsCOMPtr<Element> ret(do_QueryInterface(el));
return ret.forget();
}
already_AddRefed<Element>
BoxObject::GetLastChild()
{
nsCOMPtr<nsIDOMElement> el;
GetLastChild(getter_AddRefs(el));
nsCOMPtr<Element> ret(do_QueryInterface(el));
return ret.forget();
}
already_AddRefed<Element>
BoxObject::GetNextSibling()
{
nsCOMPtr<nsIDOMElement> el;
GetNextSibling(getter_AddRefs(el));
nsCOMPtr<Element> ret(do_QueryInterface(el));
return ret.forget();
}
already_AddRefed<Element>
BoxObject::GetPreviousSibling()
{
nsCOMPtr<nsIDOMElement> el;
GetPreviousSibling(getter_AddRefs(el));
nsCOMPtr<Element> ret(do_QueryInterface(el));
return ret.forget();
}
} // namespace dom
} // namespace mozilla
// Creation Routine ///////////////////////////////////////////////////////////////////////
using namespace mozilla::dom;
nsresult
NS_NewBoxObject(nsIBoxObject** aResult)
{
NS_ADDREF(*aResult = new BoxObject());
return NS_OK;
}

91
layout/xul/BoxObject.h Normal file
View file

@ -0,0 +1,91 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_BoxObject_h__
#define mozilla_dom_BoxObject_h__
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "nsCOMPtr.h"
#include "nsIBoxObject.h"
#include "nsPIBoxObject.h"
#include "nsPoint.h"
#include "nsAutoPtr.h"
#include "nsHashKeys.h"
#include "nsInterfaceHashtable.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "nsRect.h"
class nsIFrame;
class nsIPresShell;
namespace mozilla {
namespace dom {
class Element;
class BoxObject : public nsPIBoxObject,
public nsWrapperCache
{
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BoxObject)
NS_DECL_NSIBOXOBJECT
public:
BoxObject();
// nsPIBoxObject
virtual nsresult Init(nsIContent* aContent) override;
virtual void Clear() override;
virtual void ClearCachedValues() override;
nsIFrame* GetFrame(bool aFlushLayout);
nsIPresShell* GetPresShell(bool aFlushLayout);
nsresult GetOffsetRect(nsIntRect& aRect);
nsresult GetScreenPosition(nsIntPoint& aPoint);
// Given a parent frame and a child frame, find the frame whose
// next sibling is the given child frame and return its element
static nsresult GetPreviousSibling(nsIFrame* aParentFrame, nsIFrame* aFrame,
nsIDOMElement** aResult);
// WebIDL (wraps old impls)
nsIContent* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
Element* GetElement() const;
int32_t X();
int32_t Y();
int32_t GetScreenX(ErrorResult& aRv);
int32_t GetScreenY(ErrorResult& aRv);
int32_t Width();
int32_t Height();
already_AddRefed<nsISupports> GetPropertyAsSupports(const nsAString& propertyName);
void SetPropertyAsSupports(const nsAString& propertyName, nsISupports* value);
void GetProperty(const nsAString& propertyName, nsString& aRetVal, ErrorResult& aRv);
void SetProperty(const nsAString& propertyName, const nsAString& propertyValue);
void RemoveProperty(const nsAString& propertyName);
already_AddRefed<Element> GetParentBox();
already_AddRefed<Element> GetFirstChild();
already_AddRefed<Element> GetLastChild();
already_AddRefed<Element> GetNextSibling();
already_AddRefed<Element> GetPreviousSibling();
protected:
virtual ~BoxObject();
nsAutoPtr<nsInterfaceHashtable<nsStringHashKey,nsISupports> > mPropertyTable; //[OWNER]
nsIContent* mContent; // [WEAK]
};
} // namespace dom
} // namespace mozilla
#endif

View file

@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ContainerBoxObject.h"
#include "mozilla/dom/ContainerBoxObjectBinding.h"
#include "nsCOMPtr.h"
#include "nsIDocShell.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIFrame.h"
#include "nsSubDocumentFrame.h"
namespace mozilla {
namespace dom {
ContainerBoxObject::ContainerBoxObject()
{
}
ContainerBoxObject::~ContainerBoxObject()
{
}
JSObject*
ContainerBoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return ContainerBoxObjectBinding::Wrap(aCx, this, aGivenProto);
}
already_AddRefed<nsIDocShell>
ContainerBoxObject::GetDocShell()
{
nsSubDocumentFrame *subDocFrame = do_QueryFrame(GetFrame(false));
if (subDocFrame) {
// Ok, the frame for mContent is an nsSubDocumentFrame, it knows how
// to reach the docshell, so ask it...
nsCOMPtr<nsIDocShell> ret;
subDocFrame->GetDocShell(getter_AddRefs(ret));
return ret.forget();
}
if (!mContent) {
return nullptr;
}
// No nsSubDocumentFrame available for mContent, try if there's a mapping
// between mContent's document to mContent's subdocument.
nsIDocument *doc = mContent->GetComposedDoc();
if (!doc) {
return nullptr;
}
nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent);
if (!sub_doc) {
return nullptr;
}
nsCOMPtr<nsIDocShell> result = sub_doc->GetDocShell();
return result.forget();
}
} // namespace dom
} // namespace mozilla
nsresult
NS_NewContainerBoxObject(nsIBoxObject** aResult)
{
NS_ADDREF(*aResult = new mozilla::dom::ContainerBoxObject());
return NS_OK;
}

View file

@ -0,0 +1,31 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_ContainerBoxObject_h
#define mozilla_dom_ContainerBoxObject_h
#include "mozilla/dom/BoxObject.h"
namespace mozilla {
namespace dom {
class ContainerBoxObject final : public BoxObject
{
public:
ContainerBoxObject();
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
already_AddRefed<nsIDocShell> GetDocShell();
private:
~ContainerBoxObject();
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ContainerBoxObject_h

View file

@ -0,0 +1,238 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ListBoxObject.h"
#include "nsCOMPtr.h"
#include "nsIFrame.h"
#include "nsGkAtoms.h"
#include "nsIScrollableFrame.h"
#include "nsListBoxBodyFrame.h"
#include "ChildIterator.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ListBoxObjectBinding.h"
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS_INHERITED(ListBoxObject, BoxObject, nsIListBoxObject,
nsPIListBoxObject)
ListBoxObject::ListBoxObject()
: mListBoxBody(nullptr)
{
}
ListBoxObject::~ListBoxObject()
{
}
JSObject* ListBoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return ListBoxObjectBinding::Wrap(aCx, this, aGivenProto);
}
// nsIListBoxObject
NS_IMETHODIMP
ListBoxObject::GetRowCount(int32_t *aResult)
{
*aResult = GetRowCount();
return NS_OK;
}
NS_IMETHODIMP
ListBoxObject::GetItemAtIndex(int32_t index, nsIDOMElement **_retval)
{
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
return body->GetItemAtIndex(index, _retval);
}
return NS_OK;
}
NS_IMETHODIMP
ListBoxObject::GetIndexOfItem(nsIDOMElement* aElement, int32_t *aResult)
{
*aResult = 0;
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
return body->GetIndexOfItem(aElement, aResult);
}
return NS_OK;
}
// ListBoxObject
int32_t
ListBoxObject::GetRowCount()
{
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
return body->GetRowCount();
}
return 0;
}
int32_t
ListBoxObject::GetNumberOfVisibleRows()
{
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
return body->GetNumberOfVisibleRows();
}
return 0;
}
int32_t
ListBoxObject::GetIndexOfFirstVisibleRow()
{
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
return body->GetIndexOfFirstVisibleRow();
}
return 0;
}
void
ListBoxObject::EnsureIndexIsVisible(int32_t aRowIndex)
{
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
body->EnsureIndexIsVisible(aRowIndex);
}
}
void
ListBoxObject::ScrollToIndex(int32_t aRowIndex)
{
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
body->ScrollToIndex(aRowIndex);
}
}
void
ListBoxObject::ScrollByLines(int32_t aNumLines)
{
nsListBoxBodyFrame* body = GetListBoxBody(true);
if (body) {
body->ScrollByLines(aNumLines);
}
}
already_AddRefed<Element>
ListBoxObject::GetItemAtIndex(int32_t index)
{
nsCOMPtr<nsIDOMElement> el;
GetItemAtIndex(index, getter_AddRefs(el));
nsCOMPtr<Element> ret(do_QueryInterface(el));
return ret.forget();
}
int32_t
ListBoxObject::GetIndexOfItem(Element& aElement)
{
int32_t ret;
nsCOMPtr<nsIDOMElement> el(do_QueryInterface(&aElement));
GetIndexOfItem(el, &ret);
return ret;
}
//////////////////////
static nsIContent*
FindBodyContent(nsIContent* aParent)
{
if (aParent->IsXULElement(nsGkAtoms::listboxbody)) {
return aParent;
}
mozilla::dom::FlattenedChildIterator iter(aParent);
for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
nsIContent* result = FindBodyContent(child);
if (result) {
return result;
}
}
return nullptr;
}
nsListBoxBodyFrame*
ListBoxObject::GetListBoxBody(bool aFlush)
{
if (mListBoxBody) {
return mListBoxBody;
}
nsIPresShell* shell = GetPresShell(false);
if (!shell) {
return nullptr;
}
nsIFrame* frame = aFlush ?
GetFrame(false) /* does Flush_Frames */ :
mContent->GetPrimaryFrame();
if (!frame) {
return nullptr;
}
// Iterate over our content model children looking for the body.
nsCOMPtr<nsIContent> content = FindBodyContent(frame->GetContent());
if (!content) {
return nullptr;
}
// this frame will be a nsGFXScrollFrame
frame = content->GetPrimaryFrame();
if (!frame) {
return nullptr;
}
nsIScrollableFrame* scrollFrame = do_QueryFrame(frame);
if (!scrollFrame) {
return nullptr;
}
// this frame will be the one we want
nsIFrame* yeahBaby = scrollFrame->GetScrolledFrame();
if (!yeahBaby) {
return nullptr;
}
// It's a frame. Refcounts are irrelevant.
nsListBoxBodyFrame* listBoxBody = do_QueryFrame(yeahBaby);
NS_ENSURE_TRUE(listBoxBody &&
listBoxBody->SetBoxObject(this),
nullptr);
mListBoxBody = listBoxBody;
return mListBoxBody;
}
void
ListBoxObject::Clear()
{
ClearCachedValues();
BoxObject::Clear();
}
void
ListBoxObject::ClearCachedValues()
{
mListBoxBody = nullptr;
}
} // namespace dom
} // namespace mozilla
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewListBoxObject(nsIBoxObject** aResult)
{
NS_ADDREF(*aResult = new mozilla::dom::ListBoxObject());
return NS_OK;
}

View file

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_ListBoxObject_h
#define mozilla_dom_ListBoxObject_h
#include "mozilla/dom/BoxObject.h"
#include "nsPIListBoxObject.h"
namespace mozilla {
namespace dom {
class ListBoxObject final : public BoxObject,
public nsPIListBoxObject
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSILISTBOXOBJECT
ListBoxObject();
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
// nsPIListBoxObject
virtual nsListBoxBodyFrame* GetListBoxBody(bool aFlush) override;
// nsPIBoxObject
virtual void Clear() override;
virtual void ClearCachedValues() override;
// ListBoxObject.webidl
int32_t GetRowCount();
int32_t GetNumberOfVisibleRows();
int32_t GetIndexOfFirstVisibleRow();
void EnsureIndexIsVisible(int32_t rowIndex);
void ScrollToIndex(int32_t rowIndex);
void ScrollByLines(int32_t numLines);
already_AddRefed<Element> GetItemAtIndex(int32_t index);
int32_t GetIndexOfItem(Element& item);
protected:
nsListBoxBodyFrame *mListBoxBody;
private:
~ListBoxObject();
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ListBoxObject_h

View file

@ -0,0 +1,151 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/MenuBoxObject.h"
#include "mozilla/dom/MenuBoxObjectBinding.h"
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/Element.h"
#include "nsIDOMKeyEvent.h"
#include "nsIFrame.h"
#include "nsMenuBarFrame.h"
#include "nsMenuBarListener.h"
#include "nsMenuFrame.h"
#include "nsMenuPopupFrame.h"
namespace mozilla {
namespace dom {
MenuBoxObject::MenuBoxObject()
{
}
MenuBoxObject::~MenuBoxObject()
{
}
JSObject* MenuBoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return MenuBoxObjectBinding::Wrap(aCx, this, aGivenProto);
}
void MenuBoxObject::OpenMenu(bool aOpenFlag)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
nsIFrame* frame = GetFrame(false);
if (frame) {
if (aOpenFlag) {
nsCOMPtr<nsIContent> content = mContent;
pm->ShowMenu(content, false, false);
}
else {
nsMenuFrame* menu = do_QueryFrame(frame);
if (menu) {
nsMenuPopupFrame* popupFrame = menu->GetPopup();
if (popupFrame)
pm->HidePopup(popupFrame->GetContent(), false, true, false, false);
}
}
}
}
}
already_AddRefed<Element>
MenuBoxObject::GetActiveChild()
{
nsMenuFrame* menu = do_QueryFrame(GetFrame(false));
if (menu) {
nsCOMPtr<nsIDOMElement> el;
menu->GetActiveChild(getter_AddRefs(el));
nsCOMPtr<Element> ret(do_QueryInterface(el));
return ret.forget();
}
return nullptr;
}
void MenuBoxObject::SetActiveChild(Element* arg)
{
nsMenuFrame* menu = do_QueryFrame(GetFrame(false));
if (menu) {
nsCOMPtr<nsIDOMElement> el(do_QueryInterface(arg));
menu->SetActiveChild(el);
}
}
bool MenuBoxObject::HandleKeyPress(KeyboardEvent& keyEvent)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (!pm) {
return false;
}
// if event has already been handled, bail
bool eventHandled = false;
keyEvent.GetDefaultPrevented(&eventHandled);
if (eventHandled) {
return false;
}
if (nsMenuBarListener::IsAccessKeyPressed(&keyEvent))
return false;
nsMenuFrame* menu = do_QueryFrame(GetFrame(false));
if (!menu) {
return false;
}
nsMenuPopupFrame* popupFrame = menu->GetPopup();
if (!popupFrame) {
return false;
}
uint32_t keyCode = keyEvent.KeyCode();
switch (keyCode) {
case nsIDOMKeyEvent::DOM_VK_UP:
case nsIDOMKeyEvent::DOM_VK_DOWN:
case nsIDOMKeyEvent::DOM_VK_HOME:
case nsIDOMKeyEvent::DOM_VK_END:
{
nsNavigationDirection theDirection;
theDirection = NS_DIRECTION_FROM_KEY_CODE(popupFrame, keyCode);
return pm->HandleKeyboardNavigationInPopup(popupFrame, theDirection);
}
default:
return pm->HandleShortcutNavigation(&keyEvent, popupFrame);
}
}
bool MenuBoxObject::OpenedWithKey()
{
nsMenuFrame* menuframe = do_QueryFrame(GetFrame(false));
if (!menuframe) {
return false;
}
nsIFrame* frame = menuframe->GetParent();
while (frame) {
nsMenuBarFrame* menubar = do_QueryFrame(frame);
if (menubar) {
return menubar->IsActiveByKeyboard();
}
frame = frame->GetParent();
}
return false;
}
} // namespace dom
} // namespace mozilla
// Creation Routine ///////////////////////////////////////////////////////////////////////
using namespace mozilla::dom;
nsresult
NS_NewMenuBoxObject(nsIBoxObject** aResult)
{
NS_ADDREF(*aResult = new MenuBoxObject());
return NS_OK;
}

View file

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_MenuBoxObject_h
#define mozilla_dom_MenuBoxObject_h
#include "mozilla/dom/BoxObject.h"
namespace mozilla {
namespace dom {
class KeyboardEvent;
class MenuBoxObject final : public BoxObject
{
public:
MenuBoxObject();
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void OpenMenu(bool aOpenFlag);
already_AddRefed<Element> GetActiveChild();
void SetActiveChild(Element* arg);
bool HandleKeyPress(KeyboardEvent& keyEvent);
bool OpenedWithKey();
private:
~MenuBoxObject();
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_MenuBoxObject_h

View file

@ -0,0 +1,384 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCOMPtr.h"
#include "nsIRootBox.h"
#include "nsIPresShell.h"
#include "nsIContent.h"
#include "nsNameSpaceManager.h"
#include "nsGkAtoms.h"
#include "nsMenuPopupFrame.h"
#include "nsView.h"
#include "mozilla/AppUnits.h"
#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/PopupBoxObject.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/PopupBoxObjectBinding.h"
namespace mozilla {
namespace dom {
NS_IMPL_ADDREF_INHERITED(PopupBoxObject, BoxObject)
NS_IMPL_RELEASE_INHERITED(PopupBoxObject, BoxObject)
NS_INTERFACE_MAP_BEGIN(PopupBoxObject)
NS_INTERFACE_MAP_END_INHERITING(BoxObject)
PopupBoxObject::PopupBoxObject()
{
}
PopupBoxObject::~PopupBoxObject()
{
}
nsIContent* PopupBoxObject::GetParentObject() const
{
return BoxObject::GetParentObject();
}
JSObject* PopupBoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return PopupBoxObjectBinding::Wrap(aCx, this, aGivenProto);
}
nsPopupSetFrame*
PopupBoxObject::GetPopupSetFrame()
{
nsIRootBox* rootBox = nsIRootBox::GetRootBox(GetPresShell(false));
if (!rootBox)
return nullptr;
return rootBox->GetPopupSetFrame();
}
void
PopupBoxObject::HidePopup(bool aCancel)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm && mContent) {
pm->HidePopup(mContent, false, true, false, aCancel);
}
}
void
PopupBoxObject::ShowPopup(Element* aAnchorElement,
Element& aPopupElement,
int32_t aXPos, int32_t aYPos,
const nsAString& aPopupType,
const nsAString& aAnchorAlignment,
const nsAString& aPopupAlignment)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm && mContent) {
nsCOMPtr<nsIContent> anchorContent(do_QueryInterface(aAnchorElement));
nsAutoString popupType(aPopupType);
nsAutoString anchor(aAnchorAlignment);
nsAutoString align(aPopupAlignment);
pm->ShowPopupWithAnchorAlign(mContent, anchorContent, anchor, align,
aXPos, aYPos,
popupType.EqualsLiteral("context"));
}
}
void
PopupBoxObject::OpenPopup(Element* aAnchorElement,
const nsAString& aPosition,
int32_t aXPos, int32_t aYPos,
bool aIsContextMenu,
bool aAttributesOverride,
Event* aTriggerEvent)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm && mContent) {
nsCOMPtr<nsIContent> anchorContent(do_QueryInterface(aAnchorElement));
pm->ShowPopup(mContent, anchorContent, aPosition, aXPos, aYPos,
aIsContextMenu, aAttributesOverride, false, aTriggerEvent);
}
}
void
PopupBoxObject::OpenPopupAtScreen(int32_t aXPos, int32_t aYPos,
bool aIsContextMenu,
Event* aTriggerEvent)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm && mContent)
pm->ShowPopupAtScreen(mContent, aXPos, aYPos, aIsContextMenu, aTriggerEvent);
}
void
PopupBoxObject::OpenPopupAtScreenRect(const nsAString& aPosition,
int32_t aXPos, int32_t aYPos,
int32_t aWidth, int32_t aHeight,
bool aIsContextMenu,
bool aAttributesOverride,
Event* aTriggerEvent)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm && mContent) {
pm->ShowPopupAtScreenRect(mContent, aPosition,
nsIntRect(aXPos, aYPos, aWidth, aHeight),
aIsContextMenu, aAttributesOverride, aTriggerEvent);
}
}
void
PopupBoxObject::MoveTo(int32_t aLeft, int32_t aTop)
{
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
if (menuPopupFrame) {
menuPopupFrame->MoveTo(CSSIntPoint(aLeft, aTop), true);
}
}
void
PopupBoxObject::MoveToAnchor(Element* aAnchorElement,
const nsAString& aPosition,
int32_t aXPos, int32_t aYPos,
bool aAttributesOverride)
{
if (mContent) {
nsCOMPtr<nsIContent> anchorContent(do_QueryInterface(aAnchorElement));
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(mContent->GetPrimaryFrame());
if (menuPopupFrame && menuPopupFrame->IsVisible()) {
menuPopupFrame->MoveToAnchor(anchorContent, aPosition, aXPos, aYPos, aAttributesOverride);
}
}
}
void
PopupBoxObject::SizeTo(int32_t aWidth, int32_t aHeight)
{
if (!mContent)
return;
nsAutoString width, height;
width.AppendInt(aWidth);
height.AppendInt(aHeight);
nsCOMPtr<nsIContent> content = mContent;
// We only want to pass aNotify=true to SetAttr once, but must make sure
// we pass it when a value is being changed. Thus, we check if the height
// is the same and if so, pass true when setting the width.
bool heightSame = content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::height, height, eCaseMatters);
content->SetAttr(kNameSpaceID_None, nsGkAtoms::width, width, heightSame);
content->SetAttr(kNameSpaceID_None, nsGkAtoms::height, height, true);
}
bool
PopupBoxObject::AutoPosition()
{
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
if (menuPopupFrame) {
return menuPopupFrame->GetAutoPosition();
}
return true;
}
void
PopupBoxObject::SetAutoPosition(bool aShouldAutoPosition)
{
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
if (menuPopupFrame) {
menuPopupFrame->SetAutoPosition(aShouldAutoPosition);
}
}
void
PopupBoxObject::EnableRollup(bool aShouldRollup)
{
// this does nothing now
}
void
PopupBoxObject::SetConsumeRollupEvent(uint32_t aConsume)
{
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
if (menuPopupFrame) {
menuPopupFrame->SetConsumeRollupEvent(aConsume);
}
}
void
PopupBoxObject::EnableKeyboardNavigator(bool aEnableKeyboardNavigator)
{
if (!mContent)
return;
// Use ignorekeys="true" on the popup instead of using this function.
if (aEnableKeyboardNavigator)
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys, true);
else
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys,
NS_LITERAL_STRING("true"), true);
}
void
PopupBoxObject::GetPopupState(nsString& aState)
{
// set this here in case there's no frame for the popup
aState.AssignLiteral("closed");
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
if (menuPopupFrame) {
switch (menuPopupFrame->PopupState()) {
case ePopupShown:
aState.AssignLiteral("open");
break;
case ePopupShowing:
case ePopupPositioning:
case ePopupOpening:
case ePopupVisible:
aState.AssignLiteral("showing");
break;
case ePopupHiding:
case ePopupInvisible:
aState.AssignLiteral("hiding");
break;
case ePopupClosed:
break;
default:
NS_NOTREACHED("Bad popup state");
break;
}
}
}
nsINode*
PopupBoxObject::GetTriggerNode() const
{
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
return nsMenuPopupFrame::GetTriggerContent(menuPopupFrame);
}
Element*
PopupBoxObject::GetAnchorNode() const
{
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
if (!menuPopupFrame) {
return nullptr;
}
nsIContent* anchor = menuPopupFrame->GetAnchor();
return anchor && anchor->IsElement() ? anchor->AsElement() : nullptr;
}
already_AddRefed<DOMRect>
PopupBoxObject::GetOuterScreenRect()
{
RefPtr<DOMRect> rect = new DOMRect(mContent);
// Return an empty rectangle if the popup is not open.
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
if (!menuPopupFrame || !menuPopupFrame->IsOpen()) {
return rect.forget();
}
nsView* view = menuPopupFrame->GetView();
if (view) {
nsIWidget* widget = view->GetWidget();
if (widget) {
LayoutDeviceIntRect screenRect = widget->GetScreenBounds();
int32_t pp = menuPopupFrame->PresContext()->AppUnitsPerDevPixel();
rect->SetLayoutRect(LayoutDeviceIntRect::ToAppUnits(screenRect, pp));
}
}
return rect.forget();
}
void
PopupBoxObject::GetAlignmentPosition(nsString& positionStr)
{
positionStr.Truncate();
// This needs to flush layout.
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(true));
if (!menuPopupFrame)
return;
int8_t position = menuPopupFrame->GetAlignmentPosition();
switch (position) {
case POPUPPOSITION_AFTERSTART:
positionStr.AssignLiteral("after_start");
break;
case POPUPPOSITION_AFTEREND:
positionStr.AssignLiteral("after_end");
break;
case POPUPPOSITION_BEFORESTART:
positionStr.AssignLiteral("before_start");
break;
case POPUPPOSITION_BEFOREEND:
positionStr.AssignLiteral("before_end");
break;
case POPUPPOSITION_STARTBEFORE:
positionStr.AssignLiteral("start_before");
break;
case POPUPPOSITION_ENDBEFORE:
positionStr.AssignLiteral("end_before");
break;
case POPUPPOSITION_STARTAFTER:
positionStr.AssignLiteral("start_after");
break;
case POPUPPOSITION_ENDAFTER:
positionStr.AssignLiteral("end_after");
break;
case POPUPPOSITION_OVERLAP:
positionStr.AssignLiteral("overlap");
break;
case POPUPPOSITION_AFTERPOINTER:
positionStr.AssignLiteral("after_pointer");
break;
case POPUPPOSITION_SELECTION:
positionStr.AssignLiteral("selection");
break;
default:
// Leave as an empty string.
break;
}
}
int32_t
PopupBoxObject::AlignmentOffset()
{
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
if (!menuPopupFrame)
return 0;
int32_t pp = mozilla::AppUnitsPerCSSPixel();
// Note that the offset might be along either the X or Y axis, but for the
// sake of simplicity we use a point with only the X axis set so we can
// use ToNearestPixels().
nsPoint appOffset(menuPopupFrame->GetAlignmentOffset(), 0);
nsIntPoint popupOffset = appOffset.ToNearestPixels(pp);
return popupOffset.x;
}
void
PopupBoxObject::SetConstraintRect(dom::DOMRectReadOnly& aRect)
{
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
if (menuPopupFrame) {
menuPopupFrame->SetOverrideConstraintRect(
LayoutDeviceIntRect::Truncate(aRect.Left(), aRect.Top(), aRect.Width(), aRect.Height()));
}
}
} // namespace dom
} // namespace mozilla
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewPopupBoxObject(nsIBoxObject** aResult)
{
*aResult = new mozilla::dom::PopupBoxObject();
NS_ADDREF(*aResult);
return NS_OK;
}

115
layout/xul/PopupBoxObject.h Normal file
View file

@ -0,0 +1,115 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_PopupBoxObject_h
#define mozilla_dom_PopupBoxObject_h
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/BoxObject.h"
#include "nsString.h"
struct JSContext;
class nsPopupSetFrame;
namespace mozilla {
namespace dom {
class DOMRect;
class Element;
class Event;
class PopupBoxObject final : public BoxObject
{
public:
NS_DECL_ISUPPORTS_INHERITED
// also in PopupBoxObject.webidl
static const uint32_t ROLLUP_DEFAULT = 0; /* widget/platform default */
static const uint32_t ROLLUP_CONSUME = 1; /* consume the rollup event */
static const uint32_t ROLLUP_NO_CONSUME = 2; /* don't consume the rollup event */
PopupBoxObject();
nsIContent* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void ShowPopup(Element* aAnchorElement,
Element& aPopupElement,
int32_t aXPos,
int32_t aYPos,
const nsAString& aPopupType,
const nsAString& aAnchorAlignment,
const nsAString& aPopupAlignment);
void HidePopup(bool aCancel);
bool AutoPosition();
void SetAutoPosition(bool aShouldAutoPosition);
void EnableKeyboardNavigator(bool aEnableKeyboardNavigator);
void EnableRollup(bool aShouldRollup);
void SetConsumeRollupEvent(uint32_t aConsume);
void SizeTo(int32_t aWidth, int32_t aHeight);
void MoveTo(int32_t aLeft, int32_t aTop);
void OpenPopup(Element* aAnchorElement,
const nsAString& aPosition,
int32_t aXPos,
int32_t aYPos,
bool aIsContextMenu, bool aAttributesOverride,
Event* aTriggerEvent);
void OpenPopupAtScreen(int32_t aXPos,
int32_t aYPos,
bool aIsContextMenu,
Event* aTriggerEvent);
void OpenPopupAtScreenRect(const nsAString& aPosition,
int32_t aXPos, int32_t aYPos,
int32_t aWidth, int32_t aHeight,
bool aIsContextMenu,
bool aAttributesOverride,
Event* aTriggerEvent);
void GetPopupState(nsString& aState);
nsINode* GetTriggerNode() const;
Element* GetAnchorNode() const;
already_AddRefed<DOMRect> GetOuterScreenRect();
void MoveToAnchor(Element* aAnchorElement,
const nsAString& aPosition,
int32_t aXPos,
int32_t aYPos,
bool aAttributesOverride);
void GetAlignmentPosition(nsString& positionStr);
int32_t AlignmentOffset();
void SetConstraintRect(dom::DOMRectReadOnly& aRect);
private:
~PopupBoxObject();
protected:
nsPopupSetFrame* GetPopupSetFrame();
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_PopupBoxObject_h

View file

@ -0,0 +1,384 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ScrollBoxObject.h"
#include "mozilla/dom/ScrollBoxObjectBinding.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsCOMPtr.h"
#include "nsIPresShell.h"
#include "nsIContent.h"
#include "nsIDOMElement.h"
#include "nsPresContext.h"
#include "nsBox.h"
#include "nsIScrollableFrame.h"
namespace mozilla {
namespace dom {
ScrollBoxObject::ScrollBoxObject()
{
}
ScrollBoxObject::~ScrollBoxObject()
{
}
JSObject* ScrollBoxObject::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return ScrollBoxObjectBinding::Wrap(aCx, this, aGivenProto);
}
nsIScrollableFrame* ScrollBoxObject::GetScrollFrame()
{
return do_QueryFrame(GetFrame(false));
}
void ScrollBoxObject::ScrollTo(int32_t x, int32_t y, ErrorResult& aRv)
{
nsIScrollableFrame* sf = GetScrollFrame();
if (!sf) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
sf->ScrollToCSSPixels(CSSIntPoint(x, y));
}
void ScrollBoxObject::ScrollBy(int32_t dx, int32_t dy, ErrorResult& aRv)
{
CSSIntPoint pt;
GetPosition(pt, aRv);
if (aRv.Failed()) {
return;
}
ScrollTo(pt.x + dx, pt.y + dy, aRv);
}
void ScrollBoxObject::ScrollByLine(int32_t dlines, ErrorResult& aRv)
{
nsIScrollableFrame* sf = GetScrollFrame();
if (!sf) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
sf->ScrollBy(nsIntPoint(0, dlines), nsIScrollableFrame::LINES,
nsIScrollableFrame::SMOOTH);
}
// XUL <scrollbox> elements have a single box child element.
// Get a pointer to that box.
// Note that now that the <scrollbox> is just a regular box
// with 'overflow:hidden', the boxobject's frame is an nsXULScrollFrame,
// the <scrollbox>'s box frame is the scrollframe's "scrolled frame", and
// the <scrollbox>'s child box is a child of that.
static nsIFrame* GetScrolledBox(BoxObject* aScrollBox) {
nsIFrame* frame = aScrollBox->GetFrame(false);
if (!frame) {
return nullptr;
}
nsIScrollableFrame* scrollFrame = do_QueryFrame(frame);
if (!scrollFrame) {
NS_WARNING("ScrollBoxObject attached to something that's not a scroll frame!");
return nullptr;
}
nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
if (!scrolledFrame)
return nullptr;
return nsBox::GetChildXULBox(scrolledFrame);
}
void ScrollBoxObject::ScrollByIndex(int32_t dindexes, ErrorResult& aRv)
{
nsIScrollableFrame* sf = GetScrollFrame();
if (!sf) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nsIFrame* scrolledBox = GetScrolledBox(this);
if (!scrolledBox) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nsRect rect;
// now get the scrolled boxes first child.
nsIFrame* child = nsBox::GetChildXULBox(scrolledBox);
bool horiz = scrolledBox->IsXULHorizontal();
nsPoint cp = sf->GetScrollPosition();
nscoord diff = 0;
int32_t curIndex = 0;
bool isLTR = scrolledBox->IsXULNormalDirection();
int32_t frameWidth = 0;
if (!isLTR && horiz) {
GetWidth(&frameWidth);
nsCOMPtr<nsIPresShell> shell = GetPresShell(false);
if (!shell) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
frameWidth = nsPresContext::CSSPixelsToAppUnits(frameWidth);
}
// first find out what index we are currently at
while(child) {
rect = child->GetRect();
if (horiz) {
// In the left-to-right case we break from the loop when the center of
// the current child rect is greater than the scrolled position of
// the left edge of the scrollbox
// In the right-to-left case we break when the center of the current
// child rect is less than the scrolled position of the right edge of
// the scrollbox.
diff = rect.x + rect.width/2; // use the center, to avoid rounding errors
if ((isLTR && diff > cp.x) ||
(!isLTR && diff < cp.x + frameWidth)) {
break;
}
} else {
diff = rect.y + rect.height/2;// use the center, to avoid rounding errors
if (diff > cp.y) {
break;
}
}
child = nsBox::GetNextXULBox(child);
curIndex++;
}
int32_t count = 0;
if (dindexes == 0)
return;
if (dindexes > 0) {
while(child) {
child = nsBox::GetNextXULBox(child);
if (child) {
rect = child->GetRect();
}
count++;
if (count >= dindexes) {
break;
}
}
} else if (dindexes < 0) {
child = nsBox::GetChildXULBox(scrolledBox);
while(child) {
rect = child->GetRect();
if (count >= curIndex + dindexes) {
break;
}
count++;
child = nsBox::GetNextXULBox(child);
}
}
nscoord csspixel = nsPresContext::CSSPixelsToAppUnits(1);
if (horiz) {
// In the left-to-right case we scroll so that the left edge of the
// selected child is scrolled to the left edge of the scrollbox.
// In the right-to-left case we scroll so that the right edge of the
// selected child is scrolled to the right edge of the scrollbox.
nsPoint pt(isLTR ? rect.x : rect.x + rect.width - frameWidth,
cp.y);
// Use a destination range that ensures the left edge (or right edge,
// for RTL) will indeed be visible. Also ensure that the top edge
// is visible.
nsRect range(pt.x, pt.y, csspixel, 0);
if (isLTR) {
range.x -= csspixel;
}
sf->ScrollTo(pt, nsIScrollableFrame::INSTANT, &range);
} else {
// Use a destination range that ensures the top edge will be visible.
nsRect range(cp.x, rect.y - csspixel, 0, csspixel);
sf->ScrollTo(nsPoint(cp.x, rect.y), nsIScrollableFrame::INSTANT, &range);
}
}
void ScrollBoxObject::ScrollToLine(int32_t line, ErrorResult& aRv)
{
nsIScrollableFrame* sf = GetScrollFrame();
if (!sf) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nscoord y = sf->GetLineScrollAmount().height * line;
nsRect range(0, y - nsPresContext::CSSPixelsToAppUnits(1),
0, nsPresContext::CSSPixelsToAppUnits(1));
sf->ScrollTo(nsPoint(0, y), nsIScrollableFrame::INSTANT, &range);
}
void ScrollBoxObject::ScrollToElement(Element& child, ErrorResult& aRv)
{
nsCOMPtr<nsIPresShell> shell = GetPresShell(false);
if (!shell) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
shell->ScrollContentIntoView(&child,
nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_TOP,
nsIPresShell::SCROLL_ALWAYS),
nsIPresShell::ScrollAxis(
nsIPresShell::SCROLL_LEFT,
nsIPresShell::SCROLL_ALWAYS),
nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY |
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
}
void ScrollBoxObject::ScrollToIndex(int32_t index, ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
}
int32_t ScrollBoxObject::GetPositionX(ErrorResult& aRv)
{
CSSIntPoint pt;
GetPosition(pt, aRv);
return pt.x;
}
int32_t ScrollBoxObject::GetPositionY(ErrorResult& aRv)
{
CSSIntPoint pt;
GetPosition(pt, aRv);
return pt.y;
}
int32_t ScrollBoxObject::GetScrolledWidth(ErrorResult& aRv)
{
nsRect scrollRect;
GetScrolledSize(scrollRect, aRv);
return scrollRect.width;
}
int32_t ScrollBoxObject::GetScrolledHeight(ErrorResult& aRv)
{
nsRect scrollRect;
GetScrolledSize(scrollRect, aRv);
return scrollRect.height;
}
/* private helper */
void ScrollBoxObject::GetPosition(CSSIntPoint& aPos, ErrorResult& aRv)
{
nsIScrollableFrame* sf = GetScrollFrame();
if (!sf) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
aPos = sf->GetScrollPositionCSSPixels();
}
/* private helper */
void ScrollBoxObject::GetScrolledSize(nsRect& aRect, ErrorResult& aRv)
{
nsIFrame* scrolledBox = GetScrolledBox(this);
if (!scrolledBox) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
aRect = scrolledBox->GetRect();
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
}
void ScrollBoxObject::GetPosition(JSContext* cx,
JS::Handle<JSObject*> x,
JS::Handle<JSObject*> y,
ErrorResult& aRv)
{
CSSIntPoint pt;
GetPosition(pt, aRv);
JS::Rooted<JS::Value> v(cx);
if (!ToJSValue(cx, pt.x, &v) ||
!JS_SetProperty(cx, x, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;
}
if (!ToJSValue(cx, pt.y, &v) ||
!JS_SetProperty(cx, y, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;
}
}
void ScrollBoxObject::GetScrolledSize(JSContext* cx,
JS::Handle<JSObject*> width,
JS::Handle<JSObject*> height,
ErrorResult& aRv)
{
nsRect rect;
GetScrolledSize(rect, aRv);
JS::Rooted<JS::Value> v(cx);
if (!ToJSValue(cx, rect.width, &v) ||
!JS_SetProperty(cx, width, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;
}
if (!ToJSValue(cx, rect.height, &v) ||
!JS_SetProperty(cx, height, "value", v)) {
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
return;
}
}
void ScrollBoxObject::EnsureElementIsVisible(Element& child, ErrorResult& aRv)
{
nsCOMPtr<nsIPresShell> shell = GetPresShell(false);
if (!shell) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
shell->ScrollContentIntoView(&child,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY |
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
}
void ScrollBoxObject::EnsureIndexIsVisible(int32_t index, ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
}
void ScrollBoxObject::EnsureLineIsVisible(int32_t line, ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
}
} // namespace dom
} // namespace mozilla
// Creation Routine ///////////////////////////////////////////////////////////////////////
using namespace mozilla::dom;
nsresult
NS_NewScrollBoxObject(nsIBoxObject** aResult)
{
NS_ADDREF(*aResult = new ScrollBoxObject());
return NS_OK;
}

View file

@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_ScrollBoxObject_h
#define mozilla_dom_ScrollBoxObject_h
#include "mozilla/dom/BoxObject.h"
#include "Units.h"
class nsIScrollableFrame;
struct nsRect;
namespace mozilla {
namespace dom {
class ScrollBoxObject final : public BoxObject
{
public:
ScrollBoxObject();
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual nsIScrollableFrame* GetScrollFrame();
void ScrollTo(int32_t x, int32_t y, ErrorResult& aRv);
void ScrollBy(int32_t dx, int32_t dy, ErrorResult& aRv);
void ScrollByLine(int32_t dlines, ErrorResult& aRv);
void ScrollByIndex(int32_t dindexes, ErrorResult& aRv);
void ScrollToLine(int32_t line, ErrorResult& aRv);
void ScrollToElement(Element& child, ErrorResult& aRv);
void ScrollToIndex(int32_t index, ErrorResult& aRv);
int32_t GetPositionX(ErrorResult& aRv);
int32_t GetPositionY(ErrorResult& aRv);
int32_t GetScrolledWidth(ErrorResult& aRv);
int32_t GetScrolledHeight(ErrorResult& aRv);
void EnsureElementIsVisible(Element& child, ErrorResult& aRv);
void EnsureIndexIsVisible(int32_t index, ErrorResult& aRv);
void EnsureLineIsVisible(int32_t line, ErrorResult& aRv);
// Deprecated APIs from old IDL
void GetPosition(JSContext* cx,
JS::Handle<JSObject*> x,
JS::Handle<JSObject*> y,
ErrorResult& aRv);
void GetScrolledSize(JSContext* cx,
JS::Handle<JSObject*> width,
JS::Handle<JSObject*> height,
ErrorResult& aRv);
protected:
void GetScrolledSize(nsRect& aRect, ErrorResult& aRv);
void GetPosition(CSSIntPoint& aPos, ErrorResult& aRv);
private:
~ScrollBoxObject();
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ScrollBoxObject_h

View file

@ -0,0 +1,11 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="MainWindow"
title="IWindow Test">
<div style="position:absolute">abc</div>
</window>

View file

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<iframe style="position:absolute;"/>
</window>

View file

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<treechildren style = " display: block; " />
</window>

View file

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
title = "Arrowscrollbox->Splitter Crash Testcase"
xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
width = "300"
height = "200"
orient = "vertical"
>
<vbox flex="1">
<scrollbox flex="1">
<vbox flex="1">
<vbox id="box_1">
<hbox><label value="Test"/></hbox>
</vbox>
<splitter collapse="none"/>
<vbox id="box_2">
<hbox><label value="Test"/></hbox>
</vbox>
</vbox>
</scrollbox>
</vbox>
</window>

View file

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css" ?>
<window
id="nodeCreator" title="Node Creator"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>
<description context="context">Right-click here, and expect a crash.</description>
<popupset id="context-set">
<popup id="context">
<deck selectedItem="0">
<menuitem label="You should never see this" />
</deck>
</popup>
</popupset>
</window>

View file

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<window
id="sliderprint" title="Print These Sliders"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="background-color: white">
<label>
With the Classic theme, printing causes the browser to crash. adding style="-moz-appearance: none" to the
thumb prevents the crash. The crash doesn't happen at all with Modern.
</label>
<spacer height="10"/>
<hbox>
<slider style="height: 174px; width: 24px" orient="vertical">
<thumb/>
</slider>
</hbox>
</window>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<toolbar>
<arrowscrollbox>
<menulist editable="true">
</menulist>
</arrowscrollbox>
</toolbar>
</window>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<html:div>
<listitem>
</listitem>
</html:div>
</window>

View file

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="crash-window"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<scrollbox>
<tree id="crash-tree">
<treecols/>
<treechildren/>
</tree>
</scrollbox>
</window>

View file

@ -0,0 +1,6 @@
<html>
<head><title>Testcase bug 290743 - This display:-moz-grid testcase freezes Mozilla</title></head>
<body style="display:-moz-grid;">
<input type="radio"><input type="radio">
</body>
</html>

View file

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window title="Negative flex bug #2"
orient="horizontal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<button label="Button" flex="2"/>
<label value="This is a label" flex="1"/>
<label value="This is the second label" flex="-2"/>
<label value="This is another label" flex="-1"/>
</window>

View file

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window title="Negative flex bug #2"
orient="horizontal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<button label="Button" flex="1073741824"/>
<label value="This is a label" flex="1073741824"/>
<label value="This is the second label" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
</window>

View file

@ -0,0 +1,137 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window title="Negative flex bug #2"
orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 2;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 2;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 2;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
<button label="Button" flex="1"/>
<label value="This is another label" style="-moz-box-flex: 1;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
<button label="Button" flex="1"/>
<label value="This is another label" style="-moz-box-flex: 1;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
<button label="Button" flex="1"/>
<label value="This is another label" style="-moz-box-flex: 1;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741823"/>
<label value="This is another label" style="-moz-box-flex: 1073741823;"/>
<button label="Button" flex="2"/>
<label value="This is another label" style="-moz-box-flex: 2;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741824"/>
<label value="This is another label" style="-moz-box-flex: 1073741824;"/>
<button label="Button" flex="2"/>
<label value="This is another label" style="-moz-box-flex: 2;"/>
</hbox>
<hbox>
<button label="Button" flex="1073741825"/>
<label value="This is another label" style="-moz-box-flex: 1073741825;"/>
<button label="Button" flex="2"/>
<label value="This is another label" style="-moz-box-flex: 2;"/>
</hbox>
</window>

View file

@ -0,0 +1,53 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<window
id = "overflow crash"
title = "scrollbox crasher"
xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="sizemode width height screenX screenY"
width="320"
height="240">
<scrollbox flex="1">
<grid style="overflow: auto">
<columns>
<column flex="0"/>
</columns>
<rows>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
<row><label value="Date"/></row>
</rows>
</grid>
</scrollbox>
</window>

View file

@ -0,0 +1,12 @@
<html><head>
</head>
<body>
<div style="display: -moz-deck"><div style="display: -moz-popup"></div></div>
<div style="position: relative">Y</div>
</body>
</html>

View file

@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<xul:titlebar id="a"/>
<script>
var html = document.firstChild;
var a = document.getElementById('a')
document.removeChild(html)
document.appendChild(a)
</script>
</html>

View file

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<foo style="display: inline;">
<scrollbox/>
</foo>
</window>

View file

@ -0,0 +1,16 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
title="Testcase bug 325377 - Crash on reload with evil xul textcase, using menulist and nested tooltips">
<menulist style="display: table-cell;">
<tooltip style="display: none;">
<tooltip/>
</tooltip>
</menulist>
<html:script>
function removestyles(){
document.getElementsByTagName('tooltip')[0].removeAttribute('style');
}
try { document.getElementsByTagName('tooltip')[0].offsetHeight; } catch(e) {}
setTimeout(removestyles,0);
</html:script>
</window>

View file

@ -0,0 +1,17 @@
<window title="Testcase bug 326834 - Crash with evil xul testcase, using listbox/listitem and display: table-cell"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<listbox>
<listitem label="This page should not crash Mozilla"/>
</listbox>
<html:script>
function doe() {
var el=document.getElementsByTagName('*');
document.getElementsByTagName('listbox')[0].style.display = 'table-cell';
document.getElementsByTagName('listitem')[0].style.display = 'table-cell';
window.getComputedStyle(document.getElementsByTagName('listitem')[0], '').getPropertyValue("height");
document.getElementsByTagName('listitem')[0].style.display = '';
}
setTimeout(doe,500);
</html:script>
</window>

View file

@ -0,0 +1,9 @@
<html class="reftest-wait">
<head>
<script>
setTimeout('document.documentElement.className = ""', 1000);
</script>
<body>
<iframe src="326834-1-inner.xul"></iframe>
</body>
</html>

View file

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
function init() {
var menupopup = document.getElementsByTagName("menupopup")[0];
menupopup.ordinal = null;
};
window.addEventListener("load", init, false);
</script>
<menulist>
<menupopup>
<menuitem label="Foo"/>
</menupopup>
</menulist>
</window>

View file

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
<![CDATA[
function init()
{
var span = document.getElementsByTagName("span")[0];
var boxobj = document.getBoxObjectFor(span);
try {
boxobj.setPropertyAsSupports(undefined, undefined);
} catch(e) {
}
}
window.addEventListener("load", init, false);
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<span></span>
</body>
</window>

View file

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
function init() {
var pop = document.getElementsByTagName("popup")[0];
SpecialPowers.wrap(document).getAnonymousNodes(pop)[0];
eval.eee = document.documentElement;
};
window.addEventListener("load", init, false);
</script>
<popup/>
<tabbox/>
</window>

View file

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><menulist equalsize="always"><y/> <z width="-444981589286"/> </menulist></window>

View file

@ -0,0 +1,14 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>
<body>
<xul:hbox>
<select/>
<select/>
</xul:hbox>
</body>
</html>

View file

@ -0,0 +1,31 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
<![CDATA[
function init()
{
var textbox = document.getElementsByTagName("textbox")[0];
var hbox = SpecialPowers.wrap(document).getAnonymousNodes(textbox)[0];
var menupopup = SpecialPowers.wrap(document).getAnonymousNodes(hbox)[1];
menupopup.click();
}
window.addEventListener("load", init, false);
]]>
</script>
</head>
<body>
<textbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
</body>
</html>

View file

@ -0,0 +1,17 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
function init() {
document.getElementById("foopy").style.position = "absolute";
}
window.addEventListener("load", init, 0);
</script>
<box id="foopy" />
</window>

View file

@ -0,0 +1,27 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="setTimeout(boom, 30);" class="reftest-wait">
<script>
function remove(q1) { q1.parentNode.removeChild(q1); }
function boom()
{
var x = document.getElementById("x");
var y = document.getElementById("y");
remove(x);
remove(y);
document.documentElement.removeAttribute("class");
}
</script>
<tree>
<treechildren id="y"/>
<richlistbox>
<hbox id="x"/>
<menulist/>
</richlistbox>
</tree>
</window>

View file

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body xmlns="http://www.w3.org/1999/xhtml">
<script>
<![CDATA[
document.getBoxObjectFor(document.getElementsByTagName("body")[0]).setProperty("foo", undefined);
]]>
</script>
</body>
</window>

View file

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body xmlns="http://www.w3.org/1999/xhtml">
<script>
<![CDATA[
var boxy = document.getBoxObjectFor(document.getElementsByTagName("body")[0]);
boxy.setPropertyAsSupports("zoink", undefined);
try {
boxy.removeProperty(undefined);
} catch(e) { }
]]>
</script>
</body>
</window>

View file

@ -0,0 +1,8 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Crash [@ DoDeletingFrameSubtree] after reloading a xul page a few times with display: -moz-popup and menuitem">
<menuitem style="display: -moz-popup;">
<box style="display: -moz-popup;">
<box style="display: -moz-popup;"/>
</box>
</menuitem>
</window>

View file

@ -0,0 +1,9 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="reftest-wait"
onload="setTimeout(function() { var foo = document.getElementById('foo'); foo.parentNode.removeChild(foo); document.documentElement.removeAttribute('class'); }, 30);">
<listboxbody>
<hbox id="foo"/>
</listboxbody>
</window>

View file

@ -0,0 +1,39 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="boom()" class="reftest-wait">
<script>
function boom()
{
try {
var tree = document.getElementById("tree");
var col = tree.treeBoxObject.columns.getFirstColumn();
var treecols = document.getElementById("treecols");
treecols.parentNode.removeChild(treecols);
var x = col.x;
} finally {
document.documentElement.removeAttribute("class");
}
}
</script>
<tree rows="6" id="tree">
<treecols id="treecols">
<treecol id="firstname" label="First Name"/>
</treecols>
<treechildren id="treechildren">
<treeitem>
<treerow>
<treecell label="Bob"/>
</treerow>
</treeitem>
</treechildren>
</tree>
</window>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<nativescrollbar />
</window>

View file

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="setTimeout(boom, 500);">
<script>
function boom()
{
tc1 = document.getElementById("tc1");
tc1.parentNode.removeChild(tc1);
}
</script>
<tree rows="6">
<treecols>
<treecol id="firstname" label="First Name" primary="true" flex="3"/>
<treecol id="lastname" label="Last Name" flex="7"/>
</treecols>
<treechildren id="tc1">
<treeitem container="true" open="true">
<treerow>
<treecell label="Foo"/>
</treerow>
</treeitem>
</treechildren>
<treechildren>
<treeitem container="true" open="true">
<treerow>
<treecell label="Bar"/>
</treerow>
</treeitem>
</treechildren>
</tree>
</window>

View file

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<title>Testcase bug - ASSERTION: shouldn't use unconstrained widths anymore with nested marquees</title>
</head>
<body>
<xul:hbox style="margin: 0 100%;"><span><xul:hbox style="margin: 0 100%;"></xul:hbox></span></xul:hbox>
</body>
</html>

View file

@ -0,0 +1,36 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="reftest-wait">
<head>
<script>
function boom()
{
var span = document.getElementById("span");
var radio = document.getElementById("radio");
radio.appendChild(span);
document.documentElement.removeAttribute("class");
}
</script>
<style>
body {
text-align: center;
font-size: 9px;
}
</style>
</head>
<body onload="setTimeout(boom, 30);">
<span id="span"><xul:wizard/><div>Industries</div></span>
<xul:radio id="radio"/>
</body>
</html>

View file

@ -0,0 +1,5 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<tabpanels>
<treechildren style="display: -moz-deck;"/>
</tabpanels>
</window>

View file

@ -0,0 +1,18 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
span { display:block; outline: 10px solid yellow; }
</style>
</head>
<body>
<div>
<div style="display: -moz-inline-grid">
<span>M</span>
<span>N</span>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Bug 376137</title>
<style>
p { width: 100%; border: solid 1px;}
</style>
<div style="display: -moz-inline-grid">
<div><p>M</p></div>
<div><p>N</p></div>
</div>

View file

@ -0,0 +1,27 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="setTimeout(boom, 30);"
class="reftest-wait">
<script>
var emptyBinding = "url('data:text/xml,%3Cbindings%20xmlns%3D%22http%3A%2F%2Fwww.mozilla.org%2Fxbl%22%3E%3Cbinding%20id%3D%22foo%22%3E%3Ccontent%3E%0A%0A%20%20%20%20%0A%3C%2Fcontent%3E%3C%2Fbinding%3E%3C%2Fbindings%3E%0A')";
function boom()
{
var foreignObject = document.getElementById("foreignObject")
foreignObject.style.MozBinding = emptyBinding;
document.documentElement.removeAttribute("class");
}
</script>
<foreignObject width="500" height="500" transform="scale(.7,.7)" id="foreignObject" y="300">
<xul:menuitem />
</foreignObject>
</svg>

After

Width:  |  Height:  |  Size: 758 B

View file

@ -0,0 +1,9 @@
<html>
<head>
<title>Testcase bug 378961 - Crash [@ nsSplitterFrameInner::RemoveListener] when dragging splitter and DOMAttrModified event removing window</title>
</head>
<body>
<iframe src="data:application/vnd.mozilla.xul+xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3C%3Fxml-stylesheet%20href%3D%22chrome%3A//global/skin%22%20type%3D%22text/css%22%3F%3E%0A%3Cwindow%20xmlns%3D%22http%3A//www.mozilla.org/keymaster/gatekeeper/there.is.only.xul%22%20orient%3D%22horizontal%22%3E%0A%3Ctextbox/%3E%3Csplitter/%3E%3Cbox/%3E%0A%0A%3Cscript%20xmlns%3D%22http%3A//www.w3.org/1999/xhtml%22%3E%0Afunction%20doe%28%29%20%7B%0Awindow.frameElement.parentNode.removeChild%28window.frameElement%29%3B%0A%7D%0Adocument.addEventListener%28%27DOMAttrModified%27%2C%20doe%2C%20true%29%3B%0A%3C/script%3E%0A%3C/window%3E" style="width: 500px;height:200px;"></iframe>
</body>
</html>

View file

@ -0,0 +1,23 @@
<html><head>
<title>Testcase bug - Crash [@ nsBoxFrame::BuildDisplayListForChildren] with tree stuff in iframe toggling display</title>
</head>
<body>
<iframe src="data:application/vnd.mozilla.xul+xml;charset=utf-8,%3Cwindow%20xmlns%3D%22http%3A//www.mozilla.org/keymaster/gatekeeper/there.is.only.xul%22%3E%0A%20%20%3Ctree%20style%3D%22display%3A%20block%3B%20position%3A%20absolute%3B%22%3E%0A%20%20%20%20%3Ctree%20style%3D%22display%3A%20table%3B%22%3E%0A%20%20%20%20%20%20%3Ctreeseparator%20style%3D%22display%3A%20block%3B%20position%3A%20absolute%3B%22%3E%0A%20%20%20%20%20%20%20%20%3Ctreechildren%20style%3D%22display%3A%20block%3B%22/%3E%0A%20%20%20%20%20%20%3C/treeseparator%3E%0A%20%20%20%20%20%20%3Ctreechildren%20style%3D%22display%3A%20none%3B%22/%3E%0A%20%20%20%20%3C/tree%3E%0A%20%20%3C/tree%3E%0A%3C/window%3E" id="content"></iframe>
<script>
function toggleIframe(){
var x=document.getElementById('content');
x.style.display = x.style.display == 'none' ? x.style.display = 'block' : x.style.display = 'none';
setTimeout(toggleIframe,200);
}
setTimeout(toggleIframe,500);
function removestyles(i){
window.frames[0].document.getElementsByTagName('*')[1].removeAttribute('style');
}
setTimeout(removestyles,500,1);
/*template*/
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<grid>
<rows>
<column>
<hbox/>
<hbox/>
</column>
<hbox/>
</rows>
</grid>
</window>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox equalsize="always"><grid/>x</hbox>
</window>

View file

@ -0,0 +1,5 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<listbox><listhead>x</listhead></listbox>
</window>

View file

@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body>
<xul:splitter id="s" collapse="both" state="collapsed" />
</body>
</html>

View file

@ -0,0 +1,21 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script id="script" xmlns="http://www.w3.org/1999/xhtml">
function doe(){
document.getElementById('a').removeAttribute('style');
}
setTimeout(doe,100);
</script>
<box id="a" style="position: absolute;">
<menuitem sizetopopup="always">
<menupopup style="position: absolute;"/>
</menuitem>
<box style="position: fixed;">
<tree>
<treecol>
<treecol/>
</treecol>
</tree>
</box>
</box>
</window>

View file

@ -0,0 +1,9 @@
<html class="reftest-wait">
<head>
<script>
setTimeout('document.documentElement.className = ""', 1000);
</script>
<body>
<iframe src="384105-1-inner.xul"></iframe>
</body>
</html>

View file

@ -0,0 +1,10 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onerror="var x=document.getElementsByTagName('*');x[Math.floor(Math.random()*x.length)].focus()"
onblur="event.originalTarget.parentNode.parentNode.removeChild(event.originalTarget.parentNode)">
<script xmlns="http://www.w3.org/1999/xhtml">setTimeout(function() {window.location.reload()}, 200);</script>
<broadcasterset style="display: block;">
<broadcaster style="display: block;"></broadcaster>
</broadcasterset>
<preferences></preferences>
</window>

View file

@ -0,0 +1,4 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onerror="document.getElementsByTagName('*')[1].focus()" onfocus="event.target.parentNode.removeChild(event.target)">
<broadcaster style="display: block;"/>
<preferences/>
</window>

View file

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html class="reftest-wait"><head>
<meta charset="utf-8">
<title>Testcase for bug 384373</title>
<script>
function reload() {
this.location.reload();
}
// Run the test for 1 second
setTimeout(function() {
document.body.getBoundingClientRect();
document.documentElement.removeChild(document.body);
document.documentElement.className = "";
}, 2000);
</script>
</head>
<body onload="document.body.getBoundingClientRect()">
<iframe src="384373-1.xul"></iframe>
<iframe onload="this.contentWindow.setTimeout(reload,500)" src="384373-2.xul"></iframe>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body>
<xul:listboxbody style="overflow: hidden" />
</body>
</html>

View file

@ -0,0 +1,9 @@
<popup xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script xmlns="http://www.w3.org/1999/xhtml">
function doe(){
document.documentElement.autoPosition = 'on';
window.location.reload();
}
setTimeout(doe, 300);
</script>
</popup>

View file

@ -0,0 +1,9 @@
<html class="reftest-wait">
<head>
<script>
setTimeout('document.documentElement.className = ""', 500);
</script>
<body>
<iframe src="384871-1-inner.xul"></iframe>
</body>
</html>

View file

@ -0,0 +1,31 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Bug 386642 Crash [@ IsCanvasFrame] while opening context menu or changing styles">
<toolbarbutton type="menu" id="a">
<menupopup id="b"/>
</toolbarbutton>
<style xmlns="http://www.w3.org/1999/xhtml">
.one image {
display: -moz-box;
}
image{
display: none;
}
</style>
<script><![CDATA[
var gg=0;
function doe() {
var a = document.getElementById('a');
if (!a.hasAttribute('class')) {
a.setAttribute('class', 'one');
} else {
a.removeAttribute('class');
}
document.getElementById('b').hidePopup();
}
doe();
setInterval(doe, 200);
]]></script>
</window>

View file

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<xbl:bindings>
<xbl:binding id="test" extends="chrome://global/content/bindings/text.xml#text-label">
<xbl:implementation>
<xbl:property name="accessKey">
<xbl:getter>
<![CDATA[
this.parentNode.parentNode.removeChild(this.parentNode);
return "";
]]>
</xbl:getter>
<xbl:setter>
<![CDATA[
return val;
]]>
</xbl:setter>
</xbl:property>
</xbl:implementation>
</xbl:binding>
</xbl:bindings>
</head>
<body>
<xul:hbox>
<xul:label value="foobar" style="-moz-binding: url(#test)"/>
</xul:hbox>
</body>
</html>

View file

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<description>
<foo height="1793689537164611773" width="20000238421986669650" />
</description>
</window>

View file

@ -0,0 +1,19 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menuitem>
<tooltip/>
<box/>
</menuitem>
<script xmlns="http://www.w3.org/1999/xhtml">
function doe2() {
document.getElementsByTagName('menuitem')[0].setAttribute('description', 'tetx');
}
function doe3() {
document.getElementsByTagName('menuitem')[0].removeAttribute('description');
document.getElementsByTagName('tooltip')[0].setAttribute('ordinal', '0');
}
setTimeout(doe2,150);
setTimeout(doe3,200);
</script>
</window>

View file

@ -0,0 +1,9 @@
<html class="reftest-wait">
<head>
<script>
setTimeout('document.documentElement.className = ""', 1000);
</script>
<body>
<iframe src="391974-1-inner.xul"></iframe>
</body>
</html>

View file

@ -0,0 +1,19 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<script>
function boom()
{
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var xultext = document.createElementNS(XUL_NS, "text");
var hbox = document.getElementById("hbox")
hbox.appendChild(xultext);
}
</script>
</head>
<body onload="boom();">
<xul:listboxbody><xul:hbox id="hbox" /></xul:listboxbody>
</body>
</html>

View file

@ -0,0 +1,21 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="opacity: 0.2;">
<head>
<script>
function x()
{
document.documentElement.style.counterReset = "chicken";
document.body.offsetHeight;
}
</script>
</head>
<body onload="setTimeout(x, 0);">Foo</body>
<xul:listbox/>
</html>

View file

@ -0,0 +1 @@
<html><body><listboxbody style="display: -moz-grid-group;"></listboxbody></body></html>

View file

@ -0,0 +1,17 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
function boom()
{
var listbox = document.createElementNS(XUL_NS, 'listbox');
document.body.appendChild(listbox);
var listitem = document.createElementNS(XUL_NS, 'listitem');
listbox.appendChild(listitem);
}
</script>
</head>
<body onload="boom();">
</body>
</html>

View file

@ -0,0 +1,31 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menulist id="b" style="display: -moz-groupbox;">
<panel id="c" style=" position: absolute;">
<popup onunderflow="document.getElementById('c').removeAttribute('style')"/>
</panel>
<menupopup id="a" style="display: -moz-stack;">
<menulist/>
</menupopup>
<panel style="display: -moz-deck;" onoverflow="document.getElementById('b').removeAttribute('style')">
<popup style="display: -moz-deck;"/>
</panel>
</menulist>
<script id="script" xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
function doe() {
document.getElementById('c').removeAttribute('style');
document.documentElement.boxObject.height;
document.getElementById('b').removeAttribute('style');
document.getElementById('a').setAttribute('selected', 'true');
document.getElementById('a').setAttribute('style', 'position: fixed;');
document.documentElement.boxObject.height;
document.getElementById('a').removeAttribute('style');
}
function doe2() {
window.location.reload();
}
setTimeout(doe2, 200);
setTimeout(doe,100);
]]></script>
</window>

View file

@ -0,0 +1,16 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<script>
function boom()
{
var menulist = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menulist");
document.getElementById("h").appendChild(menulist);
}
</script>
</head>
<body onload="boom();">
<xul:listboxbody><xul:hbox id="h"/></xul:listboxbody>
</body>
</html>

View file

@ -0,0 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body>
<xul:vbox equalsize="always"><xul:hbox flex="1"><span><xul:hbox width="10" height="10"/></span><xul:button /></xul:hbox><xul:hbox maxheight="0"/></xul:vbox>
</body>
</html>

View file

@ -0,0 +1,12 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" class="reftest-wait">
<xul:titlebar id="a" style="overflow: auto;"/>
<script>
function doe() {
document.getElementsByTagName('*')[1].focus();
document.getElementsByTagName('*')[0].focus();
document.documentElement.removeAttribute("class");
}
setTimeout(doe, 200);
</script>
</html>

View file

@ -0,0 +1,7 @@
<triple xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" style="display: block;">
<box style="display: block; position: relative; -moz-binding: url(data:text/xml;charset=utf-8,%3Cbindings%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%3E%0A%3Cbinding%20id%3D%22a%22%3E%0A%3Cimplementation%3E%0A%3Cfield%20name%3D%22_field%22%3Ethis.ownerDocument.getBoxObjectFor%28this.ownerDocument.documentElement%29%3B%3C/field%3E%0A%3C/implementation%3E%0A%3Ccontent%3E%0A%3C/binding%3E%0A%3C/bindings%3E);">
<box style="position: fixed; -moz-binding: url(data:text/xml;charset=utf-8,%3Cbindings%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%3E%0A%3Cbinding%20id%3D%22a%22%3E%0A%3Ccontent%3E%0A%3Cchildren%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22/%3E%3C/content%3E%3C/binding%3E%3C/bindings%3E);"/>
<iframe/>
</box>
<scrollbox onoverflow="document.documentElement.removeAttribute('style')"/>
</triple>

View file

@ -0,0 +1 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><grid><rows><label/></rows><columns><column><label/></column></columns></grid></window>

View file

@ -0,0 +1,4 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head></head>
<body><xul:menubar style="display: table-column; padding: 10px 3000px;"/></body>
</html>

View file

@ -0,0 +1,28 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="reftest-wait">
<head>
<script type="text/javascript">
function boom()
{
document.execCommand("justifycenter", false, null);
var listboxbody = document.getElementById("lbb");
listboxbody.height = 9;
setTimeout(boom2, 0);
function boom2()
{
var td = document.createElementNS("http://www.w3.org/1999/xhtml", "td");
listboxbody.appendChild(td);
document.documentElement.removeAttribute("class");
}
}
</script>
</head>
<body onload="setTimeout(boom, 0);" contenteditable="true"><xul:listboxbody id="lbb"><xul:hbox/><span><col style="width: 100px;" /></span></xul:listboxbody></body>
</html>

View file

@ -0,0 +1,7 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<span id="a" datasources="" xmlns="http://www.w3.org/1999/xhtml"/>
<script xmlns="http://www.w3.org/1999/xhtml">
document.documentElement.appendChild(document.getElementById('a'));
</script>
</window>

View file

@ -0,0 +1,6 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="document.getElementById('a').ensureElementIsVisible(null);">
<listbox id="a"/>
</window>

View file

@ -0,0 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<body style="visibility: collapse;">
<tabpanels xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" style="width: -moz-max-content;"></tabpanels>
</body>
</html>

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body>
<div>
<span style="font-size: 0pt;"><xul:listboxbody><span style="border: 1px solid red;"/></xul:listboxbody></span>
</div>
</body>
</html>

View file

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="boom();">
<script type="text/javascript">
// <![CDATA[
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
function boom()
{
var lb = document.getElementById("lb");
var firstli = document.getElementById("firstli");
lb.appendChild(document.createElementNS(XUL_NS, "hbox"));
lb.appendChild(document.createElementNS(XUL_NS, "listitem"));
firstli.style.display = "none";
// Flush layout.
document.getBoxObjectFor(document.documentElement).height;
lb.removeChild(firstli);
}
// ]]>
</script>
<listbox id="lb"><listitem id="firstli"/></listbox>
</window>

View file

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="boom();">
<hbox style="display: none;">
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="x">
<content><listitem xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/></content>
</binding>
</bindings>
</hbox>
<script type="text/javascript">
function boom()
{
document.getElementById("b").style.MozBinding = "url('#x')";
// Flush layout.
document.documentElement.boxObject.height;
document.getElementById("listbox").removeChild(document.getElementById("c"));
}
</script>
<listbox id="listbox"><listitem/><listitem id="b"/><listitem id="c"/></listbox>
</window>

View file

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="boom();">
<script type="text/javascript">
function boom()
{
var l = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "listitem");
l.style.display = "none";
var c = document.getElementById("c");
c.parentNode.insertBefore(l, c);
document.getElementById("listbox").removeChild(document.getElementById("c"));
}
</script>
<listbox id="listbox"><listitem/><listitem id="c"/></listbox>
</window>

View file

@ -0,0 +1,5 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox><listboxbody><listheader/><hbox><iframe/></hbox></listboxbody><tabpanels><tabpanels/></tabpanels></hbox>
</window>

View file

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="boom();">
<script type="text/javascript">
function boom()
{
var listbox = document.getElementById("listbox");
listbox.removeChild(listbox.childNodes[1]);
document.documentElement.style.MozBinding = "url('data:text/xml,%3Cbindings%20xmlns%3D%22http%3A%2F%2Fwww.mozilla.org%2Fxbl%22%3E%3Cbinding%20id%3D%22foo%22%3E%3Ccontent%3E%0A%3Chbox%20xmlns%3D%22http%3A%2F%2Fwww.mozilla.org%2Fkeymaster%2Fgatekeeper%2Fthere.is.only.xul%22%2F%3E%0A%3C%2Fcontent%3E%3C%2Fbinding%3E%3C%2Fbindings%3E%0A')";
document.documentElement.boxObject.height;
listbox.removeChild(listbox.childNodes[0]);
}
</script>
<listbox id="listbox" style="-moz-binding: url(data:text/xml,%3Cbindings%20xmlns%3D%22http%3A%2F%2Fwww.mozilla.org%2Fxbl%22%3E%3Cbinding%20id%3D%22foo%22%3E%3Ccontent%3E%0A%3Clistbox%20xmlns%3D%22http%3A%2F%2Fwww.mozilla.org%2Fkeymaster%2Fgatekeeper%2Fthere.is.only.xul%22%3E%3Cchildren%20xmlns%3D%22http%3A%2F%2Fwww.mozilla.org%2Fxbl%22%2F%3E%3C%2Flistbox%3E%0A%3C%2Fcontent%3E%3C%2Fbinding%3E%3C%2Fbindings%3E%0A);"><listitem/><listitem/></listbox>
</window>

View file

@ -0,0 +1,20 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="setTimeout(boom, 30);" class="reftest-wait">
<script>
function boom() {
var a = document.getElementById('a');
var x = a.popupBoxObject;
a.parentNode.removeChild(a);
x.enableKeyboardNavigator(true);
x.openPopup(null, "after_start", 0, 0, false, false, null);
x.openPopupAtScreen(2, 2, false, null);
x.showPopup(document.documentElement, a, -1, -1, "popup", "topleft", "topleft");
x.hidePopup();
document.documentElement.removeAttribute("class");
}
</script>
<menupopup id="a"/>
</window>

View file

@ -0,0 +1,3 @@
<html><head></head><body><div style="position: absolute;"> </div>
<style>div, head {-moz-binding:url(452185.xml#a);</style>
</body></html>

View file

@ -0,0 +1,5 @@
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xlink="http://www.w3.org/1999/xlink">
<binding id="a">
<content><tbody xmlns="http://www.w3.org/1999/xhtml"><style>*::before { content:"b"; }</style></tbody></content>
</binding></bindings>

View file

@ -0,0 +1,3 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="document.getElementById('label').control='c';">
<label id="label"><hbox><listboxbody><hbox/><tooltip/></listboxbody><autorepeatbutton/></hbox></label>
</window>

View file

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window onload="boom();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="m"><content><xul:textbox type="text"><children/></xul:textbox></content></binding>
</bindings>
<script type="text/javascript">
<![CDATA[
function boom()
{
document.getElementById("b").style.MozBinding = 'url("data:text/xml,' + encodeURIComponent("<bindings xmlns='http://www.mozilla.org/xbl'><binding id='foo'><content><hbox xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'><children xmlns='http://www.mozilla.org/xbl'/></hbox></content></binding></bindings>\n") + '")';
}
]]>
</script>
<listbox style="float: right;"><listitem/><listitem id="b"/><listitem><hbox style="-moz-binding: url(#m);"/></listitem></listbox>
</window>

View file

@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
</head>
<body>
<xul:radio style="overflow: auto; height: 72057594037927940pt; display: table-cell;"/>
</body>
</html>

View file

@ -0,0 +1,24 @@
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mathml="http://www.w3.org/1998/Math/MathML" style="-moz-binding:url(#a);" class="reftest-wait">
<content xmlns="http://www.mozilla.org/xbl" ordinal="-1">
<mathml:median style="display: block;"/>
</content>
<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
function finish() {
document.documentElement.removeAttribute("class");
}
function doe() {
document.documentElement.removeAttribute('style');
setTimeout(finish, 0);
}
setTimeout(doe, 100);
]]></script>
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="a">
<content><children/></content>
</binding></bindings>
</window>

Some files were not shown because too many files have changed in this diff Show more