?? cssstyleselector.cpp
字號:
/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) * * 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 "config.h"#include "CSSStyleSelector.h"#include "CSSBorderImageValue.h"#include "CSSCursorImageValue.h"#include "CSSFontFace.h"#include "CSSFontFaceRule.h"#include "CSSFontFaceSource.h"#include "CSSImportRule.h"#include "CSSMediaRule.h"#include "CSSParser.h"#include "CSSPrimitiveValueMappings.h"#include "CSSProperty.h"#include "CSSPropertyNames.h"#include "CSSReflectValue.h"#include "CSSRuleList.h"#include "CSSSelector.h"#include "CSSSelectorList.h"#include "CSSStyleRule.h"#include "CSSStyleSheet.h"#include "CSSTimingFunctionValue.h"#include "CSSValueList.h"#include "CSSVariableDependentValue.h"#include "CSSVariablesDeclaration.h"#include "CSSVariablesRule.h"#include "CachedImage.h"#include "Counter.h"#include "CounterContent.h"#include "FocusController.h"#include "FontFamilyValue.h"#include "FontValue.h"#include "Frame.h"#include "FrameView.h"#include "HTMLDocument.h"#include "HTMLElement.h"#include "HTMLInputElement.h"#include "HTMLNames.h"#include "HTMLTextAreaElement.h"#include "LinkHash.h"#include "MatrixTransformOperation.h"#include "Matrix3DTransformOperation.h"#include "MediaList.h"#include "MediaQueryEvaluator.h"#include "NodeRenderStyle.h"#include "Page.h"#include "PageGroup.h"#include "Pair.h"#include "PerspectiveTransformOperation.h"#include "Rect.h"#include "RenderScrollbar.h"#include "RenderScrollbarTheme.h"#include "RenderStyleConstants.h"#include "RenderTheme.h"#include "RotateTransformOperation.h"#include "ScaleTransformOperation.h"#include "SelectionController.h"#include "Settings.h"#include "ShadowValue.h"#include "SkewTransformOperation.h"#include "StyleCachedImage.h"#include "StyleGeneratedImage.h"#include "StyleSheetList.h"#include "Text.h"#include "TransformationMatrix.h"#include "TranslateTransformOperation.h"#include "UserAgentStyleSheets.h"#include "WebKitCSSKeyframeRule.h"#include "WebKitCSSKeyframesRule.h"#include "WebKitCSSTransformValue.h"#include "XMLNames.h"#include "loader.h"#include <wtf/StdLibExtras.h>#include <wtf/Vector.h>#if ENABLE(DASHBOARD_SUPPORT)#include "DashboardRegion.h"#endif#if ENABLE(SVG)#include "XLinkNames.h"#include "SVGNames.h"#endif#if ENABLE(WML)#include "WMLNames.h"#endifusing namespace std;namespace WebCore {using namespace HTMLNames;// #define STYLE_SHARING_STATS 1#define HANDLE_INHERIT(prop, Prop) \if (isInherit) { \ m_style->set##Prop(m_parentStyle->prop()); \ return; \}#define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \HANDLE_INHERIT(prop, Prop) \if (isInitial) { \ m_style->set##Prop(RenderStyle::initial##Prop()); \ return; \}#define HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(prop, Prop, Value) \HANDLE_INHERIT(prop, Prop) \if (isInitial) { \ m_style->set##Prop(RenderStyle::initial##Value());\ return;\}#define HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(layerType, LayerType, prop, Prop) \if (isInherit) { \ FillLayer* currChild = m_style->access##LayerType##Layers(); \ FillLayer* prevChild = 0; \ const FillLayer* currParent = m_parentStyle->layerType##Layers(); \ while (currParent && currParent->is##Prop##Set()) { \ if (!currChild) { \ /* Need to make a new layer.*/ \ currChild = new FillLayer(LayerType##FillLayer); \ prevChild->setNext(currChild); \ } \ currChild->set##Prop(currParent->prop()); \ prevChild = currChild; \ currChild = prevChild->next(); \ currParent = currParent->next(); \ } \ \ while (currChild) { \ /* Reset any remaining layers to not have the property set. */ \ currChild->clear##Prop(); \ currChild = currChild->next(); \ } \} else if (isInitial) { \ FillLayer* currChild = m_style->access##LayerType##Layers(); \ currChild->set##Prop(FillLayer::initialFill##Prop(LayerType##FillLayer)); \ for (currChild = currChild->next(); currChild; currChild = currChild->next()) \ currChild->clear##Prop(); \}#define HANDLE_FILL_LAYER_VALUE(layerType, LayerType, prop, Prop, value) { \HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(layerType, LayerType, prop, Prop) \if (isInherit || isInitial) \ return; \FillLayer* currChild = m_style->access##LayerType##Layers(); \FillLayer* prevChild = 0; \if (value->isValueList()) { \ /* Walk each value and put it into a layer, creating new layers as needed. */ \ CSSValueList* valueList = static_cast<CSSValueList*>(value); \ for (unsigned int i = 0; i < valueList->length(); i++) { \ if (!currChild) { \ /* Need to make a new layer to hold this value */ \ currChild = new FillLayer(LayerType##FillLayer); \ prevChild->setNext(currChild); \ } \ mapFill##Prop(currChild, valueList->itemWithoutBoundsCheck(i)); \ prevChild = currChild; \ currChild = currChild->next(); \ } \} else { \ mapFill##Prop(currChild, value); \ currChild = currChild->next(); \} \while (currChild) { \ /* Reset all remaining layers to not have the property set. */ \ currChild->clear##Prop(); \ currChild = currChild->next(); \} }#define HANDLE_BACKGROUND_INHERIT_AND_INITIAL(prop, Prop) \HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(background, Background, prop, Prop)#define HANDLE_BACKGROUND_VALUE(prop, Prop, value) \HANDLE_FILL_LAYER_VALUE(background, Background, prop, Prop, value)#define HANDLE_MASK_INHERIT_AND_INITIAL(prop, Prop) \HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(mask, Mask, prop, Prop)#define HANDLE_MASK_VALUE(prop, Prop, value) \HANDLE_FILL_LAYER_VALUE(mask, Mask, prop, Prop, value)#define HANDLE_ANIMATION_INHERIT_AND_INITIAL(prop, Prop) \if (isInherit) { \ AnimationList* list = m_style->accessAnimations(); \ const AnimationList* parentList = m_parentStyle->animations(); \ size_t i = 0, parentSize = parentList ? parentList->size() : 0; \ for ( ; i < parentSize && parentList->animation(i)->is##Prop##Set(); ++i) { \ if (list->size() <= i) \ list->append(Animation::create()); \ list->animation(i)->set##Prop(parentList->animation(i)->prop()); \ } \ \ /* Reset any remaining animations to not have the property set. */ \ for ( ; i < list->size(); ++i) \ list->animation(i)->clear##Prop(); \} else if (isInitial) { \ AnimationList* list = m_style->accessAnimations(); \ if (list->isEmpty()) \ list->append(Animation::create()); \ list->animation(0)->set##Prop(Animation::initialAnimation##Prop()); \ for (size_t i = 1; i < list->size(); ++i) \ list->animation(0)->clear##Prop(); \}#define HANDLE_ANIMATION_VALUE(prop, Prop, value) { \HANDLE_ANIMATION_INHERIT_AND_INITIAL(prop, Prop) \if (isInherit || isInitial) \ return; \AnimationList* list = m_style->accessAnimations(); \size_t childIndex = 0; \if (value->isValueList()) { \ /* Walk each value and put it into an animation, creating new animations as needed. */ \ CSSValueList* valueList = static_cast<CSSValueList*>(value); \ for (unsigned int i = 0; i < valueList->length(); i++) { \ if (childIndex <= list->size()) \ list->append(Animation::create()); \ mapAnimation##Prop(list->animation(childIndex), valueList->itemWithoutBoundsCheck(i)); \ ++childIndex; \ } \} else { \ if (list->isEmpty()) \ list->append(Animation::create()); \ mapAnimation##Prop(list->animation(childIndex), value); \ childIndex = 1; \} \for ( ; childIndex < list->size(); ++childIndex) { \ /* Reset all remaining animations to not have the property set. */ \ list->animation(childIndex)->clear##Prop(); \} \}#define HANDLE_TRANSITION_INHERIT_AND_INITIAL(prop, Prop) \if (isInherit) { \ AnimationList* list = m_style->accessTransitions(); \ const AnimationList* parentList = m_parentStyle->transitions(); \ size_t i = 0, parentSize = parentList ? parentList->size() : 0; \ for ( ; i < parentSize && parentList->animation(i)->is##Prop##Set(); ++i) { \ if (list->size() <= i) \ list->append(Animation::create()); \ list->animation(i)->set##Prop(parentList->animation(i)->prop()); \ } \ \ /* Reset any remaining transitions to not have the property set. */ \ for ( ; i < list->size(); ++i) \ list->animation(i)->clear##Prop(); \} else if (isInitial) { \ AnimationList* list = m_style->accessTransitions(); \ if (list->isEmpty()) \ list->append(Animation::create()); \ list->animation(0)->set##Prop(Animation::initialAnimation##Prop()); \ for (size_t i = 1; i < list->size(); ++i) \ list->animation(0)->clear##Prop(); \}#define HANDLE_TRANSITION_VALUE(prop, Prop, value) { \HANDLE_TRANSITION_INHERIT_AND_INITIAL(prop, Prop) \if (isInherit || isInitial) \ return; \AnimationList* list = m_style->accessTransitions(); \size_t childIndex = 0; \if (value->isValueList()) { \ /* Walk each value and put it into a transition, creating new animations as needed. */ \ CSSValueList* valueList = static_cast<CSSValueList*>(value); \ for (unsigned int i = 0; i < valueList->length(); i++) { \ if (childIndex <= list->size()) \ list->append(Animation::create()); \ mapAnimation##Prop(list->animation(childIndex), valueList->itemWithoutBoundsCheck(i)); \ ++childIndex; \ } \} else { \ if (list->isEmpty()) \ list->append(Animation::create()); \ mapAnimation##Prop(list->animation(childIndex), value); \ childIndex = 1; \} \for ( ; childIndex < list->size(); ++childIndex) { \ /* Reset all remaining transitions to not have the property set. */ \ list->animation(childIndex)->clear##Prop(); \} \}#define HANDLE_INHERIT_COND(propID, prop, Prop) \if (id == propID) { \ m_style->set##Prop(m_parentStyle->prop()); \ return; \} #define HANDLE_INHERIT_COND_WITH_BACKUP(propID, prop, propAlt, Prop) \if (id == propID) { \ if (m_parentStyle->prop().isValid()) \ m_style->set##Prop(m_parentStyle->prop()); \ else \ m_style->set##Prop(m_parentStyle->propAlt()); \ return; \}#define HANDLE_INITIAL_COND(propID, Prop) \if (id == propID) { \ m_style->set##Prop(RenderStyle::initial##Prop()); \ return; \}#define HANDLE_INITIAL_COND_WITH_VALUE(propID, Prop, Value) \if (id == propID) { \ m_style->set##Prop(RenderStyle::initial##Value()); \ return; \}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -