mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Merge last PGO-green changeset of mozilla-inbound to mozilla-central
This commit is contained in:
commit
9e8cf21871
@ -49,8 +49,6 @@
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
@ -66,8 +64,6 @@ using namespace mozilla::a11y;
|
||||
|
||||
nsIStringBundle *nsAccessNode::gStringBundle = 0;
|
||||
|
||||
bool nsAccessNode::gIsFormFillEnabled = false;
|
||||
|
||||
ApplicationAccessible* nsAccessNode::gApplicationAccessible = nsnull;
|
||||
|
||||
/*
|
||||
@ -162,11 +158,6 @@ void nsAccessNode::InitXPAccessibility()
|
||||
stringBundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL,
|
||||
&gStringBundle);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch) {
|
||||
prefBranch->GetBoolPref("browser.formfill.enable", &gIsFormFillEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
void nsAccessNode::ShutdownXPAccessibility()
|
||||
|
@ -167,8 +167,6 @@ protected:
|
||||
// Static data, we do our own refcounting for our static data.
|
||||
static nsIStringBundle* gStringBundle;
|
||||
|
||||
static bool gIsFormFillEnabled;
|
||||
|
||||
private:
|
||||
nsAccessNode() MOZ_DELETE;
|
||||
nsAccessNode(const nsAccessNode&) MOZ_DELETE;
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "AtkSocketAccessible.h"
|
||||
#endif
|
||||
#include "FocusManager.h"
|
||||
#include "HTMLListAccessible.h"
|
||||
#include "nsAccessiblePivot.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsARIAMap.h"
|
||||
@ -222,7 +223,7 @@ nsAccessibilityService::CreateHTMLLIAccessible(nsIContent* aContent,
|
||||
nsIPresShell* aPresShell)
|
||||
{
|
||||
nsAccessible* accessible =
|
||||
new nsHTMLLIAccessible(aContent, GetDocAccessible(aPresShell));
|
||||
new HTMLLIAccessible(aContent, GetDocAccessible(aPresShell));
|
||||
NS_ADDREF(accessible);
|
||||
return accessible;
|
||||
}
|
||||
@ -599,7 +600,7 @@ nsAccessibilityService::UpdateListBullet(nsIPresShell* aPresShell,
|
||||
if (document) {
|
||||
nsAccessible* accessible = document->GetAccessible(aHTMLListItemContent);
|
||||
if (accessible) {
|
||||
nsHTMLLIAccessible* listItem = accessible->AsHTMLListItem();
|
||||
HTMLLIAccessible* listItem = accessible->AsHTMLListItem();
|
||||
if (listItem)
|
||||
listItem->UpdateBullet(aHasBullet);
|
||||
}
|
||||
@ -1658,7 +1659,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
|
||||
|
||||
if (tag == nsGkAtoms::ul || tag == nsGkAtoms::ol ||
|
||||
tag == nsGkAtoms::dl) {
|
||||
nsAccessible* accessible = new nsHTMLListAccessible(aContent, aDoc);
|
||||
nsAccessible* accessible = new HTMLListAccessible(aContent, aDoc);
|
||||
NS_IF_ADDREF(accessible);
|
||||
return accessible;
|
||||
}
|
||||
@ -1685,7 +1686,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
|
||||
// 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
|
||||
// must have been styled using display: foo
|
||||
nsAccessible* accessible = new nsHTMLLIAccessible(aContent, aDoc);
|
||||
nsAccessible* accessible = new HTMLLIAccessible(aContent, aDoc);
|
||||
NS_IF_ADDREF(accessible);
|
||||
return accessible;
|
||||
}
|
||||
|
@ -62,12 +62,13 @@ class nsAccessible;
|
||||
class nsHyperTextAccessible;
|
||||
class nsHTMLImageAccessible;
|
||||
class nsHTMLImageMapAccessible;
|
||||
class nsHTMLLIAccessible;
|
||||
struct nsRoleMapEntry;
|
||||
class Relation;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class HTMLLIAccessible;
|
||||
class TableAccessible;
|
||||
|
||||
/**
|
||||
@ -476,7 +477,7 @@ public:
|
||||
inline bool IsHTMLFileInput() const { return mFlags & eHTMLFileInputAccessible; }
|
||||
|
||||
inline bool IsHTMLListItem() const { return mFlags & eHTMLListItemAccessible; }
|
||||
nsHTMLLIAccessible* AsHTMLListItem();
|
||||
mozilla::a11y::HTMLLIAccessible* AsHTMLListItem();
|
||||
|
||||
inline bool IsImageAccessible() const { return mFlags & eImageAccessible; }
|
||||
nsHTMLImageAccessible* AsImage();
|
||||
|
@ -63,6 +63,9 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -496,7 +499,7 @@ HTMLTextFieldAccessible::NativeState()
|
||||
|
||||
// No parent can mean a fake widget created for XUL textbox. If accessible
|
||||
// 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
|
||||
// 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
|
||||
|
201
accessible/src/html/HTMLListAccessible.cpp
Normal file
201
accessible/src/html/HTMLListAccessible.cpp
Normal 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));
|
||||
}
|
104
accessible/src/html/HTMLListAccessible.h
Normal file
104
accessible/src/html/HTMLListAccessible.h
Normal 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
|
@ -52,6 +52,7 @@ LIBXUL_LIBRARY = 1
|
||||
CPPSRCS = \
|
||||
nsHTMLCanvasAccessible.cpp \
|
||||
HTMLFormControlAccessible.cpp \
|
||||
HTMLListAccessible.cpp \
|
||||
nsHTMLImageAccessible.cpp \
|
||||
nsHTMLImageMapAccessible.cpp \
|
||||
nsHTMLLinkAccessible.cpp \
|
||||
|
@ -41,19 +41,12 @@
|
||||
|
||||
#include "nsDocAccessible.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsIAccessibleRelation.h"
|
||||
#include "nsTextEquivUtils.h"
|
||||
#include "Relation.h"
|
||||
#include "Role.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;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -227,198 +220,3 @@ nsHTMLOutputAccessible::GetAttributesInternal(nsIPersistentProperties* aAttribut
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -119,78 +119,4 @@ public:
|
||||
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
|
||||
|
@ -873,7 +873,7 @@ public:
|
||||
* host content. When the content is in designMode, this returns its body
|
||||
* 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
|
||||
|
@ -85,6 +85,7 @@
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "nsDOMDataTransfer.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
class NS_STACK_CLASS DragDataProducer
|
||||
{
|
||||
|
@ -1552,7 +1552,7 @@ nsIContent::HasIndependentSelection()
|
||||
return (frame && frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION);
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
dom::Element*
|
||||
nsIContent::GetEditingHost()
|
||||
{
|
||||
// If this isn't editable, return NULL.
|
||||
@ -1566,12 +1566,12 @@ nsIContent::GetEditingHost()
|
||||
}
|
||||
|
||||
nsIContent* content = this;
|
||||
for (nsIContent* parent = GetParent();
|
||||
for (dom::Element* parent = GetElementParent();
|
||||
parent && parent->HasFlag(NODE_IS_EDITABLE);
|
||||
parent = content->GetParent()) {
|
||||
parent = content->GetElementParent()) {
|
||||
content = parent;
|
||||
}
|
||||
return content;
|
||||
return content->AsElement();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
@ -62,6 +62,8 @@ struct AudioTrack {
|
||||
jmethodID stop;
|
||||
jmethodID write;
|
||||
jmethodID getpos;
|
||||
jmethodID getstate;
|
||||
jmethodID release;
|
||||
};
|
||||
|
||||
enum AudioTrackMode {
|
||||
@ -91,11 +93,18 @@ enum AudioFormatEncoding {
|
||||
ENCODING_PCM_8BIT = 3
|
||||
};
|
||||
|
||||
enum AudioFormatState {
|
||||
STATE_UNINITIALIZED = 0,
|
||||
STATE_INITIALIZED = 1,
|
||||
STATE_NO_STATIC_DATA = 2
|
||||
};
|
||||
|
||||
static struct AudioTrack at;
|
||||
|
||||
static jclass
|
||||
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.flush = jenv->GetMethodID(jc, "flush", "()V");
|
||||
@ -105,6 +114,8 @@ init_jni_bindings(JNIEnv *jenv) {
|
||||
at.stop = jenv->GetMethodID(jc, "stop", "()V");
|
||||
at.write = jenv->GetMethodID(jc, "write", "([BII)I");
|
||||
at.getpos = jenv->GetMethodID(jc, "getPlaybackHeadPosition", "()I");
|
||||
at.getstate = jenv->GetMethodID(jc, "getState", "()I");
|
||||
at.release = jenv->GetMethodID(jc, "release", "()V");
|
||||
|
||||
return jc;
|
||||
}
|
||||
@ -143,7 +154,7 @@ AudioRunnable::Run()
|
||||
if (!jenv)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv);
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 2);
|
||||
|
||||
jbyteArray bytearray = jenv->NewByteArray(mTrack->bufferSize);
|
||||
if (!bytearray) {
|
||||
@ -193,6 +204,8 @@ AudioRunnable::Run()
|
||||
} while(wroteSoFar < buffer.size);
|
||||
}
|
||||
|
||||
jenv->CallVoidMethod(mTrack->output_unit, at.release);
|
||||
|
||||
jenv->DeleteGlobalRef(mTrack->output_unit);
|
||||
jenv->DeleteGlobalRef(mTrack->at_class);
|
||||
|
||||
@ -257,6 +270,8 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz
|
||||
break;
|
||||
}
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv);
|
||||
|
||||
jobject obj = jenv->NewObject(s->at_class,
|
||||
at.constructor,
|
||||
STREAM_MUSIC,
|
||||
@ -266,11 +281,15 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz
|
||||
s->bufferSize,
|
||||
MODE_STREAM);
|
||||
|
||||
jthrowable exception = jenv->ExceptionOccurred();
|
||||
if (exception) {
|
||||
LOG("%s fAILED ", __PRETTY_FUNCTION__);
|
||||
jenv->ExceptionDescribe();
|
||||
jenv->ExceptionClear();
|
||||
if (autoFrame.CheckForException() || obj == NULL) {
|
||||
jenv->DeleteGlobalRef(s->at_class);
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jint state = jenv->CallIntMethod(obj, at.getstate);
|
||||
|
||||
if (autoFrame.CheckForException() || state == STATE_UNINITIALIZED) {
|
||||
jenv->DeleteGlobalRef(s->at_class);
|
||||
free(s);
|
||||
return NULL;
|
||||
@ -300,7 +319,7 @@ anp_audio_start(ANPAudioTrack* s)
|
||||
if (s == NULL || s->output_unit == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (s->keepGoing) {
|
||||
// we are already playing. Ignore.
|
||||
return;
|
||||
@ -310,8 +329,15 @@ anp_audio_start(ANPAudioTrack* s)
|
||||
if (!jenv)
|
||||
return;
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
|
||||
jenv->CallVoidMethod(s->output_unit, at.play);
|
||||
|
||||
if (autoFrame.CheckForException()) {
|
||||
jenv->DeleteGlobalRef(s->at_class);
|
||||
free(s);
|
||||
return;
|
||||
}
|
||||
|
||||
s->isStopped = false;
|
||||
s->keepGoing = true;
|
||||
|
||||
@ -332,6 +358,8 @@ anp_audio_pause(ANPAudioTrack* s)
|
||||
JNIEnv *jenv = GetJNIForThread();
|
||||
if (!jenv)
|
||||
return;
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
|
||||
jenv->CallVoidMethod(s->output_unit, at.pause);
|
||||
}
|
||||
|
||||
@ -346,6 +374,8 @@ anp_audio_stop(ANPAudioTrack* s)
|
||||
JNIEnv *jenv = GetJNIForThread();
|
||||
if (!jenv)
|
||||
return;
|
||||
|
||||
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
|
||||
jenv->CallVoidMethod(s->output_unit, at.stop);
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -51,7 +51,15 @@ interface nsIContentFilter;
|
||||
#define NS_EDITOR_ELEMENT_NOT_FOUND \
|
||||
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)]
|
||||
|
||||
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
|
||||
* active in the DOM window, this returns NULL.
|
||||
*/
|
||||
[noscript, notxpcom] nsIContent GetActiveEditingHost();
|
||||
[noscript, notxpcom] Element GetActiveEditingHost();
|
||||
};
|
||||
|
||||
|
@ -3148,8 +3148,7 @@ nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent *aActiveEditorRoot)
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
|
||||
*aResultNode = nsnull;
|
||||
@ -3158,8 +3157,8 @@ nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
|
||||
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aResultNode = do_QueryInterface(GetPriorNode(parentNode, aOffset,
|
||||
aEditableNode, bNoBlockCrossing,
|
||||
aActiveEditorRoot));
|
||||
aEditableNode,
|
||||
bNoBlockCrossing));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3167,8 +3166,7 @@ nsIContent*
|
||||
nsEditor::GetPriorNode(nsINode* aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
bool aNoBlockCrossing,
|
||||
nsIContent* aActiveEditorRoot)
|
||||
bool aNoBlockCrossing)
|
||||
{
|
||||
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.
|
||||
return nsnull;
|
||||
}
|
||||
return GetPriorNode(aParentNode, aEditableNode,
|
||||
aNoBlockCrossing, aActiveEditorRoot);
|
||||
return GetPriorNode(aParentNode, aEditableNode, aNoBlockCrossing);
|
||||
}
|
||||
|
||||
// else look before the child at 'aOffset'
|
||||
if (nsIContent* child = aParentNode->GetChildAt(aOffset)) {
|
||||
return GetPriorNode(child, aEditableNode, aNoBlockCrossing,
|
||||
aActiveEditorRoot);
|
||||
return GetPriorNode(child, aEditableNode, aNoBlockCrossing);
|
||||
}
|
||||
|
||||
// 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
|
||||
return GetPriorNode(resultNode, aEditableNode, aNoBlockCrossing, aActiveEditorRoot);
|
||||
return GetPriorNode(resultNode, aEditableNode, aNoBlockCrossing);
|
||||
}
|
||||
|
||||
|
||||
@ -3206,8 +3202,7 @@ nsEditor::GetNextNode(nsIDOMNode *aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent *aActiveEditorRoot)
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
|
||||
*aResultNode = nsnull;
|
||||
@ -3216,8 +3211,8 @@ nsEditor::GetNextNode(nsIDOMNode *aParentNode,
|
||||
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aResultNode = do_QueryInterface(GetNextNode(parentNode, aOffset,
|
||||
aEditableNode, bNoBlockCrossing,
|
||||
aActiveEditorRoot));
|
||||
aEditableNode,
|
||||
bNoBlockCrossing));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3225,8 +3220,7 @@ nsIContent*
|
||||
nsEditor::GetNextNode(nsINode* aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
bool aNoBlockCrossing,
|
||||
nsIContent* aActiveEditorRoot)
|
||||
bool aNoBlockCrossing)
|
||||
{
|
||||
MOZ_ASSERT(aParentNode);
|
||||
|
||||
@ -3250,7 +3244,7 @@ nsEditor::GetNextNode(nsINode* aParentNode,
|
||||
return child;
|
||||
}
|
||||
|
||||
if (!IsDescendantOfBody(resultNode)) {
|
||||
if (!IsDescendantOfEditorRoot(resultNode)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -3259,8 +3253,7 @@ nsEditor::GetNextNode(nsINode* aParentNode,
|
||||
}
|
||||
|
||||
// restart the search from the non-editable node we just found
|
||||
return GetNextNode(resultNode, aEditableNode, aNoBlockCrossing,
|
||||
aActiveEditorRoot);
|
||||
return GetNextNode(resultNode, aEditableNode, aNoBlockCrossing);
|
||||
}
|
||||
|
||||
// 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 GetNextNode(aParentNode, aEditableNode, aNoBlockCrossing,
|
||||
aActiveEditorRoot);
|
||||
return GetNextNode(aParentNode, aEditableNode, aNoBlockCrossing);
|
||||
}
|
||||
|
||||
|
||||
@ -3279,8 +3271,7 @@ nsresult
|
||||
nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent *aActiveEditorRoot)
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -3288,40 +3279,31 @@ nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
|
||||
NS_ENSURE_TRUE(currentNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aResultNode = do_QueryInterface(GetPriorNode(currentNode, aEditableNode,
|
||||
bNoBlockCrossing,
|
||||
aActiveEditorRoot));
|
||||
bNoBlockCrossing));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsEditor::GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
|
||||
bool aNoBlockCrossing /* = false */,
|
||||
nsIContent* aActiveEditorRoot /* = null */)
|
||||
bool aNoBlockCrossing /* = false */)
|
||||
{
|
||||
MOZ_ASSERT(aCurrentNode);
|
||||
|
||||
if (!IsDescendantOfBody(aCurrentNode) ||
|
||||
(aActiveEditorRoot &&
|
||||
!nsContentUtils::ContentIsDescendantOf(aCurrentNode,
|
||||
aActiveEditorRoot))) {
|
||||
if (!IsDescendantOfEditorRoot(aCurrentNode)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return FindNode(aCurrentNode, false, aEditableNode, aNoBlockCrossing,
|
||||
aActiveEditorRoot);
|
||||
return FindNode(aCurrentNode, false, aEditableNode, aNoBlockCrossing);
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
|
||||
bool aGoForward,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent *aActiveEditorRoot)
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
// called only by GetPriorNode so we don't need to check params.
|
||||
NS_PRECONDITION(IsDescendantOfBody(aCurrentNode) && !IsRootNode(aCurrentNode) &&
|
||||
(!aActiveEditorRoot ||
|
||||
nsContentUtils::ContentIsDescendantOf(aCurrentNode,
|
||||
aActiveEditorRoot)),
|
||||
NS_PRECONDITION(IsDescendantOfEditorRoot(aCurrentNode) &&
|
||||
!IsEditorRoot(aCurrentNode),
|
||||
"Bogus arguments");
|
||||
|
||||
nsINode* cur = aCurrentNode;
|
||||
@ -3350,13 +3332,12 @@ nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_ASSERTION(IsDescendantOfBody(parent),
|
||||
NS_ASSERTION(IsDescendantOfEditorRoot(parent),
|
||||
"We started with a proper descendant of root, and should stop "
|
||||
"if we ever hit the root, so we better have a descendant of "
|
||||
"root now!");
|
||||
if (IsRootNode(parent) ||
|
||||
(bNoBlockCrossing && IsBlockNode(parent)) ||
|
||||
parent == aActiveEditorRoot) {
|
||||
if (IsEditorRoot(parent) ||
|
||||
(bNoBlockCrossing && IsBlockNode(parent))) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -3371,8 +3352,7 @@ nsresult
|
||||
nsEditor::GetNextNode(nsIDOMNode* aCurrentNode,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent* aActiveEditorRoot)
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
|
||||
if (!currentNode || !aResultNode) {
|
||||
@ -3380,39 +3360,31 @@ nsEditor::GetNextNode(nsIDOMNode* aCurrentNode,
|
||||
}
|
||||
|
||||
*aResultNode = do_QueryInterface(GetNextNode(currentNode, aEditableNode,
|
||||
bNoBlockCrossing,
|
||||
aActiveEditorRoot));
|
||||
bNoBlockCrossing));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsEditor::GetNextNode(nsINode* aCurrentNode,
|
||||
bool aEditableNode,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent* aActiveEditorRoot)
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
MOZ_ASSERT(aCurrentNode);
|
||||
|
||||
if (!IsDescendantOfBody(aCurrentNode) ||
|
||||
(aActiveEditorRoot &&
|
||||
!nsContentUtils::ContentIsDescendantOf(aCurrentNode,
|
||||
aActiveEditorRoot))) {
|
||||
if (!IsDescendantOfEditorRoot(aCurrentNode)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return FindNode(aCurrentNode, true, aEditableNode, bNoBlockCrossing,
|
||||
aActiveEditorRoot);
|
||||
return FindNode(aCurrentNode, true, aEditableNode, bNoBlockCrossing);
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsEditor::FindNode(nsINode *aCurrentNode,
|
||||
bool aGoForward,
|
||||
bool aEditableNode,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent *aActiveEditorRoot)
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
if (IsRootNode(aCurrentNode) || aCurrentNode == aActiveEditorRoot)
|
||||
{
|
||||
if (IsEditorRoot(aCurrentNode)) {
|
||||
// Don't allow traversal above the root node! This helps
|
||||
// prevent us from accidentally editing browser content
|
||||
// when the editor is in a text widget.
|
||||
@ -3421,8 +3393,7 @@ nsEditor::FindNode(nsINode *aCurrentNode,
|
||||
}
|
||||
|
||||
nsIContent* candidate =
|
||||
FindNextLeafNode(aCurrentNode, aGoForward, bNoBlockCrossing,
|
||||
aActiveEditorRoot);
|
||||
FindNextLeafNode(aCurrentNode, aGoForward, bNoBlockCrossing);
|
||||
|
||||
if (!candidate) {
|
||||
return nsnull;
|
||||
@ -3432,8 +3403,7 @@ nsEditor::FindNode(nsINode *aCurrentNode,
|
||||
return candidate;
|
||||
}
|
||||
|
||||
return FindNode(candidate, aGoForward, aEditableNode, bNoBlockCrossing,
|
||||
aActiveEditorRoot);
|
||||
return FindNode(candidate, aGoForward, aEditableNode, bNoBlockCrossing);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMNode>
|
||||
@ -3589,7 +3559,7 @@ nsEditor::TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag)
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditor::IsRootNode(nsIDOMNode *inNode)
|
||||
nsEditor::IsRoot(nsIDOMNode* inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
|
||||
@ -3599,7 +3569,7 @@ nsEditor::IsRootNode(nsIDOMNode *inNode)
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditor::IsRootNode(nsINode *inNode)
|
||||
nsEditor::IsRoot(nsINode* inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
|
||||
@ -3608,15 +3578,23 @@ nsEditor::IsRootNode(nsINode *inNode)
|
||||
return inNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditor::IsEditorRoot(nsINode* aNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, false);
|
||||
nsCOMPtr<nsINode> rootNode = GetEditorRoot();
|
||||
return aNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditor::IsDescendantOfBody(nsIDOMNode *inNode)
|
||||
nsEditor::IsDescendantOfRoot(nsIDOMNode* inNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
|
||||
return IsDescendantOfBody(node);
|
||||
return IsDescendantOfRoot(node);
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditor::IsDescendantOfBody(nsINode *inNode)
|
||||
nsEditor::IsDescendantOfRoot(nsINode* inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
nsCOMPtr<nsIContent> root = GetRoot();
|
||||
@ -3625,6 +3603,23 @@ nsEditor::IsDescendantOfBody(nsINode *inNode)
|
||||
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
|
||||
nsEditor::IsContainer(nsIDOMNode *aNode)
|
||||
{
|
||||
@ -5233,6 +5228,12 @@ nsEditor::GetRoot()
|
||||
return mRootElement;
|
||||
}
|
||||
|
||||
dom::Element*
|
||||
nsEditor::GetEditorRoot()
|
||||
{
|
||||
return GetRoot();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEditor::DetermineCurrentDirection()
|
||||
{
|
||||
|
@ -373,8 +373,7 @@ protected:
|
||||
// helper for GetPriorNode and GetNextNode
|
||||
nsIContent* FindNextLeafNode(nsINode *aCurrentNode,
|
||||
bool aGoForward,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent *aActiveEditorRoot);
|
||||
bool bNoBlockCrossing);
|
||||
|
||||
// Get nsIWidget interface
|
||||
nsresult GetWidget(nsIWidget **aWidget);
|
||||
@ -477,29 +476,24 @@ public:
|
||||
* skipping non-editable nodes if aEditableNode is true.
|
||||
* If there is no prior node, aResultNode will be nsnull.
|
||||
* @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,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing = false,
|
||||
nsIContent *aActiveEditorRoot = nsnull);
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
|
||||
bool aNoBlockCrossing = false,
|
||||
nsIContent* aActiveEditorRoot = nsnull);
|
||||
bool aNoBlockCrossing = false);
|
||||
|
||||
// and another version that takes a {parent,offset} pair rather than a node
|
||||
nsresult GetPriorNode(nsIDOMNode *aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing = false,
|
||||
nsIContent *aActiveEditorRoot = nsnull);
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetPriorNode(nsINode* aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
bool aNoBlockCrossing = false,
|
||||
nsIContent* aActiveEditorRoot = nsnull);
|
||||
bool aNoBlockCrossing = false);
|
||||
|
||||
|
||||
/** get the node immediately after to aCurrentNode
|
||||
@ -512,32 +506,27 @@ public:
|
||||
nsresult GetNextNode(nsIDOMNode *aCurrentNode,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing = false,
|
||||
nsIContent *aActiveEditorRoot = nsnull);
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetNextNode(nsINode* aCurrentNode,
|
||||
bool aEditableNode,
|
||||
bool bNoBlockCrossing = false,
|
||||
nsIContent* aActiveEditorRoot = nsnull);
|
||||
bool bNoBlockCrossing = false);
|
||||
|
||||
// and another version that takes a {parent,offset} pair rather than a node
|
||||
nsresult GetNextNode(nsIDOMNode *aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
nsCOMPtr<nsIDOMNode> *aResultNode,
|
||||
bool bNoBlockCrossing = false,
|
||||
nsIContent *aActiveEditorRoot = nsnull);
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetNextNode(nsINode* aParentNode,
|
||||
PRInt32 aOffset,
|
||||
bool aEditableNode,
|
||||
bool aNoBlockCrossing = false,
|
||||
nsIContent* aActiveEditorRoot = nsnull);
|
||||
bool aNoBlockCrossing = false);
|
||||
|
||||
// Helper for GetNextNode and GetPriorNode
|
||||
nsIContent* FindNode(nsINode *aCurrentNode,
|
||||
bool aGoForward,
|
||||
bool aEditableNode,
|
||||
bool bNoBlockCrossing,
|
||||
nsIContent *aActiveEditorRoot);
|
||||
bool bNoBlockCrossing);
|
||||
/**
|
||||
* Get the rightmost child of aCurrentNode;
|
||||
* return nsnull if aCurrentNode has no children.
|
||||
@ -577,12 +566,15 @@ public:
|
||||
virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag);
|
||||
|
||||
/** returns true if aNode is our root node */
|
||||
bool IsRootNode(nsIDOMNode *inNode);
|
||||
bool IsRootNode(nsINode *inNode);
|
||||
bool IsRoot(nsIDOMNode* inNode);
|
||||
bool IsRoot(nsINode* inNode);
|
||||
bool IsEditorRoot(nsINode* aNode);
|
||||
|
||||
/** returns true if aNode is a descendant of our root node */
|
||||
bool IsDescendantOfBody(nsIDOMNode *inNode);
|
||||
bool IsDescendantOfBody(nsINode *inNode);
|
||||
bool IsDescendantOfRoot(nsIDOMNode* inNode);
|
||||
bool IsDescendantOfRoot(nsINode* inNode);
|
||||
bool IsDescendantOfEditorRoot(nsIDOMNode* aNode);
|
||||
bool IsDescendantOfEditorRoot(nsINode* aNode);
|
||||
|
||||
/** returns true if aNode is a container */
|
||||
virtual bool IsContainer(nsIDOMNode *aNode);
|
||||
@ -672,6 +664,10 @@ public:
|
||||
// Fast non-refcounting editor root element accessor
|
||||
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
|
||||
bool IsPlaintextEditor() const
|
||||
{
|
||||
|
@ -4085,7 +4085,7 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, bool *aCancel, bool *aHan
|
||||
curBlockQuoteIsIndentedWithCSS = false;
|
||||
// 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)
|
||||
while (!nsTextEditUtils::IsBody(n) && mHTMLEditor->IsNodeInActiveEditor(n)
|
||||
while (!nsTextEditUtils::IsBody(n) && mHTMLEditor->IsDescendantOfEditorRoot(n)
|
||||
&& (nsHTMLEditUtils::IsTable(n) || !nsHTMLEditUtils::IsTableElement(n)))
|
||||
{
|
||||
n->GetParentNode(getter_AddRefs(tmp));
|
||||
@ -5597,8 +5597,8 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode,
|
||||
|| (actionID == nsHTMLEditor::kOpOutdent)
|
||||
|| (actionID == nsHTMLEditor::kOpAlign)
|
||||
|| (actionID == nsHTMLEditor::kOpMakeBasicBlock);
|
||||
if (!mHTMLEditor->IsNodeInActiveEditor(parent) &&
|
||||
(blockLevelAction || !mHTMLEditor->IsNodeInActiveEditor(node))) {
|
||||
if (!mHTMLEditor->IsDescendantOfEditorRoot(parent) &&
|
||||
(blockLevelAction || !mHTMLEditor->IsDescendantOfEditorRoot(node))) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5653,8 +5653,8 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode,
|
||||
// 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
|
||||
// it's OK.
|
||||
if (!mHTMLEditor->IsNodeInActiveEditor(node) &&
|
||||
!mHTMLEditor->IsNodeInActiveEditor(parent)) {
|
||||
if (!mHTMLEditor->IsDescendantOfEditorRoot(node) &&
|
||||
!mHTMLEditor->IsDescendantOfEditorRoot(parent)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5787,8 +5787,8 @@ nsHTMLEditRules::PromoteRange(nsIDOMRange *inRange,
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// Make sure that the new range ends up to be in the editable section.
|
||||
if (!mHTMLEditor->IsNodeInActiveEditor(nsEditor::GetNodeAtRangeOffsetPoint(opStartNode, opStartOffset)) ||
|
||||
!mHTMLEditor->IsNodeInActiveEditor(nsEditor::GetNodeAtRangeOffsetPoint(opEndNode, opEndOffset - 1))) {
|
||||
if (!mHTMLEditor->IsDescendantOfEditorRoot(nsEditor::GetNodeAtRangeOffsetPoint(opStartNode, opStartOffset)) ||
|
||||
!mHTMLEditor->IsDescendantOfEditorRoot(nsEditor::GetNodeAtRangeOffsetPoint(opEndNode, opEndOffset - 1))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -6492,7 +6492,7 @@ nsHTMLEditRules::IsInListItem(nsINode* aNode)
|
||||
}
|
||||
|
||||
nsINode* parent = aNode->GetNodeParent();
|
||||
while (parent && mHTMLEditor->IsNodeInActiveEditor(parent) &&
|
||||
while (parent && mHTMLEditor->IsDescendantOfEditorRoot(parent) &&
|
||||
!(parent->IsElement() &&
|
||||
nsHTMLEditUtils::IsTableElement(parent->AsElement()))) {
|
||||
if (nsHTMLEditUtils::IsListItem(parent->AsElement())) {
|
||||
@ -7294,7 +7294,7 @@ nsHTMLEditRules::SplitAsNeeded(const nsAString *aTag,
|
||||
// a legal place for the block
|
||||
if (!parent) break;
|
||||
// Don't leave the active editing host
|
||||
if (!mHTMLEditor->IsNodeInActiveEditor(parent)) {
|
||||
if (!mHTMLEditor->IsDescendantOfEditorRoot(parent)) {
|
||||
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parent);
|
||||
if (parentContent != mHTMLEditor->GetActiveEditingHost()) {
|
||||
break;
|
||||
@ -8356,8 +8356,7 @@ nsHTMLEditRules::UpdateDocChangeRange(nsIDOMRange *aRange)
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
res = aRange->GetStartContainer(getter_AddRefs(startNode));
|
||||
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
|
||||
return NS_OK;
|
||||
}
|
||||
@ -8893,7 +8892,7 @@ nsHTMLEditRules::RelativeChangeIndentationOfElementNode(nsIDOMNode *aNode, PRInt
|
||||
nsCOMPtr<dom::Element> node = do_QueryInterface(aNode);
|
||||
if (!node || !node->IsHTML(nsGkAtoms::div) ||
|
||||
node == mHTMLEditor->GetActiveEditingHost() ||
|
||||
!mHTMLEditor->IsNodeInActiveEditor(node) ||
|
||||
!mHTMLEditor->IsDescendantOfEditorRoot(node) ||
|
||||
nsHTMLEditor::HasAttributes(node)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1882,7 +1882,7 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement)
|
||||
nsresult res = NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Must be sure that element is contained in the document body
|
||||
if (IsNodeInActiveEditor(aElement)) {
|
||||
if (IsDescendantOfEditorRoot(aElement)) {
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@ -1914,7 +1914,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
|
||||
nsresult res = NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Be sure the element is contained in the document body
|
||||
if (aElement && IsNodeInActiveEditor(aElement)) {
|
||||
if (aElement && IsDescendantOfEditorRoot(aElement)) {
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
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
|
||||
nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement)
|
||||
{
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aElement);
|
||||
if (!element || !element->IsHTML() ||
|
||||
!nsHTMLEditUtils::IsTableElement(element) ||
|
||||
!IsNodeInActiveEditor(element)) {
|
||||
!IsDescendantOfEditorRoot(element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4353,10 +4336,11 @@ nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode
|
||||
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_ASSERTION(!*outNode || IsNodeInActiveEditor(*outNode),
|
||||
NS_ASSERTION(!*outNode || IsDescendantOfEditorRoot(*outNode),
|
||||
"GetPriorNode screwed up");
|
||||
return res;
|
||||
}
|
||||
@ -4376,10 +4360,11 @@ nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<
|
||||
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_ASSERTION(!*outNode || IsNodeInActiveEditor(*outNode),
|
||||
NS_ASSERTION(!*outNode || IsDescendantOfEditorRoot(*outNode),
|
||||
"GetPriorNode screwed up");
|
||||
return res;
|
||||
}
|
||||
@ -4397,7 +4382,7 @@ nsHTMLEditor::GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode,
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// if it's not in the body, then zero it out
|
||||
if (*outNode && !IsNodeInActiveEditor(*outNode)) {
|
||||
if (*outNode && !IsDescendantOfEditorRoot(*outNode)) {
|
||||
*outNode = nsnull;
|
||||
}
|
||||
return res;
|
||||
@ -4415,7 +4400,7 @@ nsHTMLEditor::GetNextHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<n
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// if it's not in the body, then zero it out
|
||||
if (*outNode && !IsNodeInActiveEditor(*outNode)) {
|
||||
if (*outNode && !IsDescendantOfEditorRoot(*outNode)) {
|
||||
*outNode = nsnull;
|
||||
}
|
||||
return res;
|
||||
@ -5474,7 +5459,7 @@ nsHTMLEditor::IsActiveInDOMWindow()
|
||||
return true;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
dom::Element*
|
||||
nsHTMLEditor::GetActiveEditingHost()
|
||||
{
|
||||
NS_ENSURE_TRUE(mDocWeak, nsnull);
|
||||
@ -5715,3 +5700,10 @@ nsHTMLEditor::GetInputEventTargetContent()
|
||||
nsCOMPtr<nsIContent> target = GetActiveEditingHost();
|
||||
return target.forget();
|
||||
}
|
||||
|
||||
// virtual MOZ_OVERRIDE
|
||||
dom::Element*
|
||||
nsHTMLEditor::GetEditorRoot()
|
||||
{
|
||||
return GetActiveEditingHost();
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ public:
|
||||
virtual already_AddRefed<nsIContent> GetFocusedContent();
|
||||
virtual bool IsActiveInDOMWindow();
|
||||
virtual already_AddRefed<nsIDOMEventTarget> GetDOMEventTarget();
|
||||
virtual mozilla::dom::Element* GetEditorRoot() MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode *aNode);
|
||||
virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent);
|
||||
virtual already_AddRefed<nsIContent> GetInputEventTargetContent();
|
||||
@ -441,8 +442,6 @@ protected:
|
||||
|
||||
// Return TRUE if aElement is a table-related elemet and caret was set
|
||||
bool SetCaretInTableCell(nsIDOMElement* aElement);
|
||||
bool IsNodeInActiveEditor(nsIDOMNode* aNode);
|
||||
bool IsNodeInActiveEditor(nsINode* aNode);
|
||||
|
||||
// key event helpers
|
||||
NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled);
|
||||
|
@ -142,7 +142,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
||||
|
||||
// Contenteditable should disregard mousedowns outside it
|
||||
if (element && !htmlEditor->IsNodeInActiveEditor(element)) {
|
||||
if (element && !htmlEditor->IsDescendantOfEditorRoot(element)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
|
||||
nsIContent* nextNode = GetNextHTMLSibling(aNode);
|
||||
if (nextNode && nextNode->Tag() == aProperty &&
|
||||
HasAttrVal(nextNode, aAttribute, *aValue) &&
|
||||
IsOnlyAttribute(priorNode, *aAttribute)) {
|
||||
IsOnlyAttribute(nextNode, *aAttribute)) {
|
||||
// following sib is already right kind of inline node; slide this over into it
|
||||
return MoveNode(aNode->AsDOMNode(), nextNode->AsDOMNode(), 0);
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = harfbuzz
|
||||
LIBRARY_NAME = mozharfbuzz
|
||||
ifneq ($(OS_ARCH),WINNT)
|
||||
LIBXUL_LIBRARY = 1
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
hb-blob.cc \
|
||||
|
@ -128,6 +128,7 @@ static const mozilla::Module::CategoryEntry kImageCategories[] = {
|
||||
static nsresult
|
||||
imglib_Initialize()
|
||||
{
|
||||
mozilla::image::DiscardTracker::Initialize();
|
||||
imgLoader::InitCache();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -365,9 +365,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
if (mIsPNG) {
|
||||
mContainedDecoder = new nsPNGDecoder(mImage, mObserver);
|
||||
mContainedDecoder->InitSharedDecoder();
|
||||
mContainedDecoder->Write(mSignature, PNGSIGNATURESIZE);
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(mSignature, PNGSIGNATURESIZE)) {
|
||||
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 (mIsPNG && mContainedDecoder && mPos >= mImageOffset + PNGSIGNATURESIZE) {
|
||||
mContainedDecoder->Write(aBuffer, aCount);
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(aBuffer, aCount)) {
|
||||
return;
|
||||
}
|
||||
mPos += aCount;
|
||||
@ -445,9 +441,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
PostDataError();
|
||||
return;
|
||||
}
|
||||
mContainedDecoder->Write((const char*)bfhBuffer, sizeof(bfhBuffer));
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder((const char*)bfhBuffer, sizeof(bfhBuffer))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -468,9 +462,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
}
|
||||
|
||||
// Write out the BMP's bitmap info header
|
||||
mContainedDecoder->Write(mBIHraw, sizeof(mBIHraw));
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(mBIHraw, sizeof(mBIHraw))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -515,9 +507,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
|
||||
toFeed = aCount;
|
||||
}
|
||||
|
||||
mContainedDecoder->Write(aBuffer, toFeed);
|
||||
mDataError = mContainedDecoder->HasDataError();
|
||||
if (mContainedDecoder->HasDataError()) {
|
||||
if (!WriteToContainedDecoder(aBuffer, toFeed)) {
|
||||
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
|
||||
nsICODecoder::ProcessDirEntry(IconDirEntry& aTarget)
|
||||
{
|
||||
|
@ -77,6 +77,10 @@ public:
|
||||
virtual void FinishInternal();
|
||||
|
||||
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
|
||||
void ProcessDirEntry(IconDirEntry& aTarget);
|
||||
// Sets the hotspot property of if we have a cursor
|
||||
|
@ -18,10 +18,11 @@ static const char* sDiscardTimeoutPref = "image.mem.min_discard_timeout_ms";
|
||||
/* static */ nsCOMPtr<nsITimer> DiscardTracker::sTimer;
|
||||
/* static */ bool DiscardTracker::sInitialized = false;
|
||||
/* static */ bool DiscardTracker::sTimerOn = false;
|
||||
/* static */ bool DiscardTracker::sDiscardRunnablePending = false;
|
||||
/* static */ PRInt32 DiscardTracker::sDiscardRunnablePending = 0;
|
||||
/* static */ PRInt64 DiscardTracker::sCurrentDecodedImageBytes = 0;
|
||||
/* static */ PRUint32 DiscardTracker::sMinDiscardTimeoutMs = 10000;
|
||||
/* 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
|
||||
@ -30,7 +31,8 @@ static const char* sDiscardTimeoutPref = "image.mem.min_discard_timeout_ms";
|
||||
NS_IMETHODIMP
|
||||
DiscardTracker::DiscardRunnable::Run()
|
||||
{
|
||||
sDiscardRunnablePending = false;
|
||||
PR_ATOMIC_SET(&sDiscardRunnablePending, 0);
|
||||
|
||||
DiscardTracker::DiscardNow();
|
||||
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
|
||||
// be discarded, or on animated images (which should be marked as
|
||||
// non-discardable, anyway).
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(sInitialized);
|
||||
MOZ_ASSERT(node->img);
|
||||
MOZ_ASSERT(node->img->CanDiscard());
|
||||
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.
|
||||
bool wasInList = node->isInList();
|
||||
if (wasInList) {
|
||||
@ -75,7 +72,7 @@ DiscardTracker::Reset(Node *node)
|
||||
}
|
||||
|
||||
// Make sure the timer is running.
|
||||
rv = EnableTimer();
|
||||
nsresult rv = EnableTimer();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
@ -84,6 +81,8 @@ DiscardTracker::Reset(Node *node)
|
||||
void
|
||||
DiscardTracker::Remove(Node *node)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (node->isInList())
|
||||
node->remove();
|
||||
|
||||
@ -97,6 +96,8 @@ DiscardTracker::Remove(Node *node)
|
||||
void
|
||||
DiscardTracker::Shutdown()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (sTimer) {
|
||||
sTimer->Cancel();
|
||||
sTimer = NULL;
|
||||
@ -109,6 +110,8 @@ DiscardTracker::Shutdown()
|
||||
void
|
||||
DiscardTracker::DiscardAll()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!sInitialized)
|
||||
return;
|
||||
|
||||
@ -128,8 +131,12 @@ DiscardTracker::InformAllocation(PRInt64 bytes)
|
||||
{
|
||||
// This function is called back e.g. from RasterImage::Discard(); be careful!
|
||||
|
||||
MOZ_ASSERT(sInitialized);
|
||||
|
||||
PR_Lock(sAllocationLock);
|
||||
sCurrentDecodedImageBytes += bytes;
|
||||
MOZ_ASSERT(sCurrentDecodedImageBytes >= 0);
|
||||
PR_Unlock(sAllocationLock);
|
||||
|
||||
// If we're using too much memory for decoded images, MaybeDiscardSoon will
|
||||
// enqueue a callback to discard some images.
|
||||
@ -142,6 +149,8 @@ DiscardTracker::InformAllocation(PRInt64 bytes)
|
||||
nsresult
|
||||
DiscardTracker::Initialize()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Watch the timeout pref for changes.
|
||||
Preferences::RegisterCallback(DiscardTimeoutChangedCallback,
|
||||
sDiscardTimeoutPref);
|
||||
@ -153,6 +162,9 @@ DiscardTracker::Initialize()
|
||||
// Create the timer.
|
||||
sTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
|
||||
// Create a lock for safegarding the 64-bit sCurrentDecodedImageBytes
|
||||
sAllocationLock = PR_NewLock();
|
||||
|
||||
// Mark us as initialized
|
||||
sInitialized = true;
|
||||
|
||||
@ -275,10 +287,12 @@ DiscardTracker::MaybeDiscardSoon()
|
||||
// Are we carrying around too much decoded image data? If so, enqueue an
|
||||
// event to try to get us down under our limit.
|
||||
if (sCurrentDecodedImageBytes > sMaxDecodedImageKB * 1024 &&
|
||||
!sDiscardableImages.isEmpty() && !sDiscardRunnablePending) {
|
||||
sDiscardRunnablePending = true;
|
||||
nsRefPtr<DiscardRunnable> runnable = new DiscardRunnable();
|
||||
NS_DispatchToCurrentThread(runnable);
|
||||
!sDiscardableImages.isEmpty()) {
|
||||
// Check if the value of sDiscardRunnablePending used to be false
|
||||
if (!PR_ATOMIC_SET(&sDiscardRunnablePending, 1)) {
|
||||
nsRefPtr<DiscardRunnable> runnable = new DiscardRunnable();
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,32 +48,39 @@ class DiscardTracker
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Discard the decoded image data for all images tracked by the discard
|
||||
* tracker.
|
||||
* tracker. This function is main thread only.
|
||||
*/
|
||||
static void DiscardAll();
|
||||
|
||||
/**
|
||||
* Inform the discard tracker that we've allocated or deallocated some
|
||||
* 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);
|
||||
|
||||
@ -92,7 +99,6 @@ class DiscardTracker
|
||||
NS_IMETHOD Run();
|
||||
};
|
||||
|
||||
static nsresult Initialize();
|
||||
static void ReloadTimeout();
|
||||
static nsresult EnableTimer();
|
||||
static void DisableTimer();
|
||||
@ -104,10 +110,12 @@ class DiscardTracker
|
||||
static nsCOMPtr<nsITimer> sTimer;
|
||||
static bool sInitialized;
|
||||
static bool sTimerOn;
|
||||
static bool sDiscardRunnablePending;
|
||||
static PRInt32 sDiscardRunnablePending;
|
||||
static PRInt64 sCurrentDecodedImageBytes;
|
||||
static PRUint32 sMinDiscardTimeoutMs;
|
||||
static PRUint32 sMaxDecodedImageKB;
|
||||
// Lock for safegarding the 64-bit sCurrentDecodedImageBytes
|
||||
static PRLock *sAllocationLock;
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
|
@ -248,10 +248,9 @@ RasterImage::~RasterImage()
|
||||
num_discardable_containers,
|
||||
total_source_bytes,
|
||||
discardable_source_bytes));
|
||||
DiscardTracker::Remove(&mDiscardTrackerNode);
|
||||
}
|
||||
|
||||
DiscardTracker::Remove(&mDiscardTrackerNode);
|
||||
|
||||
// If we have a decoder open, shut it down
|
||||
if (mDecoder) {
|
||||
nsresult rv = ShutdownDecoder(eShutdownIntent_Interrupted);
|
||||
|
@ -49,7 +49,12 @@ ifeq (WINNT,$(OS_TARGET))
|
||||
FORCE_SHARED_LIB = 1
|
||||
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
|
||||
SHARED_LIBRARY_LIBS += $(MOZ_GRAPHITE_LIBS)
|
||||
|
@ -443,3 +443,43 @@ cairo_win32_surface_create_with_alpha
|
||||
cairo_win32_surface_get_height
|
||||
cairo_win32_surface_get_width
|
||||
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
|
||||
|
@ -324,14 +324,6 @@ public class AboutHomeContent extends ScrollView
|
||||
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) {
|
||||
// Ensure we initialize GeckoApp's startup mode in
|
||||
// background thread before we use it when updating
|
||||
@ -361,8 +353,6 @@ public class AboutHomeContent extends ScrollView
|
||||
mTopSitesAdapter.changeCursor(mCursor);
|
||||
}
|
||||
|
||||
mTopSitesGrid.setNumColumns(getNumberOfColumns());
|
||||
|
||||
updateLayout(startupMode, syncIsSetup);
|
||||
}
|
||||
});
|
||||
@ -396,8 +386,6 @@ public class AboutHomeContent extends ScrollView
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
if (mTopSitesGrid != null)
|
||||
mTopSitesGrid.setNumColumns(getNumberOfColumns());
|
||||
if (mTopSitesAdapter != null)
|
||||
mTopSitesAdapter.notifyDataSetChanged();
|
||||
|
||||
@ -709,13 +697,16 @@ public class AboutHomeContent extends ScrollView
|
||||
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_LANDSCAPE);
|
||||
numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_LANDSCAPE);
|
||||
setNumColumns(NUMBER_OF_COLS_LANDSCAPE);
|
||||
} else {
|
||||
nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_PORTRAIT);
|
||||
numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_PORTRAIT);
|
||||
setNumColumns(NUMBER_OF_COLS_PORTRAIT);
|
||||
}
|
||||
int expandedHeightSpec =
|
||||
MeasureSpec.makeMeasureSpec((int)(mDisplayDensity * numRows * kTopSiteItemHeight),
|
||||
MeasureSpec.EXACTLY);
|
||||
|
||||
super.onMeasure(widthMeasureSpec, expandedHeightSpec);
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +339,6 @@ EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NSS_LIBS) \
|
||||
$(MOZ_CAIRO_OSLIBS) \
|
||||
$(MOZ_HARFBUZZ_LIBS) \
|
||||
$(MOZ_APP_EXTRA_LIBS) \
|
||||
$(SQLITE_LIBS) \
|
||||
$(NULL)
|
||||
|
@ -1154,7 +1154,7 @@ AndroidBridge::CallEglCreateWindowSurface(void *dpy, void *config, AndroidGeckoS
|
||||
* 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)
|
||||
return nsnull;
|
||||
|
||||
|
@ -574,6 +574,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
JNIEnv* GetEnv() {
|
||||
return mJNIEnv;
|
||||
}
|
||||
|
||||
bool CheckForException() {
|
||||
if (mJNIEnv->ExceptionCheck()) {
|
||||
mJNIEnv->ExceptionDescribe();
|
||||
|
@ -736,12 +736,12 @@ AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float a
|
||||
}
|
||||
|
||||
jobject
|
||||
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap(JNIEnv *env, AutoLocalJNIFrame *jniFrame)
|
||||
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!env || !jniFrame)
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return nsnull;
|
||||
|
||||
jobject ret = env->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBitmapMethod);
|
||||
jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBitmapMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return nsnull;
|
||||
|
||||
@ -749,12 +749,12 @@ AndroidGeckoSurfaceView::GetSoftwareDrawBitmap(JNIEnv *env, AutoLocalJNIFrame *j
|
||||
}
|
||||
|
||||
jobject
|
||||
AndroidGeckoSurfaceView::GetSoftwareDrawBuffer(JNIEnv *env, AutoLocalJNIFrame *jniFrame)
|
||||
AndroidGeckoSurfaceView::GetSoftwareDrawBuffer(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!env || !jniFrame)
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return nsnull;
|
||||
|
||||
jobject ret = env->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBufferMethod);
|
||||
jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBufferMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return nsnull;
|
||||
|
||||
@ -762,12 +762,12 @@ AndroidGeckoSurfaceView::GetSoftwareDrawBuffer(JNIEnv *env, AutoLocalJNIFrame *j
|
||||
}
|
||||
|
||||
jobject
|
||||
AndroidGeckoSurfaceView::GetSurface(JNIEnv *env, AutoLocalJNIFrame *jniFrame)
|
||||
AndroidGeckoSurfaceView::GetSurface(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!env || !jniFrame)
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return nsnull;
|
||||
|
||||
jobject ret = env->CallObjectMethod(wrapped_obj, jGetSurfaceMethod);
|
||||
jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetSurfaceMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return nsnull;
|
||||
|
||||
@ -775,12 +775,12 @@ AndroidGeckoSurfaceView::GetSurface(JNIEnv *env, AutoLocalJNIFrame *jniFrame)
|
||||
}
|
||||
|
||||
jobject
|
||||
AndroidGeckoSurfaceView::GetSurfaceHolder(JNIEnv *env, AutoLocalJNIFrame *jniFrame)
|
||||
AndroidGeckoSurfaceView::GetSurfaceHolder(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!env || !jniFrame)
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return nsnull;
|
||||
|
||||
jobject ret = env->CallObjectMethod(wrapped_obj, jGetHolderMethod);
|
||||
jobject ret = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetHolderMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return nsnull;
|
||||
|
||||
@ -788,53 +788,96 @@ AndroidGeckoSurfaceView::GetSurfaceHolder(JNIEnv *env, AutoLocalJNIFrame *jniFra
|
||||
}
|
||||
|
||||
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);
|
||||
if (jniFrame.CheckForException())
|
||||
jobject frameJObj = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jCreateFrameMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
NS_ABORT_IF_FALSE(frameJObj, "No frame object!");
|
||||
|
||||
aFrame.Init(env, frameJObj);
|
||||
aFrame.Init(jniFrame->GetEnv(), frameJObj);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::ActivateProgram(JNIEnv *env)
|
||||
bool
|
||||
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
|
||||
AndroidGeckoLayerClient::DeactivateProgram(JNIEnv *env)
|
||||
bool
|
||||
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
|
||||
AndroidLayerRendererFrame::BeginDrawing(JNIEnv *env)
|
||||
bool
|
||||
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
|
||||
AndroidLayerRendererFrame::DrawBackground(JNIEnv *env)
|
||||
bool
|
||||
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
|
||||
AndroidLayerRendererFrame::DrawForeground(JNIEnv *env)
|
||||
bool
|
||||
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
|
||||
AndroidLayerRendererFrame::EndDrawing(JNIEnv *env)
|
||||
bool
|
||||
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
|
||||
|
@ -181,10 +181,10 @@ public:
|
||||
void Init(JNIEnv *env, jobject jobj);
|
||||
void Dispose(JNIEnv *env);
|
||||
|
||||
void BeginDrawing(JNIEnv *env);
|
||||
void DrawBackground(JNIEnv *env);
|
||||
void DrawForeground(JNIEnv *env);
|
||||
void EndDrawing(JNIEnv *env);
|
||||
bool BeginDrawing(AutoLocalJNIFrame *jniFrame);
|
||||
bool DrawBackground(AutoLocalJNIFrame *jniFrame);
|
||||
bool DrawForeground(AutoLocalJNIFrame *jniFrame);
|
||||
bool EndDrawing(AutoLocalJNIFrame *jniFrame);
|
||||
|
||||
private:
|
||||
static jclass jLayerRendererFrameClass;
|
||||
@ -208,9 +208,9 @@ public:
|
||||
void SetPageSize(float aZoom, float aPageWidth, float aPageHeight, float aCssPageWidth, float aCssPageHeight);
|
||||
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
|
||||
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
|
||||
bool CreateFrame(JNIEnv *env, AndroidLayerRendererFrame& aFrame);
|
||||
void ActivateProgram(JNIEnv *env);
|
||||
void DeactivateProgram(JNIEnv *env);
|
||||
bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
|
||||
bool ActivateProgram(AutoLocalJNIFrame *jniFrame);
|
||||
bool DeactivateProgram(AutoLocalJNIFrame *jniFrame);
|
||||
|
||||
protected:
|
||||
static jclass jGeckoLayerClientClass;
|
||||
@ -242,14 +242,14 @@ public:
|
||||
};
|
||||
|
||||
int BeginDrawing();
|
||||
jobject GetSoftwareDrawBitmap(JNIEnv *env, AutoLocalJNIFrame *jniFrame);
|
||||
jobject GetSoftwareDrawBuffer(JNIEnv *env, AutoLocalJNIFrame *jniFrame);
|
||||
jobject GetSoftwareDrawBitmap(AutoLocalJNIFrame *jniFrame);
|
||||
jobject GetSoftwareDrawBuffer(AutoLocalJNIFrame *jniFrame);
|
||||
void EndDrawing();
|
||||
void Draw2D(jobject bitmap, int width, int height);
|
||||
void Draw2D(jobject buffer, int stride);
|
||||
|
||||
jobject GetSurface(JNIEnv *env, AutoLocalJNIFrame *jniFrame);
|
||||
jobject GetSurfaceHolder(JNIEnv *env, AutoLocalJNIFrame *jniFrame);
|
||||
jobject GetSurface(AutoLocalJNIFrame *jniFrame);
|
||||
jobject GetSurfaceHolder(AutoLocalJNIFrame *jniFrame);
|
||||
|
||||
protected:
|
||||
static jclass jGeckoSurfaceViewClass;
|
||||
|
@ -917,7 +917,7 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
||||
if (env) {
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
jobject surface = sview.GetSurface(env, &jniFrame);
|
||||
jobject surface = sview.GetSurface(&jniFrame);
|
||||
if (surface) {
|
||||
sNativeWindow = AndroidBridge::Bridge()->AcquireNativeWindow(env, surface);
|
||||
if (sNativeWindow) {
|
||||
@ -1181,7 +1181,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
|
||||
AndroidBridge::Bridge()->UnlockWindow(sNativeWindow);
|
||||
} else if (AndroidBridge::Bridge()->HasNativeBitmapAccess()) {
|
||||
jobject bitmap = sview.GetSoftwareDrawBitmap(env, &jniFrame);
|
||||
jobject bitmap = sview.GetSoftwareDrawBitmap(&jniFrame);
|
||||
if (!bitmap) {
|
||||
ALOG("no bitmap to draw into - skipping draw");
|
||||
return;
|
||||
@ -1210,7 +1210,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
AndroidBridge::Bridge()->UnlockBitmap(bitmap);
|
||||
sview.Draw2D(bitmap, mBounds.width, mBounds.height);
|
||||
} else {
|
||||
jobject bytebuf = sview.GetSoftwareDrawBuffer(env, &jniFrame);
|
||||
jobject bytebuf = sview.GetSoftwareDrawBuffer(&jniFrame);
|
||||
if (!bytebuf) {
|
||||
ALOG("no buffer to draw into - skipping draw");
|
||||
return;
|
||||
@ -2233,15 +2233,11 @@ nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect)
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
if (!client.CreateFrame(env, mLayerRendererFrame))
|
||||
return;
|
||||
client.ActivateProgram(env);
|
||||
if (jniFrame.CheckForException()) return;
|
||||
mLayerRendererFrame.BeginDrawing(env);
|
||||
if (jniFrame.CheckForException()) return;
|
||||
mLayerRendererFrame.DrawBackground(env);
|
||||
if (jniFrame.CheckForException()) return;
|
||||
client.DeactivateProgram(env);
|
||||
if (!client.CreateFrame(&jniFrame, mLayerRendererFrame)) return;
|
||||
if (!client.ActivateProgram(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.BeginDrawing(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.DrawBackground(&jniFrame)) return;
|
||||
if (!client.DeactivateProgram(&jniFrame)) return; // redundant, but in case somebody adds code after this...
|
||||
}
|
||||
|
||||
void
|
||||
@ -2259,15 +2255,10 @@ nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect)
|
||||
|
||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
|
||||
client.ActivateProgram(env);
|
||||
if (jniFrame.CheckForException()) return;
|
||||
mLayerRendererFrame.DrawForeground(env);
|
||||
if (jniFrame.CheckForException()) return;
|
||||
mLayerRendererFrame.EndDrawing(env);
|
||||
if (jniFrame.CheckForException()) return;
|
||||
client.DeactivateProgram(env);
|
||||
if (jniFrame.CheckForException()) return;
|
||||
|
||||
if (!client.ActivateProgram(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.DrawForeground(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.EndDrawing(&jniFrame)) return;
|
||||
if (!client.DeactivateProgram(&jniFrame)) return;
|
||||
mLayerRendererFrame.Dispose(env);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user