mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Merge mozilla-central to inbound. a=merge CLOSED TREE
This commit is contained in:
commit
390957966b
@ -556,6 +556,16 @@ HandlerProvider::Refresh(DynamicIA2Data* aOutData)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (!aOutData->mUniqueId) {
|
||||
// BuildDynamicIA2Data failed.
|
||||
if (!mTargetUnk) {
|
||||
// Even though we checked this before, the accessible can be shut down
|
||||
// before BuildDynamicIA2Data executes on the main thread.
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,7 @@ AccessibleHandler::MaybeUpdateCachedData()
|
||||
|
||||
uint32_t gen = ctl->GetCacheGen();
|
||||
if (gen == mCacheGen) {
|
||||
// Cache is already up to date.
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -214,7 +215,13 @@ AccessibleHandler::MaybeUpdateCachedData()
|
||||
return E_POINTER;
|
||||
}
|
||||
|
||||
return mCachedData.mGeckoBackChannel->Refresh(&mCachedData.mDynamicData);
|
||||
HRESULT hr = mCachedData.mGeckoBackChannel->Refresh(&mCachedData.mDynamicData);
|
||||
if (SUCCEEDED(hr)) {
|
||||
// We just updated the cache, so update this object's cache generation
|
||||
// so we only update the cache again after the next change.
|
||||
mCacheGen = gen;
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -3,15 +3,22 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* Listeners for the compact theme. This adds an extra stylesheet
|
||||
* to browser.xul if a pref is set and no other themes are applied.
|
||||
* Enables compacttheme.css when needed.
|
||||
*/
|
||||
var CompactTheme = {
|
||||
styleSheetLocation: "chrome://browser/skin/compacttheme.css",
|
||||
styleSheet: null,
|
||||
get styleSheet() {
|
||||
delete this.styleSheet;
|
||||
for (let styleSheet of document.styleSheets) {
|
||||
if (styleSheet.href == "chrome://browser/skin/compacttheme.css") {
|
||||
this.styleSheet = styleSheet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.styleSheet;
|
||||
},
|
||||
|
||||
get isStyleSheetEnabled() {
|
||||
return this.styleSheet && !this.styleSheet.sheet.disabled;
|
||||
return this.styleSheet && !this.styleSheet.disabled;
|
||||
},
|
||||
|
||||
get isThemeCurrentlyApplied() {
|
||||
@ -29,14 +36,6 @@ var CompactTheme = {
|
||||
}
|
||||
},
|
||||
|
||||
createStyleSheet() {
|
||||
let styleSheetAttr = `href="${this.styleSheetLocation}" type="text/css"`;
|
||||
this.styleSheet = document.createProcessingInstruction(
|
||||
"xml-stylesheet", styleSheetAttr);
|
||||
document.insertBefore(this.styleSheet, document.documentElement);
|
||||
this.styleSheet.sheet.disabled = true;
|
||||
},
|
||||
|
||||
observe(subject, topic, data) {
|
||||
if (topic == "lightweight-theme-styling-update") {
|
||||
let newTheme = JSON.parse(data);
|
||||
@ -56,14 +55,9 @@ var CompactTheme = {
|
||||
_toggleStyleSheet(enabled) {
|
||||
let wasEnabled = this.isStyleSheetEnabled;
|
||||
if (enabled) {
|
||||
// The stylesheet may not have been created yet if it wasn't
|
||||
// needed on initial load. Make it now.
|
||||
if (!this.styleSheet) {
|
||||
this.createStyleSheet();
|
||||
}
|
||||
this.styleSheet.sheet.disabled = false;
|
||||
this.styleSheet.disabled = false;
|
||||
} else if (!enabled && wasEnabled) {
|
||||
this.styleSheet.sheet.disabled = true;
|
||||
this.styleSheet.disabled = true;
|
||||
}
|
||||
},
|
||||
|
||||
@ -72,10 +66,3 @@ var CompactTheme = {
|
||||
this.styleSheet = null;
|
||||
}
|
||||
};
|
||||
|
||||
// If the compact theme is going to be applied in gBrowserInit.onLoad,
|
||||
// then preload it now. This prevents a flash of unstyled content where the
|
||||
// normal theme is applied while the compact theme stylesheet is loading.
|
||||
if (this != Services.appShell.hiddenDOMWindow && CompactTheme.isThemeCurrentlyApplied) {
|
||||
CompactTheme.createStyleSheet();
|
||||
}
|
||||
|
@ -339,14 +339,6 @@ var StarUI = {
|
||||
}
|
||||
};
|
||||
|
||||
// Checks if an element is visible without flushing layout changes.
|
||||
function isVisible(element) {
|
||||
let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
let bounds = windowUtils.getBoundsWithoutFlushing(element);
|
||||
return bounds.height > 0 && bounds.width > 0;
|
||||
}
|
||||
|
||||
var PlacesCommandHook = {
|
||||
/**
|
||||
* Adds a bookmark to the page loaded in the given browser.
|
||||
@ -1572,69 +1564,6 @@ var BookmarkingUI = {
|
||||
this._initMobileBookmarks(document.getElementById("menu_mobileBookmarks"));
|
||||
},
|
||||
|
||||
_showBookmarkedNotification: function BUI_showBookmarkedNotification() {
|
||||
function getCenteringTransformForRects(rectToPosition, referenceRect) {
|
||||
let topDiff = referenceRect.top - rectToPosition.top;
|
||||
let leftDiff = referenceRect.left - rectToPosition.left;
|
||||
let heightDiff = referenceRect.height - rectToPosition.height;
|
||||
let widthDiff = referenceRect.width - rectToPosition.width;
|
||||
return [(leftDiff + .5 * widthDiff) + "px", (topDiff + .5 * heightDiff) + "px"];
|
||||
}
|
||||
|
||||
if (this._notificationTimeout) {
|
||||
clearTimeout(this._notificationTimeout);
|
||||
}
|
||||
|
||||
if (this.notifier.style.transform == "") {
|
||||
// Get all the relevant nodes and computed style objects
|
||||
let dropmarker = document.getAnonymousElementByAttribute(this.button, "anonid", "dropmarker");
|
||||
let dropmarkerIcon = document.getAnonymousElementByAttribute(dropmarker, "class", "dropmarker-icon");
|
||||
let dropmarkerStyle = getComputedStyle(dropmarkerIcon);
|
||||
|
||||
// Check for RTL and get bounds
|
||||
let isRTL = getComputedStyle(this.button).direction == "rtl";
|
||||
let buttonRect = this.button.getBoundingClientRect();
|
||||
let notifierRect = this.notifier.getBoundingClientRect();
|
||||
let dropmarkerRect = dropmarkerIcon.getBoundingClientRect();
|
||||
let dropmarkerNotifierRect = this.dropmarkerNotifier.getBoundingClientRect();
|
||||
|
||||
// Compute, but do not set, transform for star icon
|
||||
let [translateX, translateY] = getCenteringTransformForRects(notifierRect, buttonRect);
|
||||
let starIconTransform = "translate(" + translateX + ", " + translateY + ")";
|
||||
if (isRTL) {
|
||||
starIconTransform += " scaleX(-1)";
|
||||
}
|
||||
|
||||
// Compute, but do not set, transform for dropmarker
|
||||
[translateX, translateY] = getCenteringTransformForRects(dropmarkerNotifierRect, dropmarkerRect);
|
||||
let dropmarkerTransform = "translate(" + translateX + ", " + translateY + ")";
|
||||
|
||||
// Do all layout invalidation in one go:
|
||||
this.notifier.style.transform = starIconTransform;
|
||||
this.dropmarkerNotifier.style.transform = dropmarkerTransform;
|
||||
|
||||
let dropmarkerAnimationNode = this.dropmarkerNotifier.firstChild;
|
||||
dropmarkerAnimationNode.style.listStyleImage = dropmarkerStyle.listStyleImage;
|
||||
dropmarkerAnimationNode.style.fill = dropmarkerStyle.fill;
|
||||
}
|
||||
|
||||
let isInOverflowPanel = this.button.getAttribute("overflowedItem") == "true";
|
||||
if (!isInOverflowPanel) {
|
||||
this.notifier.setAttribute("notification", "finish");
|
||||
this.button.setAttribute("notification", "finish");
|
||||
this.dropmarkerNotifier.setAttribute("notification", "finish");
|
||||
}
|
||||
|
||||
this._notificationTimeout = setTimeout( () => {
|
||||
this.notifier.removeAttribute("notification");
|
||||
this.dropmarkerNotifier.removeAttribute("notification");
|
||||
this.button.removeAttribute("notification");
|
||||
|
||||
this.dropmarkerNotifier.style.transform = "";
|
||||
this.notifier.style.transform = "";
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
showSubView(anchor) {
|
||||
this._showSubView(null, anchor);
|
||||
},
|
||||
@ -1729,17 +1658,6 @@ var BookmarkingUI = {
|
||||
aEvent.target.removeEventListener("ViewHiding", this);
|
||||
},
|
||||
|
||||
onPanelMenuViewCommand: function BUI_onPanelMenuViewCommand(aEvent) {
|
||||
let target = aEvent.originalTarget;
|
||||
if (!target._placesNode)
|
||||
return;
|
||||
if (PlacesUtils.nodeIsContainer(target._placesNode))
|
||||
PlacesCommandHook.showPlacesOrganizer([ "BookmarksMenu", target._placesNode.itemId ]);
|
||||
else
|
||||
PlacesUIUtils.openNodeWithEvent(target._placesNode, aEvent);
|
||||
PanelUI.hide();
|
||||
},
|
||||
|
||||
showBookmarkingTools(triggerNode) {
|
||||
const panelID = "PanelUI-bookmarkingTools";
|
||||
let viewNode = document.getElementById(panelID);
|
||||
|
@ -42,6 +42,8 @@ var TabsInTitlebar = {
|
||||
|
||||
addEventListener("resolutionchange", this, false);
|
||||
|
||||
gDragSpaceObserver.init();
|
||||
|
||||
this._update(true, true);
|
||||
},
|
||||
|
||||
@ -277,6 +279,7 @@ var TabsInTitlebar = {
|
||||
Services.prefs.removeObserver(this._prefName, this);
|
||||
this._menuObserver.disconnect();
|
||||
CustomizableUI.removeListener(this);
|
||||
gDragSpaceObserver.uninit();
|
||||
}
|
||||
};
|
||||
|
||||
@ -303,3 +306,35 @@ function onTitlebarMaxClick() {
|
||||
else
|
||||
window.maximize();
|
||||
}
|
||||
|
||||
// Adds additional drag space to the window by listening to
|
||||
// the corresponding preference.
|
||||
var gDragSpaceObserver = {
|
||||
pref: "browser.tabs.extraDragSpace",
|
||||
|
||||
init() {
|
||||
this.update();
|
||||
Services.prefs.addObserver(this.pref, this);
|
||||
},
|
||||
|
||||
uninit() {
|
||||
Services.prefs.removeObserver(this.pref, this);
|
||||
},
|
||||
|
||||
observe(aSubject, aTopic, aPrefName) {
|
||||
if (aTopic != "nsPref:changed" || aPrefName != this.pref) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
update() {
|
||||
if (Services.prefs.getBoolPref(this.pref)) {
|
||||
document.documentElement.setAttribute("extradragspace", "true");
|
||||
} else {
|
||||
document.documentElement.removeAttribute("extradragspace");
|
||||
}
|
||||
TabsInTitlebar.updateAppearance(true);
|
||||
},
|
||||
};
|
||||
|
@ -1296,10 +1296,6 @@ var gBrowserInit = {
|
||||
|
||||
gUIDensity.init();
|
||||
|
||||
if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
|
||||
gDragSpaceObserver.init();
|
||||
}
|
||||
|
||||
// Hack to ensure that the about:home favicon is loaded
|
||||
// instantaneously, to avoid flickering and improve perceived performance.
|
||||
this._callWithURIToLoad(uriToLoad => {
|
||||
@ -1492,9 +1488,6 @@ var gBrowserInit = {
|
||||
|
||||
UpdateUrlbarSearchSplitterState();
|
||||
|
||||
// Enable/Disable auto-hide tabbar
|
||||
gBrowser.tabContainer.updateVisibility();
|
||||
|
||||
BookmarkingUI.init();
|
||||
AutoShowBookmarksToolbar.init();
|
||||
|
||||
@ -1849,10 +1842,6 @@ var gBrowserInit = {
|
||||
onUnload() {
|
||||
gUIDensity.uninit();
|
||||
|
||||
if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
|
||||
gDragSpaceObserver.uninit();
|
||||
}
|
||||
|
||||
TabsInTitlebar.uninit();
|
||||
|
||||
// In certain scenarios it's possible for unload to be fired before onload,
|
||||
@ -5632,38 +5621,6 @@ function displaySecurityInfo() {
|
||||
BrowserPageInfo(null, "securityTab");
|
||||
}
|
||||
|
||||
// Adds additional drag space to the window by listening to
|
||||
// the corresponding preference.
|
||||
var gDragSpaceObserver = {
|
||||
pref: "browser.tabs.extraDragSpace",
|
||||
|
||||
init() {
|
||||
this.update();
|
||||
Services.prefs.addObserver(this.pref, this);
|
||||
},
|
||||
|
||||
uninit() {
|
||||
Services.prefs.removeObserver(this.pref, this);
|
||||
},
|
||||
|
||||
observe(aSubject, aTopic, aPrefName) {
|
||||
if (aTopic != "nsPref:changed" || aPrefName != this.pref) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
update() {
|
||||
if (Services.prefs.getBoolPref(this.pref)) {
|
||||
document.documentElement.setAttribute("extradragspace", "true");
|
||||
} else {
|
||||
document.documentElement.removeAttribute("extradragspace");
|
||||
}
|
||||
TabsInTitlebar.updateAppearance(true);
|
||||
},
|
||||
};
|
||||
|
||||
// Updates the UI density (for touch and compact mode) based on the uidensity pref.
|
||||
var gUIDensity = {
|
||||
MODE_NORMAL: 0,
|
||||
|
@ -17,6 +17,7 @@
|
||||
<?xml-stylesheet href="chrome://browser/skin/places/editBookmark.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/tabbrowser.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/compacttheme.css" type="text/css" alternate="yes" title="Light/Dark"?>
|
||||
|
||||
# All DTD information is stored in a separate file so that it can be shared by
|
||||
# hiddenWindow.xul.
|
||||
|
@ -109,6 +109,28 @@ this.DownloadsViewUI.DownloadElementShell.prototype = {
|
||||
return OS.Path.basename(this.download.target.path);
|
||||
},
|
||||
|
||||
/**
|
||||
* The user-facing label for the size (if any) of the download. The return value
|
||||
* is an object 'sizeStrings' with 2 strings:
|
||||
* 1. stateLabel - The size with the units (e.g. "1.5 MB").
|
||||
* 2. status - The status of the download (e.g. "Completed");
|
||||
*/
|
||||
get sizeStrings() {
|
||||
let s = DownloadsCommon.strings;
|
||||
let sizeStrings = {};
|
||||
|
||||
if (this.download.target.size !== undefined) {
|
||||
let [size, unit] = DownloadUtils.convertByteUnits(this.download.target.size);
|
||||
sizeStrings.stateLabel = s.sizeWithUnits(size, unit);
|
||||
sizeStrings.status = s.statusSeparator(s.stateCompleted, sizeStrings.stateLabel);
|
||||
} else {
|
||||
// History downloads may not have a size defined.
|
||||
sizeStrings.stateLabel = s.sizeUnknown;
|
||||
sizeStrings.status = s.stateCompleted;
|
||||
}
|
||||
return sizeStrings;
|
||||
},
|
||||
|
||||
get browserWindow() {
|
||||
return RecentWindow.getMostRecentBrowserWindow();
|
||||
},
|
||||
@ -245,17 +267,10 @@ this.DownloadsViewUI.DownloadElementShell.prototype = {
|
||||
stateLabel = s.fileMovedOrMissing;
|
||||
hoverStatus = stateLabel;
|
||||
} else if (this.download.succeeded) {
|
||||
// For completed downloads, show the file size (e.g. "1.5 MB").
|
||||
if (this.download.target.size !== undefined) {
|
||||
let [size, unit] =
|
||||
DownloadUtils.convertByteUnits(this.download.target.size);
|
||||
stateLabel = s.sizeWithUnits(size, unit);
|
||||
status = s.statusSeparator(s.stateCompleted, stateLabel);
|
||||
} else {
|
||||
// History downloads may not have a size defined.
|
||||
stateLabel = s.sizeUnknown;
|
||||
status = s.stateCompleted;
|
||||
}
|
||||
// For completed downloads, show the file size
|
||||
let sizeStrings = this.sizeStrings;
|
||||
stateLabel = sizeStrings.stateLabel;
|
||||
status = sizeStrings.status;
|
||||
hoverStatus = status;
|
||||
} else if (this.download.canceled) {
|
||||
stateLabel = s.stateCanceled;
|
||||
|
@ -49,7 +49,7 @@ function devtools_page() {
|
||||
const harLog = await browser.devtools.network.getHAR();
|
||||
browser.test.sendMessage("getHAR-result", harLog);
|
||||
|
||||
if (harLogCount === 2) {
|
||||
if (harLogCount === 3) {
|
||||
harLogCount = 0;
|
||||
browser.test.onMessage.removeListener(harListener);
|
||||
}
|
||||
@ -166,11 +166,18 @@ add_task(async function test_devtools_network_get_har() {
|
||||
const getHAREmptyPromise = extension.awaitMessage("getHAR-result");
|
||||
extension.sendMessage("getHAR");
|
||||
const getHAREmptyResult = await getHAREmptyPromise;
|
||||
is(getHAREmptyResult.log.entries.length, 0, "HAR log should be empty");
|
||||
is(getHAREmptyResult.entries.length, 0, "HAR log should be empty");
|
||||
|
||||
// Select the Net panel.
|
||||
await toolbox.selectTool("netmonitor");
|
||||
|
||||
// Get HAR again, it should be empty because the Panel is selected
|
||||
// but no data collected yet.
|
||||
const getHAREmptyPromiseWithPanel = extension.awaitMessage("getHAR-result");
|
||||
extension.sendMessage("getHAR");
|
||||
const emptyResultWithPanel = await getHAREmptyPromiseWithPanel;
|
||||
is(emptyResultWithPanel.entries.length, 0, "HAR log should be empty");
|
||||
|
||||
// Reload the page to collect some HTTP requests.
|
||||
extension.sendMessage("navigate");
|
||||
|
||||
@ -189,7 +196,7 @@ add_task(async function test_devtools_network_get_har() {
|
||||
const getHARPromise = extension.awaitMessage("getHAR-result");
|
||||
extension.sendMessage("getHAR");
|
||||
const getHARResult = await getHARPromise;
|
||||
is(getHARResult.log.entries.length, 1, "HAR log should not be empty");
|
||||
is(getHARResult.entries.length, 1, "HAR log should not be empty");
|
||||
|
||||
// Shutdown
|
||||
await gDevTools.closeToolbox(target);
|
||||
|
@ -629,16 +629,6 @@ var PlacesOrganizer = {
|
||||
additionalInfoBroadcaster.hidden = infoBox.getAttribute("minimal") == "true";
|
||||
},
|
||||
|
||||
// NOT YET USED
|
||||
updateThumbnailProportions: function PO_updateThumbnailProportions() {
|
||||
var previewBox = document.getElementById("previewBox");
|
||||
var canvas = document.getElementById("itemThumbnail");
|
||||
var height = previewBox.boxObject.height;
|
||||
var width = height * (screen.width / screen.height);
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
},
|
||||
|
||||
_fillDetailsPane: function PO__fillDetailsPane(aNodeList) {
|
||||
var infoBox = document.getElementById("infoBox");
|
||||
var detailsDeck = document.getElementById("detailsDeck");
|
||||
@ -726,28 +716,6 @@ var PlacesOrganizer = {
|
||||
}
|
||||
},
|
||||
|
||||
// NOT YET USED
|
||||
_updateThumbnail: function PO__updateThumbnail() {
|
||||
var bo = document.getElementById("previewBox").boxObject;
|
||||
var width = bo.width;
|
||||
var height = bo.height;
|
||||
|
||||
var canvas = document.getElementById("itemThumbnail");
|
||||
var ctx = canvas.getContext("2d");
|
||||
var notAvailableText = canvas.getAttribute("notavailabletext");
|
||||
ctx.save();
|
||||
ctx.fillStyle = "-moz-Dialog";
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
ctx.translate(width / 2, height / 2);
|
||||
|
||||
ctx.fillStyle = "GrayText";
|
||||
ctx.mozTextStyle = "12pt sans serif";
|
||||
var len = ctx.mozMeasureText(notAvailableText);
|
||||
ctx.translate(-len / 2, 0);
|
||||
ctx.mozDrawText(notAvailableText);
|
||||
ctx.restore();
|
||||
},
|
||||
|
||||
toggleAdditionalInfoFields: function PO_toggleAdditionalInfoFields() {
|
||||
var infoBox = document.getElementById("infoBox");
|
||||
var infoBoxExpander = document.getElementById("infoBoxExpander");
|
||||
|
@ -51,12 +51,12 @@ subsuite = clipboard
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_forgetthissite_single.js]
|
||||
[browser_history_sidebar_search.js]
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_library_commands.js]
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_library_delete_bookmarks_in_tags.js]
|
||||
[browser_library_delete_tags.js]
|
||||
[browser_library_delete.js]
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_library_downloads.js]
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_library_infoBox.js]
|
||||
@ -68,6 +68,7 @@ skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_library_middleclick.js]
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_library_new_bookmark.js]
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
[browser_library_open_leak.js]
|
||||
[browser_library_openFlatContainer.js]
|
||||
skip-if = (os == 'win' && ccov) # Bug 1423667
|
||||
|
@ -123,6 +123,12 @@ if test "$GNU_CC"; then
|
||||
if test -z "$DEVELOPER_OPTIONS"; then
|
||||
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
|
||||
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
|
||||
|
||||
# For MinGW, we need big-obj otherwise we create too many sections in Unified builds
|
||||
if test "${OS_ARCH}" = "WINNT"; then
|
||||
CFLAGS="$CFLAGS -Wa,-mbig-obj"
|
||||
CXXFLAGS="$CXXFLAGS -Wa,-mbig-obj"
|
||||
fi
|
||||
fi
|
||||
CFLAGS="$CFLAGS -fno-math-errno"
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-math-errno"
|
||||
|
@ -19,7 +19,6 @@ module.exports = {
|
||||
"client/memory/test/**",
|
||||
"server/tests/browser/**",
|
||||
"server/tests/mochitest/**",
|
||||
"server/tests/unit/**",
|
||||
"shared/heapsnapshot/tests/unit/**",
|
||||
"shared/tests/unit/**",
|
||||
"shared/webconsole/test/**",
|
||||
|
@ -3050,18 +3050,23 @@ Toolbox.prototype = {
|
||||
/**
|
||||
* Returns data (HAR) collected by the Network panel.
|
||||
*/
|
||||
getHARFromNetMonitor: function() {
|
||||
getHARFromNetMonitor: async function() {
|
||||
let netPanel = this.getPanel("netmonitor");
|
||||
|
||||
// The panel doesn't have to exist (it must be selected
|
||||
// by the user at least once to be created).
|
||||
// Return default empty HAR file in such case.
|
||||
// Return default empty HAR log in such case.
|
||||
if (!netPanel) {
|
||||
return Promise.resolve(buildHarLog(Services.appinfo));
|
||||
let har = await buildHarLog(Services.appinfo);
|
||||
return har.log;
|
||||
}
|
||||
|
||||
// Use Netmonitor object to get the current HAR log.
|
||||
return netPanel.panelWin.Netmonitor.getHar();
|
||||
let har = await netPanel.panelWin.Netmonitor.getHar();
|
||||
|
||||
// Return the log directly to be compatible with
|
||||
// Chrome WebExtension API.
|
||||
return har.log;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ class AnimationInspector {
|
||||
this.onElementPickerStarted = this.onElementPickerStarted.bind(this);
|
||||
this.onElementPickerStopped = this.onElementPickerStopped.bind(this);
|
||||
this.onSidebarResized = this.onSidebarResized.bind(this);
|
||||
this.onSidebarSelect = this.onSidebarSelect.bind(this);
|
||||
this.onSidebarSelectionChanged = this.onSidebarSelectionChanged.bind(this);
|
||||
|
||||
EventEmitter.decorate(this);
|
||||
this.emit = this.emit.bind(this);
|
||||
@ -134,22 +134,20 @@ class AnimationInspector {
|
||||
);
|
||||
this.provider = provider;
|
||||
|
||||
this.inspector.selection.on("new-node-front", this.update);
|
||||
this.inspector.sidebar.on("newanimationinspector-selected", this.onSidebarSelect);
|
||||
this.inspector.toolbox.on("inspector-sidebar-resized", this.onSidebarResized);
|
||||
this.inspector.sidebar.on("select", this.onSidebarSelectionChanged);
|
||||
this.inspector.toolbox.on("picker-started", this.onElementPickerStarted);
|
||||
this.inspector.toolbox.on("picker-stopped", this.onElementPickerStopped);
|
||||
|
||||
this.animationsFront.on("mutations", this.onAnimationsMutation);
|
||||
this.inspector.toolbox.on("select", this.onSidebarSelectionChanged);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.setAnimationStateChangedListenerEnabled(false);
|
||||
this.inspector.selection.off("new-node-front", this.update);
|
||||
this.inspector.sidebar.off("newanimationinspector-selected", this.onSidebarSelect);
|
||||
this.inspector.sidebar.off("select", this.onSidebarSelectionChanged);
|
||||
this.inspector.toolbox.off("inspector-sidebar-resized", this.onSidebarResized);
|
||||
this.inspector.toolbox.off("picker-started", this.onElementPickerStarted);
|
||||
this.inspector.toolbox.off("picker-stopped", this.onElementPickerStopped);
|
||||
this.inspector.toolbox.off("select", this.onSidebarSelectionChanged);
|
||||
|
||||
this.animationsFront.off("mutations", this.onAnimationsMutation);
|
||||
|
||||
@ -289,9 +287,11 @@ class AnimationInspector {
|
||||
for (const {type, player: animation} of changes) {
|
||||
if (type === "added") {
|
||||
animations.push(animation);
|
||||
animation.on("changed", this.onAnimationStateChanged);
|
||||
} else if (type === "removed") {
|
||||
const index = animations.indexOf(animation);
|
||||
animations.splice(index, 1);
|
||||
animation.off("changed", this.onAnimationStateChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,16 +306,33 @@ class AnimationInspector {
|
||||
this.inspector.store.dispatch(updateElementPickerEnabled(false));
|
||||
}
|
||||
|
||||
onSidebarSelect() {
|
||||
this.update();
|
||||
this.onSidebarResized(this.inspector.getSidebarSize());
|
||||
}
|
||||
async onSidebarSelectionChanged() {
|
||||
const isPanelVisibled = this.isPanelVisible();
|
||||
|
||||
onSidebarResized(size) {
|
||||
if (!this.isPanelVisible()) {
|
||||
if (this.wasPanelVisibled === isPanelVisibled) {
|
||||
// onSidebarSelectionChanged is called some times even same state
|
||||
// from sidebar and toolbar.
|
||||
return;
|
||||
}
|
||||
|
||||
this.wasPanelVisibled = isPanelVisibled;
|
||||
|
||||
if (this.isPanelVisible()) {
|
||||
await this.update();
|
||||
this.onSidebarResized(null, this.inspector.getSidebarSize());
|
||||
this.animationsFront.on("mutations", this.onAnimationsMutation);
|
||||
this.inspector.selection.on("new-node-front", this.update);
|
||||
this.inspector.toolbox.on("inspector-sidebar-resized", this.onSidebarResized);
|
||||
} else {
|
||||
this.stopAnimationsCurrentTimeTimer();
|
||||
this.animationsFront.off("mutations", this.onAnimationsMutation);
|
||||
this.inspector.selection.off("new-node-front", this.update);
|
||||
this.inspector.toolbox.off("inspector-sidebar-resized", this.onSidebarResized);
|
||||
this.setAnimationStateChangedListenerEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
onSidebarResized(size) {
|
||||
this.inspector.store.dispatch(updateSidebarSize(size));
|
||||
}
|
||||
|
||||
@ -511,11 +528,6 @@ class AnimationInspector {
|
||||
}
|
||||
|
||||
async update() {
|
||||
if (!this.inspector || !this.isPanelVisible()) {
|
||||
// AnimationInspector was destroyed already or the panel is hidden.
|
||||
return;
|
||||
}
|
||||
|
||||
const done = this.inspector.updating("newanimationinspector");
|
||||
|
||||
const selection = this.inspector.selection;
|
||||
@ -527,6 +539,7 @@ class AnimationInspector {
|
||||
|
||||
if (!currentAnimations || !isAllAnimationEqual(currentAnimations, nextAnimations)) {
|
||||
this.updateState(nextAnimations);
|
||||
this.setAnimationStateChangedListenerEnabled(true);
|
||||
}
|
||||
|
||||
done();
|
||||
@ -560,8 +573,6 @@ class AnimationInspector {
|
||||
|
||||
this.inspector.store.dispatch(updateAnimations(animations));
|
||||
|
||||
this.setAnimationStateChangedListenerEnabled(true);
|
||||
|
||||
if (hasRunningAnimation(animations)) {
|
||||
this.startAnimationsCurrentTimeTimer();
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class AnimationTimelineTickList extends PureComponent {
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
sidebarWidth: state.animations.sidebarSize.width
|
||||
sidebarWidth: state.animations.sidebarSize ? state.animations.sidebarSize.width : 0
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -33,6 +33,7 @@ support-files =
|
||||
[browser_animation_keyframes-graph_keyframe-marker.js]
|
||||
[browser_animation_keyframes-progress-bar.js]
|
||||
[browser_animation_logic_auto-stop.js]
|
||||
[browser_animation_logic_avoid-updating-during-hiding.js]
|
||||
[browser_animation_logic_mutations.js]
|
||||
[browser_animation_pause-resume-button.js]
|
||||
[browser_animation_pause-resume-button_spacebar.js]
|
||||
|
@ -0,0 +1,64 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Animation inspector should not update when hidden.
|
||||
// Test for followings:
|
||||
// * whether the UIs update after selecting another inspector
|
||||
// * whether the UIs update after selecting another tool
|
||||
// * whether the UIs update after selecting animation inspector again
|
||||
|
||||
add_task(async function() {
|
||||
await addTab(URL_ROOT + "doc_custom_playback_rate.html");
|
||||
const { animationInspector, inspector, panel } = await openAnimationInspector();
|
||||
|
||||
info("Checking the UIs update after selecting another inspector");
|
||||
await selectNodeAndWaitForAnimations("head", inspector);
|
||||
inspector.sidebar.select("ruleview");
|
||||
await selectNode("div", inspector);
|
||||
is(animationInspector.state.animations.length, 0,
|
||||
"Should not update after selecting another inspector");
|
||||
await selectAnimationInspector(inspector);
|
||||
is(animationInspector.state.animations.length, 1,
|
||||
"Should update after selecting animation inspector");
|
||||
await assertCurrentTimeUpdated(animationInspector, panel, true);
|
||||
inspector.sidebar.select("ruleview");
|
||||
is(animationInspector.state.animations.length, 1,
|
||||
"Should not update after selecting another inspector again");
|
||||
await assertCurrentTimeUpdated(animationInspector, panel, false);
|
||||
|
||||
info("Checking the UIs update after selecting another tool");
|
||||
await selectAnimationInspector(inspector);
|
||||
await selectNodeAndWaitForAnimations("head", inspector);
|
||||
await inspector.toolbox.selectTool("webconsole");
|
||||
await selectNode("div", inspector);
|
||||
is(animationInspector.state.animations.length, 0,
|
||||
"Should not update after selecting another tool");
|
||||
await selectAnimationInspector(inspector);
|
||||
is(animationInspector.state.animations.length, 1,
|
||||
"Should update after selecting animation inspector");
|
||||
await assertCurrentTimeUpdated(animationInspector, panel, true);
|
||||
await inspector.toolbox.selectTool("webconsole");
|
||||
is(animationInspector.state.animations.length, 1,
|
||||
"Should not update after selecting another tool again");
|
||||
await assertCurrentTimeUpdated(animationInspector, panel, false);
|
||||
});
|
||||
|
||||
async function assertCurrentTimeUpdated(animationInspector, panel, shouldRunning) {
|
||||
let count = 0;
|
||||
|
||||
const listener = () => {
|
||||
count++;
|
||||
};
|
||||
|
||||
animationInspector.addAnimationsCurrentTimeListener(listener);
|
||||
await new Promise(resolve => panel.ownerGlobal.requestAnimationFrame(resolve));
|
||||
animationInspector.removeAnimationsCurrentTimeListener(listener);
|
||||
|
||||
if (shouldRunning) {
|
||||
isnot(count, 0, "Should forward current time");
|
||||
} else {
|
||||
is(count, 0, "Should not forward current time");
|
||||
}
|
||||
}
|
@ -293,6 +293,19 @@ const getDurationAndRate = function(animationInspector, panel, pixels) {
|
||||
return { duration, rate };
|
||||
};
|
||||
|
||||
/**
|
||||
* Select animation inspector in sidebar and toolbar.
|
||||
*
|
||||
* @param {InspectorPanel} inspector
|
||||
*/
|
||||
const selectAnimationInspector = async function(inspector) {
|
||||
await inspector.toolbox.selectTool("inspector");
|
||||
const onUpdated = inspector.once("inspector-updated");
|
||||
inspector.sidebar.select("newanimationinspector");
|
||||
await onUpdated;
|
||||
await waitForRendering(inspector.animationinspector);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the inspector's current selection to a node or to the first match of the
|
||||
* given css selector and wait for the animations to be displayed
|
||||
|
@ -1189,6 +1189,7 @@ MarkupView.prototype = {
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* The node to expand, or null to start from the top.
|
||||
* @return {Promise} promise that resolves once all children are expanded.
|
||||
*/
|
||||
expandAll: function(node) {
|
||||
node = node || this._rootNode;
|
||||
@ -1211,9 +1212,16 @@ MarkupView.prototype = {
|
||||
|
||||
/**
|
||||
* Collapse the entire tree beneath a node.
|
||||
*
|
||||
* @param {DOMNode} node
|
||||
* The node to collapse.
|
||||
* @return {Promise} promise that resolves once all children are collapsed.
|
||||
*/
|
||||
collapseAll: function(node) {
|
||||
this._collapseAll(this.getContainer(node));
|
||||
|
||||
// collapseAll is synchronous, return a promise for consistency with expandAll.
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -466,6 +466,34 @@ certmgr.certdetail.sha256fingerprint=SHA-256 Fingerprint:
|
||||
# A label used for Fingerprints sub-section in security tab
|
||||
certmgr.certdetail.sha1fingerprint=SHA1 Fingerprint:
|
||||
|
||||
# LOCALIZATION NOTE (certmgr.certificateTransparency.label):
|
||||
# This string is used as a label in the security tab.
|
||||
certmgr.certificateTransparency.label=Transparency:
|
||||
|
||||
# LOCALIZATION NOTE (certmgr.certificateTransparency.status.none):
|
||||
# This string is used to indicate that there are no signed certificate
|
||||
# timestamps available. This is a property for the 'Transparency'
|
||||
# field in the security tab.
|
||||
certmgr.certificateTransparency.status.none=No SCTs records
|
||||
|
||||
# LOCALIZATION NOTE (netmonitor.security.certificateTransparency.status.ok):
|
||||
# This string is used to indicate that there are valid signed certificate
|
||||
# timestamps. This is a property for the 'Transparency'
|
||||
# field in the security tab.
|
||||
certmgr.certificateTransparency.status.ok=Valid SCTs records
|
||||
|
||||
# LOCALIZATION NOTE (certmgr.certificateTransparency.status.notEnoughSCTS):
|
||||
# This string is used to indicate that there are not enough valid signed
|
||||
# certificate timestamps. This is a property for the 'Transparency'
|
||||
# field in the security tab.
|
||||
certmgr.certificateTransparency.status.notEnoughSCTS=Not enough SCTs
|
||||
|
||||
# LOCALIZATION NOTE (certmgr.certificateTransparency.status.notDiverseSCTS):
|
||||
# This string is used to indicate that there ar not enough diverse signed
|
||||
# certificate timestamps. This is a property for the 'Transparency'
|
||||
# field in the security tab.
|
||||
certmgr.certificateTransparency.status.notDiverseSCTS=Not diverse SCTs
|
||||
|
||||
# LOCALIZATION NOTE (netmonitor.perfNotice1/2/3): These are the labels displayed
|
||||
# in the network table when empty to start performance analysis.
|
||||
netmonitor.perfNotice1=• Click on the
|
||||
|
@ -110,6 +110,8 @@ window.Netmonitor = {
|
||||
let options = {
|
||||
connector,
|
||||
items: getSortedRequests(state),
|
||||
// Always generate HAR log even if there are no requests.
|
||||
forceExport: true,
|
||||
};
|
||||
|
||||
return HarExporter.getHar(options);
|
||||
|
@ -346,6 +346,7 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.network-monitor .stack-trace .frame-link-source-inner,
|
||||
|
@ -220,7 +220,7 @@ class HeadersPanel extends Component {
|
||||
|
||||
let statusCodeDocURL = getHTTPStatusCodeURL(status.toString());
|
||||
let inputWidth = status.toString().length + statusText.length + 1;
|
||||
let toggleRawHeadersClassList = ["devtools-button"];
|
||||
let toggleRawHeadersClassList = ["devtools-button", "raw-headers-button"];
|
||||
if (this.state.rawHeadersOpened) {
|
||||
toggleRawHeadersClassList.push("checked");
|
||||
}
|
||||
@ -272,6 +272,7 @@ class HeadersPanel extends Component {
|
||||
div({ className: "raw-headers" },
|
||||
div({ className: "tabpanel-summary-label" }, RAW_HEADERS_REQUEST),
|
||||
textarea({
|
||||
className: "raw-request-headers-textarea",
|
||||
value: writeHeaderText(requestHeaders.headers),
|
||||
readOnly: true,
|
||||
}),
|
||||
@ -279,6 +280,7 @@ class HeadersPanel extends Component {
|
||||
div({ className: "raw-headers" },
|
||||
div({ className: "tabpanel-summary-label" }, RAW_HEADERS_RESPONSE),
|
||||
textarea({
|
||||
className: "raw-response-headers-textarea",
|
||||
value: statusLine + writeHeaderText(responseHeaders.headers),
|
||||
readOnly: true,
|
||||
}),
|
||||
|
@ -34,6 +34,8 @@ const SIGNATURE_SCHEME_LABEL = L10N.getStr("netmonitor.security.signatureScheme"
|
||||
const HSTS_LABEL = L10N.getStr("netmonitor.security.hsts");
|
||||
const HPKP_LABEL = L10N.getStr("netmonitor.security.hpkp");
|
||||
const CERTIFICATE_LABEL = L10N.getStr("netmonitor.security.certificate");
|
||||
const CERTIFICATE_TRANSPARENCY_LABEL =
|
||||
L10N.getStr("certmgr.certificateTransparency.label");
|
||||
const SUBJECT_INFO_LABEL = L10N.getStr("certmgr.subjectinfo.label");
|
||||
const CERT_DETAIL_COMMON_NAME_LABEL = L10N.getStr("certmgr.certdetail.cn");
|
||||
const CERT_DETAIL_ORG_LABEL = L10N.getStr("certmgr.certdetail.o");
|
||||
@ -166,6 +168,8 @@ class SecurityPanel extends Component {
|
||||
[SHA1_FINGERPRINT_LABEL]:
|
||||
fingerprint.sha1 || NOT_AVAILABLE,
|
||||
},
|
||||
[CERTIFICATE_TRANSPARENCY_LABEL]:
|
||||
securityInfo.certificateTransparency || NOT_AVAILABLE,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
|
@ -68,7 +68,8 @@ var HeadersProvider = {
|
||||
* Helper data structures for list of headers.
|
||||
*/
|
||||
function HeaderList(headers) {
|
||||
this.headers = headers;
|
||||
// Clone, so the sort doesn't affect the original array.
|
||||
this.headers = headers.slice(0);
|
||||
this.headers.sort((a, b) => {
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
});
|
||||
|
@ -7,24 +7,39 @@
|
||||
* Tests if Request-Headers and Response-Headers are sorted in Headers tab.
|
||||
* The test also verifies that headers with the same name and headers
|
||||
* with an empty value are also displayed.
|
||||
*
|
||||
* The test also checks that raw headers are displayed in the original
|
||||
* order and not sorted.
|
||||
*/
|
||||
add_task(async function() {
|
||||
let { tab, monitor } = await initNetMonitor(SIMPLE_SJS);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, store, windowRequire } = monitor.panelWin;
|
||||
let { store, windowRequire } = monitor.panelWin;
|
||||
let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
let {
|
||||
getSortedRequests,
|
||||
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
|
||||
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.reload();
|
||||
await wait;
|
||||
|
||||
wait = waitForDOM(document, ".headers-overview");
|
||||
// Verify request and response headers.
|
||||
await verifyHeaders(monitor);
|
||||
await verifyRawHeaders(monitor);
|
||||
|
||||
// Clean up
|
||||
await teardown(monitor);
|
||||
});
|
||||
|
||||
async function verifyHeaders(monitor) {
|
||||
let { document, store, windowRequire } = monitor.panelWin;
|
||||
let {
|
||||
getSortedRequests,
|
||||
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
|
||||
|
||||
info("Check if Request-Headers and Response-Headers are sorted");
|
||||
|
||||
let wait = waitForDOM(document, ".headers-overview");
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll(".request-list-item")[0]);
|
||||
await wait;
|
||||
@ -34,7 +49,6 @@ add_task(async function() {
|
||||
return request.requestHeaders && request.responseHeaders;
|
||||
});
|
||||
|
||||
info("Check if Request-Headers and Response-Headers are sorted");
|
||||
let expectedResponseHeaders = ["cache-control", "connection", "content-length",
|
||||
"content-type", "date", "expires", "foo-bar",
|
||||
"foo-bar", "foo-bar", "pragma", "server", "set-cookie",
|
||||
@ -61,6 +75,56 @@ add_task(async function() {
|
||||
|
||||
is(actualRequestHeaders.toString(), expectedRequestHeaders.toString(),
|
||||
"Request Headers are sorted");
|
||||
}
|
||||
|
||||
await teardown(monitor);
|
||||
});
|
||||
async function verifyRawHeaders(monitor) {
|
||||
let { document } = monitor.panelWin;
|
||||
|
||||
info("Check if raw Request-Headers and raw Response-Headers are not sorted");
|
||||
|
||||
let actualResponseHeaders = [];
|
||||
let actualRequestHeaders = [];
|
||||
|
||||
let expectedResponseHeaders = ["cache-control", "pragma", "expires",
|
||||
"set-cookie", "set-cookie", "content-type", "foo-bar",
|
||||
"foo-bar", "foo-bar", "connection", "server",
|
||||
"date", "content-length"];
|
||||
|
||||
let expectedRequestHeaders = ["Host", "User-Agent", "Accept", "Accept-Language",
|
||||
"Accept-Encoding", "Cookie", "Connection",
|
||||
"Upgrade-Insecure-Requests", "Pragma",
|
||||
"Cache-Control"];
|
||||
|
||||
// Click the 'Raw headers' button to show original headers source.
|
||||
let rawHeadersBtn = document.querySelector(".raw-headers-button");
|
||||
rawHeadersBtn.click();
|
||||
|
||||
// Wait till raw headers are available.
|
||||
await waitUntil(() => {
|
||||
return document.querySelector(".raw-request-headers-textarea") &&
|
||||
document.querySelector(".raw-response-headers-textarea");
|
||||
});
|
||||
|
||||
let requestHeadersText =
|
||||
document.querySelector(".raw-request-headers-textarea").textContent;
|
||||
let responseHeadersText =
|
||||
document.querySelector(".raw-response-headers-textarea").textContent;
|
||||
|
||||
let rawRequestHeadersArray = requestHeadersText.split("\n");
|
||||
for (let i = 0; i < rawRequestHeadersArray.length; i++) {
|
||||
let header = rawRequestHeadersArray[i];
|
||||
actualRequestHeaders.push(header.split(":")[0]);
|
||||
}
|
||||
|
||||
let rawResponseHeadersArray = responseHeadersText.split("\n");
|
||||
for (let i = 1; i < rawResponseHeadersArray.length; i++) {
|
||||
let header = rawResponseHeadersArray[i];
|
||||
actualResponseHeaders.push(header.split(":")[0]);
|
||||
}
|
||||
|
||||
is(actualResponseHeaders.toString(), expectedResponseHeaders.toString(),
|
||||
"Raw Response Headers are not sorted");
|
||||
|
||||
is(actualRequestHeaders.toString(), expectedRequestHeaders.toString(),
|
||||
"Raw Request Headers are not sorted");
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
*/
|
||||
|
||||
add_task(async function() {
|
||||
await pushPref("security.pki.certificate_transparency.mode", 1);
|
||||
|
||||
let { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL);
|
||||
let { document, store, windowRequire } = monitor.panelWin;
|
||||
let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
@ -77,5 +79,8 @@ add_task(async function() {
|
||||
// cert sha256 fingerprint
|
||||
isnot(textboxes[15].value, "", "Label was not empty.");
|
||||
|
||||
// Certificate transparency
|
||||
isnot(textboxes[16].value, "", "Label was not empty.");
|
||||
|
||||
await teardown(monitor);
|
||||
});
|
||||
|
@ -8,23 +8,34 @@
|
||||
* Styles for React component at `devtools/client/shared/components/Frame.js`
|
||||
*/
|
||||
|
||||
.frame-link {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
.theme-light {
|
||||
--frame-link-line-color: var(--theme-highlight-blue);
|
||||
--frame-link-source: var(--theme-highlight-purple);
|
||||
}
|
||||
|
||||
.theme-dark .frame-link {
|
||||
.theme-dark {
|
||||
--frame-link-source: #6B89FF;
|
||||
}
|
||||
|
||||
.stack-trace {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.stack-trace .frame-link-async-cause {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.stack-trace .frame-link {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.frame-link-async-cause {
|
||||
color: var(--theme-comment);
|
||||
}
|
||||
|
||||
.frame-link .frame-link-source {
|
||||
flex: initial;
|
||||
color: var(--frame-link-source);
|
||||
}
|
||||
|
||||
@ -49,11 +60,16 @@
|
||||
color: var(--console-output-color, currentColor);
|
||||
}
|
||||
|
||||
.frame-link .frame-link-function-display-name::before {
|
||||
content: "\3BB"; /* The "lambda" symbol */
|
||||
display: inline-block;
|
||||
margin: 0 0.3em;
|
||||
}
|
||||
|
||||
.frame-link .frame-link-line {
|
||||
color: var(--frame-link-line-color);
|
||||
}
|
||||
|
||||
|
||||
.focused .frame-link .frame-link-source,
|
||||
.focused .frame-link .frame-link-line,
|
||||
.focused .frame-link .frame-link-host {
|
||||
|
@ -131,6 +131,7 @@ a {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.stack-trace .frame-link-source-inner,
|
||||
@ -141,7 +142,6 @@ a {
|
||||
}
|
||||
|
||||
.stack-trace .frame-link-function-display-name {
|
||||
max-width: 50%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@ -776,7 +776,6 @@ a.learn-more-link.webconsole-learn-more-link {
|
||||
--warning-color: var(--yellow-80);
|
||||
--warning-background-color: #FFFBD5;
|
||||
--console-output-color: var(--grey-90);
|
||||
--attachment-border-color: var(--theme-content-color1);
|
||||
--repeat-bubble-background-color: var(--theme-highlight-blue);
|
||||
}
|
||||
|
||||
@ -786,7 +785,6 @@ a.learn-more-link.webconsole-learn-more-link {
|
||||
--warning-color: #FCE19F;
|
||||
--warning-background-color: #44391F;
|
||||
--console-output-color: white;
|
||||
--attachment-border-color: var(--theme-body-color);
|
||||
--repeat-bubble-background-color: var(--blue-60);
|
||||
}
|
||||
|
||||
@ -1108,10 +1106,10 @@ a.learn-more-link.webconsole-learn-more-link {
|
||||
}
|
||||
|
||||
/* Stacktraces */
|
||||
.webconsole-output-wrapper .stacktrace {
|
||||
border: 1px solid var(--attachment-border-color);
|
||||
border-radius: 2px;
|
||||
.webconsole-output-wrapper .stacktrace {
|
||||
border: none;
|
||||
margin-block-end: var(--attachment-margin-block-end);
|
||||
padding: 0 0 0 4px;
|
||||
}
|
||||
|
||||
.theme-dark .webconsole-output-wrapper .message.error .stacktrace,
|
||||
|
@ -316,17 +316,6 @@ var listener = {
|
||||
|
||||
Services.console.registerListener(listener);
|
||||
|
||||
function check_except(func) {
|
||||
try {
|
||||
func();
|
||||
} catch (e) {
|
||||
Assert.ok(true);
|
||||
return;
|
||||
}
|
||||
dumpn("Should have thrown an exception: " + func.toString());
|
||||
Assert.ok(false);
|
||||
}
|
||||
|
||||
function testGlobal(name) {
|
||||
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"]
|
||||
.createInstance(Ci.nsIPrincipal));
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Uses the same scope as test_add_actors.js
|
||||
/* import-globals-from head_dbg.js */
|
||||
|
||||
function PostInitGlobalActor(connection) {}
|
||||
|
||||
PostInitGlobalActor.prototype = {
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Uses the same scope as test_add_actors.js
|
||||
/* import-globals-from head_dbg.js */
|
||||
|
||||
function PostInitTabActor(connection) {}
|
||||
|
||||
PostInitTabActor.prototype = {
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Uses the same scope as test_add_actors.js
|
||||
/* import-globals-from head_dbg.js */
|
||||
|
||||
function PreInitGlobalActor(connection) {}
|
||||
|
||||
PreInitGlobalActor.prototype = {
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Uses the same scope as test_add_actors.js
|
||||
/* import-globals-from head_dbg.js */
|
||||
|
||||
function PreInitTabActor(connection) {}
|
||||
|
||||
PreInitTabActor.prototype = {
|
||||
|
@ -52,7 +52,7 @@ function test_black_box() {
|
||||
}
|
||||
});
|
||||
|
||||
/* eslint-disable no-multi-spaces */
|
||||
/* eslint-disable no-multi-spaces, no-undef */
|
||||
Cu.evalInSandbox(
|
||||
"" + function doStuff(k) { // line 1
|
||||
let arg = 15; // line 2 - Break here
|
||||
@ -78,7 +78,7 @@ function test_black_box() {
|
||||
SOURCE_URL,
|
||||
1
|
||||
);
|
||||
/* eslint-enable no-multi-spaces */
|
||||
/* eslint-enable no-multi-spaces, no-undef */
|
||||
}
|
||||
|
||||
function test_black_box_breakpoint() {
|
||||
|
@ -42,7 +42,7 @@ function test_black_box() {
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-disable no-multi-spaces */
|
||||
/* eslint-disable no-multi-spaces, no-undef */
|
||||
Cu.evalInSandbox(
|
||||
"" + function doStuff(k) { // line 1
|
||||
debugger; // line 2 - Break here
|
||||
@ -68,7 +68,7 @@ function test_black_box() {
|
||||
SOURCE_URL,
|
||||
1
|
||||
);
|
||||
/* eslint-enable no-multi-spaces */
|
||||
/* eslint-enable no-multi-spaces, no-undef */
|
||||
}
|
||||
|
||||
function test_black_box_dbg_statement() {
|
||||
|
@ -49,7 +49,7 @@ function test_black_box() {
|
||||
}
|
||||
});
|
||||
|
||||
/* eslint-disable no-multi-spaces */
|
||||
/* eslint-disable no-multi-spaces, no-undef */
|
||||
Cu.evalInSandbox(
|
||||
"" + function doStuff(k) { // line 1
|
||||
debugger; // line 2
|
||||
@ -75,7 +75,7 @@ function test_black_box() {
|
||||
SOURCE_URL,
|
||||
1
|
||||
);
|
||||
/* eslint-enable no-multi-spaces */
|
||||
/* eslint-enable no-multi-spaces, no-undef */
|
||||
}
|
||||
|
||||
function test_black_box_paused() {
|
||||
|
@ -38,7 +38,7 @@ const SOURCE_URL = "http://example.com/source.js";
|
||||
function test_black_box() {
|
||||
gClient.addOneTimeListener("paused", test_black_box_exception);
|
||||
|
||||
/* eslint-disable no-multi-spaces, no-unreachable */
|
||||
/* eslint-disable no-multi-spaces, no-unreachable, no-undef */
|
||||
Cu.evalInSandbox(
|
||||
"" + function doStuff(k) { // line 1
|
||||
throw new Error("wu tang clan ain't nuthin' ta fuck wit"); // line 2
|
||||
@ -65,7 +65,7 @@ function test_black_box() {
|
||||
SOURCE_URL,
|
||||
1
|
||||
);
|
||||
/* eslint-enable no-multi-spaces */
|
||||
/* eslint-enable no-multi-spaces, no-unreachable, no-undef */
|
||||
}
|
||||
|
||||
function test_black_box_exception() {
|
||||
|
@ -40,7 +40,7 @@ function run_test() {
|
||||
}
|
||||
|
||||
function setup_code() {
|
||||
/* eslint-disable no-multi-spaces */
|
||||
/* eslint-disable no-multi-spaces, no-undef */
|
||||
let { code, map } = (new SourceNode(null, null, null, [
|
||||
new SourceNode(1, 0, "a.js", "" + function a() {
|
||||
return b();
|
||||
@ -59,7 +59,7 @@ function setup_code() {
|
||||
file: "abc.js",
|
||||
sourceRoot: "http://example.com/"
|
||||
});
|
||||
/* eslint-enable no-multi-spaces */
|
||||
/* eslint-enable no-multi-spaces, no-undef */
|
||||
|
||||
code += "//# sourceMappingURL=data:text/json," + map.toString();
|
||||
|
||||
|
@ -6,19 +6,27 @@
|
||||
function run_test() {
|
||||
// Should get an exception if we try to interact with DebuggerServer
|
||||
// before we initialize it...
|
||||
check_except(function() {
|
||||
DebuggerServer.createListener();
|
||||
});
|
||||
check_except(DebuggerServer.closeAllListeners);
|
||||
check_except(DebuggerServer.connectPipe);
|
||||
Assert.throws(() => DebuggerServer.createListener(),
|
||||
/DebuggerServer has not been initialized/,
|
||||
"createListener should throw before it has been initialized");
|
||||
Assert.throws(DebuggerServer.closeAllListeners,
|
||||
/this is undefined/,
|
||||
"closeAllListeners should throw before it has been initialized");
|
||||
Assert.throws(DebuggerServer.connectPipe,
|
||||
/this is undefined/,
|
||||
"connectPipe should throw before it has been initialized");
|
||||
|
||||
// Allow incoming connections.
|
||||
DebuggerServer.init();
|
||||
|
||||
// These should still fail because we haven't added a createRootActor
|
||||
// implementation yet.
|
||||
check_except(DebuggerServer.closeAllListeners);
|
||||
check_except(DebuggerServer.connectPipe);
|
||||
Assert.throws(DebuggerServer.closeAllListeners,
|
||||
/this is undefined/,
|
||||
"closeAllListeners should throw if createRootActor hasn't been added");
|
||||
Assert.throws(DebuggerServer.connectPipe,
|
||||
/this is undefined/,
|
||||
"closeAllListeners should throw if createRootActor hasn't been added");
|
||||
|
||||
DebuggerServer.registerModule("xpcshell-test/testactors");
|
||||
|
||||
|
@ -18,7 +18,7 @@ function run_test() {
|
||||
|
||||
g.eval("function stopMe(arg) {debugger;}");
|
||||
|
||||
g2 = testGlobal("test2");
|
||||
let g2 = testGlobal("test2");
|
||||
g2.g = g;
|
||||
g2.eval("(" + function createBadEvent() {
|
||||
let parser = Cc["@mozilla.org/xmlextras/domparser;1"]
|
||||
|
@ -57,10 +57,11 @@ function test_object_grip() {
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-disable no-undef */
|
||||
gDebuggee.eval("(" + function() {
|
||||
let obj1 = {};
|
||||
Object.freeze(obj1);
|
||||
stopMe(obj1, {});
|
||||
} + "())");
|
||||
/* eslint-enable no-undef */
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,11 @@ function test_object_grip() {
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-disable no-undef */
|
||||
gDebuggee.eval("(" + function() {
|
||||
let obj1 = {};
|
||||
Object.seal(obj1);
|
||||
stopMe(obj1, {});
|
||||
} + "())");
|
||||
/* eslint-enable no-undef */
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ function test_object_grip() {
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-disable no-undef */
|
||||
gDebuggee.eval("(" + function() {
|
||||
let f = {};
|
||||
Object.freeze(f);
|
||||
@ -70,5 +71,5 @@ function test_object_grip() {
|
||||
Object.preventExtensions(ne);
|
||||
stopMe(f, s, ne, {});
|
||||
} + "())");
|
||||
/* eslint-enable no-undef */
|
||||
}
|
||||
|
||||
|
@ -13,20 +13,23 @@ add_task(async function() {
|
||||
|
||||
let response = await listTabs(client);
|
||||
let targetTab = findTab(response.tabs, "promises-actor-test");
|
||||
ok(targetTab, "Found our target tab.");
|
||||
Assert.ok(targetTab, "Found our target tab.");
|
||||
|
||||
// Attach to the TabActor and check the response
|
||||
client.request({ to: targetTab.actor, type: "attach" }, response => {
|
||||
ok(!("error" in response), "Expect no error in response.");
|
||||
ok(response.from, targetTab.actor,
|
||||
"Expect the target TabActor in response form field.");
|
||||
ok(response.type, "tabAttached",
|
||||
"Expect tabAttached in the response type.");
|
||||
is(typeof response.promisesActor === "string",
|
||||
"Should have a tab context PromisesActor.");
|
||||
await new Promise(resolve => {
|
||||
client.request({ to: targetTab.actor, type: "attach" }, response => {
|
||||
Assert.ok(!("error" in response), "Expect no error in response.");
|
||||
Assert.equal(response.from, targetTab.actor,
|
||||
"Expect the target TabActor in response form field.");
|
||||
Assert.equal(response.type, "tabAttached",
|
||||
"Expect tabAttached in the response type.");
|
||||
Assert.ok(typeof response.promisesActor === "string",
|
||||
"Should have a tab context PromisesActor.");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
let chromeActors = await getChromeActors(client);
|
||||
ok(typeof chromeActors.promisesActor === "string",
|
||||
Assert.ok(typeof chromeActors.promisesActor === "string",
|
||||
"Should have a chrome context PromisesActor.");
|
||||
});
|
||||
|
@ -181,20 +181,23 @@ function run_test() {
|
||||
});
|
||||
DebuggerServer.init();
|
||||
|
||||
check_except(() => {
|
||||
let badActor = ActorClassWithSpec({}, {
|
||||
missing: preEvent("missing-event", function() {
|
||||
Assert.throws(() => {
|
||||
let badActor = protocol.ActorClassWithSpec({}, {
|
||||
missing: protocol.preEvent("missing-event", function() {
|
||||
})
|
||||
});
|
||||
void badActor;
|
||||
});
|
||||
}, /Actor specification must have a typeName member/);
|
||||
|
||||
protocol.types.getType("array:array:array:number");
|
||||
protocol.types.getType("array:array:array:number");
|
||||
|
||||
check_except(() => protocol.types.getType("unknown"));
|
||||
check_except(() => protocol.types.getType("array:unknown"));
|
||||
check_except(() => protocol.types.getType("unknown:number"));
|
||||
Assert.throws(() => protocol.types.getType("unknown"),
|
||||
/Unknown type:/, "Should throw for unknown type");
|
||||
Assert.throws(() => protocol.types.getType("array:unknown"),
|
||||
/Unknown type:/, "Should throw for unknown type");
|
||||
Assert.throws(() => protocol.types.getType("unknown:number"),
|
||||
/Unknown collection type:/, "Should throw for unknown collection type");
|
||||
let trace = connectPipeTracing();
|
||||
let client = new DebuggerClient(trace);
|
||||
let rootClient;
|
||||
@ -218,10 +221,9 @@ function run_test() {
|
||||
trace.expectReceive({"value": 1, "from": "<actorid>"});
|
||||
Assert.equal(ret, 1);
|
||||
}).then(() => {
|
||||
// Missing argument should throw an exception
|
||||
check_except(() => {
|
||||
rootClient.simpleArgs(5);
|
||||
});
|
||||
Assert.throws(() => rootClient.simpleArgs(5),
|
||||
/undefined passed where a value is required/,
|
||||
"Should throw if simpleArgs is missing an argument.");
|
||||
|
||||
return rootClient.simpleArgs(5, 10);
|
||||
}).then(ret => {
|
||||
|
@ -11,6 +11,7 @@ function run_test() {
|
||||
let testFile = do_get_file("xpcshell_debugging_script.js");
|
||||
|
||||
// _setupDebuggerServer is from xpcshell-test's head.js
|
||||
/* global _setupDebuggerServer */
|
||||
let testResumed = false;
|
||||
let DebuggerServer = _setupDebuggerServer([testFile.path], () => {
|
||||
testResumed = true;
|
||||
|
@ -654,6 +654,34 @@ var NetworkHelper = {
|
||||
// Certificate.
|
||||
info.cert = this.parseCertificateInfo(SSLStatus.serverCert);
|
||||
|
||||
info.certificateTransparency = null;
|
||||
|
||||
switch (SSLStatus.certificateTransparencyStatus) {
|
||||
case SSLStatus.CERTIFICATE_TRANSPARENCY_NOT_APPLICABLE:
|
||||
default:
|
||||
break;
|
||||
case SSLStatus.CERTIFICATE_TRANSPARENCY_NONE:
|
||||
info.certificateTransparency =
|
||||
L10N.getStr("certmgr.certificateTransparency.status.none");
|
||||
break;
|
||||
case SSLStatus.CERTIFICATE_TRANSPARENCY_POLICY_COMPLIANT:
|
||||
info.certificateTransparency =
|
||||
L10N.getStr("certmgr.certificateTransparency.status.ok");
|
||||
break;
|
||||
case SSLStatus.CERTIFICATE_TRANSPARENCY_POLICY_NOT_ENOUGH_SCTS:
|
||||
info.certificateTransparency =
|
||||
L10N.getStr(
|
||||
"certmgr.certificateTransparency.status.notEnoughSCTS"
|
||||
);
|
||||
break;
|
||||
case SSLStatus.CERTIFICATE_TRANSPARENCY_POLICY_NOT_DIVERSE_SCTS:
|
||||
info.certificateTransparency =
|
||||
L10N.getStr(
|
||||
"certmgr.certificateTransparency.status.notDiverseSCTS"
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// HSTS and HPKP if available.
|
||||
if (httpActivity.hostname) {
|
||||
const sss = Cc["@mozilla.org/ssservice;1"]
|
||||
|
@ -153,7 +153,7 @@ this.DevToolsShim = {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initDevTools();
|
||||
this.initDevTools("SessionRestore");
|
||||
this._gDevTools.restoreDevToolsSession(session);
|
||||
},
|
||||
|
||||
|
@ -273,7 +273,7 @@ DevToolsStartup.prototype = {
|
||||
if (Services.prefs.getBoolPref(TOOLBAR_VISIBLE_PREF, false)) {
|
||||
// Loading devtools-browser will open the developer toolbar by also checking this
|
||||
// pref.
|
||||
this.initDevTools();
|
||||
this.initDevTools("DeveloperToolbar");
|
||||
}
|
||||
|
||||
// This listener is called for all Firefox windows, but we want to execute some code
|
||||
@ -612,18 +612,7 @@ DevToolsStartup.prototype = {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (reason && !this.recorded) {
|
||||
// Only save the first call for each firefox run as next call
|
||||
// won't necessarely start the tool. For example key shortcuts may
|
||||
// only change the currently selected tool.
|
||||
try {
|
||||
Services.telemetry.getHistogramById("DEVTOOLS_ENTRY_POINT")
|
||||
.add(reason);
|
||||
} catch (e) {
|
||||
dump("DevTools telemetry entry point failed: " + e + "\n");
|
||||
}
|
||||
this.recorded = true;
|
||||
}
|
||||
this.sendEntryPointTelemetry(reason);
|
||||
|
||||
this.initialized = true;
|
||||
let { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
@ -750,6 +739,8 @@ DevToolsStartup.prototype = {
|
||||
Services.obs.addObserver(observe, "devtools-thread-resumed");
|
||||
}
|
||||
|
||||
this.sendEntryPointTelemetry("CommandLine");
|
||||
|
||||
const { BrowserToolboxProcess } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
|
||||
BrowserToolboxProcess.init();
|
||||
|
||||
@ -834,6 +825,21 @@ DevToolsStartup.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
sendEntryPointTelemetry(reason) {
|
||||
if (reason && !this.recorded) {
|
||||
// Only save the first call for each firefox run as next call
|
||||
// won't necessarely start the tool. For example key shortcuts may
|
||||
// only change the currently selected tool.
|
||||
try {
|
||||
Services.telemetry.getHistogramById("DEVTOOLS_ENTRY_POINT")
|
||||
.add(reason);
|
||||
} catch (e) {
|
||||
dump("DevTools telemetry entry point failed: " + e + "\n");
|
||||
}
|
||||
this.recorded = true;
|
||||
}
|
||||
},
|
||||
|
||||
// Used by tests and the toolbox to register the same key shortcuts in toolboxes loaded
|
||||
// in a window window.
|
||||
get KeyShortcuts() {
|
||||
|
@ -609,7 +609,6 @@ ContentParent::PreallocateProcess()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
process->Init();
|
||||
return process.forget();
|
||||
}
|
||||
|
||||
@ -836,8 +835,6 @@ ContentParent::GetNewOrUsedBrowserProcess(const nsAString& aRemoteType,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
p->Init();
|
||||
|
||||
contentParents.AppendElement(p);
|
||||
p->mActivateTS = TimeStamp::Now();
|
||||
return p.forget();
|
||||
@ -865,8 +862,6 @@ ContentParent::GetNewOrUsedJSPluginProcess(uint32_t aPluginID,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
p->Init();
|
||||
|
||||
sJSPluginContentParents->Put(aPluginID, p);
|
||||
|
||||
return p.forget();
|
||||
@ -2091,6 +2086,8 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
|
||||
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-initializing", cpId.get());
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,7 @@ private:
|
||||
// Returns false if the process fails to start.
|
||||
bool LaunchSubprocess(hal::ProcessPriority aInitialPriority = hal::PROCESS_PRIORITY_FOREGROUND);
|
||||
|
||||
// Common initialization after sub process launch or adoption.
|
||||
// Common initialization after sub process launch.
|
||||
void InitInternal(ProcessPriority aPriority);
|
||||
|
||||
virtual ~ContentParent();
|
||||
|
@ -32,20 +32,34 @@ namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
template already_AddRefed<CreateElementTransaction>
|
||||
CreateElementTransaction::Create(
|
||||
EditorBase& aEditorBase,
|
||||
nsAtom& aTag,
|
||||
const EditorDOMPoint& aPointToInsert);
|
||||
template already_AddRefed<CreateElementTransaction>
|
||||
CreateElementTransaction::Create(
|
||||
EditorBase& aEditorBase,
|
||||
nsAtom& aTag,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<CreateElementTransaction>
|
||||
CreateElementTransaction::Create(EditorBase& aEditorBase,
|
||||
nsAtom& aTag,
|
||||
const EditorRawDOMPoint& aPointToInsert)
|
||||
CreateElementTransaction::Create(
|
||||
EditorBase& aEditorBase,
|
||||
nsAtom& aTag,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
{
|
||||
RefPtr<CreateElementTransaction> transaction =
|
||||
new CreateElementTransaction(aEditorBase, aTag, aPointToInsert);
|
||||
return transaction.forget();
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
CreateElementTransaction::CreateElementTransaction(
|
||||
EditorBase& aEditorBase,
|
||||
nsAtom& aTag,
|
||||
const EditorRawDOMPoint& aPointToInsert)
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
: EditTransactionBase()
|
||||
, mEditorBase(&aEditorBase)
|
||||
, mTag(&aTag)
|
||||
|
@ -29,9 +29,10 @@ class Element;
|
||||
class CreateElementTransaction final : public EditTransactionBase
|
||||
{
|
||||
protected:
|
||||
template<typename PT, typename CT>
|
||||
CreateElementTransaction(EditorBase& aEditorBase,
|
||||
nsAtom& aTag,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -45,10 +46,11 @@ public:
|
||||
* or after, the new node will be appended to the
|
||||
* container.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
static already_AddRefed<CreateElementTransaction>
|
||||
Create(EditorBase& aEditorBase,
|
||||
nsAtom& aTag,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTransaction,
|
||||
|
@ -123,6 +123,31 @@ using namespace widget;
|
||||
* mozilla::EditorBase
|
||||
*****************************************************************************/
|
||||
|
||||
template already_AddRefed<Element>
|
||||
EditorBase::CreateNode(nsAtom* aTag, const EditorDOMPoint& aPointToInsert);
|
||||
template already_AddRefed<Element>
|
||||
EditorBase::CreateNode(nsAtom* aTag, const EditorRawDOMPoint& aPointToInsert);
|
||||
template nsresult
|
||||
EditorBase::InsertNode(nsIContent& aContentToInsert,
|
||||
const EditorDOMPoint& aPointToInsert);
|
||||
template nsresult
|
||||
EditorBase::InsertNode(nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
template already_AddRefed<nsIContent>
|
||||
EditorBase::SplitNode(const EditorDOMPoint& aStartOfRightNode,
|
||||
ErrorResult& aError);
|
||||
template already_AddRefed<nsIContent>
|
||||
EditorBase::SplitNode(const EditorRawDOMPoint& aStartOfRightNode,
|
||||
ErrorResult& aError);
|
||||
template SplitNodeResult
|
||||
EditorBase::SplitNodeDeep(nsIContent& aMostAncestorToSplit,
|
||||
const EditorDOMPoint& aStartOfDeepestRightNode,
|
||||
SplitAtEdges aSplitAtEdges);
|
||||
template SplitNodeResult
|
||||
EditorBase::SplitNodeDeep(nsIContent& aMostAncestorToSplit,
|
||||
const EditorRawDOMPoint& aStartOfDeepestRightNode,
|
||||
SplitAtEdges aSplitAtEdges);
|
||||
|
||||
EditorBase::EditorBase()
|
||||
: mPlaceholderName(nullptr)
|
||||
, mModCount(0)
|
||||
@ -1417,9 +1442,10 @@ EditorBase::SetSpellcheckUserOverride(bool enable)
|
||||
return SyncRealTimeSpell();
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
EditorBase::CreateNode(nsAtom* aTag,
|
||||
const EditorRawDOMPoint& aPointToInsert)
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
{
|
||||
MOZ_ASSERT(aTag);
|
||||
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
|
||||
@ -1489,9 +1515,10 @@ EditorBase::InsertNode(nsIDOMNode* aNodeToInsert,
|
||||
return InsertNode(*contentToInsert, EditorRawDOMPoint(container, offset));
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsresult
|
||||
EditorBase::InsertNode(nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert)
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
{
|
||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -1504,7 +1531,7 @@ EditorBase::InsertNode(nsIContent& aContentToInsert,
|
||||
InsertNodeTransaction::Create(*this, aContentToInsert, aPointToInsert);
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
|
||||
mRangeUpdater.SelAdjInsertNode(aPointToInsert.AsRaw());
|
||||
mRangeUpdater.SelAdjInsertNode(aPointToInsert);
|
||||
|
||||
if (mRules && mRules->AsHTMLEditRules()) {
|
||||
RefPtr<HTMLEditRules> htmlEditRules = mRules->AsHTMLEditRules();
|
||||
@ -1543,8 +1570,9 @@ EditorBase::SplitNode(nsIDOMNode* aNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<nsIContent>
|
||||
EditorBase::SplitNode(const EditorRawDOMPoint& aStartOfRightNode,
|
||||
EditorBase::SplitNode(const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (NS_WARN_IF(!aStartOfRightNode.IsSet()) ||
|
||||
@ -1775,7 +1803,7 @@ EditorBase::ReplaceContainer(Element* aOldContainer,
|
||||
// Insert new container into tree.
|
||||
NS_WARNING_ASSERTION(atOldContainer.IsSetAndValid(),
|
||||
"The old container might be moved by mutation observer");
|
||||
nsresult rv = InsertNode(*newContainer, atOldContainer.AsRaw());
|
||||
nsresult rv = InsertNode(*newContainer, atOldContainer);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1889,7 +1917,7 @@ EditorBase::InsertContainerAbove(nsIContent* aNode,
|
||||
}
|
||||
|
||||
// Put the new container where aNode was.
|
||||
rv = InsertNode(*newContainer, pointToInsertNewContainer.AsRaw());
|
||||
rv = InsertNode(*newContainer, pointToInsertNewContainer);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -4132,10 +4160,12 @@ EditorBase::IsPreformatted(nsIDOMNode* aNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
SplitNodeResult
|
||||
EditorBase::SplitNodeDeep(nsIContent& aMostAncestorToSplit,
|
||||
const EditorRawDOMPoint& aStartOfDeepestRightNode,
|
||||
SplitAtEdges aSplitAtEdges)
|
||||
EditorBase::SplitNodeDeep(
|
||||
nsIContent& aMostAncestorToSplit,
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode,
|
||||
SplitAtEdges aSplitAtEdges)
|
||||
{
|
||||
MOZ_ASSERT(aStartOfDeepestRightNode.IsSetAndValid());
|
||||
MOZ_ASSERT(aStartOfDeepestRightNode.GetContainer() == &aMostAncestorToSplit ||
|
||||
@ -4174,8 +4204,7 @@ EditorBase::SplitNodeDeep(nsIContent& aMostAncestorToSplit,
|
||||
(!atStartOfRightNode.IsStartOfContainer() &&
|
||||
!atStartOfRightNode.IsEndOfContainer())) {
|
||||
ErrorResult error;
|
||||
nsCOMPtr<nsIContent> newLeftNode =
|
||||
SplitNode(atStartOfRightNode.AsRaw(), error);
|
||||
nsCOMPtr<nsIContent> newLeftNode = SplitNode(atStartOfRightNode, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return SplitNodeResult(error.StealNSResult());
|
||||
}
|
||||
@ -4522,7 +4551,7 @@ EditorBase::DeleteSelectionAndPrepareToCreateNode()
|
||||
}
|
||||
|
||||
ErrorResult error;
|
||||
nsCOMPtr<nsIContent> newLeftNode = SplitNode(atAnchor.AsRaw(), error);
|
||||
nsCOMPtr<nsIContent> newLeftNode = SplitNode(atAnchor, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
@ -350,8 +350,9 @@ public:
|
||||
* container. Otherwise, will insert the node
|
||||
* before child node referred by this.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
nsresult InsertNode(nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
enum ECloneAttributes { eDontCloneAttributes, eCloneAttributes };
|
||||
already_AddRefed<Element> ReplaceContainer(Element* aOldContainer,
|
||||
@ -381,8 +382,9 @@ public:
|
||||
* @param aError If succeed, returns no error. Otherwise, an
|
||||
* error.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<nsIContent>
|
||||
SplitNode(const EditorRawDOMPoint& aStartOfRightNode,
|
||||
SplitNode(const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
||||
ErrorResult& aResult);
|
||||
|
||||
nsresult JoinNodes(nsINode& aLeftNode, nsINode& aRightNode);
|
||||
@ -520,8 +522,10 @@ protected:
|
||||
* child node referred by this.
|
||||
* @return The created new element node.
|
||||
*/
|
||||
already_AddRefed<Element> CreateNode(nsAtom* aTag,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
CreateNode(nsAtom* aTag,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
/**
|
||||
* Create an aggregate transaction for delete selection. The result may
|
||||
@ -905,28 +909,35 @@ public:
|
||||
* you want. They start to search the result from next node of the given
|
||||
* node.
|
||||
*/
|
||||
nsIContent* GetNextNode(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextNode(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextNodeInternal(aPoint, false, true, false);
|
||||
}
|
||||
nsIContent* GetNextElementOrText(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextElementOrText(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextNodeInternal(aPoint, false, false, false);
|
||||
}
|
||||
nsIContent* GetNextEditableNode(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextEditableNode(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextNodeInternal(aPoint, true, true, false);
|
||||
}
|
||||
nsIContent* GetNextNodeInBlock(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextNodeInBlock(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextNodeInternal(aPoint, false, true, true);
|
||||
}
|
||||
nsIContent* GetNextElementOrTextInBlock(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextElementOrTextInBlock(
|
||||
const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextNodeInternal(aPoint, false, false, true);
|
||||
}
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextEditableNodeInBlock(
|
||||
const EditorRawDOMPoint& aPoint)
|
||||
const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextNodeInternal(aPoint, true, true, true);
|
||||
}
|
||||
@ -1182,9 +1193,10 @@ public:
|
||||
* be good to insert something if the
|
||||
* caller want to do it.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
SplitNodeResult
|
||||
SplitNodeDeep(nsIContent& aMostAncestorToSplit,
|
||||
const EditorRawDOMPoint& aDeepestStartOfRightNode,
|
||||
const EditorDOMPointBase<PT, CT>& aDeepestStartOfRightNode,
|
||||
SplitAtEdges aSplitAtEdges);
|
||||
|
||||
EditorDOMPoint JoinNodeDeep(nsIContent& aLeftNode,
|
||||
|
@ -629,14 +629,6 @@ public:
|
||||
return mChild->IsHTMLElement(nsGkAtoms::br);
|
||||
}
|
||||
|
||||
// Convenience methods for switching between the two types
|
||||
// of EditorDOMPointBase.
|
||||
EditorDOMPointBase<nsINode*, nsIContent*>
|
||||
AsRaw() const
|
||||
{
|
||||
return EditorRawDOMPoint(*this);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
EditorDOMPointBase& operator=(const RangeBoundaryBase<A,B>& aOther)
|
||||
{
|
||||
|
@ -221,7 +221,7 @@ public:
|
||||
return EditorRawDOMPoint();
|
||||
}
|
||||
if (mGivenSplitPoint.IsSet()) {
|
||||
return mGivenSplitPoint.AsRaw();
|
||||
return EditorRawDOMPoint(mGivenSplitPoint);
|
||||
}
|
||||
if (!mPreviousNode) {
|
||||
return EditorRawDOMPoint(mNextNode);
|
||||
|
@ -1258,8 +1258,11 @@ HTMLEditRules::WillInsert(Selection& aSelection,
|
||||
// the same block as the selection. We need to move the selection start
|
||||
// to be before the mozBR.
|
||||
EditorRawDOMPoint point(priorNode);
|
||||
nsresult rv = aSelection.Collapse(point.AsRaw());
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
IgnoredErrorResult error;
|
||||
aSelection.Collapse(point, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1349,7 +1352,8 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
}
|
||||
|
||||
if (inString->IsEmpty()) {
|
||||
rv = mHTMLEditor->InsertTextImpl(*doc, *inString, pointToInsert.AsRaw());
|
||||
rv = mHTMLEditor->InsertTextImpl(*doc, *inString,
|
||||
EditorRawDOMPoint(pointToInsert));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1357,7 +1361,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
}
|
||||
|
||||
WSRunObject wsObj(mHTMLEditor, pointToInsert);
|
||||
rv = wsObj.InsertText(*doc, *inString, pointToInsert.AsRaw());
|
||||
rv = wsObj.InsertText(*doc, *inString, pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1422,7 +1426,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
if (subStr.Equals(newlineStr)) {
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nsCOMPtr<Element> br =
|
||||
mHTMLEditor->CreateBRImpl(*aSelection, currentPoint.AsRaw(),
|
||||
mHTMLEditor->CreateBRImpl(*aSelection, currentPoint,
|
||||
nsIEditor::eNone);
|
||||
NS_ENSURE_STATE(br);
|
||||
pos++;
|
||||
@ -1444,7 +1448,8 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
} else {
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
EditorRawDOMPoint pointAfterInsertedString;
|
||||
rv = mHTMLEditor->InsertTextImpl(*doc, subStr, currentPoint.AsRaw(),
|
||||
rv = mHTMLEditor->InsertTextImpl(*doc, subStr,
|
||||
EditorRawDOMPoint(currentPoint),
|
||||
&pointAfterInsertedString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
currentPoint = pointAfterInsertedString;
|
||||
@ -1479,7 +1484,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
// is it a tab?
|
||||
if (subStr.Equals(tabStr)) {
|
||||
EditorRawDOMPoint pointAfterInsertedSpaces;
|
||||
rv = wsObj.InsertText(*doc, spacesStr, currentPoint.AsRaw(),
|
||||
rv = wsObj.InsertText(*doc, spacesStr, currentPoint,
|
||||
&pointAfterInsertedSpaces);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -1491,8 +1496,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
// is it a return?
|
||||
else if (subStr.Equals(newlineStr)) {
|
||||
RefPtr<Element> newBRElement =
|
||||
wsObj.InsertBreak(*aSelection, currentPoint.AsRaw(),
|
||||
nsIEditor::eNone);
|
||||
wsObj.InsertBreak(*aSelection, currentPoint, nsIEditor::eNone);
|
||||
if (NS_WARN_IF(!newBRElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1514,7 +1518,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
"Perhaps, newBRElement has been moved or removed unexpectedly");
|
||||
} else {
|
||||
EditorRawDOMPoint pointAfterInsertedString;
|
||||
rv = wsObj.InsertText(*doc, subStr, currentPoint.AsRaw(),
|
||||
rv = wsObj.InsertText(*doc, subStr, currentPoint,
|
||||
&pointAfterInsertedString);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@ -1532,7 +1536,7 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
|
||||
if (currentPoint.IsSet()) {
|
||||
ErrorResult error;
|
||||
aSelection->Collapse(currentPoint.AsRaw(), error);
|
||||
aSelection->Collapse(currentPoint, error);
|
||||
if (error.Failed()) {
|
||||
NS_WARNING("Failed to collapse at current point");
|
||||
error.SuppressException();
|
||||
@ -1546,15 +1550,14 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
}
|
||||
|
||||
if (currentPoint.IsSet()) {
|
||||
rv = mDocChangeRange->SetStartAndEnd(pointToInsert.AsRaw(),
|
||||
currentPoint.AsRaw());
|
||||
rv = mDocChangeRange->SetStartAndEnd(pointToInsert, currentPoint);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = mDocChangeRange->CollapseTo(pointToInsert.AsRaw());
|
||||
rv = mDocChangeRange->CollapseTo(pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1856,7 +1859,7 @@ HTMLEditRules::InsertBRElement(Selection& aSelection,
|
||||
// First, insert a <br> element.
|
||||
RefPtr<Element> brElement;
|
||||
if (IsPlaintextEditor()) {
|
||||
brElement = htmlEditor->CreateBR(aPointToBreak.AsRaw());
|
||||
brElement = htmlEditor->CreateBR(aPointToBreak);
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1886,15 +1889,14 @@ HTMLEditRules::InsertBRElement(Selection& aSelection,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
SplitNodeResult splitLinkNodeResult =
|
||||
htmlEditor->SplitNodeDeep(*linkNode, pointToBreak.AsRaw(),
|
||||
htmlEditor->SplitNodeDeep(*linkNode, pointToBreak,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (NS_WARN_IF(splitLinkNodeResult.Failed())) {
|
||||
return splitLinkNodeResult.Rv();
|
||||
}
|
||||
pointToBreak = splitLinkNodeResult.SplitPoint();
|
||||
}
|
||||
brElement =
|
||||
wsObj.InsertBreak(aSelection, pointToBreak.AsRaw(), nsIEditor::eNone);
|
||||
brElement = wsObj.InsertBreak(aSelection, pointToBreak, nsIEditor::eNone);
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1963,7 +1965,7 @@ HTMLEditRules::InsertBRElement(Selection& aSelection,
|
||||
aSelection.SetInterlinePosition(!(nextSiblingOfBRElement &&
|
||||
IsBlockNode(*nextSiblingOfBRElement)));
|
||||
ErrorResult error;
|
||||
aSelection.Collapse(afterBRElement.AsRaw(), error);
|
||||
aSelection.Collapse(afterBRElement, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
@ -2474,8 +2476,11 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Fix up selection
|
||||
rv = aSelection->Collapse(pt.AsRaw());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult error;
|
||||
aSelection->Collapse(pt, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
}
|
||||
rv = InsertBRIfNeeded(aSelection);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -2547,7 +2552,7 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
if (NS_WARN_IF(!newSel.IsSet())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
aSelection->Collapse(newSel.AsRaw());
|
||||
aSelection->Collapse(newSel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2739,8 +2744,11 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Fix up selection
|
||||
rv = aSelection->Collapse(pt.AsRaw());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult error;
|
||||
aSelection->Collapse(pt, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3474,7 +3482,7 @@ HTMLEditRules::DidDeleteSelection(Selection* aSelection,
|
||||
}
|
||||
}
|
||||
if (atCiteNode.IsSet() && seenBR) {
|
||||
RefPtr<Element> brNode = htmlEditor->CreateBR(atCiteNode.AsRaw());
|
||||
RefPtr<Element> brNode = htmlEditor->CreateBR(atCiteNode);
|
||||
if (NS_WARN_IF(!brNode)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -3584,7 +3592,7 @@ HTMLEditRules::WillMakeList(Selection* aSelection,
|
||||
}
|
||||
|
||||
SplitNodeResult splitAtSelectionStartResult =
|
||||
MaybeSplitAncestorsForInsert(listType, atStartOfSelection.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(listType, atStartOfSelection);
|
||||
if (NS_WARN_IF(splitAtSelectionStartResult.Failed())) {
|
||||
return splitAtSelectionStartResult.Rv();
|
||||
}
|
||||
@ -3941,7 +3949,7 @@ HTMLEditRules::MakeBasicBlock(Selection& aSelection, nsAtom& blockType)
|
||||
// Otherwise it gets pushed into a following block after the split,
|
||||
// which is visually bad.
|
||||
nsCOMPtr<nsIContent> brNode =
|
||||
htmlEditor->GetNextEditableHTMLNode(pointToInsertBlock.AsRaw());
|
||||
htmlEditor->GetNextEditableHTMLNode(pointToInsertBlock);
|
||||
if (brNode && brNode->IsHTMLElement(nsGkAtoms::br)) {
|
||||
AutoEditorDOMPointChildInvalidator lockOffset(pointToInsertBlock);
|
||||
rv = htmlEditor->DeleteNode(brNode);
|
||||
@ -3949,7 +3957,7 @@ HTMLEditRules::MakeBasicBlock(Selection& aSelection, nsAtom& blockType)
|
||||
}
|
||||
// Do the splits!
|
||||
SplitNodeResult splitNodeResult =
|
||||
htmlEditor->SplitNodeDeep(*curBlock, pointToInsertBlock.AsRaw(),
|
||||
htmlEditor->SplitNodeDeep(*curBlock, pointToInsertBlock,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
@ -3972,7 +3980,7 @@ HTMLEditRules::MakeBasicBlock(Selection& aSelection, nsAtom& blockType)
|
||||
|
||||
// We are making a block. Consume a br, if needed.
|
||||
nsCOMPtr<nsIContent> brNode =
|
||||
htmlEditor->GetNextEditableHTMLNodeInBlock(pointToInsertBlock.AsRaw());
|
||||
htmlEditor->GetNextEditableHTMLNodeInBlock(pointToInsertBlock);
|
||||
if (brNode && brNode->IsHTMLElement(nsGkAtoms::br)) {
|
||||
AutoEditorDOMPointChildInvalidator lockOffset(pointToInsertBlock);
|
||||
rv = htmlEditor->DeleteNode(brNode);
|
||||
@ -3982,7 +3990,7 @@ HTMLEditRules::MakeBasicBlock(Selection& aSelection, nsAtom& blockType)
|
||||
}
|
||||
// Make sure we can put a block here.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(blockType, pointToInsertBlock.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(blockType, pointToInsertBlock);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -4131,7 +4139,7 @@ HTMLEditRules::WillCSSIndent(Selection* aSelection,
|
||||
|
||||
// make sure we can put a block here
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atStartOfSelection.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atStartOfSelection);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -4219,7 +4227,7 @@ HTMLEditRules::WillCSSIndent(Selection* aSelection,
|
||||
atCurNode.GetContainer()->NodeInfo()->NameAtom();
|
||||
// Create a new nested list of correct type.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*containerName, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*containerName, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -4254,7 +4262,7 @@ HTMLEditRules::WillCSSIndent(Selection* aSelection,
|
||||
}
|
||||
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -4329,7 +4337,7 @@ HTMLEditRules::WillHTMLIndent(Selection* aSelection,
|
||||
// Make sure we can put a block here.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::blockquote,
|
||||
atStartOfSelection.AsRaw());
|
||||
atStartOfSelection);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -4417,7 +4425,7 @@ HTMLEditRules::WillHTMLIndent(Selection* aSelection,
|
||||
atCurNode.GetContainer()->NodeInfo()->NameAtom();
|
||||
// Create a new nested list of correct type.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*containerName, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*containerName, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -4466,7 +4474,7 @@ HTMLEditRules::WillHTMLIndent(Selection* aSelection,
|
||||
atListItem.GetContainer()->NodeInfo()->NameAtom();
|
||||
// Create a new nested list of correct type.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*containerName, atListItem.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*containerName, atListItem);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -4500,7 +4508,7 @@ HTMLEditRules::WillHTMLIndent(Selection* aSelection,
|
||||
}
|
||||
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::blockquote, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::blockquote, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -5104,7 +5112,7 @@ HTMLEditRules::WillAlign(Selection& aSelection,
|
||||
}
|
||||
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atStartOfSelection.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atStartOfSelection);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -5129,7 +5137,7 @@ HTMLEditRules::WillAlign(Selection& aSelection,
|
||||
}
|
||||
}
|
||||
RefPtr<Element> div =
|
||||
htmlEditor->CreateNode(nsGkAtoms::div, pointToInsertDiv.AsRaw());
|
||||
htmlEditor->CreateNode(nsGkAtoms::div, pointToInsertDiv);
|
||||
NS_ENSURE_STATE(div);
|
||||
// Remember our new block for postprocessing
|
||||
mNewBlock = div;
|
||||
@ -5238,7 +5246,7 @@ HTMLEditRules::WillAlign(Selection& aSelection,
|
||||
}
|
||||
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -5396,7 +5404,7 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode,
|
||||
// If we are a sublist, skip the br creation
|
||||
if (!HTMLEditUtils::IsList(atBlockParent.GetContainer())) {
|
||||
// Create a br before list
|
||||
RefPtr<Element> br = htmlEditor->CreateBR(atBlockParent.AsRaw());
|
||||
RefPtr<Element> br = htmlEditor->CreateBR(atBlockParent);
|
||||
if (NS_WARN_IF(!br)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -5422,16 +5430,22 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode,
|
||||
htmlEditor->GetNextNode(afterEmptyBlock);
|
||||
if (nextNode) {
|
||||
EditorDOMPoint pt = GetGoodSelPointForNode(*nextNode, aAction);
|
||||
nsresult rv = aSelection->Collapse(pt.AsRaw());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult error;
|
||||
aSelection->Collapse(pt, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
} else {
|
||||
// Adjust selection to be right after it.
|
||||
EditorRawDOMPoint afterEmptyBlock(emptyBlock);
|
||||
if (NS_WARN_IF(!afterEmptyBlock.AdvanceOffset())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = aSelection->Collapse(afterEmptyBlock);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult error;
|
||||
aSelection->Collapse(afterEmptyBlock, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
}
|
||||
} else if (aAction == nsIEditor::ePrevious ||
|
||||
aAction == nsIEditor::ePreviousWord ||
|
||||
@ -5442,7 +5456,7 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode,
|
||||
htmlEditor->GetPreviousEditableNode(atEmptyBlock);
|
||||
if (priorNode) {
|
||||
EditorDOMPoint pt = GetGoodSelPointForNode(*priorNode, aAction);
|
||||
nsresult rv = aSelection->Collapse(pt.AsRaw());
|
||||
nsresult rv = aSelection->Collapse(pt);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
EditorRawDOMPoint afterEmptyBlock(emptyBlock);
|
||||
@ -5899,20 +5913,20 @@ HTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere,
|
||||
// look back through any further inline nodes that aren't across a <br>
|
||||
// from us, and that are enclosed in the same block.
|
||||
nsCOMPtr<nsINode> priorNode =
|
||||
htmlEditor->GetPreviousEditableHTMLNodeInBlock(point.AsRaw());
|
||||
htmlEditor->GetPreviousEditableHTMLNodeInBlock(point);
|
||||
|
||||
while (priorNode && priorNode->GetParentNode() &&
|
||||
!htmlEditor->IsVisibleBRElement(priorNode) &&
|
||||
!IsBlockNode(*priorNode)) {
|
||||
point.Set(priorNode);
|
||||
priorNode = htmlEditor->GetPreviousEditableHTMLNodeInBlock(point.AsRaw());
|
||||
priorNode = htmlEditor->GetPreviousEditableHTMLNodeInBlock(point);
|
||||
}
|
||||
|
||||
// finding the real start for this point. look up the tree for as long as
|
||||
// we are the first node in the container, and as long as we haven't hit
|
||||
// the body node.
|
||||
nsCOMPtr<nsIContent> nearNode =
|
||||
htmlEditor->GetPreviousEditableHTMLNodeInBlock(point.AsRaw());
|
||||
htmlEditor->GetPreviousEditableHTMLNodeInBlock(point);
|
||||
while (!nearNode &&
|
||||
!point.IsContainerHTMLElement(nsGkAtoms::body) &&
|
||||
point.GetContainer()->GetParentNode()) {
|
||||
@ -5941,7 +5955,7 @@ HTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere,
|
||||
}
|
||||
|
||||
point.Set(point.GetContainer());
|
||||
nearNode = htmlEditor->GetPreviousEditableHTMLNodeInBlock(point.AsRaw());
|
||||
nearNode = htmlEditor->GetPreviousEditableHTMLNodeInBlock(point);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
@ -5975,7 +5989,7 @@ HTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere,
|
||||
// Only in the first case, after the caret position isn't wrapped with
|
||||
// new <div> element.
|
||||
nsCOMPtr<nsIContent> nextNode =
|
||||
htmlEditor->GetNextEditableHTMLNodeInBlock(point.AsRaw());
|
||||
htmlEditor->GetNextEditableHTMLNodeInBlock(point);
|
||||
|
||||
while (nextNode && !IsBlockNode(*nextNode) && nextNode->GetParentNode()) {
|
||||
point.Set(nextNode);
|
||||
@ -6003,14 +6017,14 @@ HTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere,
|
||||
}
|
||||
}
|
||||
}
|
||||
nextNode = htmlEditor->GetNextEditableHTMLNodeInBlock(point.AsRaw());
|
||||
nextNode = htmlEditor->GetNextEditableHTMLNodeInBlock(point);
|
||||
}
|
||||
|
||||
// finding the real end for this point. look up the tree for as long as we
|
||||
// are the last node in the container, and as long as we haven't hit the body
|
||||
// node.
|
||||
nsCOMPtr<nsIContent> nearNode =
|
||||
htmlEditor->GetNextEditableHTMLNodeInBlock(point.AsRaw());
|
||||
htmlEditor->GetNextEditableHTMLNodeInBlock(point);
|
||||
while (!nearNode &&
|
||||
!point.IsContainerHTMLElement(nsGkAtoms::body) &&
|
||||
point.GetContainer()->GetParentNode()) {
|
||||
@ -6027,7 +6041,7 @@ HTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere,
|
||||
if (NS_WARN_IF(!point.AdvanceOffset())) {
|
||||
break;
|
||||
}
|
||||
nearNode = htmlEditor->GetNextEditableHTMLNodeInBlock(point.AsRaw());
|
||||
nearNode = htmlEditor->GetNextEditableHTMLNodeInBlock(point);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
@ -6126,20 +6140,19 @@ HTMLEditRules::PromoteRange(nsRange& aRange,
|
||||
EditorDOMPoint startPoint =
|
||||
GetPromotedPoint(kStart, *startNode, startOffset, aOperationType);
|
||||
if (!htmlEditor->IsDescendantOfEditorRoot(
|
||||
EditorBase::GetNodeAtRangeOffsetPoint(startPoint.AsRaw()))) {
|
||||
EditorBase::GetNodeAtRangeOffsetPoint(startPoint))) {
|
||||
return;
|
||||
}
|
||||
EditorDOMPoint endPoint =
|
||||
GetPromotedPoint(kEnd, *endNode, endOffset, aOperationType);
|
||||
EditorRawDOMPoint lastRawPoint(endPoint.AsRaw());
|
||||
EditorRawDOMPoint lastRawPoint(endPoint);
|
||||
lastRawPoint.RewindOffset();
|
||||
if (!htmlEditor->IsDescendantOfEditorRoot(
|
||||
EditorBase::GetNodeAtRangeOffsetPoint(lastRawPoint))) {
|
||||
return;
|
||||
}
|
||||
|
||||
DebugOnly<nsresult> rv =
|
||||
aRange.SetStartAndEnd(startPoint.AsRaw(), endPoint.AsRaw());
|
||||
DebugOnly<nsresult> rv = aRange.SetStartAndEnd(startPoint, endPoint);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
@ -6189,7 +6202,7 @@ HTMLEditRules::GetNodesForOperation(
|
||||
// Split the text node.
|
||||
ErrorResult error;
|
||||
nsCOMPtr<nsIContent> newLeftNode =
|
||||
htmlEditor->SplitNode(atEnd.AsRaw(), error);
|
||||
htmlEditor->SplitNode(atEnd, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
@ -7034,7 +7047,7 @@ HTMLEditRules::ReturnInParagraph(Selection& aSelection,
|
||||
if (doesCRCreateNewP) {
|
||||
ErrorResult error;
|
||||
nsCOMPtr<nsIContent> newLeftDivOrP =
|
||||
htmlEditor->SplitNode(pointToSplitParentDivOrP.AsRaw(), error);
|
||||
htmlEditor->SplitNode(pointToSplitParentDivOrP, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return EditActionResult(error.StealNSResult());
|
||||
}
|
||||
@ -7053,12 +7066,12 @@ HTMLEditRules::ReturnInParagraph(Selection& aSelection,
|
||||
// is there a BR prior to it?
|
||||
nsCOMPtr<nsIContent> nearNode;
|
||||
nearNode =
|
||||
htmlEditor->GetPreviousEditableHTMLNode(atStartOfSelection.AsRaw());
|
||||
htmlEditor->GetPreviousEditableHTMLNode(atStartOfSelection);
|
||||
if (!nearNode || !htmlEditor->IsVisibleBRElement(nearNode) ||
|
||||
TextEditUtils::HasMozAttr(GetAsDOMNode(nearNode))) {
|
||||
// is there a BR after it?
|
||||
nearNode =
|
||||
htmlEditor->GetNextEditableHTMLNode(atStartOfSelection.AsRaw());
|
||||
htmlEditor->GetNextEditableHTMLNode(atStartOfSelection);
|
||||
if (!nearNode || !htmlEditor->IsVisibleBRElement(nearNode) ||
|
||||
TextEditUtils::HasMozAttr(GetAsDOMNode(nearNode))) {
|
||||
pointToInsertBR = atStartOfSelection;
|
||||
@ -7090,7 +7103,7 @@ HTMLEditRules::ReturnInParagraph(Selection& aSelection,
|
||||
}
|
||||
}
|
||||
EditActionResult result(
|
||||
SplitParagraph(aSelection, aParentDivOrP, pointToSplitParentDivOrP.AsRaw(),
|
||||
SplitParagraph(aSelection, aParentDivOrP, pointToSplitParentDivOrP,
|
||||
brNode));
|
||||
result.MarkAsHandled();
|
||||
if (NS_WARN_IF(result.Failed())) {
|
||||
@ -7099,11 +7112,13 @@ HTMLEditRules::ReturnInParagraph(Selection& aSelection,
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsresult
|
||||
HTMLEditRules::SplitParagraph(Selection& aSelection,
|
||||
Element& aParentDivOrP,
|
||||
const EditorRawDOMPoint& aStartOfRightNode,
|
||||
nsIContent* aNextBRNode)
|
||||
HTMLEditRules::SplitParagraph(
|
||||
Selection& aSelection,
|
||||
Element& aParentDivOrP,
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
||||
nsIContent* aNextBRNode)
|
||||
{
|
||||
if (NS_WARN_IF(!mHTMLEditor)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
@ -7417,7 +7432,7 @@ HTMLEditRules::MakeBlockquote(nsTArray<OwningNonNull<nsINode>>& aNodeArray)
|
||||
if (!curBlock) {
|
||||
EditorDOMPoint atCurNode(curNode);
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::blockquote, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::blockquote, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -7594,7 +7609,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
|
||||
// Make sure we can put a block here
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(aBlockTag, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(aBlockTag, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -7620,7 +7635,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
// The break is the first (or even only) node we encountered. Create a
|
||||
// block for it.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(aBlockTag, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(aBlockTag, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -7653,7 +7668,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
AutoEditorDOMPointOffsetInvalidator lockChild(atCurNode);
|
||||
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(aBlockTag, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(aBlockTag, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -7681,10 +7696,11 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
SplitNodeResult
|
||||
HTMLEditRules::MaybeSplitAncestorsForInsert(
|
||||
nsAtom& aTag,
|
||||
const EditorRawDOMPoint& aStartOfDeepestRightNode)
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode)
|
||||
{
|
||||
if (NS_WARN_IF(!aStartOfDeepestRightNode.IsSet())) {
|
||||
return SplitNodeResult(NS_ERROR_INVALID_ARG);
|
||||
@ -8131,7 +8147,7 @@ HTMLEditRules::CheckInterlinePosition(Selection& aSelection)
|
||||
// special-case first so that we don't accidentally fall through into one of
|
||||
// the other conditionals.
|
||||
nsCOMPtr<nsIContent> node =
|
||||
htmlEditor->GetPreviousEditableHTMLNodeInBlock(atStartOfSelection.AsRaw());
|
||||
htmlEditor->GetPreviousEditableHTMLNodeInBlock(atStartOfSelection);
|
||||
if (node && node->IsHTMLElement(nsGkAtoms::br)) {
|
||||
aSelection.SetInterlinePosition(true);
|
||||
return;
|
||||
@ -8218,7 +8234,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
}
|
||||
|
||||
// we know we can skip the rest of this routine given the cirumstance
|
||||
RefPtr<Element> brElement = CreateMozBR(point.AsRaw());
|
||||
RefPtr<Element> brElement = CreateMozBR(point);
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -8237,7 +8253,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
// 3) that br is not visible
|
||||
|
||||
nsCOMPtr<nsIContent> nearNode =
|
||||
htmlEditor->GetPreviousEditableHTMLNode(point.AsRaw());
|
||||
htmlEditor->GetPreviousEditableHTMLNode(point);
|
||||
if (nearNode) {
|
||||
// is nearNode also a descendant of same block?
|
||||
RefPtr<Element> block = htmlEditor->GetBlock(*point.GetContainer());
|
||||
@ -8248,7 +8264,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
// need to insert special moz BR. Why? Because if we don't
|
||||
// the user will see no new line for the break. Also, things
|
||||
// like table cells won't grow in height.
|
||||
RefPtr<Element> brElement = CreateMozBR(point.AsRaw());
|
||||
RefPtr<Element> brElement = CreateMozBR(point);
|
||||
if (NS_WARN_IF(!brElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -8256,7 +8272,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
// selection stays *before* moz-br, sticking to it
|
||||
aSelection->SetInterlinePosition(true);
|
||||
ErrorResult error;
|
||||
aSelection->Collapse(point.AsRaw(), error);
|
||||
aSelection->Collapse(point, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
@ -8274,7 +8290,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
}
|
||||
|
||||
// we aren't in a textnode: are we adjacent to text or a break or an image?
|
||||
nearNode = htmlEditor->GetPreviousEditableHTMLNodeInBlock(point.AsRaw());
|
||||
nearNode = htmlEditor->GetPreviousEditableHTMLNodeInBlock(point);
|
||||
if (nearNode && (TextEditUtils::IsBreak(nearNode) ||
|
||||
EditorBase::IsTextNode(nearNode) ||
|
||||
HTMLEditUtils::IsImage(nearNode) ||
|
||||
@ -8282,7 +8298,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
// this is a good place for the caret to be
|
||||
return NS_OK;
|
||||
}
|
||||
nearNode = htmlEditor->GetNextEditableHTMLNodeInBlock(point.AsRaw());
|
||||
nearNode = htmlEditor->GetNextEditableHTMLNodeInBlock(point);
|
||||
if (nearNode && (TextEditUtils::IsBreak(nearNode) ||
|
||||
EditorBase::IsTextNode(nearNode) ||
|
||||
nearNode->IsAnyOfHTMLElements(nsGkAtoms::img,
|
||||
@ -8292,22 +8308,23 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
|
||||
// look for a nearby text node.
|
||||
// prefer the correct direction.
|
||||
nearNode = FindNearEditableNode(point.AsRaw(), aAction);
|
||||
nearNode = FindNearEditableNode(point, aAction);
|
||||
if (!nearNode) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
EditorDOMPoint pt = GetGoodSelPointForNode(*nearNode, aAction);
|
||||
ErrorResult error;
|
||||
aSelection->Collapse(pt.AsRaw(), error);
|
||||
aSelection->Collapse(pt, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
HTMLEditRules::FindNearEditableNode(const EditorRawDOMPoint& aPoint,
|
||||
HTMLEditRules::FindNearEditableNode(const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
nsIEditor::EDirection aDirection)
|
||||
{
|
||||
if (NS_WARN_IF(!aPoint.IsSet()) ||
|
||||
@ -8662,7 +8679,7 @@ HTMLEditRules::PopListItem(nsIContent& aListItem,
|
||||
|
||||
// split the list
|
||||
ErrorResult error;
|
||||
leftListNode = mHTMLEditor->SplitNode(atListItem.AsRaw(), error);
|
||||
leftListNode = mHTMLEditor->SplitNode(atListItem, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
@ -9335,7 +9352,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
|
||||
|
||||
// Make sure we can put a block here.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atStartOfSelection.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atStartOfSelection);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -9390,7 +9407,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
|
||||
atCurNode.GetContainer()->NodeInfo()->NameAtom();
|
||||
// Create a new nested list of correct type.
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*containerName, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*containerName, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -9441,7 +9458,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
|
||||
atListItem.GetContainer()->NodeInfo()->NameAtom();
|
||||
// Create a new nested list of correct type
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*containerName, atListItem.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*containerName, atListItem);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
@ -9473,7 +9490,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
|
||||
continue;
|
||||
}
|
||||
SplitNodeResult splitNodeResult =
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atCurNode.AsRaw());
|
||||
MaybeSplitAncestorsForInsert(*nsGkAtoms::div, atCurNode);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
}
|
||||
|
@ -320,9 +320,10 @@ protected:
|
||||
* If this is not nullptr, the <br> node may be
|
||||
* removed.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
nsresult SplitParagraph(Selection& aSelection,
|
||||
Element& aParentDivOrP,
|
||||
const EditorRawDOMPoint& aStartOfRightNode,
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode,
|
||||
nsIContent* aBRNode);
|
||||
|
||||
nsresult ReturnInListItem(Selection& aSelection, Element& aHeader,
|
||||
@ -457,9 +458,10 @@ protected:
|
||||
* @return When succeeded, SplitPoint() returns
|
||||
* the point to insert the element.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
SplitNodeResult MaybeSplitAncestorsForInsert(
|
||||
nsAtom& aTag,
|
||||
const EditorRawDOMPoint& aStartOfDeepestRightNode);
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfDeepestRightNode);
|
||||
|
||||
nsresult AddTerminatingBR(nsIDOMNode *aBlock);
|
||||
EditorDOMPoint JoinNodesSmart(nsIContent& aNodeLeft,
|
||||
@ -490,7 +492,8 @@ protected:
|
||||
* And also if aDirection is not nsIEditor::ePrevious,
|
||||
* the result may be the node pointed by aPoint.
|
||||
*/
|
||||
nsIContent* FindNearEditableNode(const EditorRawDOMPoint& aPoint,
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* FindNearEditableNode(const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
nsIEditor::EDirection aDirection);
|
||||
/**
|
||||
* Returns true if aNode1 or aNode2 or both is the descendant of some type of
|
||||
|
@ -88,6 +88,17 @@ IsNamedAnchorTag(const nsString& s)
|
||||
return s.EqualsIgnoreCase("anchor") || s.EqualsIgnoreCase("namedanchor");
|
||||
}
|
||||
|
||||
template EditorDOMPoint
|
||||
HTMLEditor::InsertNodeIntoProperAncestor(
|
||||
nsIContent& aNode,
|
||||
const EditorDOMPoint& aPointToInsert,
|
||||
SplitAtEdges aSplitAtEdges);
|
||||
template EditorDOMPoint
|
||||
HTMLEditor::InsertNodeIntoProperAncestor(
|
||||
nsIContent& aNode,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
SplitAtEdges aSplitAtEdges);
|
||||
|
||||
HTMLEditor::HTMLEditor()
|
||||
: mCRInParagraphCreatesParagraph(false)
|
||||
, mCSSAware(false)
|
||||
@ -1600,7 +1611,7 @@ HTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement,
|
||||
"Failed to advance offset from inserted point");
|
||||
// Collapse selection to the new <br> element node after creating it.
|
||||
RefPtr<Element> newBRElement =
|
||||
CreateBRImpl(*selection, insertedPoint.AsRaw(), ePrevious);
|
||||
CreateBRImpl(*selection, insertedPoint, ePrevious);
|
||||
if (NS_WARN_IF(!newBRElement)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1611,10 +1622,11 @@ HTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement,
|
||||
return rv;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
EditorDOMPoint
|
||||
HTMLEditor::InsertNodeIntoProperAncestor(
|
||||
nsIContent& aNode,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
SplitAtEdges aSplitAtEdges)
|
||||
{
|
||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||
@ -1670,7 +1682,7 @@ HTMLEditor::InsertNodeIntoProperAncestor(
|
||||
// when it's necessary.
|
||||
AutoEditorDOMPointChildInvalidator lockOffset(pointToInsert);
|
||||
// Now we can insert the new node.
|
||||
nsresult rv = InsertNode(aNode, pointToInsert.AsRaw());
|
||||
nsresult rv = InsertNode(aNode, pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return EditorDOMPoint();
|
||||
}
|
||||
@ -2042,7 +2054,7 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType,
|
||||
// Create a list and insert it before the right node if we split some
|
||||
// parents of start of selection above, or just start of selection
|
||||
// otherwise.
|
||||
RefPtr<Element> newList = CreateNode(listAtom, pointToInsertList.AsRaw());
|
||||
RefPtr<Element> newList = CreateNode(listAtom, pointToInsertList);
|
||||
NS_ENSURE_STATE(newList);
|
||||
// make a list item
|
||||
EditorRawDOMPoint atStartOfNewList(newList, 0);
|
||||
@ -2192,8 +2204,7 @@ HTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
|
||||
// Create a block and insert it before the right node if we split some
|
||||
// parents of start of selection above, or just start of selection
|
||||
// otherwise.
|
||||
RefPtr<Element> newBlock =
|
||||
CreateNode(blockAtom, pointToInsertBlock.AsRaw());
|
||||
RefPtr<Element> newBlock = CreateNode(blockAtom, pointToInsertBlock);
|
||||
NS_ENSURE_STATE(newBlock);
|
||||
|
||||
// reposition selection to inside the block
|
||||
@ -2276,7 +2287,7 @@ HTMLEditor::Indent(const nsAString& aIndent)
|
||||
// parents of start of selection above, or just start of selection
|
||||
// otherwise.
|
||||
RefPtr<Element> newBQ =
|
||||
CreateNode(nsGkAtoms::blockquote, pointToInsertBlockquote.AsRaw());
|
||||
CreateNode(nsGkAtoms::blockquote, pointToInsertBlockquote);
|
||||
NS_ENSURE_STATE(newBQ);
|
||||
// put a space in it so layout will draw the list item
|
||||
rv = selection->Collapse(newBQ, 0);
|
||||
@ -3801,9 +3812,10 @@ HTMLEditor::GetPreviousHTMLElementOrTextInternal(nsINode& aNode,
|
||||
GetPreviousElementOrText(aNode);
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
HTMLEditor::GetPreviousHTMLElementOrTextInternal(
|
||||
const EditorRawDOMPoint& aPoint,
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing)
|
||||
{
|
||||
if (!GetActiveEditingHost()) {
|
||||
@ -3824,9 +3836,11 @@ HTMLEditor::GetPreviousEditableHTMLNodeInternal(nsINode& aNode,
|
||||
GetPreviousEditableNode(aNode);
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
HTMLEditor::GetPreviousEditableHTMLNodeInternal(const EditorRawDOMPoint& aPoint,
|
||||
bool aNoBlockCrossing)
|
||||
HTMLEditor::GetPreviousEditableHTMLNodeInternal(
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing)
|
||||
{
|
||||
if (!GetActiveEditingHost()) {
|
||||
return nullptr;
|
||||
@ -3846,9 +3860,11 @@ HTMLEditor::GetNextHTMLElementOrTextInternal(nsINode& aNode,
|
||||
GetNextElementOrText(aNode);
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
HTMLEditor::GetNextHTMLElementOrTextInternal(const EditorRawDOMPoint& aPoint,
|
||||
bool aNoBlockCrossing)
|
||||
HTMLEditor::GetNextHTMLElementOrTextInternal(
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing)
|
||||
{
|
||||
if (!GetActiveEditingHost()) {
|
||||
return nullptr;
|
||||
@ -3868,9 +3884,11 @@ HTMLEditor::GetNextEditableHTMLNodeInternal(nsINode& aNode,
|
||||
GetNextEditableNode(aNode);
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
HTMLEditor::GetNextEditableHTMLNodeInternal(const EditorRawDOMPoint& aPoint,
|
||||
bool aNoBlockCrossing)
|
||||
HTMLEditor::GetNextEditableHTMLNodeInternal(
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing)
|
||||
{
|
||||
if (!GetActiveEditingHost()) {
|
||||
return nullptr;
|
||||
|
@ -423,9 +423,10 @@ public:
|
||||
* @return Returns inserted point if succeeded.
|
||||
* Otherwise, the result is not set.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
EditorDOMPoint
|
||||
InsertNodeIntoProperAncestor(nsIContent& aNode,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
SplitAtEdges aSplitAtEdges);
|
||||
|
||||
/**
|
||||
@ -934,12 +935,15 @@ protected:
|
||||
{
|
||||
return GetPreviousHTMLElementOrTextInternal(aNode, true);
|
||||
}
|
||||
nsIContent* GetPreviousHTMLElementOrText(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
GetPreviousHTMLElementOrText(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetPreviousHTMLElementOrTextInternal(aPoint, false);
|
||||
}
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
GetPreviousHTMLElementOrTextInBlock(const EditorRawDOMPoint& aPoint)
|
||||
GetPreviousHTMLElementOrTextInBlock(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetPreviousHTMLElementOrTextInternal(aPoint, true);
|
||||
}
|
||||
@ -950,8 +954,9 @@ protected:
|
||||
*/
|
||||
nsIContent* GetPreviousHTMLElementOrTextInternal(nsINode& aNode,
|
||||
bool aNoBlockCrossing);
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
GetPreviousHTMLElementOrTextInternal(const EditorRawDOMPoint& aPoint,
|
||||
GetPreviousHTMLElementOrTextInternal(const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing);
|
||||
|
||||
/**
|
||||
@ -967,12 +972,15 @@ protected:
|
||||
{
|
||||
return GetPreviousEditableHTMLNodeInternal(aNode, true);
|
||||
}
|
||||
nsIContent* GetPreviousEditableHTMLNode(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
GetPreviousEditableHTMLNode(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetPreviousEditableHTMLNodeInternal(aPoint, false);
|
||||
}
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetPreviousEditableHTMLNodeInBlock(
|
||||
const EditorRawDOMPoint& aPoint)
|
||||
const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetPreviousEditableHTMLNodeInternal(aPoint, true);
|
||||
}
|
||||
@ -983,8 +991,9 @@ protected:
|
||||
*/
|
||||
nsIContent* GetPreviousEditableHTMLNodeInternal(nsINode& aNode,
|
||||
bool aNoBlockCrossing);
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetPreviousEditableHTMLNodeInternal(
|
||||
const EditorRawDOMPoint& aPoint,
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing);
|
||||
|
||||
/**
|
||||
@ -1005,11 +1014,15 @@ protected:
|
||||
{
|
||||
return GetNextHTMLElementOrTextInternal(aNode, true);
|
||||
}
|
||||
nsIContent* GetNextHTMLElementOrText(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
GetNextHTMLElementOrText(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextHTMLElementOrTextInternal(aPoint, false);
|
||||
}
|
||||
nsIContent* GetNextHTMLElementOrTextInBlock(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
GetNextHTMLElementOrTextInBlock(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextHTMLElementOrTextInternal(aPoint, true);
|
||||
}
|
||||
@ -1020,8 +1033,10 @@ protected:
|
||||
*/
|
||||
nsIContent* GetNextHTMLElementOrTextInternal(nsINode& aNode,
|
||||
bool aNoBlockCrossing);
|
||||
nsIContent* GetNextHTMLElementOrTextInternal(const EditorRawDOMPoint& aPoint,
|
||||
bool aNoBlockCrossing);
|
||||
template<typename PT, typename CT>
|
||||
nsIContent*
|
||||
GetNextHTMLElementOrTextInternal(const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing);
|
||||
|
||||
/**
|
||||
* GetNextEditableHTMLNode*() methods are similar to
|
||||
@ -1041,12 +1056,14 @@ protected:
|
||||
{
|
||||
return GetNextEditableHTMLNodeInternal(aNode, true);
|
||||
}
|
||||
nsIContent* GetNextEditableHTMLNode(const EditorRawDOMPoint& aPoint)
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextEditableHTMLNode(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextEditableHTMLNodeInternal(aPoint, false);
|
||||
}
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextEditableHTMLNodeInBlock(
|
||||
const EditorRawDOMPoint& aPoint)
|
||||
const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return GetNextEditableHTMLNodeInternal(aPoint, true);
|
||||
}
|
||||
@ -1056,9 +1073,10 @@ protected:
|
||||
* of above methods. Please don't use this method directly.
|
||||
*/
|
||||
nsIContent* GetNextEditableHTMLNodeInternal(nsINode& aNode,
|
||||
bool aNoBlockCrossing);
|
||||
bool aNoBlockCrossing);
|
||||
template<typename PT, typename CT>
|
||||
nsIContent* GetNextEditableHTMLNodeInternal(
|
||||
const EditorRawDOMPoint& aPoint,
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
bool aNoBlockCrossing);
|
||||
|
||||
bool IsFirstEditableChild(nsINode* aNode);
|
||||
|
@ -142,7 +142,7 @@ HTMLEditor::LoadHTML(const nsAString& aInputString)
|
||||
documentFragment->GetFirstChild();
|
||||
contentToInsert;
|
||||
contentToInsert = documentFragment->GetFirstChild()) {
|
||||
rv = InsertNode(*contentToInsert, pointToInsert.AsRaw());
|
||||
rv = InsertNode(*contentToInsert, pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -362,8 +362,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
// Are we in a text node? If so, split it.
|
||||
if (pointToInsert.IsInTextNode()) {
|
||||
SplitNodeResult splitNodeResult =
|
||||
SplitNodeDeep(*pointToInsert.GetContainerAsContent(),
|
||||
pointToInsert.AsRaw(),
|
||||
SplitNodeDeep(*pointToInsert.GetContainerAsContent(), pointToInsert,
|
||||
SplitAtEdges::eAllowToCreateEmptyContainer);
|
||||
if (NS_WARN_IF(splitNodeResult.Failed())) {
|
||||
return splitNodeResult.Rv();
|
||||
@ -452,7 +451,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
firstChild = curNode->GetFirstChild()) {
|
||||
EditorDOMPoint insertedPoint =
|
||||
InsertNodeIntoProperAncestor(
|
||||
*firstChild, pointToInsert.AsRaw(),
|
||||
*firstChild, pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (NS_WARN_IF(!insertedPoint.IsSet())) {
|
||||
break;
|
||||
@ -494,7 +493,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
}
|
||||
EditorDOMPoint insertedPoint =
|
||||
InsertNodeIntoProperAncestor(
|
||||
*firstChild, pointToInsert.AsRaw(),
|
||||
*firstChild, pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (NS_WARN_IF(!insertedPoint.IsSet())) {
|
||||
break;
|
||||
@ -523,7 +522,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
firstChild = curNode->GetFirstChild()) {
|
||||
EditorDOMPoint insertedPoint =
|
||||
InsertNodeIntoProperAncestor(
|
||||
*firstChild, pointToInsert.AsRaw(),
|
||||
*firstChild, pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (NS_WARN_IF(!insertedPoint.IsSet())) {
|
||||
break;
|
||||
@ -542,7 +541,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
// Try to insert.
|
||||
EditorDOMPoint insertedPoint =
|
||||
InsertNodeIntoProperAncestor(
|
||||
*curNode->AsContent(), pointToInsert.AsRaw(),
|
||||
*curNode->AsContent(), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (insertedPoint.IsSet()) {
|
||||
lastInsertNode = curNode->AsContent();
|
||||
@ -562,7 +561,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
||||
nsCOMPtr<nsINode> oldParent = content->GetParentNode();
|
||||
insertedPoint =
|
||||
InsertNodeIntoProperAncestor(
|
||||
*content->GetParent(), pointToInsert.AsRaw(),
|
||||
*content->GetParent(), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (insertedPoint.IsSet()) {
|
||||
insertedContextParent = oldParent;
|
||||
|
@ -151,7 +151,7 @@ HTMLEditor::InsertCell(nsIDOMElement* aDOMCell,
|
||||
|
||||
// Don't let Rules System change the selection.
|
||||
AutoTransactionsConserveSelection dontChangeSelection(this);
|
||||
return InsertNode(*newCell, pointToInsert.AsRaw());
|
||||
return InsertNode(*newCell, pointToInsert);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -22,21 +22,32 @@ namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
template already_AddRefed<InsertNodeTransaction>
|
||||
InsertNodeTransaction::Create(EditorBase& aEditorBase,
|
||||
nsIContent& aContentToInsert,
|
||||
const EditorDOMPoint& aPointToInsert);
|
||||
template already_AddRefed<InsertNodeTransaction>
|
||||
InsertNodeTransaction::Create(EditorBase& aEditorBase,
|
||||
nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
|
||||
// static
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<InsertNodeTransaction>
|
||||
InsertNodeTransaction::Create(EditorBase& aEditorBase,
|
||||
nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert)
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
{
|
||||
RefPtr<InsertNodeTransaction> transaction =
|
||||
new InsertNodeTransaction(aEditorBase, aContentToInsert, aPointToInsert);
|
||||
return transaction.forget();
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
InsertNodeTransaction::InsertNodeTransaction(
|
||||
EditorBase& aEditorBase,
|
||||
nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert)
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
: mContentToInsert(&aContentToInsert)
|
||||
, mPointToInsert(aPointToInsert)
|
||||
, mEditorBase(&aEditorBase)
|
||||
|
@ -23,9 +23,10 @@ class EditorBase;
|
||||
class InsertNodeTransaction final : public EditTransactionBase
|
||||
{
|
||||
protected:
|
||||
template<typename PT, typename CT>
|
||||
InsertNodeTransaction(EditorBase& aEditorBase,
|
||||
nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -42,10 +43,11 @@ public:
|
||||
* @return A InsertNodeTranaction which was initialized
|
||||
* with the arguments.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
static already_AddRefed<InsertNodeTransaction>
|
||||
Create(EditorBase& aEditorBase,
|
||||
nsIContent& aContentToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert);
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert);
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
@ -28,6 +28,16 @@ using namespace dom;
|
||||
* { {startnode, startoffset} , {endnode, endoffset} } tuples. Can't store
|
||||
* ranges since dom gravity will possibly change the ranges.
|
||||
******************************************************************************/
|
||||
|
||||
template nsresult
|
||||
RangeUpdater::SelAdjCreateNode(const EditorDOMPoint& aPoint);
|
||||
template nsresult
|
||||
RangeUpdater::SelAdjCreateNode(const EditorRawDOMPoint& aPoint);
|
||||
template nsresult
|
||||
RangeUpdater::SelAdjInsertNode(const EditorDOMPoint& aPoint);
|
||||
template nsresult
|
||||
RangeUpdater::SelAdjInsertNode(const EditorRawDOMPoint& aPoint);
|
||||
|
||||
SelectionState::SelectionState()
|
||||
{
|
||||
}
|
||||
@ -211,8 +221,9 @@ RangeUpdater::DropSelectionState(SelectionState& aSelState)
|
||||
|
||||
// gravity methods:
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsresult
|
||||
RangeUpdater::SelAdjCreateNode(const EditorRawDOMPoint& aPoint)
|
||||
RangeUpdater::SelAdjCreateNode(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
if (mLock) {
|
||||
// lock set by Will/DidReplaceParent, etc...
|
||||
@ -243,8 +254,9 @@ RangeUpdater::SelAdjCreateNode(const EditorRawDOMPoint& aPoint)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsresult
|
||||
RangeUpdater::SelAdjInsertNode(const EditorRawDOMPoint& aPoint)
|
||||
RangeUpdater::SelAdjInsertNode(const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
return SelAdjCreateNode(aPoint);
|
||||
}
|
||||
|
@ -108,8 +108,10 @@ public:
|
||||
// if you move a node, that corresponds to deleting it and reinserting it.
|
||||
// DOM Range gravity will promote the selection out of the node on deletion,
|
||||
// which is not what you want if you know you are reinserting it.
|
||||
nsresult SelAdjCreateNode(const EditorRawDOMPoint& aPoint);
|
||||
nsresult SelAdjInsertNode(const EditorRawDOMPoint& aPoint);
|
||||
template<typename PT, typename CT>
|
||||
nsresult SelAdjCreateNode(const EditorDOMPointBase<PT, CT>& aPoint);
|
||||
template<typename PT, typename CT>
|
||||
nsresult SelAdjInsertNode(const EditorDOMPointBase<PT, CT>& aPoint);
|
||||
void SelAdjDeleteNode(nsINode* aNode);
|
||||
nsresult SelAdjSplitNode(nsIContent& aRightNode, nsIContent* aNewLeftNode);
|
||||
nsresult SelAdjJoinNodes(nsINode& aLeftNode,
|
||||
|
@ -17,19 +17,31 @@ namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
template already_AddRefed<SplitNodeTransaction>
|
||||
SplitNodeTransaction::Create(
|
||||
EditorBase& aEditorBase,
|
||||
const EditorDOMPoint& aStartOfRightNode);
|
||||
template already_AddRefed<SplitNodeTransaction>
|
||||
SplitNodeTransaction::Create(
|
||||
EditorBase& aEditorBase,
|
||||
const EditorRawDOMPoint& aStartOfRightNode);
|
||||
|
||||
// static
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<SplitNodeTransaction>
|
||||
SplitNodeTransaction::Create(EditorBase& aEditorBase,
|
||||
const EditorRawDOMPoint& aStartOfRightNode)
|
||||
SplitNodeTransaction::Create(
|
||||
EditorBase& aEditorBase,
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode)
|
||||
{
|
||||
RefPtr<SplitNodeTransaction> transaction =
|
||||
new SplitNodeTransaction(aEditorBase, aStartOfRightNode);
|
||||
return transaction.forget();
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
SplitNodeTransaction::SplitNodeTransaction(
|
||||
EditorBase& aEditorBase,
|
||||
const EditorRawDOMPoint& aStartOfRightNode)
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode)
|
||||
: mEditorBase(&aEditorBase)
|
||||
, mStartOfRightNode(aStartOfRightNode)
|
||||
{
|
||||
|
@ -27,8 +27,9 @@ class EditorBase;
|
||||
class SplitNodeTransaction final : public EditTransactionBase
|
||||
{
|
||||
private:
|
||||
template<typename PT, typename CT>
|
||||
SplitNodeTransaction(EditorBase& aEditorBase,
|
||||
const EditorRawDOMPoint& aStartOfRightNode);
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode);
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -42,9 +43,10 @@ public:
|
||||
* next sibling. And the point will be start
|
||||
* of the right node.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
static already_AddRefed<SplitNodeTransaction>
|
||||
Create(EditorBase& aEditorBase,
|
||||
const EditorRawDOMPoint& aStartOfRightNode);
|
||||
const EditorDOMPointBase<PT, CT>& aStartOfRightNode);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitNodeTransaction,
|
||||
|
@ -228,7 +228,9 @@ protected:
|
||||
* inserted.
|
||||
* @return Returns created <br> element.
|
||||
*/
|
||||
already_AddRefed<Element> CreateBR(const EditorRawDOMPoint& aPointToInsert)
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
CreateBR(const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
{
|
||||
return CreateBRInternal(aPointToInsert, false);
|
||||
}
|
||||
@ -240,7 +242,9 @@ protected:
|
||||
* inserted.
|
||||
* @return Returns created moz-<br> element.
|
||||
*/
|
||||
already_AddRefed<Element> CreateMozBR(const EditorRawDOMPoint& aPointToInsert)
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
CreateMozBR(const EditorDOMPointBase<PT, CT>& aPointToInsert)
|
||||
{
|
||||
return CreateBRInternal(aPointToInsert, true);
|
||||
}
|
||||
|
@ -63,6 +63,13 @@ namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
template already_AddRefed<Element>
|
||||
TextEditor::CreateBR(const EditorDOMPoint& aPointToInsert,
|
||||
EDirection aSelect);
|
||||
template already_AddRefed<Element>
|
||||
TextEditor::CreateBR(const EditorRawDOMPoint& aPointToInsert,
|
||||
EDirection aSelect);
|
||||
|
||||
TextEditor::TextEditor()
|
||||
: mWrapColumn(0)
|
||||
, mMaxTextLength(-1)
|
||||
@ -408,8 +415,9 @@ TextEditor::TypedText(const nsAString& aString, ETypingAction aAction)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
TextEditor::CreateBR(const EditorRawDOMPoint& aPointToInsert,
|
||||
TextEditor::CreateBR(const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EDirection aSelect /* = eNone */)
|
||||
{
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
@ -420,9 +428,10 @@ TextEditor::CreateBR(const EditorRawDOMPoint& aPointToInsert,
|
||||
return CreateBRImpl(*selection, aPointToInsert, aSelect);
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
TextEditor::CreateBRImpl(Selection& aSelection,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EDirection aSelect)
|
||||
{
|
||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||
@ -462,7 +471,7 @@ TextEditor::CreateBRImpl(Selection& aSelection,
|
||||
pointInContainer.Set(aPointToInsert.GetContainer());
|
||||
}
|
||||
// Create a <br> node.
|
||||
newBRElement = CreateNode(nsGkAtoms::br, pointInContainer.AsRaw());
|
||||
newBRElement = CreateNode(nsGkAtoms::br, pointInContainer);
|
||||
if (NS_WARN_IF(!newBRElement)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -213,8 +213,10 @@ protected:
|
||||
* @return The new <br> node. If failed to create new <br>
|
||||
* node, returns nullptr.
|
||||
*/
|
||||
already_AddRefed<Element> CreateBR(const EditorRawDOMPoint& aPointToInsert,
|
||||
EDirection aSelect = eNone);
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
CreateBR(const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EDirection aSelect = eNone);
|
||||
|
||||
/**
|
||||
* CreateBRImpl() creates a <br> element and inserts it before aPointToInsert.
|
||||
@ -233,9 +235,10 @@ protected:
|
||||
* @return The new <br> node. If failed to create new
|
||||
* <br> node, returns nullptr.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
CreateBRImpl(Selection& aSelection,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EDirection aSelect);
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,24 @@ template void WSRunObject::NextVisibleNode(const EditorRawDOMPoint& aPoint,
|
||||
nsCOMPtr<nsINode>* outVisNode,
|
||||
int32_t* outVisOffset,
|
||||
WSType* outType);
|
||||
template already_AddRefed<Element>
|
||||
WSRunObject::InsertBreak(Selection& aSelection,
|
||||
const EditorDOMPoint& aPointToInsert,
|
||||
nsIEditor::EDirection aSelect);
|
||||
template already_AddRefed<Element>
|
||||
WSRunObject::InsertBreak(Selection& aSelection,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
nsIEditor::EDirection aSelect);
|
||||
template nsresult
|
||||
WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
const nsAString& aStringToInsert,
|
||||
const EditorDOMPoint& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString);
|
||||
template nsresult
|
||||
WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
const nsAString& aStringToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString);
|
||||
|
||||
template<typename PT, typename CT>
|
||||
WSRunObject::WSRunObject(HTMLEditor* aHTMLEditor,
|
||||
@ -176,9 +194,10 @@ WSRunObject::PrepareToSplitAcrossBlocks(HTMLEditor* aHTMLEditor,
|
||||
return wsObj.PrepareToSplitAcrossBlocksPriv();
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<Element>
|
||||
WSRunObject::InsertBreak(Selection& aSelection,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
nsIEditor::EDirection aSelect)
|
||||
{
|
||||
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
|
||||
@ -205,14 +224,14 @@ WSRunObject::InsertBreak(Selection& aSelection,
|
||||
// Delete the leading ws that is after insertion point. We don't
|
||||
// have to (it would still not be significant after br), but it's
|
||||
// just more aesthetically pleasing to.
|
||||
nsresult rv = DeleteRange(pointToInsert.AsRaw(), afterRun->EndPoint());
|
||||
nsresult rv = DeleteRange(pointToInsert, afterRun->EndPoint());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
} else if (afterRun->mType == WSType::normalWS) {
|
||||
// Need to determine if break at front of non-nbsp run. If so, convert
|
||||
// run to nbsp.
|
||||
WSPoint thePoint = GetNextCharPoint(pointToInsert.AsRaw());
|
||||
WSPoint thePoint = GetNextCharPoint(pointToInsert);
|
||||
if (thePoint.mTextNode && nsCRT::IsAsciiSpace(thePoint.mChar)) {
|
||||
WSPoint prevPoint = GetPreviousCharPoint(thePoint);
|
||||
if (!prevPoint.mTextNode ||
|
||||
@ -232,14 +251,14 @@ WSRunObject::InsertBreak(Selection& aSelection,
|
||||
} else if (beforeRun->mType & WSType::trailingWS) {
|
||||
// Need to delete the trailing ws that is before insertion point, because it
|
||||
// would become significant after break inserted.
|
||||
nsresult rv = DeleteRange(beforeRun->StartPoint(), pointToInsert.AsRaw());
|
||||
nsresult rv = DeleteRange(beforeRun->StartPoint(), pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
} else if (beforeRun->mType == WSType::normalWS) {
|
||||
// Try to change an nbsp to a space, just to prevent nbsp proliferation
|
||||
nsresult rv =
|
||||
ReplacePreviousNBSPIfUnncessary(beforeRun, pointToInsert.AsRaw());
|
||||
ReplacePreviousNBSPIfUnncessary(beforeRun, pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -247,17 +266,18 @@ WSRunObject::InsertBreak(Selection& aSelection,
|
||||
}
|
||||
|
||||
RefPtr<Element> newBRElement =
|
||||
mHTMLEditor->CreateBRImpl(aSelection, pointToInsert.AsRaw(), aSelect);
|
||||
mHTMLEditor->CreateBRImpl(aSelection, pointToInsert, aSelect);
|
||||
if (NS_WARN_IF(!newBRElement)) {
|
||||
return nullptr;
|
||||
}
|
||||
return newBRElement.forget();
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsresult
|
||||
WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
const nsAString& aStringToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString)
|
||||
{
|
||||
// MOOSE: for now, we always assume non-PRE formatting. Fix this later.
|
||||
@ -297,7 +317,7 @@ WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
} else if (afterRun->mType & WSType::leadingWS) {
|
||||
// Delete the leading ws that is after insertion point, because it
|
||||
// would become significant after text inserted.
|
||||
nsresult rv = DeleteRange(pointToInsert.AsRaw(), afterRun->EndPoint());
|
||||
nsresult rv = DeleteRange(pointToInsert, afterRun->EndPoint());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -315,7 +335,7 @@ WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
} else if (beforeRun->mType & WSType::trailingWS) {
|
||||
// Need to delete the trailing ws that is before insertion point, because
|
||||
// it would become significant after text inserted.
|
||||
nsresult rv = DeleteRange(beforeRun->StartPoint(), pointToInsert.AsRaw());
|
||||
nsresult rv = DeleteRange(beforeRun->StartPoint(), pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -323,7 +343,7 @@ WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
// Try to change an nbsp to a space, if possible, just to prevent nbsp
|
||||
// proliferation
|
||||
nsresult rv =
|
||||
ReplacePreviousNBSPIfUnncessary(beforeRun, pointToInsert.AsRaw());
|
||||
ReplacePreviousNBSPIfUnncessary(beforeRun, pointToInsert);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -342,7 +362,7 @@ WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
if (beforeRun->mType & WSType::leadingWS) {
|
||||
theString.SetCharAt(kNBSP, 0);
|
||||
} else if (beforeRun->mType & WSType::normalWS) {
|
||||
WSPoint wspoint = GetPreviousCharPoint(pointToInsert.AsRaw());
|
||||
WSPoint wspoint = GetPreviousCharPoint(pointToInsert);
|
||||
if (wspoint.mTextNode && nsCRT::IsAsciiSpace(wspoint.mChar)) {
|
||||
theString.SetCharAt(kNBSP, 0);
|
||||
}
|
||||
@ -361,7 +381,7 @@ WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
if (afterRun->mType & WSType::trailingWS) {
|
||||
theString.SetCharAt(kNBSP, lastCharIndex);
|
||||
} else if (afterRun->mType & WSType::normalWS) {
|
||||
WSPoint wspoint = GetNextCharPoint(pointToInsert.AsRaw());
|
||||
WSPoint wspoint = GetNextCharPoint(pointToInsert);
|
||||
if (wspoint.mTextNode && nsCRT::IsAsciiSpace(wspoint.mChar)) {
|
||||
theString.SetCharAt(kNBSP, lastCharIndex);
|
||||
}
|
||||
@ -391,7 +411,7 @@ WSRunObject::InsertText(nsIDocument& aDocument,
|
||||
|
||||
// Ready, aim, fire!
|
||||
nsresult rv =
|
||||
mHTMLEditor->InsertTextImpl(aDocument, theString, pointToInsert.AsRaw(),
|
||||
mHTMLEditor->InsertTextImpl(aDocument, theString, pointToInsert,
|
||||
aPointAfterInsertedString);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return NS_OK;
|
||||
@ -1325,9 +1345,10 @@ WSRunObject::PrepareToSplitAcrossBlocksPriv()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template<typename PT1, typename CT1, typename PT2, typename CT2>
|
||||
nsresult
|
||||
WSRunObject::DeleteRange(const EditorRawDOMPoint& aStartPoint,
|
||||
const EditorRawDOMPoint& aEndPoint)
|
||||
WSRunObject::DeleteRange(const EditorDOMPointBase<PT1, CT1>& aStartPoint,
|
||||
const EditorDOMPointBase<PT2, CT2>& aEndPoint)
|
||||
{
|
||||
if (NS_WARN_IF(!aStartPoint.IsSet()) ||
|
||||
NS_WARN_IF(!aEndPoint.IsSet())) {
|
||||
@ -1908,9 +1929,11 @@ WSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template<typename PT, typename CT>
|
||||
nsresult
|
||||
WSRunObject::ReplacePreviousNBSPIfUnncessary(WSFragment* aRun,
|
||||
const EditorRawDOMPoint& aPoint)
|
||||
WSRunObject::ReplacePreviousNBSPIfUnncessary(
|
||||
WSFragment* aRun,
|
||||
const EditorDOMPointBase<PT, CT>& aPoint)
|
||||
{
|
||||
if (NS_WARN_IF(!aRun) ||
|
||||
NS_WARN_IF(!aPoint.IsSet())) {
|
||||
|
@ -230,9 +230,10 @@ public:
|
||||
* @return The new <br> node. If failed to create new <br>
|
||||
* node, returns nullptr.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
already_AddRefed<dom::Element>
|
||||
InsertBreak(Selection& aSelection,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
nsIEditor::EDirection aSelect);
|
||||
|
||||
/**
|
||||
@ -256,9 +257,10 @@ public:
|
||||
* does nothing during composition, returns NS_OK.
|
||||
* Otherwise, an error code.
|
||||
*/
|
||||
template<typename PT, typename CT>
|
||||
nsresult InsertText(nsIDocument& aDocument,
|
||||
const nsAString& aStringToInsert,
|
||||
const EditorRawDOMPoint& aPointToInsert,
|
||||
const EditorDOMPointBase<PT, CT>& aPointToInsert,
|
||||
EditorRawDOMPoint* aPointAfterInsertedString = nullptr);
|
||||
|
||||
// DeleteWSBackward deletes a single visible piece of ws before the ws
|
||||
@ -381,8 +383,9 @@ protected:
|
||||
* When aEndPoint is in a text node, removes the text data before the point.
|
||||
* Removes any nodes between them.
|
||||
*/
|
||||
nsresult DeleteRange(const EditorRawDOMPoint& aStartPoint,
|
||||
const EditorRawDOMPoint& aEndPoint);
|
||||
template<typename PT1, typename CT1, typename PT2, typename CT2>
|
||||
nsresult DeleteRange(const EditorDOMPointBase<PT1, CT1>& aStartPoint,
|
||||
const EditorDOMPointBase<PT2, CT2>& aEndPoint);
|
||||
|
||||
/**
|
||||
* GetNextCharPoint() returns next character's point of aPoint. If there is
|
||||
@ -486,8 +489,10 @@ protected:
|
||||
* @param aPoint Current insertion point. Its previous character is
|
||||
* unnecessary NBSP will be checked.
|
||||
*/
|
||||
nsresult ReplacePreviousNBSPIfUnncessary(WSFragment* aRun,
|
||||
const EditorRawDOMPoint& aPoint);
|
||||
template<typename PT, typename CT>
|
||||
nsresult
|
||||
ReplacePreviousNBSPIfUnncessary(WSFragment* aRun,
|
||||
const EditorDOMPointBase<PT, CT>& aPoint);
|
||||
|
||||
nsresult CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode,
|
||||
int32_t aOffset);
|
||||
|
@ -15,7 +15,8 @@ XPIDL_SOURCES += [
|
||||
XPIDL_MODULE = 'uconv'
|
||||
|
||||
EXPORTS += [
|
||||
'nsUConvCID.h',
|
||||
'nsConverterInputStream.h',
|
||||
'nsUConvCID.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
|
@ -121,6 +121,9 @@ nsConverterInputStream::ReadSegments(nsWriteUnicharSegmentFun aWriter,
|
||||
*aReadCount = 0;
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (bytesToWrite > aCount)
|
||||
|
@ -245,7 +245,7 @@ const WHITELIST_VARS: &'static [&'static str] = &[
|
||||
"JS_STRUCTURED_CLONE_VERSION",
|
||||
"JSCLASS_.*",
|
||||
"JSFUN_.*",
|
||||
"JSID_VOID",
|
||||
"JSID_TYPE_VOID",
|
||||
"JSITER_.*",
|
||||
"JSPROP_.*",
|
||||
"JS::FalseHandleValue",
|
||||
|
@ -541,8 +541,8 @@ impl JS::HandleObject {
|
||||
|
||||
impl Default for jsid {
|
||||
fn default() -> jsid {
|
||||
unsafe {
|
||||
JSID_VOID
|
||||
jsid {
|
||||
asBits: JSID_TYPE_VOID as usize,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -567,7 +567,7 @@ pub trait GCMethods {
|
||||
}
|
||||
|
||||
impl GCMethods for jsid {
|
||||
unsafe fn initial() -> jsid { JSID_VOID }
|
||||
unsafe fn initial() -> jsid { Default::default() }
|
||||
unsafe fn post_barrier(_: *mut jsid, _: jsid, _: jsid) {}
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,7 @@
|
||||
#ifdef MOZ_WEBSPEECH
|
||||
@BINPATH@/components/dom_webspeechrecognition.xpt
|
||||
#endif
|
||||
@BINPATH@/components/dom_workers.xpt
|
||||
@BINPATH@/components/dom_xhr.xpt
|
||||
@BINPATH@/components/dom_xul.xpt
|
||||
@BINPATH@/components/dom_presentation.xpt
|
||||
|
9
servo/Cargo.lock
generated
9
servo/Cargo.lock
generated
@ -431,6 +431,7 @@ dependencies = [
|
||||
"servo_url 0.0.1",
|
||||
"style_traits 0.0.1",
|
||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender 0.57.0 (git+https://github.com/servo/webrender)",
|
||||
"webrender_api 0.57.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
@ -1630,7 +1631,7 @@ dependencies = [
|
||||
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hashglobe 0.1.0",
|
||||
"mozjs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
"servo_arc 0.1.1",
|
||||
"smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1807,7 +1808,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mozjs"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2495,7 +2496,7 @@ dependencies = [
|
||||
"mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"net_traits 0.0.1",
|
||||
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -3895,7 +3896,7 @@ dependencies = [
|
||||
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
|
||||
"checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f"
|
||||
"checksum mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1f0583e6792917f498bb3a7440f777a59353102063445ab7f5e9d1dc4ed593aa"
|
||||
"checksum mozjs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "896b93aaf26a4cbdcd878b6a9e3b4b90ac018dccebaaac1fe67d2d0724f6a711"
|
||||
"checksum mozjs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4463834f4d4ffcf2a54706c8a202e25ddac3f142e3eccc4aebade58fa62bc1ff"
|
||||
"checksum mozjs_sys 0.50.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e61a792a125b1364c5ec50255ed8343ce02dc56098f8868dd209d472c8de006a"
|
||||
"checksum mp3-metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ab5f1d2693586420208d1200ce5a51cd44726f055b635176188137aff42c7de"
|
||||
"checksum mp4parse 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f821e3799bc0fd16d9b861fb02fa7ee1b5fba29f45ad591dade105c48ca9a1a0"
|
||||
|
@ -4,6 +4,7 @@ version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
publish = false
|
||||
build = "build.rs"
|
||||
|
||||
[lib]
|
||||
name = "compositing"
|
||||
@ -29,3 +30,6 @@ style_traits = {path = "../style_traits"}
|
||||
time = "0.1.17"
|
||||
webrender = {git = "https://github.com/servo/webrender", features = ["capture"]}
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
|
||||
[build-dependencies]
|
||||
toml = "0.4.5"
|
||||
|
44
servo/components/compositing/build.rs
Normal file
44
servo/components/compositing/build.rs
Normal file
@ -0,0 +1,44 @@
|
||||
/* 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/. */
|
||||
|
||||
extern crate toml;
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let lockfile_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("..").join("..").join("Cargo.lock");
|
||||
let revision_file_path = Path::new(&env::var_os("OUT_DIR").unwrap()).join("webrender_revision.rs");
|
||||
|
||||
let mut lockfile = String::new();
|
||||
File::open(lockfile_path).expect("Cannot open lockfile")
|
||||
.read_to_string(&mut lockfile)
|
||||
.expect("Failed to read lockfile");
|
||||
|
||||
match toml::from_str::<toml::value::Table>(&lockfile) {
|
||||
Ok(result) => {
|
||||
let packages = result.get("package").expect("Cargo lockfile should contain package list");
|
||||
|
||||
match *packages {
|
||||
toml::Value::Array(ref arr) => {
|
||||
let source = arr
|
||||
.iter()
|
||||
.find(|pkg| pkg.get("name").and_then(|name| name.as_str()).unwrap_or("") == "webrender")
|
||||
.and_then(|pkg| pkg.get("source").and_then(|source| source.as_str()))
|
||||
.unwrap_or("unknown");
|
||||
|
||||
let parsed: Vec<&str> = source.split("#").collect();
|
||||
let revision = if parsed.len() > 1 { parsed[1] } else { source };
|
||||
|
||||
let mut revision_module_file = File::create(&revision_file_path).unwrap();
|
||||
write!(&mut revision_module_file, "{}", format!("\"{}\"", revision)).unwrap();
|
||||
},
|
||||
_ => panic!("Cannot find package definitions in lockfile")
|
||||
}
|
||||
},
|
||||
Err(e) => panic!(e)
|
||||
}
|
||||
}
|
@ -24,7 +24,8 @@ use servo_config::opts;
|
||||
use servo_geometry::{DeviceIndependentPixel, DeviceUintLength};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::fs::{File, create_dir_all};
|
||||
use std::io::Write;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::time::{Duration, Instant};
|
||||
@ -1543,9 +1544,26 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
Ok(current_dir) => {
|
||||
let capture_id = now().to_timespec().sec.to_string();
|
||||
let capture_path = current_dir.join("capture_webrender").join(capture_id);
|
||||
let revision_file_path = capture_path.join("wr.txt");
|
||||
|
||||
if let Err(err) = create_dir_all(&capture_path) {
|
||||
eprintln!("Unable to create path '{:?}' for capture: {:?}", capture_path, err);
|
||||
return
|
||||
}
|
||||
|
||||
self.webrender_api.save_capture(capture_path, webrender_api::CaptureBits::all());
|
||||
|
||||
match File::create(revision_file_path) {
|
||||
Ok(mut file) => {
|
||||
let revision = include!(concat!(env!("OUT_DIR"), "/webrender_revision.rs"));
|
||||
if let Err(err) = write!(&mut file, "{}", revision) {
|
||||
eprintln!("Unable to write webrender revision: {:?}", err)
|
||||
}
|
||||
}
|
||||
Err(err) => eprintln!("Capture triggered, creating webrender revision info skipped: {:?}", err)
|
||||
}
|
||||
},
|
||||
Err(err) => println!("could not locate path to save captures: {:?}", err)
|
||||
Err(err) => eprintln!("Unable to locate path to save captures: {:?}", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ app_units = "0.6"
|
||||
cssparser = "0.23.0"
|
||||
euclid = "0.17"
|
||||
hashglobe = { path = "../hashglobe" }
|
||||
mozjs = { version = "0.3", features = ["promises"], optional = true }
|
||||
mozjs = { version = "0.4", features = ["promises"], optional = true }
|
||||
selectors = { path = "../selectors" }
|
||||
servo_arc = { path = "../servo_arc" }
|
||||
smallbitvec = "1.0.3"
|
||||
|
@ -62,7 +62,7 @@ metrics = {path = "../metrics"}
|
||||
mitochondria = "1.1.2"
|
||||
mime = "0.2.1"
|
||||
mime_guess = "1.8.0"
|
||||
mozjs = { version = "0.3", features = ["promises"]}
|
||||
mozjs = { version = "0.4", features = ["promises"]}
|
||||
msg = {path = "../msg"}
|
||||
net_traits = {path = "../net_traits"}
|
||||
num-traits = "0.1.32"
|
||||
|
@ -46,7 +46,8 @@ impl Reflector {
|
||||
/// Get the reflector.
|
||||
#[inline]
|
||||
pub fn get_jsobject(&self) -> HandleObject {
|
||||
self.object.handle()
|
||||
// We're rooted, so it's safe to hand out a handle to object in Heap
|
||||
unsafe { self.object.handle() }
|
||||
}
|
||||
|
||||
/// Initialize the reflector. (May be called only once.)
|
||||
|
@ -59,9 +59,9 @@ use hyper::mime::Mime;
|
||||
use hyper::status::StatusCode;
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use js::glue::{CallObjectTracer, CallValueTracer};
|
||||
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
|
||||
use js::jsapi::{GCTraceKindToAscii, Heap, Handle, JSObject, JSTracer, TraceKind};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::Runtime;
|
||||
use js::rust::{GCMethods, Runtime};
|
||||
use js::typedarray::TypedArray;
|
||||
use js::typedarray::TypedArrayElement;
|
||||
use metrics::{InteractiveMetrics, InteractiveWindow};
|
||||
@ -788,6 +788,16 @@ impl<T: JSTraceable + 'static> RootedTraceableBox<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> RootedTraceableBox<Heap<T>>
|
||||
where
|
||||
Heap<T>: JSTraceable + 'static,
|
||||
T: GCMethods + Copy,
|
||||
{
|
||||
pub fn handle(&self) -> Handle<T> {
|
||||
unsafe { (*self.ptr).handle() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: JSTraceable + Default> Default for RootedTraceableBox<T> {
|
||||
fn default() -> RootedTraceableBox<T> {
|
||||
RootedTraceableBox::new(T::default())
|
||||
|
@ -604,7 +604,8 @@ impl CustomElementReaction {
|
||||
match *self {
|
||||
CustomElementReaction::Upgrade(ref definition) => upgrade_element(definition.clone(), element),
|
||||
CustomElementReaction::Callback(ref callback, ref arguments) => {
|
||||
let arguments = arguments.iter().map(|arg| arg.handle()).collect();
|
||||
// We're rooted, so it's safe to hand out a handle to objects in Heap
|
||||
let arguments = arguments.iter().map(|arg| unsafe { arg.handle() }).collect();
|
||||
let _ = callback.Call_(&*element, arguments, ExceptionHandling::Report);
|
||||
}
|
||||
}
|
||||
|
@ -185,18 +185,17 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn AttachShader(&self, program: Option<&WebGLProgram>, shader: Option<&WebGLShader>) {
|
||||
fn AttachShader(&self, program: &WebGLProgram, shader: &WebGLShader) {
|
||||
self.base.AttachShader(program, shader)
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn DetachShader(&self, program: Option<&WebGLProgram>, shader: Option<&WebGLShader>) {
|
||||
fn DetachShader(&self, program: &WebGLProgram, shader: &WebGLShader) {
|
||||
self.base.DetachShader(program, shader)
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn BindAttribLocation(&self, program: Option<&WebGLProgram>,
|
||||
index: u32, name: DOMString) {
|
||||
fn BindAttribLocation(&self, program: &WebGLProgram, index: u32, name: DOMString) {
|
||||
self.base.BindAttribLocation(program, index, name)
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
|
||||
use super::{ext_constants, WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
|
||||
|
||||
pub mod oeselementindexuint;
|
||||
pub mod oesstandardderivatives;
|
||||
pub mod oestexturefloat;
|
||||
pub mod oestexturefloatlinear;
|
||||
|
@ -0,0 +1,50 @@
|
||||
/* 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/. */
|
||||
|
||||
use canvas_traits::webgl::WebGLVersion;
|
||||
use dom::bindings::codegen::Bindings::OESElementIndexUintBinding;
|
||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::webglrenderingcontext::WebGLRenderingContext;
|
||||
use dom_struct::dom_struct;
|
||||
use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct OESElementIndexUint {
|
||||
reflector_: Reflector,
|
||||
}
|
||||
|
||||
impl OESElementIndexUint {
|
||||
fn new_inherited() -> Self {
|
||||
Self { reflector_: Reflector::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl WebGLExtension for OESElementIndexUint {
|
||||
type Extension = Self;
|
||||
|
||||
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(OESElementIndexUint::new_inherited()),
|
||||
&*ctx.global(),
|
||||
OESElementIndexUintBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
fn spec() -> WebGLExtensionSpec {
|
||||
WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
|
||||
}
|
||||
|
||||
fn is_supported(ext: &WebGLExtensions) -> bool {
|
||||
ext.supports_gl_extension("GL_OES_element_index_uint")
|
||||
}
|
||||
|
||||
fn enable(ext: &WebGLExtensions) {
|
||||
ext.enable_element_index_uint();
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"OES_element_index_uint"
|
||||
}
|
||||
}
|
@ -57,17 +57,20 @@ struct WebGLExtensionFeatures {
|
||||
hint_targets: FnvHashSet<GLenum>,
|
||||
/// WebGL GetParameter() names enabled by extensions.
|
||||
disabled_get_parameter_names: FnvHashSet<GLenum>,
|
||||
/// WebGL OES_element_index_uint extension.
|
||||
element_index_uint_enabled: bool,
|
||||
}
|
||||
|
||||
impl WebGLExtensionFeatures {
|
||||
fn new(webgl_version: WebGLVersion) -> Self {
|
||||
let (disabled_tex_types, disabled_get_parameter_names) = match webgl_version {
|
||||
let (disabled_tex_types, disabled_get_parameter_names, element_index_uint_enabled) = match webgl_version {
|
||||
WebGLVersion::WebGL1 => {
|
||||
(DEFAULT_DISABLED_TEX_TYPES_WEBGL1.iter().cloned().collect(),
|
||||
DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL1.iter().cloned().collect())
|
||||
DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL1.iter().cloned().collect(),
|
||||
false)
|
||||
},
|
||||
WebGLVersion::WebGL2 => {
|
||||
(Default::default(), Default::default())
|
||||
(Default::default(), Default::default(), true)
|
||||
}
|
||||
};
|
||||
Self {
|
||||
@ -78,6 +81,7 @@ impl WebGLExtensionFeatures {
|
||||
query_parameter_handlers: Default::default(),
|
||||
hint_targets: Default::default(),
|
||||
disabled_get_parameter_names,
|
||||
element_index_uint_enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,7 +100,7 @@ impl WebGLExtensions {
|
||||
Self {
|
||||
extensions: DomRefCell::new(HashMap::new()),
|
||||
features: DomRefCell::new(WebGLExtensionFeatures::new(webgl_version)),
|
||||
webgl_version
|
||||
webgl_version,
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,6 +244,14 @@ impl WebGLExtensions {
|
||||
self.register::<ext::oestexturehalffloatlinear::OESTextureHalfFloatLinear>();
|
||||
self.register::<ext::oesvertexarrayobject::OESVertexArrayObject>();
|
||||
}
|
||||
|
||||
pub fn enable_element_index_uint(&self) {
|
||||
self.features.borrow_mut().element_index_uint_enabled = true;
|
||||
}
|
||||
|
||||
pub fn is_element_index_uint_enabled(&self) -> bool {
|
||||
self.features.borrow().element_index_uint_enabled
|
||||
}
|
||||
}
|
||||
|
||||
// Helper structs
|
||||
|
@ -1514,29 +1514,18 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn AttachShader(&self, program: Option<&WebGLProgram>, shader: Option<&WebGLShader>) {
|
||||
if let Some(program) = program {
|
||||
if let Some(shader) = shader {
|
||||
handle_potential_webgl_error!(self, program.attach_shader(shader));
|
||||
}
|
||||
}
|
||||
fn AttachShader(&self, program: &WebGLProgram, shader: &WebGLShader) {
|
||||
handle_potential_webgl_error!(self, program.attach_shader(shader));
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn DetachShader(&self, program: Option<&WebGLProgram>, shader: Option<&WebGLShader>) {
|
||||
if let Some(program) = program {
|
||||
if let Some(shader) = shader {
|
||||
handle_potential_webgl_error!(self, program.detach_shader(shader));
|
||||
}
|
||||
}
|
||||
fn DetachShader(&self, program: &WebGLProgram, shader: &WebGLShader) {
|
||||
handle_potential_webgl_error!(self, program.detach_shader(shader));
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn BindAttribLocation(&self, program: Option<&WebGLProgram>,
|
||||
index: u32, name: DOMString) {
|
||||
if let Some(program) = program {
|
||||
handle_potential_webgl_error!(self, program.bind_attrib_location(index, name));
|
||||
}
|
||||
fn BindAttribLocation(&self, program: &WebGLProgram, index: u32, name: DOMString) {
|
||||
handle_potential_webgl_error!(self, program.bind_attrib_location(index, name));
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||
@ -2174,6 +2163,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||
let type_size = match type_ {
|
||||
constants::UNSIGNED_BYTE => 1,
|
||||
constants::UNSIGNED_SHORT => 2,
|
||||
constants::UNSIGNED_INT if self.extension_manager.is_element_index_uint_enabled() => 4,
|
||||
_ => return self.webgl_error(InvalidEnum),
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
/* 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/. */
|
||||
/*
|
||||
* WebGL IDL definitions from the Khronos specification:
|
||||
* https://www.khronos.org/registry/webgl/extensions/OES_element_index_uint/
|
||||
*/
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface OESElementIndexUint {
|
||||
};
|
@ -475,8 +475,8 @@ interface WebGLRenderingContextBase
|
||||
object? getExtension(DOMString name);
|
||||
|
||||
void activeTexture(GLenum texture);
|
||||
void attachShader(WebGLProgram? program, WebGLShader? shader);
|
||||
void bindAttribLocation(WebGLProgram? program, GLuint index, DOMString name);
|
||||
void attachShader(WebGLProgram program, WebGLShader shader);
|
||||
void bindAttribLocation(WebGLProgram program, GLuint index, DOMString name);
|
||||
void bindBuffer(GLenum target, WebGLBuffer? buffer);
|
||||
void bindFramebuffer(GLenum target, WebGLFramebuffer? framebuffer);
|
||||
void bindRenderbuffer(GLenum target, WebGLRenderbuffer? renderbuffer);
|
||||
@ -559,7 +559,7 @@ interface WebGLRenderingContextBase
|
||||
void depthFunc(GLenum func);
|
||||
void depthMask(GLboolean flag);
|
||||
void depthRange(GLclampf zNear, GLclampf zFar);
|
||||
void detachShader(WebGLProgram? program, WebGLShader? shader);
|
||||
void detachShader(WebGLProgram program, WebGLShader shader);
|
||||
void disable(GLenum cap);
|
||||
void disableVertexAttribArray(GLuint index);
|
||||
void drawArrays(GLenum mode, GLint first, GLsizei count);
|
||||
|
@ -500,7 +500,7 @@ impl JsTimerTask {
|
||||
code_str, rval.handle_mut());
|
||||
},
|
||||
InternalTimerCallback::FunctionTimerCallback(ref function, ref arguments) => {
|
||||
let arguments = arguments.iter().map(|arg| arg.handle()).collect();
|
||||
let arguments = self.collect_heap_args(arguments);
|
||||
let _ = function.Call_(this, arguments, Report);
|
||||
},
|
||||
};
|
||||
@ -516,4 +516,11 @@ impl JsTimerTask {
|
||||
timers.initialize_and_schedule(&this.global(), self);
|
||||
}
|
||||
}
|
||||
|
||||
// Returning Handles directly from Heap values is inherently unsafe, but here it's
|
||||
// always done via rooted JsTimers, which is safe.
|
||||
#[allow(unsafe_code)]
|
||||
fn collect_heap_args(&self, args: &[Heap<JSVal>]) -> Vec<HandleValue> {
|
||||
args.iter().map(|arg| unsafe { arg.handle() }).collect()
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,12 @@ cd "${WORKSPACE}"
|
||||
|
||||
# Make sure snapcraft knows we're building amd64, even though we may not be on this arch.
|
||||
export SNAP_ARCH='amd64'
|
||||
|
||||
# When a snap is built, snapcraft fetches deb packages from ubuntu.com. They may bump packages
|
||||
# there and remove the old ones. Updating the database allows snapcraft to find the latest packages.
|
||||
# For more context, see 1448239
|
||||
apt-get update
|
||||
|
||||
snapcraft
|
||||
|
||||
mv -- *.snap "$TARGET_FULL_PATH"
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -x -e -v
|
||||
|
||||
# 0.2.6 + a fix to update jobserver
|
||||
SCCACHE_REVISION=13fa450eee47cc53fff4129aaf3c6c30fd2b621e
|
||||
# 0.2.6 + a few fixes
|
||||
SCCACHE_REVISION=9f4c18b4a6300e3a9250a09811cc985311c20217
|
||||
|
||||
# This script is for building sccache
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user