Merge mozilla-central to inbound. a=merge CLOSED TREE

--HG--
extra : rebase_source : bdcf059fd5dd355e5949760f00b5c5cb46f3528e
This commit is contained in:
Csoregi Natalia 2018-04-15 12:19:10 +03:00
Родитель 81a5dec57f bd326a2a6b
Коммит a9a2483cec
15 изменённых файлов: 2259 добавлений и 991 удалений

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

@ -516,6 +516,10 @@ MediaEngineRemoteVideoSource::DeliverFrame(uint8_t* aBuffer,
req_ideal_height = (mCapability.height >> 16) & 0xffff;
}
// This is only used in the case of screen sharing, see bug 1453269.
const int32_t target_width = aProps.width();
const int32_t target_height = aProps.height();
if (aProps.rotation() == 90 || aProps.rotation() == 270) {
// This frame is rotated, so what was negotiated as width is now height,
// and vice versa.
@ -531,6 +535,33 @@ MediaEngineRemoteVideoSource::DeliverFrame(uint8_t* aBuffer,
int32_t dst_width = std::min(req_ideal_width > 0 ? req_ideal_width : aProps.width(), dst_max_width);
int32_t dst_height = std::min(req_ideal_height > 0 ? req_ideal_height : aProps.height(), dst_max_height);
// Apply scaling for screen sharing, see bug 1453269.
switch (mMediaSource) {
case MediaSourceEnum::Screen:
case MediaSourceEnum::Window:
case MediaSourceEnum::Application: {
// scale to average of portrait and landscape
float scale_width = (float)dst_width / (float)aProps.width();
float scale_height = (float)dst_height / (float)aProps.height();
float scale = (scale_width + scale_height) / 2;
dst_width = (int)(scale * target_width);
dst_height = (int)(scale * target_height);
// if scaled rectangle exceeds max rectangle, scale to minimum of portrait and landscape
if (dst_width > dst_max_width || dst_height > dst_max_height) {
scale_width = (float)dst_max_width / (float)dst_width;
scale_height = (float)dst_max_height / (float)dst_height;
scale = std::min(scale_width, scale_height);
dst_width = (int32_t)(scale * dst_width);
dst_height = (int32_t)(scale * dst_height);
}
break;
}
default: {
break;
}
}
rtc::Callback0<void> callback_unused;
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer =
new rtc::RefCountedObject<webrtc::WrappedI420Buffer>(

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

@ -3490,6 +3490,7 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
}
containingPaintedLayerData->mDispatchToContentHitRegion.Or(
containingPaintedLayerData->mDispatchToContentHitRegion, rect);
containingPaintedLayerData->mDispatchToContentHitRegion.SimplifyOutward(8);
if (data->mDTCRequiresTargetConfirmation) {
containingPaintedLayerData->mDTCRequiresTargetConfirmation = true;
}
@ -3817,6 +3818,7 @@ PaintedLayerData::AccumulateEventRegions(ContainerState* aState, nsDisplayLayerE
// Avoid quadratic performance as a result of the region growing to include
// and arbitrarily large number of rects, which can happen on some pages.
mMaybeHitRegion.SimplifyOutward(8);
mDispatchToContentHitRegion.SimplifyOutward(8);
// Calculate scaled versions of the bounds of mHitRegion and mMaybeHitRegion
// for quick access in FindPaintedLayerFor().
@ -3921,6 +3923,7 @@ PaintedLayerData::AccumulateHitTestInfo(ContainerState* aState,
// Avoid quadratic performance as a result of the region growing to include
// and arbitrarily large number of rects, which can happen on some pages.
mMaybeHitRegion.SimplifyOutward(8);
mDispatchToContentHitRegion.SimplifyOutward(8);
// Calculate scaled versions of the bounds of mHitRegion and mMaybeHitRegion
// for quick access in FindPaintedLayerFor().

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

@ -289,6 +289,9 @@ SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorCount, void,
SERVO_BINDING_FUNC(Servo_StyleRule_SelectorMatchesElement, bool,
RawServoStyleRuleBorrowed, RawGeckoElementBorrowed,
uint32_t index, mozilla::CSSPseudoElementType pseudo_type)
SERVO_BINDING_FUNC(Servo_StyleRule_SetSelectorText, bool,
RawServoStyleSheetContentsBorrowed sheet,
RawServoStyleRuleBorrowed rule, const nsAString* text)
SERVO_BINDING_FUNC(Servo_ImportRule_GetHref, void,
RawServoImportRuleBorrowed rule, nsAString* result)
SERVO_BINDING_FUNC(Servo_ImportRule_GetSheet,

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

@ -206,9 +206,23 @@ ServoStyleRule::GetSelectorText(nsAString& aSelectorText)
void
ServoStyleRule::SetSelectorText(const nsAString& aSelectorText)
{
// XXX We need to implement this... But Gecko doesn't have this either
// so it's probably okay to leave it unimplemented currently?
// See bug 37468 and mozilla::css::StyleRule::SetSelectorText.
if (RefPtr<StyleSheet> sheet = GetStyleSheet()) {
ServoStyleSheet* servoSheet = sheet->AsServo();
nsIDocument* doc = sheet->GetAssociatedDocument();
mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true);
// StyleRule lives inside of the Inner, it is unsafe to call WillDirty
// if sheet does not already have a unique Inner.
sheet->AssertHasUniqueInner();
sheet->WillDirty();
const RawServoStyleSheetContents* contents = servoSheet->RawContents();
if (Servo_StyleRule_SetSelectorText(contents, mRawRule, &aSelectorText)) {
sheet->DidDirty();
sheet->RuleChanged(this);
}
}
}
uint32_t

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

@ -14,6 +14,7 @@
#include "mozilla/ServoUtils.h"
#include "nsICSSLoaderObserver.h"
#include "nsWrapperCache.h"
#include "StyleSheetInfo.h"
class nsIDocument;
class nsINode;
@ -149,6 +150,7 @@ public:
inline bool HasUniqueInner() const;
void EnsureUniqueInner();
inline void AssertHasUniqueInner() const;
// Append all of this sheet's child sheets to aArray.
void AppendAllChildSheets(nsTArray<StyleSheet*>& aArray);

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

@ -133,6 +133,12 @@ StyleSheet::HasUniqueInner() const
{
return mInner->mSheets.Length() == 1;
}
void
StyleSheet::AssertHasUniqueInner() const
{
MOZ_ASSERT(HasUniqueInner());
}
}

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

@ -6,7 +6,7 @@ use cssparser::{ParseErrorKind, Parser, ParserInput, SourceLocation};
use cssparser::ToCss as ParserToCss;
use env_logger::Builder;
use malloc_size_of::MallocSizeOfOps;
use selectors::NthIndexCache;
use selectors::{NthIndexCache, SelectorList};
use selectors::matching::{MatchingContext, MatchingMode, matches_selector};
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
use smallvec::SmallVec;
@ -1902,6 +1902,37 @@ pub extern "C" fn Servo_StyleRule_SelectorMatchesElement(
})
}
#[no_mangle]
pub unsafe extern "C" fn Servo_StyleRule_SetSelectorText(
sheet: RawServoStyleSheetContentsBorrowed,
rule: RawServoStyleRuleBorrowed,
text: *const nsAString,
) -> bool {
let value_str = (*text).to_string();
write_locked_arc(rule, |rule: &mut StyleRule| {
use style::selector_parser::SelectorParser;
let contents = StylesheetContents::as_arc(&sheet);
let namespaces = contents.namespaces.read();
let url_data = contents.url_data.read();
let parser = SelectorParser {
stylesheet_origin: contents.origin,
namespaces: &namespaces,
url_data: Some(&url_data),
};
let mut parser_input = ParserInput::new(&value_str);
match SelectorList::parse(&parser, &mut Parser::new(&mut parser_input)) {
Ok(selectors) => {
rule.selectors = selectors;
true
}
Err(_) => false,
}
})
}
#[no_mangle]
pub unsafe extern "C" fn Servo_SelectorList_Closest(
element: RawGeckoElementBorrowed,

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

@ -320708,6 +320708,18 @@
{}
]
],
"css/cssom/CSSStyleRule-set-selectorText-namespace.html": [
[
"/css/cssom/CSSStyleRule-set-selectorText-namespace.html",
{}
]
],
"css/cssom/CSSStyleRule-set-selectorText.html": [
[
"/css/cssom/CSSStyleRule-set-selectorText.html",
{}
]
],
"css/cssom/CSSStyleRule.html": [
[
"/css/cssom/CSSStyleRule.html",
@ -535911,6 +535923,14 @@
"4d0b19a6e29ae7a721574e36b47985233ddc8bae",
"testharness"
],
"css/cssom/CSSStyleRule-set-selectorText-namespace.html": [
"77e5def2b8be9b7fb19e81bd3630a333f45fb39b",
"testharness"
],
"css/cssom/CSSStyleRule-set-selectorText.html": [
"a4ac01a34f185fdea811733d1994070cb309be82",
"testharness"
],
"css/cssom/CSSStyleRule.html": [
"9fe62d2e23709b77e9b5cda4522ec1c04d2940cf",
"testharness"

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

@ -1,2 +0,0 @@
[selectorText-modification-restyle-001.html]
expected: FAIL

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

@ -2,48 +2,24 @@
[[foo="bar"\] /* sanity check */ setting CSSRule#cssText]
expected: FAIL
[[foo="bar"\] /* sanity check */ setting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar"\] /* sanity check */ setting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar"\] /* sanity check */ setting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar" i\] setting CSSRule#cssText]
expected: FAIL
[[foo="bar" i\] setting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar" i\] setting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar" i\] setting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar" /**/ i\] setting CSSRule#cssText]
expected: FAIL
[[foo="bar" /**/ i\] setting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar" /**/ i\] setting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar" /**/ i\] setting CSSStyleRule#selectorText in @media]
expected: FAIL
[[foo="bar"/**/i\] setting CSSRule#cssText]
expected: FAIL
[[foo="bar"/**/i\] setting CSSStyleRule#selectorText]
expected: FAIL
[[foo="bar"/**/i\] setting CSSRule#cssText in @media]
expected: FAIL
[[foo="bar"/**/i\] setting CSSStyleRule#selectorText in @media]
expected: FAIL

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

@ -0,0 +1,60 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CSSOM StyleRule selectorText property setter with namespaces</title>
<link rel="help" href="https://drafts.csswg.org/cssom-1/#dom-cssstylerule-selectortext">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style type="text/css" id="styleElement">
@namespace url(http://www.w3.org/1999/xhtml);
@namespace svg url(http://www.w3.org/2000/svg);
svg|*.style0 { background-color: rgb(0, 0, 255) !important; }
svg|*.style1 { background-color: rgb(255, 0, 255); }
</style>
<span>
<p></p>
<svg height="30" width="200" id="container" class="style1" lang="zh-CN" language segment="42 43">
<text x="0" y="15">SVG text</text>
</svg>
</span>
<script>
var styleSheet = document.getElementById("styleElement").sheet;
var rule = styleSheet.cssRules[2];
var divContainerStyle = getComputedStyle(document.getElementById("container"));
const originalStyleSelector = "svg|*.style0";
var assertColors = function(selectorMatches) {
assert_equals(divContainerStyle.getPropertyValue('background-color'), selectorMatches ? "rgb(0, 0, 255)" : "rgb(255, 0, 255)")
};
[
{selector: ".style1", isMatch: false, },
{selector: "svg|*.style1 ", isMatch: true, normalizedSelector: "svg|*.style1"},
{selector: "*|*.style1 ", isMatch: true, normalizedSelector: "*|*.style1"},
{selector: " *.style1 ", isMatch: false, normalizedSelector: ".style1"},
{selector: "p", isMatch: false},
].forEach(function(testCase) {
test(function() {
// Check if starting with the default value.
assert_equals(rule.selectorText, originalStyleSelector);
this.add_cleanup(function() { rule.selectorText = originalStyleSelector; });
assertColors(false);
rule.selectorText = testCase.selector;
var expectedSelector = testCase.normalizedSelector ? testCase.normalizedSelector : testCase.selector;
assert_equals(rule.selectorText, expectedSelector);
assertColors(testCase.isMatch);
}, "CSSStyleRule: selectorText value: |" + testCase.selector + "| isMatch: " + testCase.isMatch);
});
</script>

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

@ -0,0 +1,158 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CSSOM StyleRule selectorText property setter</title>
<link rel="help" href="https://drafts.csswg.org/cssom-1/#dom-cssstylerule-selectortext">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style type="text/css" id="styleElement">
.style0 { background-color: rgb(0, 0, 255) !important; }
.style1 { background-color: rgb(255, 0, 255); }
</style>
<span>
<p></p>
<div id="container" class="style1" lang="zh-CN" language segment="42 43">
</div>
</span>
<script>
var styleSheet = document.getElementById("styleElement").sheet;
var rule = styleSheet.cssRules[0];
var divContainerStyle = getComputedStyle(document.getElementById("container"));
const originalStyleSelector = ".style0";
var assertColors = function(selectorMatches) {
assert_equals(divContainerStyle.backgroundColor, selectorMatches ? "rgb(0, 0, 255)" : "rgb(255, 0, 255)")
};
test(function() {
assert_equals(typeof rule.selectorText, "string");
assert_equals(rule.selectorText, originalStyleSelector);
}, "CSSStyleRule: Can read selectorText value.");
[ // Invalid selector values.
"",
" ",
"!!",
"123",
"-",
"$",
":",
"::",
":::",
"::gibberish",
":gibberish",
".",
"#",
"[]",
"[",
"()",
"(",
"{}",
"{",
].forEach(function(selector) {
test(function() {
assert_equals(rule.selectorText, originalStyleSelector);
this.add_cleanup(function() { rule.selectorText = originalStyleSelector; });
rule.selectorText = selector;
assert_equals(rule.selectorText, originalStyleSelector);
}, "CSSStyleRule: Invalid CSS selector: " + selector);
});
[ // Valid selector values.
{selector: "#container", isMatch: true},
{selector: "#container ", isMatch: true, normalizedSelector: "#container"},
{selector: " #container ", isMatch: true, normalizedSelector: "#container"},
{selector: ".style1", isMatch: true},
{selector: "div.style1", isMatch: true},
{selector: "div:not(#non-existing-id)", isMatch: true},
{selector: "div", isMatch: true},
{selector: "*", isMatch: true},
{selector: "#no-match", isMatch: false},
{selector: "ÇĞıİ", isMatch: false},
{selector: "🤓", isMatch: false},
{selector: "[language]", isMatch: true},
{selector: "[language-no]", isMatch: false},
{selector: "[lang=\"zh-CN\"]", isMatch: true},
{selector: "[lang=\"ab-CD\"]", isMatch: false},
{selector: "[segment~=\"43\"]", isMatch: true},
{selector: "[segment~=\"42\"]", isMatch: true},
{selector: "[lang|=\"zh\"]", isMatch: true},
{selector: "[lang|=\"zh-CN\"]", isMatch: true},
{selector: "[lang|=\"ab\"]", isMatch: false},
{selector: "[lang|=\"z\"]", isMatch: false},
{selector: "[lang^=\"z\"]", isMatch: true},
{selector: "[lang^=\"ab\"]", isMatch: false},
{selector: "[segment$=\"43\"]", isMatch: true},
{selector: "[segment$=\"3\"]", isMatch: true},
{selector: "[segment$=\"42\"]", isMatch: false},
{selector: "[lang*=\"-\"]", isMatch: true},
{selector: "[lang*=\"h-\"]", isMatch: true},
{selector: "[lang*=\"ab\"]", isMatch: false},
{selector: "*|div", isMatch: true, normalizedSelector: "div"},
{selector: "|div", isMatch: false},
{selector: "*|a", isMatch: false, normalizedSelector: "a"},
{selector: "*|*", isMatch: true, normalizedSelector: "*"},
{selector: "[*|lang]", isMatch: true, normalizedSelector: "[*|lang]"},
{selector: "[|lang]", isMatch: true, normalizedSelector: "[lang]"},
{selector: ":active", isMatch: false},
{selector: ":not(:active)", isMatch: true},
{selector: "*:not(:active)", isMatch: true, normalizedSelector: ":not(:active)"},
{selector: "div:not(:active)", isMatch: true},
{selector: "div:active", isMatch: false},
{selector: "span div", isMatch: true},
{selector: "span div ", isMatch: true, normalizedSelector: "span div"},
{selector: "span > div", isMatch: true},
{selector: "div div", isMatch: false},
{selector: "div > div", isMatch: false},
{selector: "p + div", isMatch: true},
{selector: "span + div", isMatch: false},
{selector: "p ~ div", isMatch: true},
{selector: "span ~ div", isMatch: false},
{selector: ":lang(zh-CN)", isMatch: true},
{selector: ":lang(zh)", isMatch: true},
{selector: ":lang(tr-AZ)", isMatch: false},
{selector: "::after", isMatch: false, normalizedSelector: "::after"},
{selector: ":after", isMatch: false, normalizedSelector: "::after"},
{selector: "::before", isMatch: false, normalizedSelector: "::before"},
{selector: ":before", isMatch: false, normalizedSelector: "::before"},
{selector: "::first-letter", isMatch: false, normalizedSelector: "::first-letter"},
{selector: ":first-letter", isMatch: false, normalizedSelector: "::first-letter"},
{selector: "::first-line", isMatch: false, normalizedSelector: "::first-line"},
{selector: ":first-line", isMatch: false, normalizedSelector: "::first-line"},
{selector: "div:focus:not([lang=\"zh-CN\"])", isMatch: false},
{selector: "div[lang=\"zh-CN\"]:not(:focus)", isMatch: true},
].forEach(function(testCase) {
test(function() {
// Check if starting with the default value.
assert_equals(rule.selectorText, originalStyleSelector);
this.add_cleanup(function() { rule.selectorText = originalStyleSelector; });
assertColors(false);
rule.selectorText = testCase.selector;
var expectedSelector = testCase.normalizedSelector ? testCase.normalizedSelector : testCase.selector;
assert_equals(rule.selectorText, expectedSelector);
assertColors(testCase.isMatch);
}, "CSSStyleRule: selectorText value: |" + testCase.selector + "| isMatch: " + testCase.isMatch);
});
</script>

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

@ -157,12 +157,16 @@ nsMacDockSupport::RedrawIcon()
if (InitProgress()) {
// TODO: - Implement ERROR and PAUSED states?
NSImage *icon = [mProgressBackground copyWithZone:nil];
bool isIndeterminate = (mProgressState != STATE_NORMAL);
[icon lockFocus];
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
mTheme->DrawProgress(ctx, mProgressBounds, isIndeterminate,
true, mProgressFraction, 1.0, NULL);
nsNativeThemeCocoa::ProgressParams params;
params.value = mProgressFraction;
params.max = 1.0;
params.insideActiveWindow = true;
params.indeterminate = (mProgressState != STATE_NORMAL);
params.horizontal = true;
mTheme->DrawProgress(ctx, mProgressBounds, params);
[icon unlockFocus];
[NSApp setApplicationIconImage:icon];
[icon release];

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

@ -9,6 +9,8 @@
#import <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#include "mozilla/Variant.h"
#include "nsITheme.h"
#include "nsCOMPtr.h"
#include "nsAtom.h"
@ -16,12 +18,14 @@
@class CellDrawView;
@class NSProgressBarCell;
@class ContextAwareSearchFieldCell;
class nsDeviceContext;
struct SegmentedControlRenderSettings;
namespace mozilla {
class EventStates;
namespace gfx {
class DrawTarget;
} // namespace gfx
} // namespace mozilla
class nsNativeThemeCocoa : private nsNativeTheme,
@ -47,6 +51,317 @@ public:
eThemeGeometryTypeActiveSourceListSelection
};
enum class MenuIcon : uint8_t {
eCheckmark,
eMenuArrow,
eMenuDownScrollArrow,
eMenuUpScrollArrow
};
enum class CheckboxOrRadioState : uint8_t {
eOff,
eOn,
eIndeterminate
};
enum class ButtonType : uint8_t {
eRegularPushButton,
eDefaultPushButton,
eRegularBevelButton,
eDefaultBevelButton,
eRoundedBezelPushButton,
eSquareBezelPushButton,
eArrowButton,
eHelpButton,
eTreeTwistyPointingRight,
eTreeTwistyPointingDown,
eDisclosureButtonClosed,
eDisclosureButtonOpen
};
enum class SpinButton : uint8_t {
eUp,
eDown
};
enum class SegmentType : uint8_t {
eToolbarButton,
eTab
};
enum class OptimumState : uint8_t {
eOptimum,
eSubOptimum,
eSubSubOptimum
};
struct ControlParams {
ControlParams()
: disabled(false)
, insideActiveWindow(false)
, pressed(false)
, focused(false)
, rtl(false)
{}
bool disabled : 1;
bool insideActiveWindow : 1;
bool pressed : 1;
bool focused : 1;
bool rtl : 1;
};
struct MenuBackgroundParams {
mozilla::Maybe<mozilla::gfx::Color> vibrancyColor;
bool disabled = false;
bool submenuRightOfParent = false;
};
struct MenuIconParams {
MenuIcon icon = MenuIcon::eCheckmark;
bool disabled = false;
bool insideActiveMenuItem = false;
bool centerHorizontally = false;
bool rtl = false;
};
struct MenuItemParams {
mozilla::Maybe<mozilla::gfx::Color> vibrancyColor;
bool checked = false;
bool disabled = false;
bool selected = false;
bool rtl = false;
};
struct CheckboxOrRadioParams {
ControlParams controlParams;
CheckboxOrRadioState state = CheckboxOrRadioState::eOff;
float verticalAlignFactor = 0.5f;
};
struct ButtonParams {
ControlParams controlParams;
ButtonType button = ButtonType::eRegularPushButton;
};
struct DropdownParams {
ControlParams controlParams;
bool pullsDown = false;
bool editable = false;
};
struct SpinButtonParams {
mozilla::Maybe<SpinButton> pressedButton;
bool disabled = false;
bool insideActiveWindow = false;
};
struct SegmentParams {
SegmentType segmentType = SegmentType::eToolbarButton;
bool insideActiveWindow = false;
bool pressed = false;
bool selected = false;
bool focused = false;
bool atLeftEnd = false;
bool atRightEnd = false;
bool drawsLeftSeparator = false;
bool drawsRightSeparator = false;
bool rtl = false;
};
struct UnifiedToolbarParams {
float unifiedHeight = 0.0f;
bool isMain = false;
};
struct TextBoxParams {
bool disabled = false;
bool focused = false;
};
struct SearchFieldParams {
float verticalAlignFactor = 0.5f;
bool insideToolbar = false;
bool disabled = false;
bool focused = false;
bool rtl = false;
};
struct ProgressParams {
double value = 0.0;
double max = 0.0;
float verticalAlignFactor = 0.5f;
bool insideActiveWindow = false;
bool indeterminate = false;
bool horizontal = false;
bool rtl = false;
};
struct MeterParams {
double value = 0;
double min = 0;
double max = 0;
OptimumState optimumState = OptimumState::eOptimum;
float verticalAlignFactor = 0.5f;
bool horizontal = true;
bool rtl = false;
};
struct TreeHeaderCellParams {
ControlParams controlParams;
TreeSortDirection sortDirection = eTreeSortDirection_Natural;
bool lastTreeHeaderCell = false;
};
struct ScaleParams {
int32_t value = 0;
int32_t min = 0;
int32_t max = 0;
bool insideActiveWindow = false;
bool disabled = false;
bool focused = false;
bool horizontal = true;
bool reverse = false;
};
struct ScrollbarParams {
ScrollbarParams()
: overlay(false)
, rolledOver(false)
, small(false)
, horizontal(false)
, rtl(false)
, onDarkBackground(false)
{}
bool overlay : 1;
bool rolledOver : 1;
bool small : 1;
bool horizontal : 1;
bool rtl : 1;
bool onDarkBackground : 1;
};
enum Widget : uint8_t {
eColorFill, // mozilla::gfx::Color
eSheetBackground,
eDialogBackground,
eMenuBackground, // MenuBackgroundParams
eMenuIcon, // MenuIconParams
eMenuItem, // MenuItemParams
eMenuSeparator, // MenuItemParams
eTooltip,
eCheckbox, // CheckboxOrRadioParams
eRadio, // CheckboxOrRadioParams
eButton, // ButtonParams
eDropdown, // DropdownParams
eFocusOutline,
eSpinButtons, // SpinButtonParams
eSpinButtonUp, // SpinButtonParams
eSpinButtonDown, // SpinButtonParams
eSegment, // SegmentParams
eSeparator,
eUnifiedToolbar, // UnifiedToolbarParams
eToolbar, // bool
eNativeTitlebar, // UnifiedToolbarParams
eStatusBar, // bool
eGroupBox,
eTextBox, // TextBoxParams
eSearchField, // SearchFieldParams
eProgressBar, // ProgressParams
eMeter, // MeterParams
eTreeHeaderCell, // TreeHeaderCellParams
eScale, // ScaleParams
eScrollbarThumb, // ScrollbarParams
eScrollbarTrack, // ScrollbarParams
eMultilineTextField, // bool
eListBox,
eSourceList, // bool
eActiveSourceListSelection, // bool
eInactiveSourceListSelection, // bool
eTabPanel,
eResizer
};
struct WidgetInfo {
static WidgetInfo ColorFill(const mozilla::gfx::Color& aParams) { return WidgetInfo(Widget::eColorFill, aParams); }
static WidgetInfo SheetBackground() { return WidgetInfo(Widget::eSheetBackground, false); }
static WidgetInfo DialogBackground() { return WidgetInfo(Widget::eDialogBackground, false); }
static WidgetInfo MenuBackground(const MenuBackgroundParams& aParams) { return WidgetInfo(Widget::eMenuBackground, aParams); }
static WidgetInfo MenuIcon(const MenuIconParams& aParams) { return WidgetInfo(Widget::eMenuIcon, aParams); }
static WidgetInfo MenuItem(const MenuItemParams& aParams) { return WidgetInfo(Widget::eMenuItem, aParams); }
static WidgetInfo MenuSeparator(const MenuItemParams& aParams) { return WidgetInfo(Widget::eMenuSeparator, aParams); }
static WidgetInfo Tooltip() { return WidgetInfo(Widget::eTooltip, false); }
static WidgetInfo Checkbox(const CheckboxOrRadioParams& aParams) { return WidgetInfo(Widget::eCheckbox, aParams); }
static WidgetInfo Radio(const CheckboxOrRadioParams& aParams) { return WidgetInfo(Widget::eRadio, aParams); }
static WidgetInfo Button(const ButtonParams& aParams) { return WidgetInfo(Widget::eButton, aParams); }
static WidgetInfo Dropdown(const DropdownParams& aParams) { return WidgetInfo(Widget::eDropdown, aParams); }
static WidgetInfo FocusOutline() { return WidgetInfo(Widget::eFocusOutline, false); }
static WidgetInfo SpinButtons(const SpinButtonParams& aParams) { return WidgetInfo(Widget::eSpinButtons, aParams); }
static WidgetInfo SpinButtonUp(const SpinButtonParams& aParams) { return WidgetInfo(Widget::eSpinButtonUp, aParams); }
static WidgetInfo SpinButtonDown(const SpinButtonParams& aParams) { return WidgetInfo(Widget::eSpinButtonDown, aParams); }
static WidgetInfo Segment(const SegmentParams& aParams) { return WidgetInfo(Widget::eSegment, aParams); }
static WidgetInfo Separator() { return WidgetInfo(Widget::eSeparator, false); }
static WidgetInfo UnifiedToolbar(const UnifiedToolbarParams& aParams) { return WidgetInfo(Widget::eUnifiedToolbar, aParams); }
static WidgetInfo Toolbar(bool aParams) { return WidgetInfo(Widget::eToolbar, aParams); }
static WidgetInfo NativeTitlebar(const UnifiedToolbarParams& aParams) { return WidgetInfo(Widget::eNativeTitlebar, aParams); }
static WidgetInfo StatusBar(bool aParams) { return WidgetInfo(Widget::eStatusBar, aParams); }
static WidgetInfo GroupBox() { return WidgetInfo(Widget::eGroupBox, false); }
static WidgetInfo TextBox(const TextBoxParams& aParams) { return WidgetInfo(Widget::eTextBox, aParams); }
static WidgetInfo SearchField(const SearchFieldParams& aParams) { return WidgetInfo(Widget::eSearchField, aParams); }
static WidgetInfo ProgressBar(const ProgressParams& aParams) { return WidgetInfo(Widget::eProgressBar, aParams); }
static WidgetInfo Meter(const MeterParams& aParams) { return WidgetInfo(Widget::eMeter, aParams); }
static WidgetInfo TreeHeaderCell(const TreeHeaderCellParams& aParams) { return WidgetInfo(Widget::eTreeHeaderCell, aParams); }
static WidgetInfo Scale(const ScaleParams& aParams) { return WidgetInfo(Widget::eScale, aParams); }
static WidgetInfo ScrollbarThumb(const ScrollbarParams& aParams) { return WidgetInfo(Widget::eScrollbarThumb, aParams); }
static WidgetInfo ScrollbarTrack(const ScrollbarParams& aParams) { return WidgetInfo(Widget::eScrollbarTrack, aParams); }
static WidgetInfo MultilineTextField(bool aParams) { return WidgetInfo(Widget::eMultilineTextField, aParams); }
static WidgetInfo ListBox() { return WidgetInfo(Widget::eListBox, false); }
static WidgetInfo SourceList(bool aParams) { return WidgetInfo(Widget::eSourceList, aParams); }
static WidgetInfo ActiveSourceListSelection(bool aParams) { return WidgetInfo(Widget::eActiveSourceListSelection, aParams); }
static WidgetInfo InactiveSourceListSelection(bool aParams) { return WidgetInfo(Widget::eInactiveSourceListSelection, aParams); }
static WidgetInfo TabPanel(bool aParams) { return WidgetInfo(Widget::eTabPanel, aParams); }
static WidgetInfo Resizer(bool aParams) { return WidgetInfo(Widget::eResizer, aParams); }
template<typename T>
T Params() const
{
MOZ_RELEASE_ASSERT(mVariant.is<T>());
return mVariant.as<T>();
}
enum Widget Widget() const { return mWidget; }
private:
template<typename T> WidgetInfo(enum Widget aWidget, const T& aParams)
: mVariant(aParams)
, mWidget(aWidget)
{}
mozilla::Variant<
mozilla::gfx::Color,
MenuBackgroundParams,
MenuIconParams,
MenuItemParams,
CheckboxOrRadioParams,
ButtonParams,
DropdownParams,
SpinButtonParams,
SegmentParams,
UnifiedToolbarParams,
TextBoxParams,
SearchFieldParams,
ProgressParams,
MeterParams,
TreeHeaderCellParams,
ScaleParams,
ScrollbarParams,
bool
> mVariant;
enum Widget mWidget;
};
nsNativeThemeCocoa();
NS_DECL_ISUPPORTS_INHERITED
@ -94,10 +409,11 @@ public:
virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame,
uint8_t aWidgetType) override;
virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) override;
mozilla::Maybe<WidgetInfo> ComputeWidgetInfo(nsIFrame* aFrame,
uint8_t aWidgetType,
const nsRect& aRect);
void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
bool inIsIndeterminate, bool inIsHorizontal,
double inValue, double inMaxValue, nsIFrame* aFrame);
const ProgressParams& aParams);
static void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
CGFloat aUnifiedHeight, BOOL aIsMain, BOOL aIsFlipped);
@ -107,72 +423,125 @@ protected:
nsIntMargin DirectionAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter);
CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
nsIFrame* aCurrent, nsIFrame* aRight);
bool IsWindowSheet(nsIFrame* aFrame);
ControlParams ComputeControlParams(nsIFrame* aFrame,
mozilla::EventStates aEventState);
MenuBackgroundParams ComputeMenuBackgroundParams(nsIFrame* aFrame,
mozilla::EventStates aEventState);
MenuIconParams ComputeMenuIconParams(nsIFrame* aParams,
mozilla::EventStates aEventState,
MenuIcon aIcon);
MenuItemParams ComputeMenuItemParams(nsIFrame* aFrame,
mozilla::EventStates aEventState,
bool aIsChecked);
SegmentParams ComputeSegmentParams(nsIFrame* aFrame,
mozilla::EventStates aEventState,
SegmentType aSegmentType);
SearchFieldParams ComputeSearchFieldParams(nsIFrame* aFrame,
mozilla::EventStates aEventState);
ProgressParams ComputeProgressParams(nsIFrame* aFrame,
mozilla::EventStates aEventState,
bool aIsHorizontal);
MeterParams ComputeMeterParams(nsIFrame* aFrame);
TreeHeaderCellParams ComputeTreeHeaderCellParams(nsIFrame* aFrame,
mozilla::EventStates aEventState);
ScaleParams ComputeXULScaleParams(nsIFrame* aFrame,
mozilla::EventStates aEventState,
bool aIsHorizontal);
mozilla::Maybe<ScaleParams> ComputeHTMLScaleParams(nsIFrame* aFrame,
mozilla::EventStates aEventState);
ScrollbarParams ComputeScrollbarParams(nsIFrame* aFrame, bool aIsHorizontal);
// HITheme drawing routines
void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
const HIRect& inBoxRect, bool inReadOnly,
mozilla::EventStates inState);
void DrawTextBox(CGContextRef context, const HIRect& inBoxRect,
TextBoxParams aParams);
void DrawMeter(CGContextRef context, const HIRect& inBoxRect,
nsIFrame* aFrame);
const MeterParams& aParams);
void DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect,
mozilla::EventStates inState, nsIFrame* aFrame,
const SegmentedControlRenderSettings& aSettings);
void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect, nsIFrame* aFrame);
const SegmentParams& aParams);
void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect,
bool aIsInsideActiveWindow);
void DrawScale(CGContextRef context, const HIRect& inBoxRect,
mozilla::EventStates inState, bool inDirection,
bool inIsReverse, int32_t inCurrentValue, int32_t inMinValue,
int32_t inMaxValue, nsIFrame* aFrame);
const ScaleParams& aParams);
void DrawCheckboxOrRadio(CGContextRef cgContext, bool inCheckbox,
const HIRect& inBoxRect, bool inSelected,
mozilla::EventStates inState, nsIFrame* aFrame);
const HIRect& inBoxRect,
const CheckboxOrRadioParams& aParams);
void DrawSearchField(CGContextRef cgContext, const HIRect& inBoxRect,
nsIFrame* aFrame, mozilla::EventStates inState);
void DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
mozilla::EventStates inState, uint8_t aWidgetType,
nsIFrame* aFrame, float aOriginalHeight);
const SearchFieldParams& aParams);
void DrawRoundedBezelPushButton(CGContextRef cgContext,
const HIRect& inBoxRect,
ControlParams aControlParams);
void DrawSquareBezelPushButton(CGContextRef cgContext,
const HIRect& inBoxRect,
ControlParams aControlParams);
void DrawHelpButton(CGContextRef cgContext, const HIRect& inBoxRect,
ControlParams aControlParams);
void DrawDisclosureButton(CGContextRef cgContext, const HIRect& inBoxRect,
ControlParams aControlParams, NSCellStateValue aState);
void DrawMenuBackground(CGContextRef cgContext, const CGRect& inBoxRect,
const MenuBackgroundParams& aParams);
NSString* GetMenuIconName(const MenuIconParams& aParams);
NSSize GetMenuIconSize(MenuIcon aIcon);
void DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
mozilla::EventStates inState, nsIFrame* aFrame,
const NSSize& aIconSize, NSString* aImageName,
bool aCenterHorizontally);
void DrawButton(CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, bool inIsDefault,
ThemeButtonValue inValue, ThemeButtonAdornment inAdornment,
mozilla::EventStates inState, nsIFrame* aFrame);
void DrawFocusOutline(CGContextRef cgContext, const HIRect& inBoxRect,
mozilla::EventStates inState, uint8_t aWidgetType,
nsIFrame* aFrame);
const MenuIconParams& aParams);
void DrawMenuItem(CGContextRef cgContext, const CGRect& inBoxRect,
const MenuItemParams& aParams);
void DrawMenuSeparator(CGContextRef cgContext, const CGRect& inBoxRect,
const MenuItemParams& aParams);
void DrawHIThemeButton(CGContextRef cgContext, const HIRect& aRect,
ThemeButtonKind aKind, ThemeButtonValue aValue,
ThemeDrawState aState, ThemeButtonAdornment aAdornment,
const ControlParams& aParams);
void DrawButton(CGContextRef context, const HIRect& inBoxRect,
const ButtonParams& aParams);
void DrawTreeHeaderCell(CGContextRef context, const HIRect& inBoxRect,
const TreeHeaderCellParams& aParams);
void DrawFocusOutline(CGContextRef cgContext, const HIRect& inBoxRect);
void DrawDropdown(CGContextRef context, const HIRect& inBoxRect,
mozilla::EventStates inState, uint8_t aWidgetType,
nsIFrame* aFrame);
void DrawSpinButtons(CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, ThemeDrawState inDrawState,
ThemeButtonAdornment inAdornment,
mozilla::EventStates inState, nsIFrame* aFrame);
void DrawSpinButton(CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, ThemeDrawState inDrawState,
ThemeButtonAdornment inAdornment,
mozilla::EventStates inState,
nsIFrame* aFrame, uint8_t aWidgetType);
const DropdownParams& aParams);
HIThemeButtonDrawInfo SpinButtonDrawInfo(ThemeButtonKind aKind,
const SpinButtonParams& aParams);
void DrawSpinButtons(CGContextRef context, const HIRect& inBoxRect,
const SpinButtonParams& aParams);
void DrawSpinButton(CGContextRef context,
const HIRect& inBoxRect, SpinButton aDrawnButton,
const SpinButtonParams& aParams);
void DrawToolbar(CGContextRef cgContext, const CGRect& inBoxRect,
bool aIsMain);
void DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inBoxRect,
NSWindow* aWindow);
const UnifiedToolbarParams& aParams);
void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
const UnifiedToolbarParams& aParams);
void DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect,
nsIFrame *aFrame);
void DrawResizer(CGContextRef cgContext, const HIRect& aRect, nsIFrame *aFrame);
bool aIsMain);
void DrawResizer(CGContextRef cgContext, const HIRect& aRect, bool aIsRTL);
void DrawScrollbarThumb(CGContextRef cgContext, const CGRect& inBoxRect,
ScrollbarParams aParams);
void DrawScrollbarTrack(CGContextRef cgContext, const CGRect& inBoxRect,
ScrollbarParams aParams);
void DrawMultilineTextField(CGContextRef cgContext, const CGRect& inBoxRect,
bool aIsFocused);
void DrawSourceList(CGContextRef cgContext, const CGRect& inBoxRect,
bool aIsActive);
// Scrollbars
nsIFrame* GetParentScrollbarFrame(nsIFrame *aFrame);
bool IsParentScrollbarRolledOver(nsIFrame* aFrame);
void RenderWidget(const WidgetInfo& aWidgetInfo,
mozilla::gfx::DrawTarget& aDrawTarget,
const mozilla::gfx::Rect& aWidgetRect,
const mozilla::gfx::Rect& aDirtyRect,
float aScale);
private:
NSButtonCell* mDisclosureButtonCell;
NSButtonCell* mHelpButtonCell;
NSButtonCell* mPushButtonCell;
NSButtonCell* mRadioButtonCell;
NSButtonCell* mCheckboxCell;
ContextAwareSearchFieldCell* mSearchFieldCell;
NSSearchFieldCell* mSearchFieldCell;
NSSearchFieldCell* mToolbarSearchFieldCell;
NSPopUpButtonCell* mDropdownCell;
NSComboBoxCell* mComboBoxCell;
NSProgressBarCell* mProgressBarCell;

Разница между файлами не показана из-за своего большого размера Загрузить разницу