Skip to content

Commit

Permalink
Merge mozilla-central to autoland. a=merge on a CLOSED TREE
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreeaPavel committed Apr 26, 2018
2 parents a740ab9 + bc57d2a commit c3ac64e
Show file tree
Hide file tree
Showing 394 changed files with 4,514 additions and 5,071 deletions.
5 changes: 3 additions & 2 deletions accessible/base/TextAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,9 +656,10 @@ TextAttrsMgr::FontWeightTextAttr::
// which may not be the weight of the font face used to render the
// characters. On Mac, font->GetStyle()->weight will just give the same
// number as getComputedStyle(). fontEntry->Weight() will give the weight
// of the font face used.
// range supported by the font face used, so we clamp the weight that was
// requested by style to what is actually supported by the font.
gfxFontEntry *fontEntry = font->GetFontEntry();
return fontEntry->Weight();
return fontEntry->Weight().Clamp(font->GetStyle()->weight);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions accessible/generic/Accessible-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ Accessible::InsertAfter(Accessible* aNewChild, Accessible* aRefChild)
aNewChild);
}

inline nsIntRect
Accessible::Bounds() const
{
return BoundsInAppUnits().ToNearestPixels(mDoc->PresContext()->AppUnitsPerDevPixel());
}

} // namespace a11y
} // namespace mozilla

Expand Down
31 changes: 15 additions & 16 deletions accessible/generic/Accessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,32 +670,31 @@ Accessible::RelativeBounds(nsIFrame** aBoundingFrame) const
return nsRect();
}

nsIntRect
Accessible::Bounds() const
nsRect
Accessible::BoundsInAppUnits() const
{
nsIFrame* boundingFrame = nullptr;
nsRect unionRectTwips = RelativeBounds(&boundingFrame);
if (!boundingFrame)
return nsIntRect();

nsIntRect screenRect;
nsPresContext* presContext = mDoc->PresContext();
screenRect.SetRect(presContext->AppUnitsToDevPixels(unionRectTwips.X()),
presContext->AppUnitsToDevPixels(unionRectTwips.Y()),
presContext->AppUnitsToDevPixels(unionRectTwips.Width()),
presContext->AppUnitsToDevPixels(unionRectTwips.Height()));
if (!boundingFrame) {
return nsRect();
}

// We need to take into account a non-1 resolution set on the presshell.
// This happens in mobile platforms with async pinch zooming. Here we
// scale the bounds before adding the screen-relative offset.
screenRect.ScaleRoundOut(presContext->PresShell()->GetResolution());
unionRectTwips.ScaleRoundOut(mDoc->PresContext()->PresShell()->GetResolution());
// We have the union of the rectangle, now we need to put it in absolute
// screen coords.
nsIntRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits().
ToNearestPixels(presContext->AppUnitsPerDevPixel());
screenRect.MoveBy(orgRectPixels.X(), orgRectPixels.Y());
nsRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits();
unionRectTwips.MoveBy(orgRectPixels.X(), orgRectPixels.Y());

return screenRect;
return unionRectTwips;
}

nsIntRect
Accessible::BoundsInCSSPixels() const
{
return BoundsInAppUnits().ToNearestPixels(mDoc->PresContext()->AppUnitsPerCSSPixel());
}

void
Expand Down
12 changes: 11 additions & 1 deletion accessible/generic/Accessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,20 @@ class Accessible : public nsISupports
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
uint32_t aLength = UINT32_MAX);

/**
* Return boundaries in screen coordinates in app units.
*/
virtual nsRect BoundsInAppUnits() const;

/**
* Return boundaries in screen coordinates.
*/
virtual nsIntRect Bounds() const;
nsIntRect Bounds() const;

/**
* Return boundaries in screen coordinates in CSS pixels.
*/
virtual nsIntRect BoundsInCSSPixels() const;

/**
* Return boundaries rect relative the bounding frame.
Expand Down
6 changes: 3 additions & 3 deletions accessible/generic/ApplicationAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ ApplicationAccessible::RelationByType(RelationType aRelationType)
return Relation();
}

nsIntRect
ApplicationAccessible::Bounds() const
nsRect
ApplicationAccessible::BoundsInAppUnits() const
{
return nsIntRect();
return nsRect();
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion accessible/generic/ApplicationAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ApplicationAccessible : public AccessibleWrap

// Accessible
virtual void Shutdown() override;
virtual nsIntRect Bounds() const override;
virtual nsRect BoundsInAppUnits() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual GroupPos GroupPosition() override;
virtual ENameValueFlag Name(nsString& aName) override;
Expand Down
12 changes: 6 additions & 6 deletions accessible/html/HTMLListAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ HTMLLIAccessible::NativeState()
return HyperTextAccessibleWrap::NativeState() | states::READONLY;
}

nsIntRect
HTMLLIAccessible::Bounds() const
nsRect
HTMLLIAccessible::BoundsInAppUnits() const
{
nsIntRect rect = AccessibleWrap::Bounds();
if (rect.IsEmpty() || !mBullet || mBullet->IsInside())
nsRect rect = AccessibleWrap::BoundsInAppUnits();
if (rect.IsEmpty() || !mBullet || mBullet->IsInside()) {
return rect;
}

nsIntRect bulletRect = mBullet->Bounds();

nsRect bulletRect = mBullet->BoundsInAppUnits();
// Move x coordinate of list item over to cover bullet as well
rect.SetLeftEdge(bulletRect.X());
return rect;
Expand Down
2 changes: 1 addition & 1 deletion accessible/html/HTMLListAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class HTMLLIAccessible : public HyperTextAccessibleWrap

// Accessible
virtual void Shutdown() override;
virtual nsIntRect Bounds() const override;
virtual nsRect BoundsInAppUnits() const override;
virtual a11y::role NativeRole() override;
virtual uint64_t NativeState() override;

Expand Down
4 changes: 4 additions & 0 deletions accessible/interfaces/gecko/IGeckoCustom.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ interface IGeckoCustom : IUnknown
{
[propget] HRESULT ID([out, retval] unsigned __int64* aID);
[propget] HRESULT anchorCount([out, retval] long* aCount);
[propget] HRESULT boundsInCSSPixels([out] __int32* aX,
[out] __int32* aY,
[out] __int32* aWidth,
[out, retval] __int32* aHeight);
[propget] HRESULT DOMNodeID([out, retval] BSTR* aID);
[propget] HRESULT minimumIncrement([out, retval] double* aIncrement);
[propget] HRESULT mozState([out, retval] unsigned __int64* aState);
Expand Down
16 changes: 11 additions & 5 deletions accessible/interfaces/nsIAccessible.idl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class Accessible;
%}

/**
* A cross-platform interface that supports platform-specific
* A cross-platform interface that supports platform-specific
* accessibility APIs like MSAA and ATK. Contains the sum of what's needed
* to support IAccessible as well as ATK's generic accessibility objects.
* Can also be used by in-process accessibility clients to get information
* about objects in the accessible tree. The accessible tree is a subset of
* about objects in the accessible tree. The accessible tree is a subset of
* nodes in the DOM tree -- such as documents, focusable elements and text.
* Mozilla creates the implementations of nsIAccessible on demand.
* See http://www.mozilla.org/projects/ui/accessibility for more information.
Expand Down Expand Up @@ -56,7 +56,7 @@ interface nsIAccessible : nsISupports
* Last child in accessible tree
*/
readonly attribute nsIAccessible lastChild;

/**
* Array of all this element's children.
*/
Expand Down Expand Up @@ -124,7 +124,7 @@ interface nsIAccessible : nsISupports
/**
* Provides localized string of accesskey name, such as Alt+D.
* The modifier may be affected by user and platform preferences.
* Usually alt+letter, or just the letter alone for menu items.
* Usually alt+letter, or just the letter alone for menu items.
*/
readonly attribute AString accessKey;

Expand Down Expand Up @@ -226,10 +226,16 @@ interface nsIAccessible : nsISupports

/**
* Return accessible's x and y coordinates relative to the screen and
* accessible's width and height.
* accessible's width and height in Dev pixels.
*/
void getBounds(out long x, out long y, out long width, out long height);

/**
* Return accessible's x and y coordinates relative to the screen and
* accessible's width and height in CSS pixels.
*/
void getBoundsInCSSPixels(out long aX, out long aY, out long aWidth, out long aHeight);

/**
* Add or remove this accessible to the current selection
*/
Expand Down
1 change: 1 addition & 0 deletions accessible/ipc/ProxyAccessibleShared.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ ProxyAccessible* FocusedChild();
ProxyAccessible* ChildAtPoint(int32_t aX, int32_t aY,
Accessible::EWhichChildAtPoint aWhichChild);
nsIntRect Bounds();
nsIntRect BoundsInCSSPixels();

void Language(nsString& aLocale);
void DocType(nsString& aType);
Expand Down
24 changes: 24 additions & 0 deletions accessible/ipc/other/DocAccessibleChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,30 @@ DocAccessibleChild::RecvExtents(const uint64_t& aID,
return IPC_OK();
}

mozilla::ipc::IPCResult
DocAccessibleChild::RecvExtentsInCSSPixels(const uint64_t& aID,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight)
{
*aX = 0;
*aY = 0;
*aWidth = 0;
*aHeight = 0;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct()) {
nsIntRect screenRect = acc->BoundsInCSSPixels();
if (!screenRect.IsEmpty()) {
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
}
}
return IPC_OK();
}

mozilla::ipc::IPCResult
DocAccessibleChild::RecvDOMNodeID(const uint64_t& aID, nsString* aDOMNodeID)
{
Expand Down
5 changes: 5 additions & 0 deletions accessible/ipc/other/DocAccessibleChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ class DocAccessibleChild : public DocAccessibleChildBase
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight) override;
virtual mozilla::ipc::IPCResult RecvExtentsInCSSPixels(const uint64_t& aID,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight) override;
virtual mozilla::ipc::IPCResult RecvDOMNodeID(const uint64_t& aID, nsString* aDOMNodeID) override;
private:

Expand Down
2 changes: 2 additions & 0 deletions accessible/ipc/other/PDocAccessible.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ child:

nested(inside_sync) sync Extents(uint64_t aID, bool aNeedsScreenCoords)
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
nested(inside_sync) sync ExtentsInCSSPixels(uint64_t aID)
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
nested(inside_sync) sync DOMNodeID(uint64_t aID) returns(nsString aDOMNodeID);
};

Expand Down
10 changes: 10 additions & 0 deletions accessible/ipc/other/ProxyAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,16 @@ ProxyAccessible::Bounds()
return rect;
}

nsIntRect
ProxyAccessible::BoundsInCSSPixels()
{
nsIntRect rect;
Unused << mDoc->SendExtentsInCSSPixels(mID,
&rect.x, &rect.y,
&rect.width, &rect.height);
return rect;
}

void
ProxyAccessible::Language(nsString& aLocale)
{
Expand Down
13 changes: 13 additions & 0 deletions accessible/ipc/win/ProxyAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ ProxyAccessible::Bounds()
return rect;
}

nsIntRect
ProxyAccessible::BoundsInCSSPixels()
{
RefPtr<IGeckoCustom> custom = QueryInterface<IGeckoCustom>(this);
if (!custom) {
return nsIntRect();
}

nsIntRect rect;
HRESULT hr = custom->get_boundsInCSSPixels(&rect.x, &rect.y, &rect.width, &rect.height);
return rect;
}

void
ProxyAccessible::Language(nsString& aLocale)
{
Expand Down
6 changes: 3 additions & 3 deletions accessible/jsat/Constants.jsm
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");

var EXPORTED_SYMBOLS = ["Roles", "Events", "Relations",
"Filters", "States", "Prefilters", "AndroidEvents"];

const AndroidEvents = {
ANDROID_VIEW_CLICKED: 0x01,
ANDROID_VIEW_LONG_CLICKED: 0x02,
Expand Down Expand Up @@ -70,3 +67,6 @@ XPCOMUtils.defineLazyGetter(
(val) => { return { base: 0, extended: val }; });
return statesMap;
});

var EXPORTED_SYMBOLS = ["Roles", "Events", "Relations",
"Filters", "States", "Prefilters", "AndroidEvents"];
2 changes: 0 additions & 2 deletions accessible/jsat/ContentControl.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.defineModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(this, "Utils",
"resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "Logger",
Expand Down
4 changes: 0 additions & 4 deletions accessible/jsat/Presentation.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
"use strict";

ChromeUtils.import("resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "Logger", // jshint ignore:line
"resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "PivotContext", // jshint ignore:line
"resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "UtteranceGenerator", // jshint ignore:line
"resource://gre/modules/accessibility/OutputGenerator.jsm");
ChromeUtils.defineModuleGetter(this, "Roles", // jshint ignore:line
"resource://gre/modules/accessibility/Constants.jsm");
ChromeUtils.defineModuleGetter(this, "States", // jshint ignore:line
"resource://gre/modules/accessibility/Constants.jsm");
ChromeUtils.defineModuleGetter(this, "AndroidEvents", // jshint ignore:line
Expand Down
7 changes: 5 additions & 2 deletions accessible/tests/browser/bounds/browser_test_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/* import-globals-from ../../mochitest/layout.js */

/* global getContentDPR */

async function getContentBoundsForDOMElm(browser, id) {
return ContentTask.spawn(browser, id, contentId => {
this.ok = ok;
Expand All @@ -17,12 +19,13 @@ async function testContentBounds(browser, acc) {
let [expectedX, expectedY, expectedWidth, expectedHeight] =
await getContentBoundsForDOMElm(browser, getAccessibleDOMNodeID(acc));

let [x, y, width, height] = getBounds(acc);
let contentDPR = await getContentDPR(browser);
let [x, y, width, height] = getBounds(acc, contentDPR);
let prettyAccName = prettyName(acc);
is(x, expectedX, "Wrong x coordinate of " + prettyAccName);
is(y, expectedY, "Wrong y coordinate of " + prettyAccName);
is(width, expectedWidth, "Wrong width of " + prettyAccName);
is(height, expectedHeight, "Wrong height of " + prettyAccName);
ok(height >= expectedHeight, "Wrong height of " + prettyAccName);
}

async function runTests(browser, accDoc) {
Expand Down
Loading

0 comments on commit c3ac64e

Please sign in to comment.