📄 domcss.mm
字号:
/* * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved. * Copyright (C) 2006 James G. Speth (speth@end.com) * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#import "config.h"#import "DOMCSS.h"#import "CSSCharsetRule.h"#import "CSSFontFaceRule.h"#import "CSSImportRule.h"#import "CSSMediaRule.h"#import "CSSPageRule.h"#import "CSSPrimitiveValue.h"#import "CSSRule.h"#import "CSSRuleList.h"#import "CSSStyleDeclaration.h"#import "CSSStyleRule.h"#import "CSSStyleSheet.h"#import "CSSValueList.h"#import "DOMInternal.h"#import "DOMPrivate.h"#import "StyleSheet.h"#import <objc/objc-class.h>#if ENABLE(SVG)#import "DOMSVGColor.h"#import "DOMSVGPaint.h"#endif//------------------------------------------------------------------------------------------// DOMStyleSheet@implementation DOMStyleSheet (WebCoreInternal)- (WebCore::StyleSheet *)_styleSheet{ return reinterpret_cast<WebCore::StyleSheet*>(_internal);}- (id)_initWithStyleSheet:(WebCore::StyleSheet *)impl{ [super _init]; _internal = reinterpret_cast<DOMObjectInternal*>(impl); impl->ref(); WebCore::addDOMWrapper(self, impl); return self;}+ (DOMStyleSheet *)_wrapStyleSheet:(WebCore::StyleSheet *)impl{ if (!impl) return nil; id cachedInstance; cachedInstance = WebCore::getDOMWrapper(impl); if (cachedInstance) return [[cachedInstance retain] autorelease]; Class wrapperClass; if (impl->isCSSStyleSheet()) wrapperClass = [DOMCSSStyleSheet class]; else wrapperClass = [DOMStyleSheet class]; return [[[wrapperClass alloc] _initWithStyleSheet:impl] autorelease];}@end//------------------------------------------------------------------------------------------// DOMCSSRule@implementation DOMCSSRule (WebCoreInternal)- (WebCore::CSSRule *)_CSSRule{ return reinterpret_cast<WebCore::CSSRule*>(_internal);}- (id)_initWithCSSRule:(WebCore::CSSRule *)impl{ [super _init]; _internal = reinterpret_cast<DOMObjectInternal*>(impl); impl->ref(); WebCore::addDOMWrapper(self, impl); return self;}+ (DOMCSSRule *)_wrapCSSRule:(WebCore::CSSRule *)impl{ if (!impl) return nil; id cachedInstance; cachedInstance = WebCore::getDOMWrapper(impl); if (cachedInstance) return [[cachedInstance retain] autorelease]; Class wrapperClass = nil; switch (impl->type()) { case DOM_UNKNOWN_RULE: wrapperClass = [DOMCSSUnknownRule class]; break; case DOM_STYLE_RULE: wrapperClass = [DOMCSSStyleRule class]; break; case DOM_CHARSET_RULE: wrapperClass = [DOMCSSCharsetRule class]; break; case DOM_IMPORT_RULE: wrapperClass = [DOMCSSImportRule class]; break; case DOM_MEDIA_RULE: wrapperClass = [DOMCSSMediaRule class]; break; case DOM_FONT_FACE_RULE: wrapperClass = [DOMCSSFontFaceRule class]; break; case DOM_PAGE_RULE: wrapperClass = [DOMCSSPageRule class]; break; case DOM_VARIABLES_RULE: wrapperClass = [DOMCSSVariablesRule class]; break; case DOM_WEBKIT_KEYFRAMES_RULE: wrapperClass = [DOMWebKitCSSKeyframesRule class]; break; case DOM_WEBKIT_KEYFRAME_RULE: wrapperClass = [DOMWebKitCSSKeyframeRule class]; break; } return [[[wrapperClass alloc] _initWithCSSRule:impl] autorelease];}@end//------------------------------------------------------------------------------------------// DOMCSSValue@implementation DOMCSSValue (WebCoreInternal)- (WebCore::CSSValue *)_CSSValue{ return reinterpret_cast<WebCore::CSSValue*>(_internal);}- (id)_initWithCSSValue:(WebCore::CSSValue *)impl{ [super _init]; _internal = reinterpret_cast<DOMObjectInternal*>(impl); impl->ref(); WebCore::addDOMWrapper(self, impl); return self;}+ (DOMCSSValue *)_wrapCSSValue:(WebCore::CSSValue *)impl{ if (!impl) return nil; id cachedInstance; cachedInstance = WebCore::getDOMWrapper(impl); if (cachedInstance) return [[cachedInstance retain] autorelease]; Class wrapperClass = nil; switch (impl->cssValueType()) { case DOM_CSS_PRIMITIVE_VALUE: wrapperClass = [DOMCSSPrimitiveValue class]; break; case DOM_CSS_VALUE_LIST: wrapperClass = [DOMCSSValueList class]; break; case DOM_CSS_INHERIT: wrapperClass = [DOMCSSValue class]; break; case DOM_CSS_CUSTOM:#if ENABLE(SVG) if (impl->isSVGPaint()) wrapperClass = [DOMSVGPaint class]; else if (impl->isSVGColor()) wrapperClass = [DOMSVGColor class]; else#endif wrapperClass = [DOMCSSValue class]; break; } return [[[wrapperClass alloc] _initWithCSSValue:impl] autorelease];}@end//------------------------------------------------------------------------------------------// DOMCSSStyleDeclaration CSS2 Properties@implementation DOMCSSStyleDeclaration (DOMCSS2Properties)- (NSString *)azimuth{ return [self getPropertyValue:@"azimuth"];}- (void)setAzimuth:(NSString *)azimuth{ [self setProperty:@"azimuth" value:azimuth priority:@""];}- (NSString *)background{ return [self getPropertyValue:@"background"];}- (void)setBackground:(NSString *)background{ [self setProperty:@"background" value:background priority:@""];}- (NSString *)backgroundAttachment{ return [self getPropertyValue:@"background-attachment"];}- (void)setBackgroundAttachment:(NSString *)backgroundAttachment{ [self setProperty:@"background-attachment" value:backgroundAttachment priority:@""];}- (NSString *)backgroundColor{ return [self getPropertyValue:@"background-color"];}- (void)setBackgroundColor:(NSString *)backgroundColor{ [self setProperty:@"background-color" value:backgroundColor priority:@""];}- (NSString *)backgroundImage{ return [self getPropertyValue:@"background-image"];}- (void)setBackgroundImage:(NSString *)backgroundImage{ [self setProperty:@"background-image" value:backgroundImage priority:@""];}- (NSString *)backgroundPosition{ return [self getPropertyValue:@"background-position"];}- (void)setBackgroundPosition:(NSString *)backgroundPosition{ [self setProperty:@"background-position" value:backgroundPosition priority:@""];}- (NSString *)backgroundRepeat{ return [self getPropertyValue:@"background-repeat"];}- (void)setBackgroundRepeat:(NSString *)backgroundRepeat{ [self setProperty:@"background-repeat" value:backgroundRepeat priority:@""];}- (NSString *)border{ return [self getPropertyValue:@"border"];}- (void)setBorder:(NSString *)border{ [self setProperty:@"border" value:border priority:@""];}- (NSString *)borderCollapse{ return [self getPropertyValue:@"border-collapse"];}- (void)setBorderCollapse:(NSString *)borderCollapse{ [self setProperty:@"border-collapse" value:borderCollapse priority:@""];}- (NSString *)borderColor{ return [self getPropertyValue:@"border-color"];}- (void)setBorderColor:(NSString *)borderColor{ [self setProperty:@"border-color" value:borderColor priority:@""];}- (NSString *)borderSpacing{ return [self getPropertyValue:@"border-spacing"];}- (void)setBorderSpacing:(NSString *)borderSpacing{ [self setProperty:@"border-spacing" value:borderSpacing priority:@""];}- (NSString *)borderStyle{ return [self getPropertyValue:@"border-style"];}- (void)setBorderStyle:(NSString *)borderStyle{ [self setProperty:@"border-style" value:borderStyle priority:@""];}- (NSString *)borderTop{ return [self getPropertyValue:@"border-top"];}- (void)setBorderTop:(NSString *)borderTop{ [self setProperty:@"border-top" value:borderTop priority:@""];}- (NSString *)borderRight{ return [self getPropertyValue:@"border-right"];}- (void)setBorderRight:(NSString *)borderRight{ [self setProperty:@"border-right" value:borderRight priority:@""];}- (NSString *)borderBottom{ return [self getPropertyValue:@"border-bottom"];}- (void)setBorderBottom:(NSString *)borderBottom{ [self setProperty:@"border-bottom" value:borderBottom priority:@""];}- (NSString *)borderLeft{ return [self getPropertyValue:@"border-left"];}- (void)setBorderLeft:(NSString *)borderLeft{ [self setProperty:@"border-left" value:borderLeft priority:@""];}- (NSString *)borderTopColor{ return [self getPropertyValue:@"border-top-color"];}- (void)setBorderTopColor:(NSString *)borderTopColor{ [self setProperty:@"border-top-color" value:borderTopColor priority:@""];}- (NSString *)borderRightColor{ return [self getPropertyValue:@"border-right-color"];}- (void)setBorderRightColor:(NSString *)borderRightColor{ [self setProperty:@"border-right-color" value:borderRightColor priority:@""];}- (NSString *)borderBottomColor{ return [self getPropertyValue:@"border-bottom-color"];}- (void)setBorderBottomColor:(NSString *)borderBottomColor{ [self setProperty:@"border-bottom-color" value:borderBottomColor priority:@""];}- (NSString *)borderLeftColor{ return [self getPropertyValue:@"border-left-color"];}- (void)setBorderLeftColor:(NSString *)borderLeftColor{ [self setProperty:@"border-left-color" value:borderLeftColor priority:@""];}- (NSString *)borderTopStyle{ return [self getPropertyValue:@"border-top-style"];}- (void)setBorderTopStyle:(NSString *)borderTopStyle{ [self setProperty:@"border-top-style" value:borderTopStyle priority:@""];}- (NSString *)borderRightStyle{ return [self getPropertyValue:@"border-right-style"];}- (void)setBorderRightStyle:(NSString *)borderRightStyle{ [self setProperty:@"border-right-style" value:borderRightStyle priority:@""];}- (NSString *)borderBottomStyle{ return [self getPropertyValue:@"border-bottom-style"];}- (void)setBorderBottomStyle:(NSString *)borderBottomStyle{ [self setProperty:@"border-bottom-style" value:borderBottomStyle priority:@""];}- (NSString *)borderLeftStyle{ return [self getPropertyValue:@"border-left-style"];}- (void)setBorderLeftStyle:(NSString *)borderLeftStyle{ [self setProperty:@"border-left-style" value:borderLeftStyle priority:@""];}- (NSString *)borderTopWidth{ return [self getPropertyValue:@"border-top-width"];}- (void)setBorderTopWidth:(NSString *)borderTopWidth{ [self setProperty:@"border-top-width" value:borderTopWidth priority:@""];}- (NSString *)borderRightWidth{ return [self getPropertyValue:@"border-right-width"];}- (void)setBorderRightWidth:(NSString *)borderRightWidth{ [self setProperty:@"border-right-width" value:borderRightWidth priority:@""];}- (NSString *)borderBottomWidth{ return [self getPropertyValue:@"border-bottom-width"];}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -