Skip to content

Commit

Permalink
GOOD Merge commit '3290b08b017325f8e903c889ae796fce48d6e467' into emb…
Browse files Browse the repository at this point in the history
…edlite_upgrade_3290b08b017325f8e903c889ae796fce48d6e467.

Conflicts:
	gfx/gl/GLContextProviderGLX.cpp
  • Loading branch information
tmeshkova committed Jan 6, 2014
2 parents eb2dcea + 3290b08 commit db1501e
Show file tree
Hide file tree
Showing 1,440 changed files with 36,537 additions and 19,933 deletions.
6 changes: 5 additions & 1 deletion CLOBBER
Expand Up @@ -18,4 +18,8 @@
# Modifying this file will now automatically clobber the buildbot machines \o/
#

Bug 946067 required a clobber on Windows because bug 928195
# Are you updating CLOBBER because you think it's needed for your WebIDL
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.

Bug 932982 apparently requires a clobber or else we get B2G mochitest-2 failures.
2 changes: 1 addition & 1 deletion accessible/src/atk/AccessibleWrap.cpp
Expand Up @@ -692,7 +692,7 @@ getRoleCB(AtkObject *aAtkObj)
return aAtkObj->role;
}

AtkAttributeSet*
static AtkAttributeSet*
ConvertToAtkAttributeSet(nsIPersistentProperties* aAttributes)
{
if (!aAttributes)
Expand Down
86 changes: 83 additions & 3 deletions accessible/src/atk/nsMaiInterfaceText.cpp
Expand Up @@ -12,12 +12,87 @@

#include "nsIAccessibleTypes.h"
#include "nsIPersistentProperties2.h"
#include "nsISimpleEnumerator.h"

#include "mozilla/Likely.h"

using namespace mozilla;
using namespace mozilla::a11y;

AtkAttributeSet* ConvertToAtkAttributeSet(nsIPersistentProperties* aAttributes);
static const char* sAtkTextAttrNames[ATK_TEXT_ATTR_LAST_DEFINED];

static AtkAttributeSet*
ConvertToAtkTextAttributeSet(nsIPersistentProperties* aAttributes)
{
if (!aAttributes)
return nullptr;

AtkAttributeSet* objAttributeSet = nullptr;
nsCOMPtr<nsISimpleEnumerator> propEnum;
nsresult rv = aAttributes->Enumerate(getter_AddRefs(propEnum));
NS_ENSURE_SUCCESS(rv, nullptr);

bool hasMore = false;
while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> sup;
rv = propEnum->GetNext(getter_AddRefs(sup));
NS_ENSURE_SUCCESS(rv, objAttributeSet);

nsCOMPtr<nsIPropertyElement> propElem(do_QueryInterface(sup));
NS_ENSURE_TRUE(propElem, objAttributeSet);

nsAutoCString name;
rv = propElem->GetKey(name);
NS_ENSURE_SUCCESS(rv, objAttributeSet);

nsAutoString value;
rv = propElem->GetValue(value);
NS_ENSURE_SUCCESS(rv, objAttributeSet);

AtkAttribute* objAttr = (AtkAttribute*)g_malloc(sizeof(AtkAttribute));
objAttr->name = g_strdup(name.get());
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(value).get());
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);

// Handle attributes where atk has its own name.
const char* atkName = nullptr;
nsAutoString atkValue;
if (name.EqualsLiteral("color")) {
// The format of the atk attribute is r,g,b and the gecko one is
// rgb(r,g,b).
atkValue = Substring(value, 5, value.Length() - 1);
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_FG_COLOR];
} else if (name.EqualsLiteral("background-color")) {
// The format of the atk attribute is r,g,b and the gecko one is
// rgb(r,g,b).
atkValue = Substring(value, 5, value.Length() - 1);
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_BG_COLOR];
} else if (name.EqualsLiteral("font-family")) {
atkValue = value;
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_FAMILY_NAME];
} else if (name.Equals("font-size")) {
// ATK wants the number of pixels without px at the end.
atkValue = StringHead(value, value.Length() - 2);
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_SIZE];
} else if (name.EqualsLiteral("font-weight")) {
atkValue = value;
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_WEIGHT];
} else if (name.EqualsLiteral("invalid")) {
atkValue = value;
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_INVALID];
}

if (atkName) {
objAttr = static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
objAttr->name = g_strdup(atkName);
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(atkValue).get());
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
}
}

// libatk-adaptor will free it
return objAttributeSet;
}

static void
ConvertTexttoAsterisks(AccessibleWrap* accWrap, nsAString& aString)
Expand Down Expand Up @@ -188,7 +263,7 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
*aStartOffset = startOffset;
*aEndOffset = endOffset;

return ConvertToAtkAttributeSet(attributes);
return ConvertToAtkTextAttributeSet(attributes);
}

static AtkAttributeSet*
Expand All @@ -203,7 +278,7 @@ getDefaultAttributesCB(AtkText *aText)
return nullptr;

nsCOMPtr<nsIPersistentProperties> attributes = text->DefaultTextAttributes();
return ConvertToAtkAttributeSet(attributes);
return ConvertToAtkTextAttributeSet(attributes);
}

static void
Expand Down Expand Up @@ -415,4 +490,9 @@ textInterfaceInitCB(AtkTextIface* aIface)
aIface->remove_selection = removeTextSelectionCB;
aIface->set_selection = setTextSelectionCB;
aIface->set_caret_offset = setCaretOffsetCB;

// Cache the string values of the atk text attribute names.
for (uint32_t i = 0; i < ArrayLength(sAtkTextAttrNames); i++)
sAtkTextAttrNames[i] =
atk_text_attribute_get_name(static_cast<AtkTextAttribute>(i));
}
93 changes: 54 additions & 39 deletions accessible/src/generic/HyperTextAccessible.cpp
Expand Up @@ -548,14 +548,34 @@ HyperTextAccessible::DOMPointToHypertextOffset(nsINode* aNode,
return nullptr;
}

nsresult
HyperTextAccessible::HypertextOffsetsToDOMRange(int32_t aStartHTOffset,
int32_t aEndHTOffset,
nsRange* aRange)
bool
HyperTextAccessible::OffsetsToDOMRange(int32_t aStartOffset, int32_t aEndOffset,
nsRange* aRange)
{
DOMPoint startPoint = OffsetToDOMPoint(aStartOffset);
if (!startPoint.node)
return false;

aRange->SetStart(startPoint.node, startPoint.idx);
if (aStartOffset == aEndOffset) {
aRange->SetEnd(startPoint.node, startPoint.idx);
return true;
}

DOMPoint endPoint = OffsetToDOMPoint(aEndOffset);
if (!endPoint.node)
return false;

aRange->SetEnd(endPoint.node, endPoint.idx);
return true;
}

DOMPoint
HyperTextAccessible::OffsetToDOMPoint(int32_t aOffset)
{
// If the given offsets are 0 and associated editor is empty then return
// collapsed range with editor root element as range container.
if (aStartHTOffset == 0 && aEndHTOffset == 0) {
// 0 offset is valid even if no children. In this case the associated editor
// is empty so return a DOM point for editor root element.
if (aOffset == 0) {
nsCOMPtr<nsIEditor> editor = GetEditor();
if (editor) {
bool isEmpty = false;
Expand All @@ -565,40 +585,36 @@ HyperTextAccessible::HypertextOffsetsToDOMRange(int32_t aStartHTOffset,
editor->GetRootElement(getter_AddRefs(editorRootElm));

nsCOMPtr<nsINode> editorRoot(do_QueryInterface(editorRootElm));
if (editorRoot) {
aRange->SetStart(editorRoot, 0);
aRange->SetEnd(editorRoot, 0);

return NS_OK;
}
return DOMPoint(editorRoot, 0);
}
}
}

nsRefPtr<Accessible> startAcc, endAcc;
int32_t startOffset = aStartHTOffset, endOffset = aEndHTOffset;
nsIFrame *startFrame = nullptr, *endFrame = nullptr;

startFrame = GetPosAndText(startOffset, endOffset, nullptr, &endFrame,
getter_AddRefs(startAcc), getter_AddRefs(endAcc));
if (!startAcc || !endAcc)
return NS_ERROR_FAILURE;

DOMPoint startPoint, endPoint;
nsresult rv = GetDOMPointByFrameOffset(startFrame, startOffset, startAcc,
&startPoint);
NS_ENSURE_SUCCESS(rv, rv);
int32_t childIdx = GetChildIndexAtOffset(aOffset);
if (childIdx == -1)
return DOMPoint();

rv = aRange->SetStart(startPoint.node, startPoint.idx);
NS_ENSURE_SUCCESS(rv, rv);
Accessible* child = GetChildAt(childIdx);
int32_t innerOffset = aOffset - GetChildOffset(childIdx);

if (aStartHTOffset == aEndHTOffset)
return aRange->SetEnd(startPoint.node, startPoint.idx);
// A text leaf case. The point is inside the text node.
if (child->IsTextLeaf()) {
nsIContent* content = child->GetContent();
int32_t idx = 0;
if (NS_FAILED(RenderedToContentOffset(content->GetPrimaryFrame(),
innerOffset, &idx)))
return DOMPoint();

rv = GetDOMPointByFrameOffset(endFrame, endOffset, endAcc, &endPoint);
NS_ENSURE_SUCCESS(rv, rv);
return DOMPoint(content, idx);
}

return aRange->SetEnd(endPoint.node, endPoint.idx);
// Case of embedded object. The point is either before or after the element.
NS_ASSERTION(innerOffset == 0 || innerOffset == 1, "A wrong inner offset!");
nsINode* node = child->GetNode();
nsINode* parentNode = node->GetParentNode();
return parentNode ?
DOMPoint(parentNode, parentNode->IndexOf(node) + innerOffset) :
DOMPoint();
}

int32_t
Expand Down Expand Up @@ -1580,7 +1596,8 @@ HyperTextAccessible::SetSelectionBoundsAt(int32_t aSelectionNum,
if (!range)
return false;

HypertextOffsetsToDOMRange(startOffset, endOffset, range);
if (!OffsetsToDOMRange(startOffset, endOffset, range))
return false;

// If new range was created then add it, otherwise notify selection listeners
// that existing selection range was changed.
Expand Down Expand Up @@ -1610,8 +1627,7 @@ HyperTextAccessible::ScrollSubstringTo(int32_t aStartOffset, int32_t aEndOffset,
uint32_t aScrollType)
{
nsRefPtr<nsRange> range = new nsRange(mContent);
nsresult rv = HypertextOffsetsToDOMRange(aStartOffset, aEndOffset, range);
if (NS_SUCCEEDED(rv))
if (OffsetsToDOMRange(aStartOffset, aEndOffset, range))
nsCoreUtils::ScrollSubstringTo(GetFrame(), range, aScrollType);
}

Expand All @@ -1629,8 +1645,7 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
this);

nsRefPtr<nsRange> range = new nsRange(mContent);
nsresult rv = HypertextOffsetsToDOMRange(aStartOffset, aEndOffset, range);
if (NS_FAILED(rv))
if (!OffsetsToDOMRange(aStartOffset, aEndOffset, range))
return;

nsPresContext* presContext = frame->PresContext();
Expand Down Expand Up @@ -1658,7 +1673,7 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
int16_t hPercent = offsetPointX * 100 / size.width;
int16_t vPercent = offsetPointY * 100 / size.height;

rv = nsCoreUtils::ScrollSubstringTo(frame, range, vPercent, hPercent);
nsresult rv = nsCoreUtils::ScrollSubstringTo(frame, range, vPercent, hPercent);
if (NS_FAILED(rv))
return;

Expand Down
26 changes: 19 additions & 7 deletions accessible/src/generic/HyperTextAccessible.h
Expand Up @@ -17,6 +17,9 @@ namespace mozilla {
namespace a11y {

struct DOMPoint {
DOMPoint() : node(nullptr), idx(0) { }
DOMPoint(nsINode* aNode, int32_t aIdx) : node(aNode), idx(aIdx) { }

nsINode* node;
int32_t idx;
};
Expand Down Expand Up @@ -128,15 +131,24 @@ class HyperTextAccessible : public AccessibleWrap,
bool aIsEndOffset = false) const;

/**
* Turn a start and end hypertext offsets into DOM range.
* Convert start and end hypertext offsets into DOM range.
*
* @param aStartOffset [in] the given start hypertext offset
* @param aEndOffset [in] the given end hypertext offset
* @param aRange [in, out] the range whose bounds to set
* @return true if conversion was successful
*/
bool OffsetsToDOMRange(int32_t aStartOffset, int32_t aEndOffset,
nsRange* aRange);

/**
* Convert the given offset into DOM point.
*
* @param aStartHTOffset [in] the given start hypertext offset
* @param aEndHTOffset [in] the given end hypertext offset
* @param aRange [out] the range whose bounds to set
* If offset is at text leaf then DOM point is (text node, offsetInTextNode),
* if before embedded object then (parent node, indexInParent), if after then
* (parent node, indexInParent + 1).
*/
nsresult HypertextOffsetsToDOMRange(int32_t aStartHTOffset,
int32_t aEndHTOffset,
nsRange* aRange);
DOMPoint OffsetToDOMPoint(int32_t aOffset);

/**
* Return true if the used ARIA role (if any) allows the hypertext accessible
Expand Down
5 changes: 2 additions & 3 deletions accessible/src/html/HTMLFormControlAccessible.cpp
Expand Up @@ -14,7 +14,6 @@
#include "States.h"

#include "nsContentList.h"
#include "nsCxPusher.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "nsIAccessibleRelation.h"
#include "nsIDOMNSEditableElement.h"
Expand All @@ -26,6 +25,7 @@
#include "nsISelectionController.h"
#include "nsIServiceManager.h"
#include "nsITextControlFrame.h"
#include "mozilla/dom/ScriptSettings.h"

#include "mozilla/FloatingPoint.h"
#include "mozilla/Preferences.h"
Expand Down Expand Up @@ -468,8 +468,7 @@ HTMLTextFieldAccessible::GetEditor() const
// nsGenericHTMLElement::GetEditor has a security check.
// Make sure we're not restricted by the permissions of
// whatever script is currently running.
nsCxPusher pusher;
pusher.PushNull();
mozilla::dom::AutoSystemCaller asc;

nsCOMPtr<nsIEditor> editor;
editableElt->GetEditor(getter_AddRefs(editor));
Expand Down
20 changes: 12 additions & 8 deletions accessible/src/jsat/AccessFu.jsm
Expand Up @@ -118,8 +118,8 @@ this.AccessFu = {
Output.start();
TouchAdapter.start();

Services.obs.addObserver(this, 'remote-browser-frame-shown', false);
Services.obs.addObserver(this, 'in-process-browser-or-app-frame-shown', false);
Services.obs.addObserver(this, 'remote-browser-shown', false);
Services.obs.addObserver(this, 'inprocess-browser-shown', false);
Services.obs.addObserver(this, 'Accessibility:NextObject', false);
Services.obs.addObserver(this, 'Accessibility:PreviousObject', false);
Services.obs.addObserver(this, 'Accessibility:Focus', false);
Expand Down Expand Up @@ -162,8 +162,8 @@ this.AccessFu = {
Utils.win.removeEventListener('TabClose', this);
Utils.win.removeEventListener('TabSelect', this);

Services.obs.removeObserver(this, 'remote-browser-frame-shown');
Services.obs.removeObserver(this, 'in-process-browser-or-app-frame-shown');
Services.obs.removeObserver(this, 'remote-browser-shown');
Services.obs.removeObserver(this, 'inprocess-browser-shown');
Services.obs.removeObserver(this, 'Accessibility:NextObject');
Services.obs.removeObserver(this, 'Accessibility:PreviousObject');
Services.obs.removeObserver(this, 'Accessibility:Focus');
Expand Down Expand Up @@ -304,11 +304,15 @@ this.AccessFu = {
case 'Accessibility:MoveByGranularity':
this.Input.moveByGranularity(JSON.parse(aData));
break;
case 'remote-browser-frame-shown':
case 'in-process-browser-or-app-frame-shown':
case 'remote-browser-shown':
case 'inprocess-browser-shown':
{
let mm = aSubject.QueryInterface(Ci.nsIFrameLoader).messageManager;
this._handleMessageManager(mm);
// Ignore notifications that aren't from a BrowserOrApp
let frameLoader = aSubject.QueryInterface(Ci.nsIFrameLoader);
if (!frameLoader.ownerIsBrowserOrAppFrame) {
return;
}
this._handleMessageManager(frameLoader.messageManager);
break;
}
}
Expand Down

0 comments on commit db1501e

Please sign in to comment.