Bug 1385791 - Fix message filtering; r=nchevobbe

MozReview-Commit-ID: 4iPLGUor0Pu

--HG--
extra : rebase_source : cbdb2894c4bc67be74bb6c58501662bb18539e37
This commit is contained in:
Jan Odvarko 2017-08-11 17:10:54 +02:00
Родитель 67606b8331
Коммит 95b942c905
6 изменённых файлов: 77 добавлений и 33 удалений

Просмотреть файл

@ -339,7 +339,8 @@ checkbox:-moz-focusring {
.devtools-toolbarbutton:not([disabled])[label][checked=true],
.devtools-toolbarbutton:not([disabled])[label][open],
.devtools-button:not(:empty).checked,
.theme-firebug .devtools-toolbarbutton:-moz-any([checked],[open]),
.theme-firebug .devtools-toolbarbutton[checked],
.theme-firebug .devtools-toolbarbutton[open],
.theme-firebug .devtools-button.checked:empty {
background: var(--toolbarbutton-checked-background);
border-color: var(--toolbarbutton-checked-border-color);

Просмотреть файл

@ -79,6 +79,10 @@ const MessageContainer = createClass({
});
function getMessageComponent(message) {
if (!message) {
return componentMap.get("DefaultRenderer");
}
switch (message.source) {
case MESSAGE_SOURCE.CONSOLE_API:
return componentMap.get("ConsoleApiCall");

Просмотреть файл

@ -65,6 +65,7 @@ const chromeRDPEnums = {
START_GROUP_COLLAPSED: "startGroupCollapsed",
END_GROUP: "endGroup",
ASSERT: "assert",
DEBUG: "debug",
PROFILE: "profile",
PROFILE_END: "profileEnd",
// Undocumented in Chrome RDP, but is used for evaluation results.

Просмотреть файл

@ -47,12 +47,13 @@ NewConsoleOutputWrapper.prototype = {
}
// Do not focus if a link was clicked
if (event.originalTarget.closest("a")) {
let target = event.originalTarget || event.target;
if (target.closest("a")) {
return;
}
// Do not focus if something other than the output region was clicked
if (!event.originalTarget.closest(".webconsole-output")) {
if (!target.closest(".webconsole-output")) {
return;
}

Просмотреть файл

@ -431,22 +431,57 @@ function getToplevelMessageCount(record) {
return record.messagesById.count(message => !message.groupId);
}
/**
* Returns true if given message should be visible, false otherwise.
*/
function shouldMessageBeVisible(message, messagesState, filtersState, checkGroup = true) {
return (
(
checkGroup === false
|| isInOpenedGroup(message, messagesState.groupsById, messagesState.messagesUiById)
)
&& (
isUnfilterable(message)
|| (
matchLevelFilters(message, filtersState)
&& matchCssFilters(message, filtersState)
&& matchNetworkFilters(message, filtersState)
&& matchSearchFilters(message, filtersState)
)
)
);
// Do not display the message if it's in closed group.
if (
checkGroup
&& !isInOpenedGroup(message, messagesState.groupsById, messagesState.messagesUiById)
) {
return false;
}
// Some messages can't be filtered out (e.g. groups).
// So, always return true for those.
if (isUnfilterable(message)) {
return true;
}
// Let's check all filters and hide the message if they say so.
if (!matchFilters(message, filtersState)) {
return false;
}
// If there is a free text available for filtering use it to decide
// whether the message is displayed or not.
let text = (filtersState.text || "").trim();
if (text) {
return matchSearchFilters(message, text);
}
return true;
}
function matchFilters(message, filtersState) {
if (matchLevelFilters(message, filtersState)) {
return true;
}
// Return true if the message source is 'css'
// and CSS filter is enabled.
if (matchCssFilters(message, filtersState)) {
return true;
}
// Return true if the message is network event
// and Network and/or XHR filter is enabled.
if (matchNetworkFilters(message, filtersState)) {
return true;
}
return false;
}
function isUnfilterable(message) {
@ -474,31 +509,33 @@ function isGroupClosed(groupId, messagesUI) {
return messagesUI.includes(groupId) === false;
}
function matchLevelFilters(message, filters) {
return filters.get(message.level) === true;
}
function matchNetworkFilters(message, filters) {
return (
message.source !== MESSAGE_SOURCE.NETWORK
|| (filters.get("net") === true && message.isXHR === false)
|| (filters.get("netxhr") === true && message.isXHR === true)
message.source === MESSAGE_SOURCE.NETWORK &&
(filters.get("net") === true && message.isXHR === false) ||
(filters.get("netxhr") === true && message.isXHR === true)
);
}
function matchLevelFilters(message, filters) {
return (
(message.source === MESSAGE_SOURCE.CONSOLE_API ||
message.source === MESSAGE_SOURCE.JAVASCRIPT) &&
filters.get(message.level) === true
);
}
function matchCssFilters(message, filters) {
return (
message.source != MESSAGE_SOURCE.CSS
|| filters.get("css") === true
message.source === MESSAGE_SOURCE.CSS &&
filters.get("css") === true
);
}
function matchSearchFilters(message, filters) {
let text = (filters.text || "").trim();
function matchSearchFilters(message, text) {
return (
text === ""
// Look for a match in parameters.
|| isTextInParameters(text, message.parameters)
isTextInParameters(text, message.parameters)
// Look for a match in location.
|| isTextInFrame(text, message.frame)
// Look for a match in net events.

Просмотреть файл

@ -328,7 +328,7 @@ function getLevelFromType(type) {
clear: levels.LEVEL_LOG,
trace: levels.LEVEL_LOG,
table: levels.LEVEL_LOG,
debug: levels.LEVEL_LOG,
debug: levels.LEVEL_DEBUG,
dir: levels.LEVEL_LOG,
dirxml: levels.LEVEL_LOG,
group: levels.LEVEL_LOG,
@ -336,7 +336,7 @@ function getLevelFromType(type) {
groupEnd: levels.LEVEL_LOG,
time: levels.LEVEL_LOG,
timeEnd: levels.LEVEL_LOG,
count: levels.LEVEL_DEBUG,
count: levels.LEVEL_LOG,
};
return levelMap[type] || MESSAGE_TYPE.LOG;