Merge last PGO-green changeset of mozilla-inbound to mozilla-central

This commit is contained in:
Ed Morley 2012-05-08 19:13:19 +01:00
commit 58f5bc3f09
39 changed files with 723 additions and 568 deletions

View File

@ -49,8 +49,6 @@
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
@ -66,8 +64,6 @@ using namespace mozilla::a11y;
nsIStringBundle *nsAccessNode::gStringBundle = 0; nsIStringBundle *nsAccessNode::gStringBundle = 0;
bool nsAccessNode::gIsFormFillEnabled = false;
ApplicationAccessible* nsAccessNode::gApplicationAccessible = nsnull; ApplicationAccessible* nsAccessNode::gApplicationAccessible = nsnull;
/* /*
@ -162,11 +158,6 @@ void nsAccessNode::InitXPAccessibility()
stringBundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL, stringBundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL,
&gStringBundle); &gStringBundle);
} }
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetBoolPref("browser.formfill.enable", &gIsFormFillEnabled);
}
} }
void nsAccessNode::ShutdownXPAccessibility() void nsAccessNode::ShutdownXPAccessibility()

View File

@ -167,8 +167,6 @@ protected:
// Static data, we do our own refcounting for our static data. // Static data, we do our own refcounting for our static data.
static nsIStringBundle* gStringBundle; static nsIStringBundle* gStringBundle;
static bool gIsFormFillEnabled;
private: private:
nsAccessNode() MOZ_DELETE; nsAccessNode() MOZ_DELETE;
nsAccessNode(const nsAccessNode&) MOZ_DELETE; nsAccessNode(const nsAccessNode&) MOZ_DELETE;

View File

@ -46,6 +46,7 @@
#include "AtkSocketAccessible.h" #include "AtkSocketAccessible.h"
#endif #endif
#include "FocusManager.h" #include "FocusManager.h"
#include "HTMLListAccessible.h"
#include "nsAccessiblePivot.h" #include "nsAccessiblePivot.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"
#include "nsARIAMap.h" #include "nsARIAMap.h"
@ -222,7 +223,7 @@ nsAccessibilityService::CreateHTMLLIAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLLIAccessible(aContent, GetDocAccessible(aPresShell)); new HTMLLIAccessible(aContent, GetDocAccessible(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -599,7 +600,7 @@ nsAccessibilityService::UpdateListBullet(nsIPresShell* aPresShell,
if (document) { if (document) {
nsAccessible* accessible = document->GetAccessible(aHTMLListItemContent); nsAccessible* accessible = document->GetAccessible(aHTMLListItemContent);
if (accessible) { if (accessible) {
nsHTMLLIAccessible* listItem = accessible->AsHTMLListItem(); HTMLLIAccessible* listItem = accessible->AsHTMLListItem();
if (listItem) if (listItem)
listItem->UpdateBullet(aHasBullet); listItem->UpdateBullet(aHasBullet);
} }
@ -1658,7 +1659,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
if (tag == nsGkAtoms::ul || tag == nsGkAtoms::ol || if (tag == nsGkAtoms::ul || tag == nsGkAtoms::ol ||
tag == nsGkAtoms::dl) { tag == nsGkAtoms::dl) {
nsAccessible* accessible = new nsHTMLListAccessible(aContent, aDoc); nsAccessible* accessible = new HTMLListAccessible(aContent, aDoc);
NS_IF_ADDREF(accessible); NS_IF_ADDREF(accessible);
return accessible; return accessible;
} }
@ -1685,7 +1686,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
// Normally for li, it is created by the list item frame (in nsBlockFrame) // Normally for li, it is created by the list item frame (in nsBlockFrame)
// which knows about the bullet frame; however, in this case the list item // which knows about the bullet frame; however, in this case the list item
// must have been styled using display: foo // must have been styled using display: foo
nsAccessible* accessible = new nsHTMLLIAccessible(aContent, aDoc); nsAccessible* accessible = new HTMLLIAccessible(aContent, aDoc);
NS_IF_ADDREF(accessible); NS_IF_ADDREF(accessible);
return accessible; return accessible;
} }

View File

@ -62,12 +62,13 @@ class nsAccessible;
class nsHyperTextAccessible; class nsHyperTextAccessible;
class nsHTMLImageAccessible; class nsHTMLImageAccessible;
class nsHTMLImageMapAccessible; class nsHTMLImageMapAccessible;
class nsHTMLLIAccessible;
struct nsRoleMapEntry; struct nsRoleMapEntry;
class Relation; class Relation;
namespace mozilla { namespace mozilla {
namespace a11y { namespace a11y {
class HTMLLIAccessible;
class TableAccessible; class TableAccessible;
/** /**
@ -476,7 +477,7 @@ public:
inline bool IsHTMLFileInput() const { return mFlags & eHTMLFileInputAccessible; } inline bool IsHTMLFileInput() const { return mFlags & eHTMLFileInputAccessible; }
inline bool IsHTMLListItem() const { return mFlags & eHTMLListItemAccessible; } inline bool IsHTMLListItem() const { return mFlags & eHTMLListItemAccessible; }
nsHTMLLIAccessible* AsHTMLListItem(); mozilla::a11y::HTMLLIAccessible* AsHTMLListItem();
inline bool IsImageAccessible() const { return mFlags & eImageAccessible; } inline bool IsImageAccessible() const { return mFlags & eImageAccessible; }
nsHTMLImageAccessible* AsImage(); nsHTMLImageAccessible* AsImage();

View File

@ -63,6 +63,9 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsITextControlFrame.h" #include "nsITextControlFrame.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
using namespace mozilla::a11y; using namespace mozilla::a11y;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -496,7 +499,7 @@ HTMLTextFieldAccessible::NativeState()
// No parent can mean a fake widget created for XUL textbox. If accessible // No parent can mean a fake widget created for XUL textbox. If accessible
// is unattached from tree then we don't care. // is unattached from tree then we don't care.
if (mParent && gIsFormFillEnabled) { if (mParent && Preferences::GetBool("browser.formfill.enable")) {
// Check to see if autocompletion is allowed on this input. We don't expose // Check to see if autocompletion is allowed on this input. We don't expose
// it for password fields even though the entire password can be remembered // it for password fields even though the entire password can be remembered
// for a page if the user asks it to be. However, the kind of autocomplete // for a page if the user asks it to be. However, the kind of autocomplete

View File

@ -0,0 +1,201 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "HTMLListAccessible.h"
#include "nsDocAccessible.h"
#include "Role.h"
#include "States.h"
#include "nsBlockFrame.h"
using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// HTMLListAccessible
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(HTMLListAccessible, nsHyperTextAccessible)
role
HTMLListAccessible::NativeRole()
{
if (mContent->Tag() == nsGkAtoms::dl)
return roles::DEFINITION_LIST;
return roles::LIST;
}
PRUint64
HTMLListAccessible::NativeState()
{
return nsHyperTextAccessibleWrap::NativeState() | states::READONLY;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLLIAccessible
////////////////////////////////////////////////////////////////////////////////
HTMLLIAccessible::
HTMLLIAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsHyperTextAccessibleWrap(aContent, aDoc), mBullet(nsnull)
{
mFlags |= eHTMLListItemAccessible;
nsBlockFrame* blockFrame = do_QueryFrame(GetFrame());
if (blockFrame && blockFrame->HasBullet()) {
mBullet = new HTMLListBulletAccessible(mContent, mDoc);
if (!Document()->BindToDocument(mBullet, nsnull))
mBullet = nsnull;
}
}
NS_IMPL_ISUPPORTS_INHERITED0(HTMLLIAccessible, nsHyperTextAccessible)
void
HTMLLIAccessible::Shutdown()
{
mBullet = nsnull;
nsHyperTextAccessibleWrap::Shutdown();
}
role
HTMLLIAccessible::NativeRole()
{
if (mContent->Tag() == nsGkAtoms::dt)
return roles::TERM;
return roles::LISTITEM;
}
PRUint64
HTMLLIAccessible::NativeState()
{
return nsHyperTextAccessibleWrap::NativeState() | states::READONLY;
}
NS_IMETHODIMP
HTMLLIAccessible::GetBounds(PRInt32* aX, PRInt32* aY,
PRInt32* aWidth, PRInt32* aHeight)
{
nsresult rv = nsAccessibleWrap::GetBounds(aX, aY, aWidth, aHeight);
if (NS_FAILED(rv) || !mBullet)
return rv;
PRInt32 bulletX = 0, bulletY = 0, bulletWidth = 0, bulletHeight = 0;
rv = mBullet->GetBounds(&bulletX, &bulletY, &bulletWidth, &bulletHeight);
NS_ENSURE_SUCCESS(rv, rv);
*aX = bulletX; // Move x coordinate of list item over to cover bullet as well
*aWidth += bulletWidth;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLLIAccessible: public
void
HTMLLIAccessible::UpdateBullet(bool aHasBullet)
{
if (aHasBullet == !!mBullet) {
NS_NOTREACHED("Bullet and accessible are in sync already!");
return;
}
nsDocAccessible* document = Document();
if (aHasBullet) {
mBullet = new HTMLListBulletAccessible(mContent, mDoc);
if (document->BindToDocument(mBullet, nsnull)) {
InsertChildAt(0, mBullet);
}
} else {
RemoveChild(mBullet);
document->UnbindFromDocument(mBullet);
mBullet = nsnull;
}
// XXXtodo: fire show/hide and reorder events. That's hard to make it
// right now because coalescence happens by DOM node.
}
////////////////////////////////////////////////////////////////////////////////
// HTMLLIAccessible: nsAccessible protected
void
HTMLLIAccessible::CacheChildren()
{
if (mBullet)
AppendChild(mBullet);
// Cache children from subtree.
nsAccessibleWrap::CacheChildren();
}
////////////////////////////////////////////////////////////////////////////////
// HTMLListBulletAccessible
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// HTMLListBulletAccessible: nsAccessNode
bool
HTMLListBulletAccessible::IsPrimaryForNode() const
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLListBulletAccessible: nsAccessible
ENameValueFlag
HTMLListBulletAccessible::Name(nsString &aName)
{
aName.Truncate();
// Native anonymous content, ARIA can't be used. Get list bullet text.
nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame());
NS_ASSERTION(blockFrame, "No frame for list item!");
if (blockFrame) {
blockFrame->GetBulletText(aName);
// Append space otherwise bullets are jammed up against list text.
aName.Append(' ');
}
return eNameOK;
}
role
HTMLListBulletAccessible::NativeRole()
{
return roles::STATICTEXT;
}
PRUint64
HTMLListBulletAccessible::NativeState()
{
PRUint64 state = nsLeafAccessible::NativeState();
state &= ~states::FOCUSABLE;
state |= states::READONLY;
return state;
}
void
HTMLListBulletAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
PRUint32 aLength)
{
nsAutoString bulletText;
nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame());
NS_ASSERTION(blockFrame, "No frame for list item!");
if (blockFrame)
blockFrame->GetBulletText(bulletText);
aText.Append(Substring(bulletText, aStartOffset, aLength));
}

View File

@ -0,0 +1,104 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_HTMLListAccessible_h__
#define mozilla_a11y_HTMLListAccessible_h__
#include "nsHyperTextAccessibleWrap.h"
#include "nsBaseWidgetAccessible.h"
namespace mozilla {
namespace a11y {
class HTMLListBulletAccessible;
/**
* Used for HTML list (like HTML ul).
*/
class HTMLListAccessible : public nsHyperTextAccessibleWrap
{
public:
HTMLListAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsHyperTextAccessibleWrap(aContent, aDoc) { }
virtual ~HTMLListAccessible() { }
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsAccessible
virtual a11y::role NativeRole();
virtual PRUint64 NativeState();
};
/**
* Used for HTML list item (e.g. HTML li).
*/
class HTMLLIAccessible : public nsHyperTextAccessibleWrap
{
public:
HTMLLIAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
virtual ~HTMLLIAccessible() { }
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsAccessNode
virtual void Shutdown();
// nsIAccessible
NS_IMETHOD GetBounds(PRInt32* aX, PRInt32* aY,
PRInt32* aWidth, PRInt32* aHeight);
// nsAccessible
virtual a11y::role NativeRole();
virtual PRUint64 NativeState();
// nsHTMLLIAccessible
void UpdateBullet(bool aHasBullet);
protected:
// nsAccessible
virtual void CacheChildren();
private:
nsRefPtr<HTMLListBulletAccessible> mBullet;
};
/**
* Used for bullet of HTML list item element (for example, HTML li).
*/
class HTMLListBulletAccessible : public nsLeafAccessible
{
public:
HTMLListBulletAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsLeafAccessible(aContent, aDoc) { }
virtual ~HTMLListBulletAccessible() { }
// nsAccessNode
virtual bool IsPrimaryForNode() const;
// nsAccessible
virtual ENameValueFlag Name(nsString& aName);
virtual a11y::role NativeRole();
virtual PRUint64 NativeState();
virtual void AppendTextTo(nsAString& aText, PRUint32 aStartOffset = 0,
PRUint32 aLength = PR_UINT32_MAX);
};
} // namespace a11y
} // namespace mozilla
inline mozilla::a11y::HTMLLIAccessible*
nsAccessible::AsHTMLListItem()
{
return mFlags & eHTMLListItemAccessible ?
static_cast<mozilla::a11y::HTMLLIAccessible*>(this) : nsnull;
}
#endif

View File

@ -52,6 +52,7 @@ LIBXUL_LIBRARY = 1
CPPSRCS = \ CPPSRCS = \
nsHTMLCanvasAccessible.cpp \ nsHTMLCanvasAccessible.cpp \
HTMLFormControlAccessible.cpp \ HTMLFormControlAccessible.cpp \
HTMLListAccessible.cpp \
nsHTMLImageAccessible.cpp \ nsHTMLImageAccessible.cpp \
nsHTMLImageMapAccessible.cpp \ nsHTMLImageMapAccessible.cpp \
nsHTMLLinkAccessible.cpp \ nsHTMLLinkAccessible.cpp \

View File

@ -41,19 +41,12 @@
#include "nsDocAccessible.h" #include "nsDocAccessible.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"
#include "nsIAccessibleRelation.h"
#include "nsTextEquivUtils.h" #include "nsTextEquivUtils.h"
#include "Relation.h" #include "Relation.h"
#include "Role.h" #include "Role.h"
#include "States.h" #include "States.h"
#include "nsIAccessibleRelation.h"
#include "nsIFrame.h"
#include "nsPresContext.h"
#include "nsBlockFrame.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla::a11y; using namespace mozilla::a11y;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -227,198 +220,3 @@ nsHTMLOutputAccessible::GetAttributesInternal(nsIPersistentProperties* aAttribut
return NS_OK; return NS_OK;
} }
////////////////////////////////////////////////////////////////////////////////
// nsHTMLLIAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLLIAccessible::
nsHTMLLIAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsHyperTextAccessibleWrap(aContent, aDoc), mBullet(nsnull)
{
mFlags |= eHTMLListItemAccessible;
nsBlockFrame* blockFrame = do_QueryFrame(GetFrame());
if (blockFrame && blockFrame->HasBullet()) {
mBullet = new nsHTMLListBulletAccessible(mContent, mDoc);
if (!Document()->BindToDocument(mBullet, nsnull))
mBullet = nsnull;
}
}
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLLIAccessible, nsHyperTextAccessible)
void
nsHTMLLIAccessible::Shutdown()
{
mBullet = nsnull;
nsHyperTextAccessibleWrap::Shutdown();
}
role
nsHTMLLIAccessible::NativeRole()
{
if (mContent->Tag() == nsGkAtoms::dt)
return roles::TERM;
return roles::LISTITEM;
}
PRUint64
nsHTMLLIAccessible::NativeState()
{
return nsHyperTextAccessibleWrap::NativeState() | states::READONLY;
}
NS_IMETHODIMP nsHTMLLIAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
nsresult rv = nsAccessibleWrap::GetBounds(x, y, width, height);
if (NS_FAILED(rv) || !mBullet)
return rv;
PRInt32 bulletX, bulletY, bulletWidth, bulletHeight;
rv = mBullet->GetBounds(&bulletX, &bulletY, &bulletWidth, &bulletHeight);
NS_ENSURE_SUCCESS(rv, rv);
*x = bulletX; // Move x coordinate of list item over to cover bullet as well
*width += bulletWidth;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLLIAccessible: public
void
nsHTMLLIAccessible::UpdateBullet(bool aHasBullet)
{
if (aHasBullet == !!mBullet) {
NS_NOTREACHED("Bullet and accessible are in sync already!");
return;
}
nsDocAccessible* document = Document();
if (aHasBullet) {
mBullet = new nsHTMLListBulletAccessible(mContent, mDoc);
if (document->BindToDocument(mBullet, nsnull)) {
InsertChildAt(0, mBullet);
}
} else {
RemoveChild(mBullet);
document->UnbindFromDocument(mBullet);
mBullet = nsnull;
}
// XXXtodo: fire show/hide and reorder events. That's hard to make it
// right now because coalescence happens by DOM node.
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLLIAccessible: nsAccessible protected
void
nsHTMLLIAccessible::CacheChildren()
{
if (mBullet)
AppendChild(mBullet);
// Cache children from subtree.
nsAccessibleWrap::CacheChildren();
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLListBulletAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLListBulletAccessible::
nsHTMLListBulletAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsLeafAccessible(aContent, aDoc)
{
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLListBulletAccessible: nsAccessNode
bool
nsHTMLListBulletAccessible::IsPrimaryForNode() const
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLListBulletAccessible: nsAccessible
ENameValueFlag
nsHTMLListBulletAccessible::Name(nsString &aName)
{
aName.Truncate();
// Native anonymous content, ARIA can't be used. Get list bullet text.
nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame());
NS_ASSERTION(blockFrame, "No frame for list item!");
if (blockFrame) {
blockFrame->GetBulletText(aName);
// Append space otherwise bullets are jammed up against list text.
aName.Append(' ');
}
return eNameOK;
}
role
nsHTMLListBulletAccessible::NativeRole()
{
return roles::STATICTEXT;
}
PRUint64
nsHTMLListBulletAccessible::NativeState()
{
PRUint64 state = nsLeafAccessible::NativeState();
state &= ~states::FOCUSABLE;
state |= states::READONLY;
return state;
}
void
nsHTMLListBulletAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
PRUint32 aLength)
{
nsAutoString bulletText;
nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame());
NS_ASSERTION(blockFrame, "No frame for list item!");
if (blockFrame)
blockFrame->GetBulletText(bulletText);
aText.Append(Substring(bulletText, aStartOffset, aLength));
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLListAccessible
////////////////////////////////////////////////////////////////////////////////
nsHTMLListAccessible::
nsHTMLListAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsHyperTextAccessibleWrap(aContent, aDoc)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLListAccessible, nsHyperTextAccessible)
role
nsHTMLListAccessible::NativeRole()
{
if (mContent->Tag() == nsGkAtoms::dl)
return roles::DEFINITION_LIST;
return roles::LIST;
}
PRUint64
nsHTMLListAccessible::NativeState()
{
return nsHyperTextAccessibleWrap::NativeState() | states::READONLY;
}

View File

@ -119,78 +119,4 @@ public:
virtual Relation RelationByType(PRUint32 aType); virtual Relation RelationByType(PRUint32 aType);
}; };
/**
* Used for bullet of HTML list item element (for example, HTML li).
*/
class nsHTMLListBulletAccessible : public nsLeafAccessible
{
public:
nsHTMLListBulletAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsAccessNode
virtual bool IsPrimaryForNode() const;
// nsAccessible
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState();
virtual void AppendTextTo(nsAString& aText, PRUint32 aStartOffset = 0,
PRUint32 aLength = PR_UINT32_MAX);
};
/**
* Used for HTML list (like HTML ul).
*/
class nsHTMLListAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLListAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsAccessible
virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState();
};
/**
* Used for HTML list item (e.g. HTML li).
*/
class nsHTMLLIAccessible : public nsHyperTextAccessibleWrap
{
public:
nsHTMLLIAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsAccessNode
virtual void Shutdown();
// nsIAccessible
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
// nsAccessible
virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState();
// nsHTMLLIAccessible
void UpdateBullet(bool aHasBullet);
protected:
// nsAccessible
virtual void CacheChildren();
private:
nsRefPtr<nsHTMLListBulletAccessible> mBullet;
};
inline nsHTMLLIAccessible*
nsAccessible::AsHTMLListItem()
{
return mFlags & eHTMLListItemAccessible ?
static_cast<nsHTMLLIAccessible*>(this) : nsnull;
}
#endif #endif

View File

@ -873,7 +873,7 @@ public:
* host content. When the content is in designMode, this returns its body * host content. When the content is in designMode, this returns its body
* element. Also, when the content isn't editable, this returns null. * element. Also, when the content isn't editable, this returns null.
*/ */
nsIContent* GetEditingHost(); mozilla::dom::Element* GetEditingHost();
/** /**
* Determing language. Look at the nearest ancestor element that has a lang * Determing language. Look at the nearest ancestor element that has a lang

View File

@ -85,6 +85,7 @@
#include "imgIContainer.h" #include "imgIContainer.h"
#include "imgIRequest.h" #include "imgIRequest.h"
#include "nsDOMDataTransfer.h" #include "nsDOMDataTransfer.h"
#include "mozilla/dom/Element.h"
class NS_STACK_CLASS DragDataProducer class NS_STACK_CLASS DragDataProducer
{ {

View File

@ -1552,7 +1552,7 @@ nsIContent::HasIndependentSelection()
return (frame && frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION); return (frame && frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION);
} }
nsIContent* dom::Element*
nsIContent::GetEditingHost() nsIContent::GetEditingHost()
{ {
// If this isn't editable, return NULL. // If this isn't editable, return NULL.
@ -1566,12 +1566,12 @@ nsIContent::GetEditingHost()
} }
nsIContent* content = this; nsIContent* content = this;
for (nsIContent* parent = GetParent(); for (dom::Element* parent = GetElementParent();
parent && parent->HasFlag(NODE_IS_EDITABLE); parent && parent->HasFlag(NODE_IS_EDITABLE);
parent = content->GetParent()) { parent = content->GetElementParent()) {
content = parent; content = parent;
} }
return content; return content->AsElement();
} }
nsresult nsresult

View File

@ -1,5 +1,5 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
/* ***** BEGIN LICENSE BLOCK ***** * ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
* The contents of this file are subject to the Mozilla Public License Version * The contents of this file are subject to the Mozilla Public License Version
@ -62,6 +62,8 @@ struct AudioTrack {
jmethodID stop; jmethodID stop;
jmethodID write; jmethodID write;
jmethodID getpos; jmethodID getpos;
jmethodID getstate;
jmethodID release;
}; };
enum AudioTrackMode { enum AudioTrackMode {
@ -91,11 +93,18 @@ enum AudioFormatEncoding {
ENCODING_PCM_8BIT = 3 ENCODING_PCM_8BIT = 3
}; };
enum AudioFormatState {
STATE_UNINITIALIZED = 0,
STATE_INITIALIZED = 1,
STATE_NO_STATIC_DATA = 2
};
static struct AudioTrack at; static struct AudioTrack at;
static jclass static jclass
init_jni_bindings(JNIEnv *jenv) { init_jni_bindings(JNIEnv *jenv) {
jclass jc = jenv->FindClass("android/media/AudioTrack"); jclass jc =
(jclass)jenv->NewGlobalRef(jenv->FindClass("android/media/AudioTrack"));
at.constructor = jenv->GetMethodID(jc, "<init>", "(IIIIII)V"); at.constructor = jenv->GetMethodID(jc, "<init>", "(IIIIII)V");
at.flush = jenv->GetMethodID(jc, "flush", "()V"); at.flush = jenv->GetMethodID(jc, "flush", "()V");
@ -105,6 +114,8 @@ init_jni_bindings(JNIEnv *jenv) {
at.stop = jenv->GetMethodID(jc, "stop", "()V"); at.stop = jenv->GetMethodID(jc, "stop", "()V");
at.write = jenv->GetMethodID(jc, "write", "([BII)I"); at.write = jenv->GetMethodID(jc, "write", "([BII)I");
at.getpos = jenv->GetMethodID(jc, "getPlaybackHeadPosition", "()I"); at.getpos = jenv->GetMethodID(jc, "getPlaybackHeadPosition", "()I");
at.getstate = jenv->GetMethodID(jc, "getState", "()I");
at.release = jenv->GetMethodID(jc, "release", "()V");
return jc; return jc;
} }
@ -143,7 +154,7 @@ AudioRunnable::Run()
if (!jenv) if (!jenv)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
mozilla::AutoLocalJNIFrame autoFrame(jenv); mozilla::AutoLocalJNIFrame autoFrame(jenv, 2);
jbyteArray bytearray = jenv->NewByteArray(mTrack->bufferSize); jbyteArray bytearray = jenv->NewByteArray(mTrack->bufferSize);
if (!bytearray) { if (!bytearray) {
@ -193,6 +204,8 @@ AudioRunnable::Run()
} while(wroteSoFar < buffer.size); } while(wroteSoFar < buffer.size);
} }
jenv->CallVoidMethod(mTrack->output_unit, at.release);
jenv->DeleteGlobalRef(mTrack->output_unit); jenv->DeleteGlobalRef(mTrack->output_unit);
jenv->DeleteGlobalRef(mTrack->at_class); jenv->DeleteGlobalRef(mTrack->at_class);
@ -257,6 +270,8 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz
break; break;
} }
mozilla::AutoLocalJNIFrame autoFrame(jenv);
jobject obj = jenv->NewObject(s->at_class, jobject obj = jenv->NewObject(s->at_class,
at.constructor, at.constructor,
STREAM_MUSIC, STREAM_MUSIC,
@ -266,11 +281,15 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz
s->bufferSize, s->bufferSize,
MODE_STREAM); MODE_STREAM);
jthrowable exception = jenv->ExceptionOccurred(); if (autoFrame.CheckForException() || obj == NULL) {
if (exception) { jenv->DeleteGlobalRef(s->at_class);
LOG("%s fAILED ", __PRETTY_FUNCTION__); free(s);
jenv->ExceptionDescribe(); return NULL;
jenv->ExceptionClear(); }
jint state = jenv->CallIntMethod(obj, at.getstate);
if (autoFrame.CheckForException() || state == STATE_UNINITIALIZED) {
jenv->DeleteGlobalRef(s->at_class); jenv->DeleteGlobalRef(s->at_class);
free(s); free(s);
return NULL; return NULL;
@ -300,7 +319,7 @@ anp_audio_start(ANPAudioTrack* s)
if (s == NULL || s->output_unit == NULL) { if (s == NULL || s->output_unit == NULL) {
return; return;
} }
if (s->keepGoing) { if (s->keepGoing) {
// we are already playing. Ignore. // we are already playing. Ignore.
return; return;
@ -310,8 +329,15 @@ anp_audio_start(ANPAudioTrack* s)
if (!jenv) if (!jenv)
return; return;
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
jenv->CallVoidMethod(s->output_unit, at.play); jenv->CallVoidMethod(s->output_unit, at.play);
if (autoFrame.CheckForException()) {
jenv->DeleteGlobalRef(s->at_class);
free(s);
return;
}
s->isStopped = false; s->isStopped = false;
s->keepGoing = true; s->keepGoing = true;
@ -332,6 +358,8 @@ anp_audio_pause(ANPAudioTrack* s)
JNIEnv *jenv = GetJNIForThread(); JNIEnv *jenv = GetJNIForThread();
if (!jenv) if (!jenv)
return; return;
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
jenv->CallVoidMethod(s->output_unit, at.pause); jenv->CallVoidMethod(s->output_unit, at.pause);
} }
@ -346,6 +374,8 @@ anp_audio_stop(ANPAudioTrack* s)
JNIEnv *jenv = GetJNIForThread(); JNIEnv *jenv = GetJNIForThread();
if (!jenv) if (!jenv)
return; return;
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
jenv->CallVoidMethod(s->output_unit, at.stop); jenv->CallVoidMethod(s->output_unit, at.stop);
} }

View File

@ -62,6 +62,7 @@
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/dom/Element.h"
using namespace mozilla; using namespace mozilla;

View File

@ -51,7 +51,15 @@ interface nsIContentFilter;
#define NS_EDITOR_ELEMENT_NOT_FOUND \ #define NS_EDITOR_ELEMENT_NOT_FOUND \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_EDITOR, 1) NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_EDITOR, 1)
namespace mozilla {
namespace dom {
class Element;
}
}
%} %}
[ptr] native Element (mozilla::dom::Element);
[scriptable, uuid(833f30de-94c7-4630-a852-2300ef329d7b)] [scriptable, uuid(833f30de-94c7-4630-a852-2300ef329d7b)]
interface nsIHTMLEditor : nsISupports interface nsIHTMLEditor : nsISupports
@ -590,6 +598,6 @@ interface nsIHTMLEditor : nsISupports
* Get an active editor's editing host in DOM window. If this editor isn't * Get an active editor's editing host in DOM window. If this editor isn't
* active in the DOM window, this returns NULL. * active in the DOM window, this returns NULL.
*/ */
[noscript, notxpcom] nsIContent GetActiveEditingHost(); [noscript, notxpcom] Element GetActiveEditingHost();
}; };

View File

@ -3148,8 +3148,7 @@ nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing, bool bNoBlockCrossing)
nsIContent *aActiveEditorRoot)
{ {
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
*aResultNode = nsnull; *aResultNode = nsnull;
@ -3158,8 +3157,8 @@ nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetPriorNode(parentNode, aOffset, *aResultNode = do_QueryInterface(GetPriorNode(parentNode, aOffset,
aEditableNode, bNoBlockCrossing, aEditableNode,
aActiveEditorRoot)); bNoBlockCrossing));
return NS_OK; return NS_OK;
} }
@ -3167,8 +3166,7 @@ nsIContent*
nsEditor::GetPriorNode(nsINode* aParentNode, nsEditor::GetPriorNode(nsINode* aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
bool aNoBlockCrossing, bool aNoBlockCrossing)
nsIContent* aActiveEditorRoot)
{ {
MOZ_ASSERT(aParentNode); MOZ_ASSERT(aParentNode);
@ -3179,14 +3177,12 @@ nsEditor::GetPriorNode(nsINode* aParentNode,
// If we aren't allowed to cross blocks, don't look before this block. // If we aren't allowed to cross blocks, don't look before this block.
return nsnull; return nsnull;
} }
return GetPriorNode(aParentNode, aEditableNode, return GetPriorNode(aParentNode, aEditableNode, aNoBlockCrossing);
aNoBlockCrossing, aActiveEditorRoot);
} }
// else look before the child at 'aOffset' // else look before the child at 'aOffset'
if (nsIContent* child = aParentNode->GetChildAt(aOffset)) { if (nsIContent* child = aParentNode->GetChildAt(aOffset)) {
return GetPriorNode(child, aEditableNode, aNoBlockCrossing, return GetPriorNode(child, aEditableNode, aNoBlockCrossing);
aActiveEditorRoot);
} }
// unless there isn't one, in which case we are at the end of the node // unless there isn't one, in which case we are at the end of the node
@ -3197,7 +3193,7 @@ nsEditor::GetPriorNode(nsINode* aParentNode,
} }
// restart the search from the non-editable node we just found // restart the search from the non-editable node we just found
return GetPriorNode(resultNode, aEditableNode, aNoBlockCrossing, aActiveEditorRoot); return GetPriorNode(resultNode, aEditableNode, aNoBlockCrossing);
} }
@ -3206,8 +3202,7 @@ nsEditor::GetNextNode(nsIDOMNode *aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing, bool bNoBlockCrossing)
nsIContent *aActiveEditorRoot)
{ {
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
*aResultNode = nsnull; *aResultNode = nsnull;
@ -3216,8 +3211,8 @@ nsEditor::GetNextNode(nsIDOMNode *aParentNode,
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetNextNode(parentNode, aOffset, *aResultNode = do_QueryInterface(GetNextNode(parentNode, aOffset,
aEditableNode, bNoBlockCrossing, aEditableNode,
aActiveEditorRoot)); bNoBlockCrossing));
return NS_OK; return NS_OK;
} }
@ -3225,8 +3220,7 @@ nsIContent*
nsEditor::GetNextNode(nsINode* aParentNode, nsEditor::GetNextNode(nsINode* aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
bool aNoBlockCrossing, bool aNoBlockCrossing)
nsIContent* aActiveEditorRoot)
{ {
MOZ_ASSERT(aParentNode); MOZ_ASSERT(aParentNode);
@ -3250,7 +3244,7 @@ nsEditor::GetNextNode(nsINode* aParentNode,
return child; return child;
} }
if (!IsDescendantOfBody(resultNode)) { if (!IsDescendantOfEditorRoot(resultNode)) {
return nsnull; return nsnull;
} }
@ -3259,8 +3253,7 @@ nsEditor::GetNextNode(nsINode* aParentNode,
} }
// restart the search from the non-editable node we just found // restart the search from the non-editable node we just found
return GetNextNode(resultNode, aEditableNode, aNoBlockCrossing, return GetNextNode(resultNode, aEditableNode, aNoBlockCrossing);
aActiveEditorRoot);
} }
// unless there isn't one, in which case we are at the end of the node // unless there isn't one, in which case we are at the end of the node
@ -3270,8 +3263,7 @@ nsEditor::GetNextNode(nsINode* aParentNode,
return NS_OK; return NS_OK;
} }
return GetNextNode(aParentNode, aEditableNode, aNoBlockCrossing, return GetNextNode(aParentNode, aEditableNode, aNoBlockCrossing);
aActiveEditorRoot);
} }
@ -3279,8 +3271,7 @@ nsresult
nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode, nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing, bool bNoBlockCrossing)
nsIContent *aActiveEditorRoot)
{ {
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
@ -3288,40 +3279,31 @@ nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
NS_ENSURE_TRUE(currentNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(currentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetPriorNode(currentNode, aEditableNode, *aResultNode = do_QueryInterface(GetPriorNode(currentNode, aEditableNode,
bNoBlockCrossing, bNoBlockCrossing));
aActiveEditorRoot));
return NS_OK; return NS_OK;
} }
nsIContent* nsIContent*
nsEditor::GetPriorNode(nsINode* aCurrentNode, bool aEditableNode, nsEditor::GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
bool aNoBlockCrossing /* = false */, bool aNoBlockCrossing /* = false */)
nsIContent* aActiveEditorRoot /* = null */)
{ {
MOZ_ASSERT(aCurrentNode); MOZ_ASSERT(aCurrentNode);
if (!IsDescendantOfBody(aCurrentNode) || if (!IsDescendantOfEditorRoot(aCurrentNode)) {
(aActiveEditorRoot &&
!nsContentUtils::ContentIsDescendantOf(aCurrentNode,
aActiveEditorRoot))) {
return nsnull; return nsnull;
} }
return FindNode(aCurrentNode, false, aEditableNode, aNoBlockCrossing, return FindNode(aCurrentNode, false, aEditableNode, aNoBlockCrossing);
aActiveEditorRoot);
} }
nsIContent* nsIContent*
nsEditor::FindNextLeafNode(nsINode *aCurrentNode, nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
bool aGoForward, bool aGoForward,
bool bNoBlockCrossing, bool bNoBlockCrossing)
nsIContent *aActiveEditorRoot)
{ {
// called only by GetPriorNode so we don't need to check params. // called only by GetPriorNode so we don't need to check params.
NS_PRECONDITION(IsDescendantOfBody(aCurrentNode) && !IsRootNode(aCurrentNode) && NS_PRECONDITION(IsDescendantOfEditorRoot(aCurrentNode) &&
(!aActiveEditorRoot || !IsEditorRoot(aCurrentNode),
nsContentUtils::ContentIsDescendantOf(aCurrentNode,
aActiveEditorRoot)),
"Bogus arguments"); "Bogus arguments");
nsINode* cur = aCurrentNode; nsINode* cur = aCurrentNode;
@ -3350,13 +3332,12 @@ nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
return nsnull; return nsnull;
} }
NS_ASSERTION(IsDescendantOfBody(parent), NS_ASSERTION(IsDescendantOfEditorRoot(parent),
"We started with a proper descendant of root, and should stop " "We started with a proper descendant of root, and should stop "
"if we ever hit the root, so we better have a descendant of " "if we ever hit the root, so we better have a descendant of "
"root now!"); "root now!");
if (IsRootNode(parent) || if (IsEditorRoot(parent) ||
(bNoBlockCrossing && IsBlockNode(parent)) || (bNoBlockCrossing && IsBlockNode(parent))) {
parent == aActiveEditorRoot) {
return nsnull; return nsnull;
} }
@ -3371,8 +3352,7 @@ nsresult
nsEditor::GetNextNode(nsIDOMNode* aCurrentNode, nsEditor::GetNextNode(nsIDOMNode* aCurrentNode,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing, bool bNoBlockCrossing)
nsIContent* aActiveEditorRoot)
{ {
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode); nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
if (!currentNode || !aResultNode) { if (!currentNode || !aResultNode) {
@ -3380,39 +3360,31 @@ nsEditor::GetNextNode(nsIDOMNode* aCurrentNode,
} }
*aResultNode = do_QueryInterface(GetNextNode(currentNode, aEditableNode, *aResultNode = do_QueryInterface(GetNextNode(currentNode, aEditableNode,
bNoBlockCrossing, bNoBlockCrossing));
aActiveEditorRoot));
return NS_OK; return NS_OK;
} }
nsIContent* nsIContent*
nsEditor::GetNextNode(nsINode* aCurrentNode, nsEditor::GetNextNode(nsINode* aCurrentNode,
bool aEditableNode, bool aEditableNode,
bool bNoBlockCrossing, bool bNoBlockCrossing)
nsIContent* aActiveEditorRoot)
{ {
MOZ_ASSERT(aCurrentNode); MOZ_ASSERT(aCurrentNode);
if (!IsDescendantOfBody(aCurrentNode) || if (!IsDescendantOfEditorRoot(aCurrentNode)) {
(aActiveEditorRoot &&
!nsContentUtils::ContentIsDescendantOf(aCurrentNode,
aActiveEditorRoot))) {
return nsnull; return nsnull;
} }
return FindNode(aCurrentNode, true, aEditableNode, bNoBlockCrossing, return FindNode(aCurrentNode, true, aEditableNode, bNoBlockCrossing);
aActiveEditorRoot);
} }
nsIContent* nsIContent*
nsEditor::FindNode(nsINode *aCurrentNode, nsEditor::FindNode(nsINode *aCurrentNode,
bool aGoForward, bool aGoForward,
bool aEditableNode, bool aEditableNode,
bool bNoBlockCrossing, bool bNoBlockCrossing)
nsIContent *aActiveEditorRoot)
{ {
if (IsRootNode(aCurrentNode) || aCurrentNode == aActiveEditorRoot) if (IsEditorRoot(aCurrentNode)) {
{
// Don't allow traversal above the root node! This helps // Don't allow traversal above the root node! This helps
// prevent us from accidentally editing browser content // prevent us from accidentally editing browser content
// when the editor is in a text widget. // when the editor is in a text widget.
@ -3421,8 +3393,7 @@ nsEditor::FindNode(nsINode *aCurrentNode,
} }
nsIContent* candidate = nsIContent* candidate =
FindNextLeafNode(aCurrentNode, aGoForward, bNoBlockCrossing, FindNextLeafNode(aCurrentNode, aGoForward, bNoBlockCrossing);
aActiveEditorRoot);
if (!candidate) { if (!candidate) {
return nsnull; return nsnull;
@ -3432,8 +3403,7 @@ nsEditor::FindNode(nsINode *aCurrentNode,
return candidate; return candidate;
} }
return FindNode(candidate, aGoForward, aEditableNode, bNoBlockCrossing, return FindNode(candidate, aGoForward, aEditableNode, bNoBlockCrossing);
aActiveEditorRoot);
} }
already_AddRefed<nsIDOMNode> already_AddRefed<nsIDOMNode>
@ -3589,7 +3559,7 @@ nsEditor::TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag)
} }
bool bool
nsEditor::IsRootNode(nsIDOMNode *inNode) nsEditor::IsRoot(nsIDOMNode* inNode)
{ {
NS_ENSURE_TRUE(inNode, false); NS_ENSURE_TRUE(inNode, false);
@ -3599,7 +3569,7 @@ nsEditor::IsRootNode(nsIDOMNode *inNode)
} }
bool bool
nsEditor::IsRootNode(nsINode *inNode) nsEditor::IsRoot(nsINode* inNode)
{ {
NS_ENSURE_TRUE(inNode, false); NS_ENSURE_TRUE(inNode, false);
@ -3608,15 +3578,23 @@ nsEditor::IsRootNode(nsINode *inNode)
return inNode == rootNode; return inNode == rootNode;
} }
bool
nsEditor::IsEditorRoot(nsINode* aNode)
{
NS_ENSURE_TRUE(aNode, false);
nsCOMPtr<nsINode> rootNode = GetEditorRoot();
return aNode == rootNode;
}
bool bool
nsEditor::IsDescendantOfBody(nsIDOMNode *inNode) nsEditor::IsDescendantOfRoot(nsIDOMNode* inNode)
{ {
nsCOMPtr<nsINode> node = do_QueryInterface(inNode); nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
return IsDescendantOfBody(node); return IsDescendantOfRoot(node);
} }
bool bool
nsEditor::IsDescendantOfBody(nsINode *inNode) nsEditor::IsDescendantOfRoot(nsINode* inNode)
{ {
NS_ENSURE_TRUE(inNode, false); NS_ENSURE_TRUE(inNode, false);
nsCOMPtr<nsIContent> root = GetRoot(); nsCOMPtr<nsIContent> root = GetRoot();
@ -3625,6 +3603,23 @@ nsEditor::IsDescendantOfBody(nsINode *inNode)
return nsContentUtils::ContentIsDescendantOf(inNode, root); return nsContentUtils::ContentIsDescendantOf(inNode, root);
} }
bool
nsEditor::IsDescendantOfEditorRoot(nsIDOMNode* aNode)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
return IsDescendantOfEditorRoot(node);
}
bool
nsEditor::IsDescendantOfEditorRoot(nsINode* aNode)
{
NS_ENSURE_TRUE(aNode, false);
nsCOMPtr<nsIContent> root = GetEditorRoot();
NS_ENSURE_TRUE(root, false);
return nsContentUtils::ContentIsDescendantOf(aNode, root);
}
bool bool
nsEditor::IsContainer(nsIDOMNode *aNode) nsEditor::IsContainer(nsIDOMNode *aNode)
{ {
@ -5233,6 +5228,12 @@ nsEditor::GetRoot()
return mRootElement; return mRootElement;
} }
dom::Element*
nsEditor::GetEditorRoot()
{
return GetRoot();
}
nsresult nsresult
nsEditor::DetermineCurrentDirection() nsEditor::DetermineCurrentDirection()
{ {

View File

@ -373,8 +373,7 @@ protected:
// helper for GetPriorNode and GetNextNode // helper for GetPriorNode and GetNextNode
nsIContent* FindNextLeafNode(nsINode *aCurrentNode, nsIContent* FindNextLeafNode(nsINode *aCurrentNode,
bool aGoForward, bool aGoForward,
bool bNoBlockCrossing, bool bNoBlockCrossing);
nsIContent *aActiveEditorRoot);
// Get nsIWidget interface // Get nsIWidget interface
nsresult GetWidget(nsIWidget **aWidget); nsresult GetWidget(nsIWidget **aWidget);
@ -477,29 +476,24 @@ public:
* skipping non-editable nodes if aEditableNode is true. * skipping non-editable nodes if aEditableNode is true.
* If there is no prior node, aResultNode will be nsnull. * If there is no prior node, aResultNode will be nsnull.
* @param bNoBlockCrossing If true, don't move across "block" nodes, whatever that means. * @param bNoBlockCrossing If true, don't move across "block" nodes, whatever that means.
* @param aActiveEditorRoot If non-null, only return descendants of aActiveEditorRoot.
*/ */
nsresult GetPriorNode(nsIDOMNode *aCurrentNode, nsresult GetPriorNode(nsIDOMNode *aCurrentNode,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false, bool bNoBlockCrossing = false);
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetPriorNode(nsINode* aCurrentNode, bool aEditableNode, nsIContent* GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
bool aNoBlockCrossing = false, bool aNoBlockCrossing = false);
nsIContent* aActiveEditorRoot = nsnull);
// and another version that takes a {parent,offset} pair rather than a node // and another version that takes a {parent,offset} pair rather than a node
nsresult GetPriorNode(nsIDOMNode *aParentNode, nsresult GetPriorNode(nsIDOMNode *aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false, bool bNoBlockCrossing = false);
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetPriorNode(nsINode* aParentNode, nsIContent* GetPriorNode(nsINode* aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
bool aNoBlockCrossing = false, bool aNoBlockCrossing = false);
nsIContent* aActiveEditorRoot = nsnull);
/** get the node immediately after to aCurrentNode /** get the node immediately after to aCurrentNode
@ -512,32 +506,27 @@ public:
nsresult GetNextNode(nsIDOMNode *aCurrentNode, nsresult GetNextNode(nsIDOMNode *aCurrentNode,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false, bool bNoBlockCrossing = false);
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetNextNode(nsINode* aCurrentNode, nsIContent* GetNextNode(nsINode* aCurrentNode,
bool aEditableNode, bool aEditableNode,
bool bNoBlockCrossing = false, bool bNoBlockCrossing = false);
nsIContent* aActiveEditorRoot = nsnull);
// and another version that takes a {parent,offset} pair rather than a node // and another version that takes a {parent,offset} pair rather than a node
nsresult GetNextNode(nsIDOMNode *aParentNode, nsresult GetNextNode(nsIDOMNode *aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode, nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false, bool bNoBlockCrossing = false);
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetNextNode(nsINode* aParentNode, nsIContent* GetNextNode(nsINode* aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
bool aEditableNode, bool aEditableNode,
bool aNoBlockCrossing = false, bool aNoBlockCrossing = false);
nsIContent* aActiveEditorRoot = nsnull);
// Helper for GetNextNode and GetPriorNode // Helper for GetNextNode and GetPriorNode
nsIContent* FindNode(nsINode *aCurrentNode, nsIContent* FindNode(nsINode *aCurrentNode,
bool aGoForward, bool aGoForward,
bool aEditableNode, bool aEditableNode,
bool bNoBlockCrossing, bool bNoBlockCrossing);
nsIContent *aActiveEditorRoot);
/** /**
* Get the rightmost child of aCurrentNode; * Get the rightmost child of aCurrentNode;
* return nsnull if aCurrentNode has no children. * return nsnull if aCurrentNode has no children.
@ -577,12 +566,15 @@ public:
virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag); virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag);
/** returns true if aNode is our root node */ /** returns true if aNode is our root node */
bool IsRootNode(nsIDOMNode *inNode); bool IsRoot(nsIDOMNode* inNode);
bool IsRootNode(nsINode *inNode); bool IsRoot(nsINode* inNode);
bool IsEditorRoot(nsINode* aNode);
/** returns true if aNode is a descendant of our root node */ /** returns true if aNode is a descendant of our root node */
bool IsDescendantOfBody(nsIDOMNode *inNode); bool IsDescendantOfRoot(nsIDOMNode* inNode);
bool IsDescendantOfBody(nsINode *inNode); bool IsDescendantOfRoot(nsINode* inNode);
bool IsDescendantOfEditorRoot(nsIDOMNode* aNode);
bool IsDescendantOfEditorRoot(nsINode* aNode);
/** returns true if aNode is a container */ /** returns true if aNode is a container */
virtual bool IsContainer(nsIDOMNode *aNode); virtual bool IsContainer(nsIDOMNode *aNode);
@ -672,6 +664,10 @@ public:
// Fast non-refcounting editor root element accessor // Fast non-refcounting editor root element accessor
mozilla::dom::Element *GetRoot(); mozilla::dom::Element *GetRoot();
// Likewise, but gets the editor's root instead, which is different for HTML
// editors
virtual mozilla::dom::Element* GetEditorRoot();
// Accessor methods to flags // Accessor methods to flags
bool IsPlaintextEditor() const bool IsPlaintextEditor() const
{ {

View File

@ -4085,7 +4085,7 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, bool *aCancel, bool *aHan
curBlockQuoteIsIndentedWithCSS = false; curBlockQuoteIsIndentedWithCSS = false;
// keep looking up the hierarchy as long as we don't hit the body or the // keep looking up the hierarchy as long as we don't hit the body or the
// active editing host or a table element (other than an entire table) // active editing host or a table element (other than an entire table)
while (!nsTextEditUtils::IsBody(n) && mHTMLEditor->IsNodeInActiveEditor(n) while (!nsTextEditUtils::IsBody(n) && mHTMLEditor->IsDescendantOfEditorRoot(n)
&& (nsHTMLEditUtils::IsTable(n) || !nsHTMLEditUtils::IsTableElement(n))) && (nsHTMLEditUtils::IsTable(n) || !nsHTMLEditUtils::IsTableElement(n)))
{ {
n->GetParentNode(getter_AddRefs(tmp)); n->GetParentNode(getter_AddRefs(tmp));
@ -5597,8 +5597,8 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode,
|| (actionID == nsHTMLEditor::kOpOutdent) || (actionID == nsHTMLEditor::kOpOutdent)
|| (actionID == nsHTMLEditor::kOpAlign) || (actionID == nsHTMLEditor::kOpAlign)
|| (actionID == nsHTMLEditor::kOpMakeBasicBlock); || (actionID == nsHTMLEditor::kOpMakeBasicBlock);
if (!mHTMLEditor->IsNodeInActiveEditor(parent) && if (!mHTMLEditor->IsDescendantOfEditorRoot(parent) &&
(blockLevelAction || !mHTMLEditor->IsNodeInActiveEditor(node))) { (blockLevelAction || !mHTMLEditor->IsDescendantOfEditorRoot(node))) {
break; break;
} }
@ -5653,8 +5653,8 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode,
// before walking up to a parent because we need to return the parent // before walking up to a parent because we need to return the parent
// object, so the parent itself might not be in the editable area, but // object, so the parent itself might not be in the editable area, but
// it's OK. // it's OK.
if (!mHTMLEditor->IsNodeInActiveEditor(node) && if (!mHTMLEditor->IsDescendantOfEditorRoot(node) &&
!mHTMLEditor->IsNodeInActiveEditor(parent)) { !mHTMLEditor->IsDescendantOfEditorRoot(parent)) {
break; break;
} }
@ -5787,8 +5787,8 @@ nsHTMLEditRules::PromoteRange(nsIDOMRange *inRange,
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
// Make sure that the new range ends up to be in the editable section. // Make sure that the new range ends up to be in the editable section.
if (!mHTMLEditor->IsNodeInActiveEditor(nsEditor::GetNodeAtRangeOffsetPoint(opStartNode, opStartOffset)) || if (!mHTMLEditor->IsDescendantOfEditorRoot(nsEditor::GetNodeAtRangeOffsetPoint(opStartNode, opStartOffset)) ||
!mHTMLEditor->IsNodeInActiveEditor(nsEditor::GetNodeAtRangeOffsetPoint(opEndNode, opEndOffset - 1))) { !mHTMLEditor->IsDescendantOfEditorRoot(nsEditor::GetNodeAtRangeOffsetPoint(opEndNode, opEndOffset - 1))) {
return NS_OK; return NS_OK;
} }
@ -6492,7 +6492,7 @@ nsHTMLEditRules::IsInListItem(nsINode* aNode)
} }
nsINode* parent = aNode->GetNodeParent(); nsINode* parent = aNode->GetNodeParent();
while (parent && mHTMLEditor->IsNodeInActiveEditor(parent) && while (parent && mHTMLEditor->IsDescendantOfEditorRoot(parent) &&
!(parent->IsElement() && !(parent->IsElement() &&
nsHTMLEditUtils::IsTableElement(parent->AsElement()))) { nsHTMLEditUtils::IsTableElement(parent->AsElement()))) {
if (nsHTMLEditUtils::IsListItem(parent->AsElement())) { if (nsHTMLEditUtils::IsListItem(parent->AsElement())) {
@ -7294,7 +7294,7 @@ nsHTMLEditRules::SplitAsNeeded(const nsAString *aTag,
// a legal place for the block // a legal place for the block
if (!parent) break; if (!parent) break;
// Don't leave the active editing host // Don't leave the active editing host
if (!mHTMLEditor->IsNodeInActiveEditor(parent)) { if (!mHTMLEditor->IsDescendantOfEditorRoot(parent)) {
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parent); nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parent);
if (parentContent != mHTMLEditor->GetActiveEditingHost()) { if (parentContent != mHTMLEditor->GetActiveEditingHost()) {
break; break;
@ -8356,8 +8356,7 @@ nsHTMLEditRules::UpdateDocChangeRange(nsIDOMRange *aRange)
nsCOMPtr<nsIDOMNode> startNode; nsCOMPtr<nsIDOMNode> startNode;
res = aRange->GetStartContainer(getter_AddRefs(startNode)); res = aRange->GetStartContainer(getter_AddRefs(startNode));
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
if (!mHTMLEditor->IsDescendantOfBody(startNode)) if (!mHTMLEditor->IsDescendantOfRoot(startNode)) {
{
// just return - we don't need to adjust mDocChangeRange in this case // just return - we don't need to adjust mDocChangeRange in this case
return NS_OK; return NS_OK;
} }
@ -8893,7 +8892,7 @@ nsHTMLEditRules::RelativeChangeIndentationOfElementNode(nsIDOMNode *aNode, PRInt
nsCOMPtr<dom::Element> node = do_QueryInterface(aNode); nsCOMPtr<dom::Element> node = do_QueryInterface(aNode);
if (!node || !node->IsHTML(nsGkAtoms::div) || if (!node || !node->IsHTML(nsGkAtoms::div) ||
node == mHTMLEditor->GetActiveEditingHost() || node == mHTMLEditor->GetActiveEditingHost() ||
!mHTMLEditor->IsNodeInActiveEditor(node) || !mHTMLEditor->IsDescendantOfEditorRoot(node) ||
nsHTMLEditor::HasAttributes(node)) { nsHTMLEditor::HasAttributes(node)) {
return NS_OK; return NS_OK;
} }

View File

@ -1882,7 +1882,7 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement)
nsresult res = NS_ERROR_NULL_POINTER; nsresult res = NS_ERROR_NULL_POINTER;
// Must be sure that element is contained in the document body // Must be sure that element is contained in the document body
if (IsNodeInActiveEditor(aElement)) { if (IsDescendantOfEditorRoot(aElement)) {
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
res = GetSelection(getter_AddRefs(selection)); res = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
@ -1914,7 +1914,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
nsresult res = NS_ERROR_NULL_POINTER; nsresult res = NS_ERROR_NULL_POINTER;
// Be sure the element is contained in the document body // Be sure the element is contained in the document body
if (aElement && IsNodeInActiveEditor(aElement)) { if (aElement && IsDescendantOfEditorRoot(aElement)) {
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
res = GetSelection(getter_AddRefs(selection)); res = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
@ -3975,30 +3975,13 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
// //
bool
nsHTMLEditor::IsNodeInActiveEditor(nsIDOMNode* aNode)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
return node && IsNodeInActiveEditor(node);
}
bool
nsHTMLEditor::IsNodeInActiveEditor(nsINode* aNode)
{
nsIContent* activeEditingHost = GetActiveEditingHost();
if (!activeEditingHost) {
return false;
}
return nsContentUtils::ContentIsDescendantOf(aNode, activeEditingHost);
}
bool bool
nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement) nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement)
{ {
nsCOMPtr<dom::Element> element = do_QueryInterface(aElement); nsCOMPtr<dom::Element> element = do_QueryInterface(aElement);
if (!element || !element->IsHTML() || if (!element || !element->IsHTML() ||
!nsHTMLEditUtils::IsTableElement(element) || !nsHTMLEditUtils::IsTableElement(element) ||
!IsNodeInActiveEditor(element)) { !IsDescendantOfEditorRoot(element)) {
return false; return false;
} }
@ -4353,10 +4336,11 @@ nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode
return NS_OK; return NS_OK;
} }
nsresult res = GetPriorNode(inNode, true, address_of(*outNode), bNoBlockCrossing, activeEditingHost); nsresult res = GetPriorNode(inNode, true, address_of(*outNode),
bNoBlockCrossing);
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
NS_ASSERTION(!*outNode || IsNodeInActiveEditor(*outNode), NS_ASSERTION(!*outNode || IsDescendantOfEditorRoot(*outNode),
"GetPriorNode screwed up"); "GetPriorNode screwed up");
return res; return res;
} }
@ -4376,10 +4360,11 @@ nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<
return NS_OK; return NS_OK;
} }
nsresult res = GetPriorNode(inParent, inOffset, true, address_of(*outNode), bNoBlockCrossing, activeEditingHost); nsresult res = GetPriorNode(inParent, inOffset, true, address_of(*outNode),
bNoBlockCrossing);
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
NS_ASSERTION(!*outNode || IsNodeInActiveEditor(*outNode), NS_ASSERTION(!*outNode || IsDescendantOfEditorRoot(*outNode),
"GetPriorNode screwed up"); "GetPriorNode screwed up");
return res; return res;
} }
@ -4397,7 +4382,7 @@ nsHTMLEditor::GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode,
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
// if it's not in the body, then zero it out // if it's not in the body, then zero it out
if (*outNode && !IsNodeInActiveEditor(*outNode)) { if (*outNode && !IsDescendantOfEditorRoot(*outNode)) {
*outNode = nsnull; *outNode = nsnull;
} }
return res; return res;
@ -4415,7 +4400,7 @@ nsHTMLEditor::GetNextHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<n
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
// if it's not in the body, then zero it out // if it's not in the body, then zero it out
if (*outNode && !IsNodeInActiveEditor(*outNode)) { if (*outNode && !IsDescendantOfEditorRoot(*outNode)) {
*outNode = nsnull; *outNode = nsnull;
} }
return res; return res;
@ -5474,7 +5459,7 @@ nsHTMLEditor::IsActiveInDOMWindow()
return true; return true;
} }
nsIContent* dom::Element*
nsHTMLEditor::GetActiveEditingHost() nsHTMLEditor::GetActiveEditingHost()
{ {
NS_ENSURE_TRUE(mDocWeak, nsnull); NS_ENSURE_TRUE(mDocWeak, nsnull);
@ -5715,3 +5700,10 @@ nsHTMLEditor::GetInputEventTargetContent()
nsCOMPtr<nsIContent> target = GetActiveEditingHost(); nsCOMPtr<nsIContent> target = GetActiveEditingHost();
return target.forget(); return target.forget();
} }
// virtual MOZ_OVERRIDE
dom::Element*
nsHTMLEditor::GetEditorRoot()
{
return GetActiveEditingHost();
}

View File

@ -136,6 +136,7 @@ public:
virtual already_AddRefed<nsIContent> GetFocusedContent(); virtual already_AddRefed<nsIContent> GetFocusedContent();
virtual bool IsActiveInDOMWindow(); virtual bool IsActiveInDOMWindow();
virtual already_AddRefed<nsIDOMEventTarget> GetDOMEventTarget(); virtual already_AddRefed<nsIDOMEventTarget> GetDOMEventTarget();
virtual mozilla::dom::Element* GetEditorRoot() MOZ_OVERRIDE;
virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode *aNode); virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode *aNode);
virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent); virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent);
virtual already_AddRefed<nsIContent> GetInputEventTargetContent(); virtual already_AddRefed<nsIContent> GetInputEventTargetContent();
@ -441,8 +442,6 @@ protected:
// Return TRUE if aElement is a table-related elemet and caret was set // Return TRUE if aElement is a table-related elemet and caret was set
bool SetCaretInTableCell(nsIDOMElement* aElement); bool SetCaretInTableCell(nsIDOMElement* aElement);
bool IsNodeInActiveEditor(nsIDOMNode* aNode);
bool IsNodeInActiveEditor(nsINode* aNode);
// key event helpers // key event helpers
NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled); NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled);

View File

@ -142,7 +142,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target); nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
// Contenteditable should disregard mousedowns outside it // Contenteditable should disregard mousedowns outside it
if (element && !htmlEditor->IsNodeInActiveEditor(element)) { if (element && !htmlEditor->IsDescendantOfEditorRoot(element)) {
return NS_OK; return NS_OK;
} }

View File

@ -457,7 +457,7 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
nsIContent* nextNode = GetNextHTMLSibling(aNode); nsIContent* nextNode = GetNextHTMLSibling(aNode);
if (nextNode && nextNode->Tag() == aProperty && if (nextNode && nextNode->Tag() == aProperty &&
HasAttrVal(nextNode, aAttribute, *aValue) && HasAttrVal(nextNode, aAttribute, *aValue) &&
IsOnlyAttribute(priorNode, *aAttribute)) { IsOnlyAttribute(nextNode, *aAttribute)) {
// following sib is already right kind of inline node; slide this over into it // following sib is already right kind of inline node; slide this over into it
return MoveNode(aNode->AsDOMNode(), nextNode->AsDOMNode(), 0); return MoveNode(aNode->AsDOMNode(), nextNode->AsDOMNode(), 0);
} }

View File

@ -34,7 +34,9 @@ include $(DEPTH)/config/autoconf.mk
MODULE = harfbuzz MODULE = harfbuzz
LIBRARY_NAME = mozharfbuzz LIBRARY_NAME = mozharfbuzz
ifneq ($(OS_ARCH),WINNT)
LIBXUL_LIBRARY = 1 LIBXUL_LIBRARY = 1
endif
CPPSRCS = \ CPPSRCS = \
hb-blob.cc \ hb-blob.cc \

View File

@ -128,6 +128,7 @@ static const mozilla::Module::CategoryEntry kImageCategories[] = {
static nsresult static nsresult
imglib_Initialize() imglib_Initialize()
{ {
mozilla::image::DiscardTracker::Initialize();
imgLoader::InitCache(); imgLoader::InitCache();
return NS_OK; return NS_OK;
} }

View File

@ -365,9 +365,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
if (mIsPNG) { if (mIsPNG) {
mContainedDecoder = new nsPNGDecoder(mImage, mObserver); mContainedDecoder = new nsPNGDecoder(mImage, mObserver);
mContainedDecoder->InitSharedDecoder(); mContainedDecoder->InitSharedDecoder();
mContainedDecoder->Write(mSignature, PNGSIGNATURESIZE); if (!WriteToContainedDecoder(mSignature, PNGSIGNATURESIZE)) {
mDataError = mContainedDecoder->HasDataError();
if (mContainedDecoder->HasDataError()) {
return; return;
} }
} }
@ -375,9 +373,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
// If we have a PNG, let the PNG decoder do all of the rest of the work // If we have a PNG, let the PNG decoder do all of the rest of the work
if (mIsPNG && mContainedDecoder && mPos >= mImageOffset + PNGSIGNATURESIZE) { if (mIsPNG && mContainedDecoder && mPos >= mImageOffset + PNGSIGNATURESIZE) {
mContainedDecoder->Write(aBuffer, aCount); if (!WriteToContainedDecoder(aBuffer, aCount)) {
mDataError = mContainedDecoder->HasDataError();
if (mContainedDecoder->HasDataError()) {
return; return;
} }
mPos += aCount; mPos += aCount;
@ -445,9 +441,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
PostDataError(); PostDataError();
return; return;
} }
mContainedDecoder->Write((const char*)bfhBuffer, sizeof(bfhBuffer)); if (!WriteToContainedDecoder((const char*)bfhBuffer, sizeof(bfhBuffer))) {
mDataError = mContainedDecoder->HasDataError();
if (mContainedDecoder->HasDataError()) {
return; return;
} }
@ -468,9 +462,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
} }
// Write out the BMP's bitmap info header // Write out the BMP's bitmap info header
mContainedDecoder->Write(mBIHraw, sizeof(mBIHraw)); if (!WriteToContainedDecoder(mBIHraw, sizeof(mBIHraw))) {
mDataError = mContainedDecoder->HasDataError();
if (mContainedDecoder->HasDataError()) {
return; return;
} }
@ -515,9 +507,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
toFeed = aCount; toFeed = aCount;
} }
mContainedDecoder->Write(aBuffer, toFeed); if (!WriteToContainedDecoder(aBuffer, toFeed)) {
mDataError = mContainedDecoder->HasDataError();
if (mContainedDecoder->HasDataError()) {
return; return;
} }
@ -592,6 +582,19 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
} }
} }
bool
nsICODecoder::WriteToContainedDecoder(const char* aBuffer, PRUint32 aCount)
{
mContainedDecoder->Write(aBuffer, aCount);
if (mContainedDecoder->HasDataError()) {
mDataError = mContainedDecoder->HasDataError();
}
if (mContainedDecoder->HasDecoderError()) {
PostDecoderError(mContainedDecoder->GetDecoderError());
}
return !HasError();
}
void void
nsICODecoder::ProcessDirEntry(IconDirEntry& aTarget) nsICODecoder::ProcessDirEntry(IconDirEntry& aTarget)
{ {

View File

@ -77,6 +77,10 @@ public:
virtual void FinishInternal(); virtual void FinishInternal();
private: private:
// Writes to the contained decoder and sets the appropriate errors
// Returns true if there are no errors.
bool WriteToContainedDecoder(const char* aBuffer, PRUint32 aCount);
// Processes a single dir entry of the icon resource // Processes a single dir entry of the icon resource
void ProcessDirEntry(IconDirEntry& aTarget); void ProcessDirEntry(IconDirEntry& aTarget);
// Sets the hotspot property of if we have a cursor // Sets the hotspot property of if we have a cursor

View File

@ -18,10 +18,11 @@ static const char* sDiscardTimeoutPref = "image.mem.min_discard_timeout_ms";
/* static */ nsCOMPtr<nsITimer> DiscardTracker::sTimer; /* static */ nsCOMPtr<nsITimer> DiscardTracker::sTimer;
/* static */ bool DiscardTracker::sInitialized = false; /* static */ bool DiscardTracker::sInitialized = false;
/* static */ bool DiscardTracker::sTimerOn = false; /* static */ bool DiscardTracker::sTimerOn = false;
/* static */ bool DiscardTracker::sDiscardRunnablePending = false; /* static */ PRInt32 DiscardTracker::sDiscardRunnablePending = 0;
/* static */ PRInt64 DiscardTracker::sCurrentDecodedImageBytes = 0; /* static */ PRInt64 DiscardTracker::sCurrentDecodedImageBytes = 0;
/* static */ PRUint32 DiscardTracker::sMinDiscardTimeoutMs = 10000; /* static */ PRUint32 DiscardTracker::sMinDiscardTimeoutMs = 10000;
/* static */ PRUint32 DiscardTracker::sMaxDecodedImageKB = 42 * 1024; /* static */ PRUint32 DiscardTracker::sMaxDecodedImageKB = 42 * 1024;
/* static */ PRLock * DiscardTracker::sAllocationLock = NULL;
/* /*
* When we notice we're using too much memory for decoded images, we enqueue a * When we notice we're using too much memory for decoded images, we enqueue a
@ -30,7 +31,8 @@ static const char* sDiscardTimeoutPref = "image.mem.min_discard_timeout_ms";
NS_IMETHODIMP NS_IMETHODIMP
DiscardTracker::DiscardRunnable::Run() DiscardTracker::DiscardRunnable::Run()
{ {
sDiscardRunnablePending = false; PR_ATOMIC_SET(&sDiscardRunnablePending, 0);
DiscardTracker::DiscardNow(); DiscardTracker::DiscardNow();
return NS_OK; return NS_OK;
} }
@ -48,17 +50,12 @@ DiscardTracker::Reset(Node *node)
// We shouldn't call Reset() with a null |img| pointer, on images which can't // We shouldn't call Reset() with a null |img| pointer, on images which can't
// be discarded, or on animated images (which should be marked as // be discarded, or on animated images (which should be marked as
// non-discardable, anyway). // non-discardable, anyway).
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(sInitialized);
MOZ_ASSERT(node->img); MOZ_ASSERT(node->img);
MOZ_ASSERT(node->img->CanDiscard()); MOZ_ASSERT(node->img->CanDiscard());
MOZ_ASSERT(!node->img->mAnim); MOZ_ASSERT(!node->img->mAnim);
// Initialize the first time through.
nsresult rv;
if (NS_UNLIKELY(!sInitialized)) {
rv = Initialize();
NS_ENSURE_SUCCESS(rv, rv);
}
// Insert the node at the front of the list and note when it was inserted. // Insert the node at the front of the list and note when it was inserted.
bool wasInList = node->isInList(); bool wasInList = node->isInList();
if (wasInList) { if (wasInList) {
@ -75,7 +72,7 @@ DiscardTracker::Reset(Node *node)
} }
// Make sure the timer is running. // Make sure the timer is running.
rv = EnableTimer(); nsresult rv = EnableTimer();
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
return NS_OK; return NS_OK;
@ -84,6 +81,8 @@ DiscardTracker::Reset(Node *node)
void void
DiscardTracker::Remove(Node *node) DiscardTracker::Remove(Node *node)
{ {
MOZ_ASSERT(NS_IsMainThread());
if (node->isInList()) if (node->isInList())
node->remove(); node->remove();
@ -97,6 +96,8 @@ DiscardTracker::Remove(Node *node)
void void
DiscardTracker::Shutdown() DiscardTracker::Shutdown()
{ {
MOZ_ASSERT(NS_IsMainThread());
if (sTimer) { if (sTimer) {
sTimer->Cancel(); sTimer->Cancel();
sTimer = NULL; sTimer = NULL;
@ -109,6 +110,8 @@ DiscardTracker::Shutdown()
void void
DiscardTracker::DiscardAll() DiscardTracker::DiscardAll()
{ {
MOZ_ASSERT(NS_IsMainThread());
if (!sInitialized) if (!sInitialized)
return; return;
@ -128,8 +131,12 @@ DiscardTracker::InformAllocation(PRInt64 bytes)
{ {
// This function is called back e.g. from RasterImage::Discard(); be careful! // This function is called back e.g. from RasterImage::Discard(); be careful!
MOZ_ASSERT(sInitialized);
PR_Lock(sAllocationLock);
sCurrentDecodedImageBytes += bytes; sCurrentDecodedImageBytes += bytes;
MOZ_ASSERT(sCurrentDecodedImageBytes >= 0); MOZ_ASSERT(sCurrentDecodedImageBytes >= 0);
PR_Unlock(sAllocationLock);
// If we're using too much memory for decoded images, MaybeDiscardSoon will // If we're using too much memory for decoded images, MaybeDiscardSoon will
// enqueue a callback to discard some images. // enqueue a callback to discard some images.
@ -142,6 +149,8 @@ DiscardTracker::InformAllocation(PRInt64 bytes)
nsresult nsresult
DiscardTracker::Initialize() DiscardTracker::Initialize()
{ {
MOZ_ASSERT(NS_IsMainThread());
// Watch the timeout pref for changes. // Watch the timeout pref for changes.
Preferences::RegisterCallback(DiscardTimeoutChangedCallback, Preferences::RegisterCallback(DiscardTimeoutChangedCallback,
sDiscardTimeoutPref); sDiscardTimeoutPref);
@ -153,6 +162,9 @@ DiscardTracker::Initialize()
// Create the timer. // Create the timer.
sTimer = do_CreateInstance("@mozilla.org/timer;1"); sTimer = do_CreateInstance("@mozilla.org/timer;1");
// Create a lock for safegarding the 64-bit sCurrentDecodedImageBytes
sAllocationLock = PR_NewLock();
// Mark us as initialized // Mark us as initialized
sInitialized = true; sInitialized = true;
@ -275,10 +287,12 @@ DiscardTracker::MaybeDiscardSoon()
// Are we carrying around too much decoded image data? If so, enqueue an // Are we carrying around too much decoded image data? If so, enqueue an
// event to try to get us down under our limit. // event to try to get us down under our limit.
if (sCurrentDecodedImageBytes > sMaxDecodedImageKB * 1024 && if (sCurrentDecodedImageBytes > sMaxDecodedImageKB * 1024 &&
!sDiscardableImages.isEmpty() && !sDiscardRunnablePending) { !sDiscardableImages.isEmpty()) {
sDiscardRunnablePending = true; // Check if the value of sDiscardRunnablePending used to be false
nsRefPtr<DiscardRunnable> runnable = new DiscardRunnable(); if (!PR_ATOMIC_SET(&sDiscardRunnablePending, 1)) {
NS_DispatchToCurrentThread(runnable); nsRefPtr<DiscardRunnable> runnable = new DiscardRunnable();
NS_DispatchToMainThread(runnable);
}
} }
} }

View File

@ -48,32 +48,39 @@ class DiscardTracker
/** /**
* Add an image to the front of the tracker's list, or move it to the front * Add an image to the front of the tracker's list, or move it to the front
* if it's already in the list. * if it's already in the list. This function is main thread only.
*/ */
static nsresult Reset(struct Node* node); static nsresult Reset(struct Node* node);
/** /**
* Remove a node from the tracker; do nothing if the node is currently * Remove a node from the tracker; do nothing if the node is currently
* untracked. * untracked. This function is main thread only.
*/ */
static void Remove(struct Node* node); static void Remove(struct Node* node);
/**
* Initializes the discard tracker. This function is main thread only.
*/
static nsresult Initialize();
/** /**
* Shut the discard tracker down. This should be called on XPCOM shutdown * Shut the discard tracker down. This should be called on XPCOM shutdown
* so we destroy the discard timer's nsITimer. * so we destroy the discard timer's nsITimer. This function is main thread
* only.
*/ */
static void Shutdown(); static void Shutdown();
/** /**
* Discard the decoded image data for all images tracked by the discard * Discard the decoded image data for all images tracked by the discard
* tracker. * tracker. This function is main thread only.
*/ */
static void DiscardAll(); static void DiscardAll();
/** /**
* Inform the discard tracker that we've allocated or deallocated some * Inform the discard tracker that we've allocated or deallocated some
* memory for a decoded image. We use this to determine when we've * memory for a decoded image. We use this to determine when we've
* allocated too much memory and should discard some images. * allocated too much memory and should discard some images. This function
* can be called from any thread and is thread-safe.
*/ */
static void InformAllocation(PRInt64 bytes); static void InformAllocation(PRInt64 bytes);
@ -92,7 +99,6 @@ class DiscardTracker
NS_IMETHOD Run(); NS_IMETHOD Run();
}; };
static nsresult Initialize();
static void ReloadTimeout(); static void ReloadTimeout();
static nsresult EnableTimer(); static nsresult EnableTimer();
static void DisableTimer(); static void DisableTimer();
@ -104,10 +110,12 @@ class DiscardTracker
static nsCOMPtr<nsITimer> sTimer; static nsCOMPtr<nsITimer> sTimer;
static bool sInitialized; static bool sInitialized;
static bool sTimerOn; static bool sTimerOn;
static bool sDiscardRunnablePending; static PRInt32 sDiscardRunnablePending;
static PRInt64 sCurrentDecodedImageBytes; static PRInt64 sCurrentDecodedImageBytes;
static PRUint32 sMinDiscardTimeoutMs; static PRUint32 sMinDiscardTimeoutMs;
static PRUint32 sMaxDecodedImageKB; static PRUint32 sMaxDecodedImageKB;
// Lock for safegarding the 64-bit sCurrentDecodedImageBytes
static PRLock *sAllocationLock;
}; };
} // namespace image } // namespace image

View File

@ -248,10 +248,9 @@ RasterImage::~RasterImage()
num_discardable_containers, num_discardable_containers,
total_source_bytes, total_source_bytes,
discardable_source_bytes)); discardable_source_bytes));
DiscardTracker::Remove(&mDiscardTrackerNode);
} }
DiscardTracker::Remove(&mDiscardTrackerNode);
// If we have a decoder open, shut it down // If we have a decoder open, shut it down
if (mDecoder) { if (mDecoder) {
nsresult rv = ShutdownDecoder(eShutdownIntent_Interrupted); nsresult rv = ShutdownDecoder(eShutdownIntent_Interrupted);

View File

@ -49,7 +49,12 @@ ifeq (WINNT,$(OS_TARGET))
FORCE_SHARED_LIB = 1 FORCE_SHARED_LIB = 1
endif endif
SHARED_LIBRARY_LIBS = $(MOZ_OTS_LIBS) $(QCMS_LIBS) $(MOZ_CAIRO_LIBS) SHARED_LIBRARY_LIBS = \
$(MOZ_OTS_LIBS) \
$(QCMS_LIBS) \
$(MOZ_CAIRO_LIBS) \
$(MOZ_HARFBUZZ_LIBS) \
$(NULL)
ifdef MOZ_GRAPHITE ifdef MOZ_GRAPHITE
SHARED_LIBRARY_LIBS += $(MOZ_GRAPHITE_LIBS) SHARED_LIBRARY_LIBS += $(MOZ_GRAPHITE_LIBS)

View File

@ -443,3 +443,43 @@ cairo_win32_surface_create_with_alpha
cairo_win32_surface_get_height cairo_win32_surface_get_height
cairo_win32_surface_get_width cairo_win32_surface_get_width
cairo_win32_surface_set_can_convert_to_dib cairo_win32_surface_set_can_convert_to_dib
hb_blob_create
hb_blob_destroy
hb_blob_get_data
hb_blob_get_empty
hb_blob_get_length
hb_blob_reference
hb_buffer_add_utf16
hb_buffer_create
hb_buffer_destroy
hb_buffer_get_glyph_infos
hb_buffer_get_glyph_positions
hb_buffer_reverse
hb_buffer_set_direction
hb_buffer_set_language
hb_buffer_set_script
hb_buffer_set_unicode_funcs
hb_face_create_for_tables
hb_face_destroy
hb_font_create
hb_font_destroy
hb_font_funcs_create
hb_font_funcs_set_glyph_contour_point_func
hb_font_funcs_set_glyph_func
hb_font_funcs_set_glyph_h_advance_func
hb_font_funcs_set_glyph_h_kerning_func
hb_font_set_funcs
hb_font_set_ppem
hb_font_set_scale
hb_language_from_string
hb_ot_tag_to_language
hb_shape
hb_unicode_funcs_create
hb_unicode_funcs_get_empty
hb_unicode_funcs_set_combining_class_func
hb_unicode_funcs_set_compose_func
hb_unicode_funcs_set_decompose_func
hb_unicode_funcs_set_eastasian_width_func
hb_unicode_funcs_set_general_category_func
hb_unicode_funcs_set_mirroring_func
hb_unicode_funcs_set_script_func

View File

@ -324,14 +324,6 @@ public class AboutHomeContent extends ScrollView
return NUMBER_OF_TOP_SITES_PORTRAIT; return NUMBER_OF_TOP_SITES_PORTRAIT;
} }
private int getNumberOfColumns() {
Configuration config = getContext().getResources().getConfiguration();
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE)
return NUMBER_OF_COLS_LANDSCAPE;
else
return NUMBER_OF_COLS_PORTRAIT;
}
private void loadTopSites(final Activity activity) { private void loadTopSites(final Activity activity) {
// Ensure we initialize GeckoApp's startup mode in // Ensure we initialize GeckoApp's startup mode in
// background thread before we use it when updating // background thread before we use it when updating
@ -361,8 +353,6 @@ public class AboutHomeContent extends ScrollView
mTopSitesAdapter.changeCursor(mCursor); mTopSitesAdapter.changeCursor(mCursor);
} }
mTopSitesGrid.setNumColumns(getNumberOfColumns());
updateLayout(startupMode, syncIsSetup); updateLayout(startupMode, syncIsSetup);
} }
}); });
@ -396,8 +386,6 @@ public class AboutHomeContent extends ScrollView
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
if (mTopSitesGrid != null)
mTopSitesGrid.setNumColumns(getNumberOfColumns());
if (mTopSitesAdapter != null) if (mTopSitesAdapter != null)
mTopSitesAdapter.notifyDataSetChanged(); mTopSitesAdapter.notifyDataSetChanged();
@ -709,13 +697,16 @@ public class AboutHomeContent extends ScrollView
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_LANDSCAPE); nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_LANDSCAPE);
numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_LANDSCAPE); numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_LANDSCAPE);
setNumColumns(NUMBER_OF_COLS_LANDSCAPE);
} else { } else {
nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_PORTRAIT); nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_PORTRAIT);
numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_PORTRAIT); numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_PORTRAIT);
setNumColumns(NUMBER_OF_COLS_PORTRAIT);
} }
int expandedHeightSpec = int expandedHeightSpec =
MeasureSpec.makeMeasureSpec((int)(mDisplayDensity * numRows * kTopSiteItemHeight), MeasureSpec.makeMeasureSpec((int)(mDisplayDensity * numRows * kTopSiteItemHeight),
MeasureSpec.EXACTLY); MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, expandedHeightSpec); super.onMeasure(widthMeasureSpec, expandedHeightSpec);
} }
} }

View File

@ -339,7 +339,6 @@ EXTRA_DSO_LDOPTS += \
$(MOZ_JS_LIBS) \ $(MOZ_JS_LIBS) \
$(NSS_LIBS) \ $(NSS_LIBS) \
$(MOZ_CAIRO_OSLIBS) \ $(MOZ_CAIRO_OSLIBS) \
$(MOZ_HARFBUZZ_LIBS) \
$(MOZ_APP_EXTRA_LIBS) \ $(MOZ_APP_EXTRA_LIBS) \
$(SQLITE_LIBS) \ $(SQLITE_LIBS) \
$(NULL) $(NULL)

View File

@ -1154,7 +1154,7 @@ AndroidBridge::CallEglCreateWindowSurface(void *dpy, void *config, AndroidGeckoS
* We can't do it from java, because the EGLConfigImpl constructor is private. * We can't do it from java, because the EGLConfigImpl constructor is private.
*/ */
jobject surfaceHolder = sview.GetSurfaceHolder(env, &jniFrame); jobject surfaceHolder = sview.GetSurfaceHolder(&jniFrame);
if (!surfaceHolder) if (!surfaceHolder)
return nsnull; return nsnull;

View File

@ -574,6 +574,10 @@ public:
} }
} }
JNIEnv* GetEnv() {
return mJNIEnv;
}
bool CheckForException() { bool CheckForException() {
if (mJNIEnv->ExceptionCheck()) { if (mJNIEnv->ExceptionCheck()) {
mJNIEnv->ExceptionDescribe(); mJNIEnv->ExceptionDescribe();

View File

@ -736,12 +736,12 @@ AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float a
} }
jobject jobject
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap(JNIEnv *env, AutoLocalJNIFrame *jniFrame) AndroidGeckoSurfaceView::GetSoftwareDrawBitmap(AutoLocalJNIFrame *jniFrame)
{ {
if (!env || !jniFrame) if (!jniFrame || !jniFrame->GetEnv())
return nsnull; return nsnull;
jobject ret = env->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBitmapMethod); jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBitmapMethod);
if (jniFrame->CheckForException()) if (jniFrame->CheckForException())
return nsnull; return nsnull;
@ -749,12 +749,12 @@ AndroidGeckoSurfaceView::GetSoftwareDrawBitmap(JNIEnv *env, AutoLocalJNIFrame *j
} }
jobject jobject
AndroidGeckoSurfaceView::GetSoftwareDrawBuffer(JNIEnv *env, AutoLocalJNIFrame *jniFrame) AndroidGeckoSurfaceView::GetSoftwareDrawBuffer(AutoLocalJNIFrame *jniFrame)
{ {
if (!env || !jniFrame) if (!jniFrame || !jniFrame->GetEnv())
return nsnull; return nsnull;
jobject ret = env->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBufferMethod); jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBufferMethod);
if (jniFrame->CheckForException()) if (jniFrame->CheckForException())
return nsnull; return nsnull;
@ -762,12 +762,12 @@ AndroidGeckoSurfaceView::GetSoftwareDrawBuffer(JNIEnv *env, AutoLocalJNIFrame *j
} }
jobject jobject
AndroidGeckoSurfaceView::GetSurface(JNIEnv *env, AutoLocalJNIFrame *jniFrame) AndroidGeckoSurfaceView::GetSurface(AutoLocalJNIFrame *jniFrame)
{ {
if (!env || !jniFrame) if (!jniFrame || !jniFrame->GetEnv())
return nsnull; return nsnull;
jobject ret = env->CallObjectMethod(wrapped_obj, jGetSurfaceMethod); jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetSurfaceMethod);
if (jniFrame->CheckForException()) if (jniFrame->CheckForException())
return nsnull; return nsnull;
@ -775,12 +775,12 @@ AndroidGeckoSurfaceView::GetSurface(JNIEnv *env, AutoLocalJNIFrame *jniFrame)
} }
jobject jobject
AndroidGeckoSurfaceView::GetSurfaceHolder(JNIEnv *env, AutoLocalJNIFrame *jniFrame) AndroidGeckoSurfaceView::GetSurfaceHolder(AutoLocalJNIFrame *jniFrame)
{ {
if (!env || !jniFrame) if (!jniFrame || !jniFrame->GetEnv())
return nsnull; return nsnull;
jobject ret = env->CallObjectMethod(wrapped_obj, jGetHolderMethod); jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetHolderMethod);
if (jniFrame->CheckForException()) if (jniFrame->CheckForException())
return nsnull; return nsnull;
@ -788,53 +788,96 @@ AndroidGeckoSurfaceView::GetSurfaceHolder(JNIEnv *env, AutoLocalJNIFrame *jniFra
} }
bool bool
AndroidGeckoLayerClient::CreateFrame(JNIEnv *env, AndroidLayerRendererFrame& aFrame) AndroidGeckoLayerClient::CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame)
{ {
AutoLocalJNIFrame jniFrame(env, 1); if (!jniFrame || !jniFrame->GetEnv())
return false;
jobject frameJObj = env->CallObjectMethod(wrapped_obj, jCreateFrameMethod); jobject frameJObj = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jCreateFrameMethod);
if (jniFrame.CheckForException()) if (jniFrame->CheckForException())
return false; return false;
NS_ABORT_IF_FALSE(frameJObj, "No frame object!"); NS_ABORT_IF_FALSE(frameJObj, "No frame object!");
aFrame.Init(env, frameJObj); aFrame.Init(jniFrame->GetEnv(), frameJObj);
return true; return true;
} }
void bool
AndroidGeckoLayerClient::ActivateProgram(JNIEnv *env) AndroidGeckoLayerClient::ActivateProgram(AutoLocalJNIFrame *jniFrame)
{ {
env->CallVoidMethod(wrapped_obj, jActivateProgramMethod); if (!jniFrame || !jniFrame->GetEnv())
return false;
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jActivateProgramMethod);
if (jniFrame->CheckForException())
return false;
return true;
} }
void bool
AndroidGeckoLayerClient::DeactivateProgram(JNIEnv *env) AndroidGeckoLayerClient::DeactivateProgram(AutoLocalJNIFrame *jniFrame)
{ {
env->CallVoidMethod(wrapped_obj, jDeactivateProgramMethod); if (!jniFrame || !jniFrame->GetEnv())
return false;
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDeactivateProgramMethod);
if (jniFrame->CheckForException())
return false;
return true;
} }
void bool
AndroidLayerRendererFrame::BeginDrawing(JNIEnv *env) AndroidLayerRendererFrame::BeginDrawing(AutoLocalJNIFrame *jniFrame)
{ {
env->CallVoidMethod(wrapped_obj, jBeginDrawingMethod); if (!jniFrame || !jniFrame->GetEnv())
return false;
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jBeginDrawingMethod);
if (jniFrame->CheckForException())
return false;
return true;
} }
void bool
AndroidLayerRendererFrame::DrawBackground(JNIEnv *env) AndroidLayerRendererFrame::DrawBackground(AutoLocalJNIFrame *jniFrame)
{ {
env->CallVoidMethod(wrapped_obj, jDrawBackgroundMethod); if (!jniFrame || !jniFrame->GetEnv())
return false;
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawBackgroundMethod);
if (jniFrame->CheckForException())
return false;
return true;
} }
void bool
AndroidLayerRendererFrame::DrawForeground(JNIEnv *env) AndroidLayerRendererFrame::DrawForeground(AutoLocalJNIFrame *jniFrame)
{ {
env->CallVoidMethod(wrapped_obj, jDrawForegroundMethod); if (!jniFrame || !jniFrame->GetEnv())
return false;
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawForegroundMethod);
if (jniFrame->CheckForException())
return false;
return true;
} }
void bool
AndroidLayerRendererFrame::EndDrawing(JNIEnv *env) AndroidLayerRendererFrame::EndDrawing(AutoLocalJNIFrame *jniFrame)
{ {
env->CallVoidMethod(wrapped_obj, jEndDrawingMethod); if (!jniFrame || !jniFrame->GetEnv())
return false;
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
if (jniFrame->CheckForException())
return false;
return true;
} }
float float

View File

@ -181,10 +181,10 @@ public:
void Init(JNIEnv *env, jobject jobj); void Init(JNIEnv *env, jobject jobj);
void Dispose(JNIEnv *env); void Dispose(JNIEnv *env);
void BeginDrawing(JNIEnv *env); bool BeginDrawing(AutoLocalJNIFrame *jniFrame);
void DrawBackground(JNIEnv *env); bool DrawBackground(AutoLocalJNIFrame *jniFrame);
void DrawForeground(JNIEnv *env); bool DrawForeground(AutoLocalJNIFrame *jniFrame);
void EndDrawing(JNIEnv *env); bool EndDrawing(AutoLocalJNIFrame *jniFrame);
private: private:
static jclass jLayerRendererFrameClass; static jclass jLayerRendererFrameClass;
@ -208,9 +208,9 @@ public:
void SetPageSize(float aZoom, float aPageWidth, float aPageHeight, float aCssPageWidth, float aCssPageHeight); void SetPageSize(float aZoom, float aPageWidth, float aPageHeight, float aCssPageWidth, float aCssPageHeight);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
bool CreateFrame(JNIEnv *env, AndroidLayerRendererFrame& aFrame); bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
void ActivateProgram(JNIEnv *env); bool ActivateProgram(AutoLocalJNIFrame *jniFrame);
void DeactivateProgram(JNIEnv *env); bool DeactivateProgram(AutoLocalJNIFrame *jniFrame);
protected: protected:
static jclass jGeckoLayerClientClass; static jclass jGeckoLayerClientClass;
@ -242,14 +242,14 @@ public:
}; };
int BeginDrawing(); int BeginDrawing();
jobject GetSoftwareDrawBitmap(JNIEnv *env, AutoLocalJNIFrame *jniFrame); jobject GetSoftwareDrawBitmap(AutoLocalJNIFrame *jniFrame);
jobject GetSoftwareDrawBuffer(JNIEnv *env, AutoLocalJNIFrame *jniFrame); jobject GetSoftwareDrawBuffer(AutoLocalJNIFrame *jniFrame);
void EndDrawing(); void EndDrawing();
void Draw2D(jobject bitmap, int width, int height); void Draw2D(jobject bitmap, int width, int height);
void Draw2D(jobject buffer, int stride); void Draw2D(jobject buffer, int stride);
jobject GetSurface(JNIEnv *env, AutoLocalJNIFrame *jniFrame); jobject GetSurface(AutoLocalJNIFrame *jniFrame);
jobject GetSurfaceHolder(JNIEnv *env, AutoLocalJNIFrame *jniFrame); jobject GetSurfaceHolder(AutoLocalJNIFrame *jniFrame);
protected: protected:
static jclass jGeckoSurfaceViewClass; static jclass jGeckoSurfaceViewClass;

View File

@ -917,7 +917,7 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
JNIEnv *env = AndroidBridge::GetJNIEnv(); JNIEnv *env = AndroidBridge::GetJNIEnv();
if (env) { if (env) {
AutoLocalJNIFrame jniFrame(env); AutoLocalJNIFrame jniFrame(env);
jobject surface = sview.GetSurface(env, &jniFrame); jobject surface = sview.GetSurface(&jniFrame);
if (surface) { if (surface) {
sNativeWindow = AndroidBridge::Bridge()->AcquireNativeWindow(env, surface); sNativeWindow = AndroidBridge::Bridge()->AcquireNativeWindow(env, surface);
if (sNativeWindow) { if (sNativeWindow) {
@ -1181,7 +1181,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
AndroidBridge::Bridge()->UnlockWindow(sNativeWindow); AndroidBridge::Bridge()->UnlockWindow(sNativeWindow);
} else if (AndroidBridge::Bridge()->HasNativeBitmapAccess()) { } else if (AndroidBridge::Bridge()->HasNativeBitmapAccess()) {
jobject bitmap = sview.GetSoftwareDrawBitmap(env, &jniFrame); jobject bitmap = sview.GetSoftwareDrawBitmap(&jniFrame);
if (!bitmap) { if (!bitmap) {
ALOG("no bitmap to draw into - skipping draw"); ALOG("no bitmap to draw into - skipping draw");
return; return;
@ -1210,7 +1210,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
AndroidBridge::Bridge()->UnlockBitmap(bitmap); AndroidBridge::Bridge()->UnlockBitmap(bitmap);
sview.Draw2D(bitmap, mBounds.width, mBounds.height); sview.Draw2D(bitmap, mBounds.width, mBounds.height);
} else { } else {
jobject bytebuf = sview.GetSoftwareDrawBuffer(env, &jniFrame); jobject bytebuf = sview.GetSoftwareDrawBuffer(&jniFrame);
if (!bytebuf) { if (!bytebuf) {
ALOG("no buffer to draw into - skipping draw"); ALOG("no buffer to draw into - skipping draw");
return; return;
@ -2233,15 +2233,11 @@ nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect)
AutoLocalJNIFrame jniFrame(env); AutoLocalJNIFrame jniFrame(env);
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient(); AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
if (!client.CreateFrame(env, mLayerRendererFrame)) if (!client.CreateFrame(&jniFrame, mLayerRendererFrame)) return;
return; if (!client.ActivateProgram(&jniFrame)) return;
client.ActivateProgram(env); if (!mLayerRendererFrame.BeginDrawing(&jniFrame)) return;
if (jniFrame.CheckForException()) return; if (!mLayerRendererFrame.DrawBackground(&jniFrame)) return;
mLayerRendererFrame.BeginDrawing(env); if (!client.DeactivateProgram(&jniFrame)) return; // redundant, but in case somebody adds code after this...
if (jniFrame.CheckForException()) return;
mLayerRendererFrame.DrawBackground(env);
if (jniFrame.CheckForException()) return;
client.DeactivateProgram(env);
} }
void void
@ -2259,15 +2255,10 @@ nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect)
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient(); AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
client.ActivateProgram(env); if (!client.ActivateProgram(&jniFrame)) return;
if (jniFrame.CheckForException()) return; if (!mLayerRendererFrame.DrawForeground(&jniFrame)) return;
mLayerRendererFrame.DrawForeground(env); if (!mLayerRendererFrame.EndDrawing(&jniFrame)) return;
if (jniFrame.CheckForException()) return; if (!client.DeactivateProgram(&jniFrame)) return;
mLayerRendererFrame.EndDrawing(env);
if (jniFrame.CheckForException()) return;
client.DeactivateProgram(env);
if (jniFrame.CheckForException()) return;
mLayerRendererFrame.Dispose(env); mLayerRendererFrame.Dispose(env);
} }