/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
void HTMLBodyElement::MapAttributesIntoRule(
MappedDeclarationsBuilder& aBuilder) { // This is the one place where we try to set the same property // multiple times in presentation attributes. Servo does not support // querying if a property is set (because that is O(n) behavior // in ServoSpecifiedValues). Instead, we use the below values to keep // track of whether we have already set a property, and if so, what value // we set it to (which is used when handling margin // attributes from the containing frame element)
const nsAttrValue* value; // if marginwidth/marginheight are set, reflect them as 'margin'
value = aBuilder.GetAttr(nsGkAtoms::marginwidth); if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginWidth = value->GetIntegerValue(); if (bodyMarginWidth < 0) {
bodyMarginWidth = 0;
}
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_left,
(float)bodyMarginWidth);
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_right,
(float)bodyMarginWidth);
}
value = aBuilder.GetAttr(nsGkAtoms::marginheight); if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginHeight = value->GetIntegerValue(); if (bodyMarginHeight < 0) {
bodyMarginHeight = 0;
}
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_top,
(float)bodyMarginHeight);
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_bottom,
(float)bodyMarginHeight);
}
// topmargin (IE-attribute) if (bodyMarginHeight == -1) {
value = aBuilder.GetAttr(nsGkAtoms::topmargin); if (value && value->Type() == nsAttrValue::eInteger) {
bodyTopMargin = value->GetIntegerValue(); if (bodyTopMargin < 0) {
bodyTopMargin = 0;
}
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_top,
(float)bodyTopMargin);
}
} // bottommargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aBuilder.GetAttr(nsGkAtoms::bottommargin); if (value && value->Type() == nsAttrValue::eInteger) {
bodyBottomMargin = value->GetIntegerValue(); if (bodyBottomMargin < 0) {
bodyBottomMargin = 0;
}
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_bottom,
(float)bodyBottomMargin);
}
}
// leftmargin (IE-attribute) if (bodyMarginWidth == -1) {
value = aBuilder.GetAttr(nsGkAtoms::leftmargin); if (value && value->Type() == nsAttrValue::eInteger) {
bodyLeftMargin = value->GetIntegerValue(); if (bodyLeftMargin < 0) {
bodyLeftMargin = 0;
}
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_left,
(float)bodyLeftMargin);
}
} // rightmargin (IE-attribute) if (bodyMarginWidth == -1) {
value = aBuilder.GetAttr(nsGkAtoms::rightmargin); if (value && value->Type() == nsAttrValue::eInteger) {
bodyRightMargin = value->GetIntegerValue(); if (bodyRightMargin < 0) {
bodyRightMargin = 0;
}
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_right,
(float)bodyRightMargin);
}
}
// if marginwidth or marginheight is set in the <frame> and not set in the // <body> reflect them as margin in the <body> if (bodyMarginWidth == -1 || bodyMarginHeight == -1) { if (nsDocShell* ds = nsDocShell::Cast(aBuilder.Document().GetDocShell())) {
CSSIntSize margins = ds->GetFrameMargins();
int32_t frameMarginWidth = margins.width;
int32_t frameMarginHeight = margins.height;
if (bodyMarginWidth == -1 && frameMarginWidth >= 0) { if (bodyLeftMargin == -1) {
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_left,
(float)frameMarginWidth);
} if (bodyRightMargin == -1) {
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_right,
(float)frameMarginWidth);
}
}
if (bodyMarginHeight == -1 && frameMarginHeight >= 0) { if (bodyTopMargin == -1) {
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_top,
(float)frameMarginHeight);
} if (bodyBottomMargin == -1) {
aBuilder.SetPixelValueIfUnset(eCSSProperty_margin_bottom,
(float)frameMarginHeight);
}
}
}
}
// When display if first asked for, go ahead and get our colors set up. if (AttributeStyles* attrStyles = aBuilder.Document().GetAttributeStyles()) {
nscolor color;
value = aBuilder.GetAttr(nsGkAtoms::link); if (value && value->GetColorValue(color)) {
attrStyles->SetLinkColor(color);
}
value = aBuilder.GetAttr(nsGkAtoms::alink); if (value && value->GetColorValue(color)) {
attrStyles->SetActiveLinkColor(color);
}
value = aBuilder.GetAttr(nsGkAtoms::vlink); if (value && value->GetColorValue(color)) {
attrStyles->SetVisitedLinkColor(color);
}
}
if (!aBuilder.PropertyIsSet(eCSSProperty_color)) { // color: color
nscolor color;
value = aBuilder.GetAttr(nsGkAtoms::text); if (value && value->GetColorValue(color)) {
aBuilder.SetColorValue(eCSSProperty_color, color);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.