blob: b7f27438c9a4f1d6659f1b6c0b51b414e1eeebf9 [file] [log] [blame]
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
* rights reserved.
* Copyright (C) 2011 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "core/css/StyleRuleCSSStyleDeclaration.h"
#include "core/css/CSSRule.h"
#include "core/css/CSSStyleSheet.h"
#include "core/dom/Document.h"
#include "core/dom/Node.h"
namespace blink {
StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(
MutableCSSPropertyValueSet& property_set_arg,
CSSRule* parent_rule)
: PropertySetCSSStyleDeclaration(property_set_arg),
parent_rule_(parent_rule) {}
StyleRuleCSSStyleDeclaration::~StyleRuleCSSStyleDeclaration() = default;
void StyleRuleCSSStyleDeclaration::WillMutate() {
if (parent_rule_ && parent_rule_->parentStyleSheet())
parent_rule_->parentStyleSheet()->WillMutateRules();
}
void StyleRuleCSSStyleDeclaration::DidMutate(MutationType type) {
// Style sheet mutation needs to be signaled even if the change failed.
// willMutateRules/didMutateRules must pair.
if (parent_rule_ && parent_rule_->parentStyleSheet())
parent_rule_->parentStyleSheet()->DidMutateRules();
}
CSSStyleSheet* StyleRuleCSSStyleDeclaration::ParentStyleSheet() const {
return parent_rule_ ? parent_rule_->parentStyleSheet() : nullptr;
}
void StyleRuleCSSStyleDeclaration::Reattach(
MutableCSSPropertyValueSet& property_set) {
property_set_ = &property_set;
}
PropertyRegistry* StyleRuleCSSStyleDeclaration::GetPropertyRegistry() const {
CSSStyleSheet* sheet = parent_rule_->parentStyleSheet();
if (!sheet)
return nullptr;
Node* node = sheet->ownerNode();
if (!node)
return nullptr;
return node->GetDocument().GetPropertyRegistry();
}
void StyleRuleCSSStyleDeclaration::Trace(blink::Visitor* visitor) {
visitor->Trace(parent_rule_);
PropertySetCSSStyleDeclaration::Trace(visitor);
}
void StyleRuleCSSStyleDeclaration::TraceWrappers(
const ScriptWrappableVisitor* visitor) const {
visitor->TraceWrappers(parent_rule_);
PropertySetCSSStyleDeclaration::TraceWrappers(visitor);
}
} // namespace blink