[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge autoland to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ncsoregi committed Aug 8, 2018
2 parents 0338d36 + 1e7cd92 commit 5962fb2
Show file tree
Hide file tree
Showing 57 changed files with 1,083 additions and 340 deletions.
11 changes: 8 additions & 3 deletions browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,15 @@
if (draggedTab && dropEffect == "copy") {
// copy the dropped tab (wherever it's from)
let newIndex = this._getDropIndex(event, false);
let newTab = gBrowser.duplicateTab(draggedTab);
gBrowser.moveTabTo(newTab, newIndex);
let draggedTabCopy;
for (let tab of movingTabs) {
let newTab = gBrowser.duplicateTab(tab);
gBrowser.moveTabTo(newTab, newIndex++);
if (tab == draggedTab)
draggedTabCopy = newTab;
}
if (draggedTab.parentNode != this || event.shiftKey) {
this.selectedItem = newTab;
this.selectedItem = draggedTabCopy;
}
} else if (draggedTab && draggedTab.parentNode == this) {
let oldTranslateX = Math.round(draggedTab._dragData.translateX);
Expand Down
1 change: 1 addition & 0 deletions browser/base/content/test/tabs/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ support-files =
[browser_multiselect_tabs_close_tabs_to_the_right.js]
[browser_multiselect_tabs_close_using_shortcuts.js]
[browser_multiselect_tabs_close.js]
[browser_multiselect_tabs_copy_through_drag_and_drop.js]
[browser_multiselect_tabs_event.js]
[browser_multiselect_tabs_move_to_new_window_contextmenu.js]
[browser_multiselect_tabs_mute_unmute.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const PREF_MULTISELECT_TABS = "browser.tabs.multiselect";
function url(tab) {
return tab.linkedBrowser.currentURI.spec;
}

add_task(async function setPref() {
await SpecialPowers.pushPrefEnv({
set: [[PREF_MULTISELECT_TABS, true]]
});
});

add_task(async function test() {
let tab0 = gBrowser.selectedTab;
let tab1 = await addTab("http://example.com/1");
let tab2 = await addTab("http://example.com/2");
let tab3 = await addTab("http://example.com/3");
let tabs = [tab0, tab1, tab2, tab3];

await BrowserTestUtils.switchTab(gBrowser, tab1);
await triggerClickOn(tab2, { ctrlKey: true });

is(gBrowser.selectedTab, tab1, "Tab1 is active");
is(gBrowser.selectedTabs.length, 2, "Two selected tabs");
is(gBrowser.visibleTabs.length, 4, "Four tabs in window before copy");

for (let i of [1, 2]) {
ok(tabs[i].multiselected, "Tab" + i + " is multiselected");
}
for (let i of [0, 3]) {
ok(!tabs[i].multiselected, "Tab" + i + " is not multiselected");
}

await dragAndDrop(tab1, tab3, true);

is(gBrowser.selectedTab, tab1, "tab1 is still active");
is(gBrowser.selectedTabs.length, 2, "Two selected tabs");
is(gBrowser.visibleTabs.length, 6, "Six tabs in window after copy");

let tab4 = gBrowser.visibleTabs[4];
let tab5 = gBrowser.visibleTabs[5];
tabs.push(tab4);
tabs.push(tab5);

for (let i of [1, 2]) {
ok(tabs[i].multiselected, "Tab" + i + " is multiselected");
}
for (let i of [0, 3, 4, 5]) {
ok(!tabs[i].multiselected, "Tab" + i + " is not multiselected");
}

await BrowserTestUtils.waitForCondition(() => url(tab4) == url(tab1));
await BrowserTestUtils.waitForCondition(() => url(tab5) == url(tab2));

ok(true, "Tab1 and tab2 are duplicated succesfully");

for (let tab of tabs.filter(t => t != tab0))
BrowserTestUtils.removeTab(tab);
});

5 changes: 2 additions & 3 deletions browser/base/content/test/tabs/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ function triggerClickOn(target, options) {
return promise;
}

async function addTab() {
const tab = BrowserTestUtils.addTab(gBrowser,
"http://mochi.test:8888/", { skipAnimation: true });
async function addTab(url = "http://mochi.test:8888/") {
const tab = BrowserTestUtils.addTab(gBrowser, url, { skipAnimation: true });
const browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return tab;
Expand Down
41 changes: 27 additions & 14 deletions build/unix/elfhack/elfhack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,25 +1095,38 @@ int do_relocation_section(Elf *elf, unsigned int rel_type, unsigned int rel_type
ElfSection* eh_frame_hdr = eh_frame_segment ? eh_frame_segment->getFirstSection() : nullptr;
// The .eh_frame section usually follows the eh_frame_hdr section.
ElfSection* eh_frame = eh_frame_hdr ? eh_frame_hdr->getNext() : nullptr;
if (eh_frame_hdr && !eh_frame) {
throw std::runtime_error("Expected to find an .eh_frame section after .eh_frame_hdr");
ElfSection* first = eh_frame_hdr;
ElfSection* second = eh_frame;
if (eh_frame && strcmp(eh_frame->getName(), ".eh_frame")) {
// But sometimes it appears *before* the eh_frame_hdr section.
eh_frame = eh_frame_hdr->getPrevious();
first = eh_frame;
second = eh_frame_hdr;
}
if (eh_frame && strcmp(eh_frame->getName(), ".eh_frame") == 0) {
if (eh_frame_hdr && (!eh_frame || strcmp(eh_frame->getName(), ".eh_frame"))) {
throw std::runtime_error("Expected to find an .eh_frame section adjacent to .eh_frame_hdr");
}
if (eh_frame && first->getAddr() > relhack->getAddr() && second->getAddr() < relhackcode->getAddr()) {
// The distance between both sections needs to be preserved because eh_frame_hdr
// contains relative offsets to eh_frame. Well, they could be relocated too, but
// it's not worth the effort for the few number of bytes this would save.
size_t distance = eh_frame->getAddr() - eh_frame_hdr->getAddr();
ElfSection* previous = eh_frame_hdr->getPrevious();
eh_frame_hdr->getShdr().sh_addr =
(previous->getAddr() + previous->getSize() + eh_frame_hdr->getAddrAlign() - 1)
& ~(eh_frame_hdr->getAddrAlign() - 1);
unsigned int distance = second->getAddr() - first->getAddr();
unsigned int origAddr = eh_frame->getAddr();
eh_frame->getShdr().sh_addr =
(eh_frame_hdr->getAddr() + eh_frame_hdr->getSize() + eh_frame->getAddrAlign() - 1)
& ~(eh_frame->getAddrAlign() - 1);
// Re-adjust the eh_frame_hdr address to keep the original distance.
eh_frame_hdr->getShdr().sh_addr = eh_frame->getAddr() - distance;
eh_frame_hdr->markDirty();
ElfSection* previous = first->getPrevious();
first->getShdr().sh_addr =
(previous->getAddr() + previous->getSize() + first->getAddrAlign() - 1)
& ~(first->getAddrAlign() - 1);
second->getShdr().sh_addr =
(first->getAddr() + std::min(first->getSize(), distance) + second->getAddrAlign() - 1)
& ~(second->getAddrAlign() - 1);
// Re-adjust to keep the original distance.
// If the first section has a smaller alignment requirement than the second,
// the second will be farther away, so we need to adjust the first.
// If the second section has a smaller alignment requirement than the first,
// it will already be at the right distance.
first->getShdr().sh_addr = second->getAddr() - distance;
assert(distance == second->getAddr() - first->getAddr());
first->markDirty();
adjust_eh_frame(eh_frame, origAddr, elf);
}

Expand Down
20 changes: 20 additions & 0 deletions devtools/client/framework/components/ToolboxToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ class ToolboxToolbar extends Component {
};
}

constructor(props) {
super(props);

this.hideMenu = this.hideMenu.bind(this);
}

componentDidMount() {
this.props.toolbox.on("panel-changed", this.hideMenu);
}

componentWillUnmount() {
this.props.toolbox.off("panel-changed", this.hideMenu);
}

hideMenu() {
if (this.refs.meatballMenuButton) {
this.refs.meatballMenuButton.hideMenu();
}
}

/**
* The render function is kept fairly short for maintainability. See the individual
* render functions for how each of the sections is rendered.
Expand Down
2 changes: 2 additions & 0 deletions devtools/client/framework/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,8 @@ Toolbox.prototype = {
* Reason the tool was opened
*/
selectTool: function(id, reason = "unknown") {
this.emit("panel-changed");

if (this.currentToolId == id) {
const panel = this._toolPanels.get(id);
if (panel) {
Expand Down
1 change: 0 additions & 1 deletion devtools/client/inspector/grids/test/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ skip-if = (verify && (os == 'win'))
[browser_grids_grid-outline-writing-mode.js]
skip-if = (verify && (os == 'win'))
[browser_grids_highlighter-setting-rules-grid-toggle.js]
[browser_grids_no_fragments.js]
[browser_grids_number-of-css-grids-telemetry.js]
[browser_grids_persist-color-palette.js]
[browser_grids_restored-after-reload.js]
49 changes: 0 additions & 49 deletions devtools/client/inspector/grids/test/browser_grids_no_fragments.js

This file was deleted.

45 changes: 20 additions & 25 deletions dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1555,36 +1555,31 @@ Element::GetElementsByClassName(const nsAString& aClassNames)
void
Element::GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements)
{
// This helper function is passed to GetElementsByMatching()
// to identify elements with styling which will cause them to
// generate a nsGridContainerFrame during layout.
auto IsDisplayGrid = [](Element* aElement) -> bool
{
RefPtr<ComputedStyle> computedStyle =
nsComputedDOMStyle::GetComputedStyle(aElement, nullptr);
if (computedStyle) {
const nsStyleDisplay* display = computedStyle->StyleDisplay();
return (display->mDisplay == StyleDisplay::Grid ||
display->mDisplay == StyleDisplay::InlineGrid);
}
return false;
};

GetElementsByMatching(IsDisplayGrid, aElements);
}
nsINode* cur = this;
while (cur) {
if (cur->IsElement()) {
Element* elem = cur->AsElement();

if (elem->GetPrimaryFrame()) {
// See if this has a GridContainerFrame. Use the same method that
// nsGridContainerFrame uses, which deals with some edge cases.
if (nsGridContainerFrame::GetGridContainerFrame(elem->GetPrimaryFrame())) {
aElements.AppendElement(elem);
}

void
Element::GetElementsByMatching(nsElementMatchFunc aFunc,
nsTArray<RefPtr<Element>>& aElements)
{
for (nsINode* cur = this; cur; cur = cur->GetNextNode(this)) {
if (cur->IsElement() && aFunc(cur->AsElement())) {
aElements.AppendElement(cur->AsElement());
// This element has a frame, so allow the traversal to go through
// the children.
cur = cur->GetNextNode(this);
continue;
}
}

// Either this isn't an element, or it has no frame. Continue with the
// traversal but ignore all the children.
cur = cur->GetNextNonChildNode(this);
}
}


/**
* Returns the count of descendants (inclusive of aContent) in
* the uncomposed document that are explicitly set as editable.
Expand Down
14 changes: 1 addition & 13 deletions dom/base/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -1167,24 +1167,12 @@ class Element : public FragmentOrElement

/**
* Return an array of all elements in the subtree rooted at this
* element that are styled as grid containers. This includes
* elements that don't actually generate any frames (by virtue of
* being in a 'display:none' subtree), but this does not include
* element that have grid container frames. This does not include
* pseudo-elements.
*/
void GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements);

private:
/**
* Define a general matching function that can be passed to
* GetElementsByMatching(). Each Element being considered is
* passed in.
*/
typedef bool (*nsElementMatchFunc)(Element* aElement);

void GetElementsByMatching(nsElementMatchFunc aFunc,
nsTArray<RefPtr<Element>>& aElements);

/**
* Implement the algorithm specified at
* https://dom.spec.whatwg.org/#insert-adjacent for both
Expand Down
20 changes: 13 additions & 7 deletions dom/base/test/chrome/test_getElementsWithGrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
let c = 0;
for (let target of targets) {
if (c >= elements.length) {
ok(false, "We have more targets than elements found.");
ok(false, "We shouldn't have more targets than elements found.");
break;
}
let element = elements[c];
Expand All @@ -47,13 +47,12 @@
}

// Make sure we don't have any extra elements after going through all the targets.
is(c, elements.length, "We found more elements than we have targets.");
is(c, elements.length, "We shouldn't have more elements than we have targets.");
}

function runTests() {
// Part 1: Look for all the grid elements starting from the document root.
let elementsFromRoot = document.documentElement.getElementsWithGrid();
is(elementsFromRoot.length, 8, "Found expected number of elements within document root.");

// Check that the expected elements were returned.
// Targets are provided in order we expect them to appear.
Expand All @@ -65,21 +64,24 @@
{id:"c", message:"'plain' grid container with display:inline-grid"},
{id:"d", message:"display:subgrid inside display:inline-grid (to be fixed in Bug 1240834)", todo:true},
{id:"e", message:"grid container with visibility:hidden"},
{id:"f", message:"grid container inside a display:none element"},
{id:"f", message:"grid container inside an element"},
{id:"g", message:"overflow:scroll grid container"},
{id:"h", message:"button as a grid container"},
{id:"i", message:"fieldset as a grid container"},
{id:"k1", message:"grid container containing a grid container"},
{id:"k2", message:"grid container inside a grid container"},
];
is(elementsFromRoot.length, 10, "Found expected number of elements within document root.");
testTargetsAreInElements(targetsFromRoot, elementsFromRoot);


// Part 2: Look for all the grid elements starting from a non-root element.
let elementsFromNonRoot = document.getElementById("a_non_root_element").getElementsWithGrid();
is(elementsFromNonRoot.length, 1, "Found expected number of elements from non-root element.");

let targetsFromNonRoot = [
{id:"f", message:"grid container inside a display:none element (from non-root element)"},
{id:"f", message:"grid container inside an element (from non-root element)"},
];
is(elementsFromNonRoot.length, 1, "Found expected number of elements from non-root element.");
testTargetsAreInElements(targetsFromNonRoot, elementsFromNonRoot);

SimpleTest.finish();
Expand All @@ -101,7 +103,7 @@

<div id="e" class="g" style="visibility:hidden"></div>

<div id="a_non_root_element" style="display:none"><div id="f" class="g"></div></div>
<div id="a_non_root_element"><div id="f" class="g"></div></div>

<div class="no-match"></div>

Expand All @@ -111,5 +113,9 @@

<fieldset id="i" class="g"></fieldset>

<div id="a_display_none_element" style="display:none"><div id="j" class="g"></div></div>

<div id="k1" class="g"><div id="k2" class="g"></div></div>

</body>
</html>
Loading

0 comments on commit 5962fb2

Please sign in to comment.