Changeset 165786 in webkit
- Timestamp:
- Mar 17, 2014 6:35:46 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r165773 r165786 1 2014-03-17 Ryosuke Niwa <rniwa@webkit.org> 2 3 Rewrite WebHTMLConverter::_getComputedFloat in C++ 4 https://bugs.webkit.org/show_bug.cgi?id=130284 5 6 Reviewed by Andreas Kling. 7 8 Rewrote _getComputedFloat as HTMLConverterCaches::floatPropertyValueForNode. 9 10 * platform/mac/HTMLConverter.h: 11 * platform/mac/HTMLConverter.mm: 12 (HTMLConverterCaches::floatPropertyValueForNode): 13 (-[WebHTMLConverter _getFloat:forNode:property:]): Now that computing the float value is fast, we don't need to 14 store it in the cache. 15 (-[WebHTMLConverter dealloc]): 16 (-[WebHTMLConverter init]): 17 1 18 2014-03-16 Andreas Kling <akling@apple.com> 2 19 -
trunk/Source/WebCore/platform/mac/HTMLConverter.h
r165761 r165786 57 57 NSMutableArray *_textTableRowArrays; 58 58 NSMutableArray *_textTableRowBackgroundColors; 59 NSMutableDictionary *_floatsForNodes;60 59 NSMutableDictionary *_colorsForNodes; 61 60 NSMutableDictionary *_attributesForElements; -
trunk/Source/WebCore/platform/mac/HTMLConverter.mm
r165761 r165786 403 403 public: 404 404 String propertyValueForNode(Node&, const String& propertyName); 405 bool floatPropertyValueForNode(Node&, const String& propertyName, float&); 405 406 406 407 PassRefPtr<CSSValue> computedStylePropertyForElement(Element&, const String&); … … 764 765 } 765 766 766 - (BOOL)_getComputedFloat:(CGFloat *)val forNode:(DOMNode *)node property:(NSString *)key 767 { 768 bool haveResult = false; 769 bool inherit = true; 770 float floatVal = 0; 767 bool HTMLConverterCaches::floatPropertyValueForNode(Node& node, const String& propertyName, float& result) 768 { 769 if (!node.isElementNode()) { 770 if (ContainerNode* parent = node.parentNode()) 771 return floatPropertyValueForNode(*parent, propertyName, result); 772 return false; 773 } 774 775 Element& element = toElement(node); 776 if (RefPtr<CSSValue> value = computedStylePropertyForElement(element, propertyName)) { 777 if (value->isPrimitiveValue() && floatValueFromPrimitiveValue(toCSSPrimitiveValue(*value), result)) 778 return true; 779 } 780 781 bool inherit = false; 782 if (RefPtr<CSSValue> value = inlineStylePropertyForElement(element, propertyName)) { 783 if (value->isPrimitiveValue() && floatValueFromPrimitiveValue(toCSSPrimitiveValue(*value), result)) 784 return true; 785 if (value->isInheritedValue()) 786 inherit = true; 787 } 788 789 switch (cssPropertyID(propertyName)) { 790 case CSSPropertyTextIndent: 791 case CSSPropertyLetterSpacing: 792 case CSSPropertyWordSpacing: 793 case CSSPropertyLineHeight: 794 case CSSPropertyWidows: 795 case CSSPropertyOrphans: 796 inherit = true; 797 break; 798 default: 799 break; 800 } 801 802 if (inherit) { 803 if (ContainerNode* parent = node.parentNode()) 804 return floatPropertyValueForNode(*parent, propertyName, result); 805 } 806 807 return false; 808 } 809 810 - (BOOL)_getFloat:(CGFloat *)val forNode:(DOMNode *)node property:(NSString *)key 811 { 771 812 Node* coreNode = core(node); 772 if (coreNode && coreNode->isElementNode()) { 773 Element& element = toElement(*coreNode); 774 String propertyName = key; 775 inherit = false; 776 if (!haveResult) { 777 if (RefPtr<CSSValue> value = _caches->computedStylePropertyForElement(element, propertyName)) { 778 if (value->isPrimitiveValue()) 779 haveResult = floatValueFromPrimitiveValue(toCSSPrimitiveValue(*value), floatVal); 780 } 781 } 782 if (!haveResult) { 783 if (RefPtr<CSSValue> value = _caches->inlineStylePropertyForElement(element, propertyName)) { 784 if (value->isInheritedValue()) 785 inherit = true; 786 else if (value->isPrimitiveValue()) 787 haveResult = floatValueFromPrimitiveValue(toCSSPrimitiveValue(*value), floatVal); 788 } 789 } 790 if (!haveResult) { 791 if ([@"text-indent" isEqualToString:key] || [@"letter-spacing" isEqualToString:key] || [@"word-spacing" isEqualToString:key] 792 || [@"line-height" isEqualToString:key] || [@"widows" isEqualToString:key] || [@"orphans" isEqualToString:key]) 793 inherit = true; 794 } 795 } 796 if (!haveResult && inherit) { 797 DOMNode *parentNode = [node parentNode]; 798 if (parentNode) 799 return [self _getFloat:val forNode:parentNode property:key]; 800 } 801 if (haveResult && val) 802 *val = floatVal; 803 return haveResult; 804 } 805 806 - (BOOL)_getFloat:(CGFloat *)val forNode:(DOMNode *)node property:(NSString *)key 807 { 808 BOOL result = NO; 809 CGFloat floatVal = 0; 810 NSNumber *floatNumber; 811 RetainPtr<NSMutableDictionary> attributeDictionary = [_floatsForNodes objectForKey:node]; 812 if (!attributeDictionary) { 813 attributeDictionary = adoptNS([[NSMutableDictionary alloc] init]); 814 [_floatsForNodes setObject:attributeDictionary.get() forKey:node]; 815 } 816 floatNumber = [attributeDictionary objectForKey:key]; 817 if (floatNumber) { 818 if (![[NSNull null] isEqual:floatNumber]) { 819 result = YES; 820 floatVal = [floatNumber floatValue]; 821 } 822 } else { 823 result = [self _getComputedFloat:&floatVal forNode:node property:key]; 824 [attributeDictionary setObject:(result ? (id)[NSNumber numberWithDouble:floatVal] : (id)[NSNull null]) forKey:key]; 825 } 826 if (result && val) 827 *val = floatVal; 828 return result; 813 if (!coreNode) 814 return NO; 815 float result; 816 if (!_caches->floatPropertyValueForNode(*coreNode, String(key), result)) 817 return NO; 818 if (val) 819 *val = result; 820 return YES; 829 821 } 830 822 … … 2424 2416 [_textTableRowArrays release]; 2425 2417 [_textTableRowBackgroundColors release]; 2426 [_floatsForNodes release];2427 2418 [_colorsForNodes release]; 2428 2419 [_attributesForElements release]; … … 2451 2442 _textTableRowArrays = [[NSMutableArray alloc] init]; 2452 2443 _textTableRowBackgroundColors = [[NSMutableArray alloc] init]; 2453 _floatsForNodes = [[NSMutableDictionary alloc] init];2454 2444 _colorsForNodes = [[NSMutableDictionary alloc] init]; 2455 2445 _attributesForElements = [[NSMutableDictionary alloc] init]; -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r165503 r165786 61 61 1AB1DAC118BC0232004B6A9F /* WebViewGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AB1DABF18BC0232004B6A9F /* WebViewGroup.mm */; }; 62 62 1AB1DAC218BC0232004B6A9F /* WebViewGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB1DAC018BC0232004B6A9F /* WebViewGroup.h */; }; 63 1AD7453C18D0D324006F3A1E /* WebKitLegacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD7451218D0D24C006F3A1E /* WebKitLegacy.cpp */; };64 63 1AEA66D40DC6B1FF003D12BF /* WebNetscapePluginEventHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEA66D20DC6B1FF003D12BF /* WebNetscapePluginEventHandler.h */; }; 65 64 1AEA66D50DC6B1FF003D12BF /* WebNetscapePluginEventHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEA66D30DC6B1FF003D12BF /* WebNetscapePluginEventHandler.mm */; }; … … 82 81 22F219CC08D236730030E078 /* WebBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 83 82 29AEF960134C76FB00FE5096 /* OutlookQuirksUserScript.js in Resources */ = {isa = PBXBuildFile; fileRef = 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */; }; 84 2D25396618CE85C200270222 /* WebSharingServicePickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D25396418CE85C200270222 /* WebSharingServicePickerController.h */; };85 2D25396718CE85C200270222 /* WebSharingServicePickerController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D25396518CE85C200270222 /* WebSharingServicePickerController.mm */; };86 83 312E2FE514E48182007CCA18 /* WebNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE314E48182007CCA18 /* WebNotification.h */; settings = {ATTRIBUTES = (Private, ); }; }; 87 84 312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 312E2FE414E48182007CCA18 /* WebNotification.mm */; }; … … 454 451 /* End PBXBuildFile section */ 455 452 456 /* Begin PBXContainerItemProxy section */457 1A5B250918D0DBD300913729 /* PBXContainerItemProxy */ = {458 isa = PBXContainerItemProxy;459 containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;460 proxyType = 1;461 remoteGlobalIDString = 9398100A0824BF01008DF038;462 remoteInfo = WebKit;463 };464 /* End PBXContainerItemProxy section */465 466 453 /* Begin PBXFileReference section */ 467 454 065AD5A10B0C32C7005A2B1D /* WebContextMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebContextMenuClient.h; sourceTree = "<group>"; }; … … 515 502 1AB1DABF18BC0232004B6A9F /* WebViewGroup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewGroup.mm; sourceTree = "<group>"; }; 516 503 1AB1DAC018BC0232004B6A9F /* WebViewGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewGroup.h; sourceTree = "<group>"; }; 517 1AD7451218D0D24C006F3A1E /* WebKitLegacy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitLegacy.cpp; sourceTree = "<group>"; };518 1AD7451918D0D26C006F3A1E /* WebKitLegacy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebKitLegacy.framework; sourceTree = BUILT_PRODUCTS_DIR; };519 1AD7453B18D0D2A6006F3A1E /* WebKitLegacy.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WebKitLegacy.xcconfig; sourceTree = "<group>"; };520 1AD7453D18D0D383006F3A1E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };521 504 1AEA66D20DC6B1FF003D12BF /* WebNetscapePluginEventHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNetscapePluginEventHandler.h; sourceTree = "<group>"; }; 522 505 1AEA66D30DC6B1FF003D12BF /* WebNetscapePluginEventHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNetscapePluginEventHandler.mm; sourceTree = "<group>"; }; … … 545 528 2568C72C0174912D0ECA149E /* WebKit.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebKit.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 546 529 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = OutlookQuirksUserScript.js; sourceTree = "<group>"; }; 547 2D25396418CE85C200270222 /* WebSharingServicePickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSharingServicePickerController.h; sourceTree = "<group>"; };548 2D25396518CE85C200270222 /* WebSharingServicePickerController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSharingServicePickerController.mm; sourceTree = "<group>"; };549 530 2D36FD5E03F78F9E00A80166 /* WebFormDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFormDelegatePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 550 531 2D81DAB203EB0B2D00A80166 /* WebFormDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFormDelegate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; … … 924 905 925 906 /* Begin PBXFrameworksBuildPhase section */ 926 1AD7451518D0D26C006F3A1E /* Frameworks */ = {927 isa = PBXFrameworksBuildPhase;928 buildActionMask = 2147483647;929 files = (930 );931 runOnlyForDeploymentPostprocessing = 0;932 };933 907 939811270824BF01008DF038 /* Frameworks */ = { 934 908 isa = PBXFrameworksBuildPhase; … … 950 924 children = ( 951 925 939811330824BF01008DF038 /* WebKit.framework */, 952 1AD7451918D0D26C006F3A1E /* WebKitLegacy.framework */,953 926 ); 954 927 name = Products; … … 973 946 511F3FC30CECC7E200852565 /* Storage */, 974 947 F5B36B400281DE87018635CB /* WebCoreSupport */, 975 1AD7451118D0D23D006F3A1E /* WebKitLegacy */,976 948 9C7CABBB0190A37C0ECA16EA /* WebView */, 977 949 1C68F63F095B5F9C00C2984E /* WebInspector */, … … 1055 1027 sourceTree = "<group>"; 1056 1028 }; 1057 1AD7451118D0D23D006F3A1E /* WebKitLegacy */ = {1058 isa = PBXGroup;1059 children = (1060 1AD7453D18D0D383006F3A1E /* Info.plist */,1061 1AD7451218D0D24C006F3A1E /* WebKitLegacy.cpp */,1062 );1063 name = WebKitLegacy;1064 path = mac/WebKitLegacy;1065 sourceTree = "<group>";1066 };1067 1029 1C68F63F095B5F9C00C2984E /* WebInspector */ = { 1068 1030 isa = PBXGroup; … … 1095 1057 1C904FD30BA9DD0F0081E9D0 /* Version.xcconfig */, 1096 1058 1C904FD20BA9DD0F0081E9D0 /* WebKit.xcconfig */, 1097 1AD7453B18D0D2A6006F3A1E /* WebKitLegacy.xcconfig */,1098 1059 ); 1099 1060 name = Configurations; … … 1174 1135 9345DDAF0365FB27008635CE /* WebNSWindowExtras.m */, 1175 1136 A57E2F22120749E600048DF3 /* WebQuotaManager.h */, 1176 2D25396418CE85C200270222 /* WebSharingServicePickerController.h */,1177 2D25396518CE85C200270222 /* WebSharingServicePickerController.mm */,1178 1137 F59668C802AD2923018635CA /* WebStringTruncator.h */, 1179 1138 F59668C902AD2923018635CA /* WebStringTruncator.mm */, … … 1896 1855 939810250824BF01008DF038 /* WebNSWindowExtras.h in Headers */, 1897 1856 A58A5799143E727000125F50 /* WebOpenPanelResultListener.h in Headers */, 1898 2D25396618CE85C200270222 /* WebSharingServicePickerController.h in Headers */,1899 1857 9398102A0824BF01008DF038 /* WebPanelAuthenticationHandler.h in Headers */, 1900 1858 37B6FB4E1063530C000FDB3B /* WebPDFDocumentExtras.h in Headers */, … … 1966 1924 1967 1925 /* Begin PBXNativeTarget section */ 1968 1AD7451818D0D26C006F3A1E /* WebKitLegacy */ = {1969 isa = PBXNativeTarget;1970 buildConfigurationList = 1AD7453318D0D26C006F3A1E /* Build configuration list for PBXNativeTarget "WebKitLegacy" */;1971 buildPhases = (1972 1A5B250818D0D90C00913729 /* Migrate Headers */,1973 1AD7451418D0D26C006F3A1E /* Sources */,1974 1AD7451518D0D26C006F3A1E /* Frameworks */,1975 );1976 buildRules = (1977 );1978 dependencies = (1979 1A5B250A18D0DBD300913729 /* PBXTargetDependency */,1980 );1981 name = WebKitLegacy;1982 productName = WebKitLegacy;1983 productReference = 1AD7451918D0D26C006F3A1E /* WebKitLegacy.framework */;1984 productType = "com.apple.product-type.framework";1985 };1986 1926 9398100A0824BF01008DF038 /* WebKit */ = { 1987 1927 isa = PBXNativeTarget; … … 2039 1979 projectRoot = ""; 2040 1980 targets = ( 2041 1AD7451818D0D26C006F3A1E /* WebKitLegacy */,2042 1981 9398100A0824BF01008DF038 /* WebKit */, 2043 1982 ); … … 2061 2000 2062 2001 /* Begin PBXShellScriptBuildPhase section */ 2063 1A5B250818D0D90C00913729 /* Migrate Headers */ = {2064 isa = PBXShellScriptBuildPhase;2065 buildActionMask = 2147483647;2066 files = (2067 );2068 inputPaths = (2069 );2070 name = "Migrate Headers";2071 outputPaths = (2072 );2073 runOnlyForDeploymentPostprocessing = 0;2074 shellPath = /bin/sh;2075 shellScript = "if [ \"${ACTION}\" = \"build\" -o \"${ACTION}\" = \"install\" -o \"${ACTION}\" = \"installhdrs\" ]; then\n mkdir -p \"${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}\"\n mkdir -p \"${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}\"\n make -C mac/WebKitLegacy -f \"MigrateHeadersToLegacy.make\" -j `/usr/sbin/sysctl -n hw.activecpu`\nfi\n";2076 };2077 2002 1C395DE20C6BE8E0000D1E52 /* Generate Export Files */ = { 2078 2003 isa = PBXShellScriptBuildPhase; … … 2107 2032 runOnlyForDeploymentPostprocessing = 0; 2108 2033 shellPath = /bin/sh; 2109 shellScript = " exec \"${SRCROOT}/mac/migrate-headers.sh\"";2034 shellScript = "mkdir -p \"${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}\"\nmkdir -p \"${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}\"\nmkdir -p \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit\"\n\n# If we didn't build WebCore, use the production copy of the headers\nif [ ! -d \"${WEBCORE_PRIVATE_HEADERS_DIR}\" ]; then\n export WEBCORE_PRIVATE_HEADERS_DIR=\"`eval 'echo ${WEBCORE_PRIVATE_HEADERS_DIR_'${PLATFORM_NAME}'_Production}'`\"\nfi\n\nif [ \"${ACTION}\" = \"build\" -o \"${ACTION}\" = \"install\" -o \"${ACTION}\" = \"installhdrs\" ]; then\n make -C mac -f \"MigrateHeaders.make\" -j `/usr/sbin/sysctl -n hw.activecpu`\nfi\n"; 2110 2035 }; 2111 2036 3713F018142905B70036387F /* Check For Inappropriate Objective-C Class Names */ = { … … 2233 2158 2234 2159 /* Begin PBXSourcesBuildPhase section */ 2235 1AD7451418D0D26C006F3A1E /* Sources */ = {2236 isa = PBXSourcesBuildPhase;2237 buildActionMask = 2147483647;2238 files = (2239 1AD7453C18D0D324006F3A1E /* WebKitLegacy.cpp in Sources */,2240 );2241 runOnlyForDeploymentPostprocessing = 0;2242 };2243 2160 939810BB0824BF01008DF038 /* Sources */ = { 2244 2161 isa = PBXSourcesBuildPhase; 2245 2162 buildActionMask = 2147483647; 2246 2163 files = ( 2247 2D25396718CE85C200270222 /* WebSharingServicePickerController.mm in Sources */,2248 2164 1A60519117502A5D00BC62F5 /* BinaryPropertyList.cpp in Sources */, 2249 2165 939811010824BF01008DF038 /* CarbonUtils.m in Sources */, … … 2429 2345 /* End PBXSourcesBuildPhase section */ 2430 2346 2431 /* Begin PBXTargetDependency section */2432 1A5B250A18D0DBD300913729 /* PBXTargetDependency */ = {2433 isa = PBXTargetDependency;2434 target = 9398100A0824BF01008DF038 /* WebKit */;2435 targetProxy = 1A5B250918D0DBD300913729 /* PBXContainerItemProxy */;2436 };2437 /* End PBXTargetDependency section */2438 2439 2347 /* Begin PBXVariantGroup section */ 2440 2348 5DE83A740D0F7F9400CAD12A /* WebJavaScriptTextInputPanel.nib */ = { … … 2522 2430 name = Production; 2523 2431 }; 2524 1AD7453418D0D26C006F3A1E /* Debug */ = {2525 isa = XCBuildConfiguration;2526 baseConfigurationReference = 1AD7453B18D0D2A6006F3A1E /* WebKitLegacy.xcconfig */;2527 buildSettings = {2528 };2529 name = Debug;2530 };2531 1AD7453518D0D26C006F3A1E /* Release */ = {2532 isa = XCBuildConfiguration;2533 baseConfigurationReference = 1AD7453B18D0D2A6006F3A1E /* WebKitLegacy.xcconfig */;2534 buildSettings = {2535 };2536 name = Release;2537 };2538 1AD7453618D0D26C006F3A1E /* Production */ = {2539 isa = XCBuildConfiguration;2540 baseConfigurationReference = 1AD7453B18D0D2A6006F3A1E /* WebKitLegacy.xcconfig */;2541 buildSettings = {2542 };2543 name = Production;2544 };2545 2432 /* End XCBuildConfiguration section */ 2546 2433 … … 2566 2453 defaultConfigurationName = Production; 2567 2454 }; 2568 1AD7453318D0D26C006F3A1E /* Build configuration list for PBXNativeTarget "WebKitLegacy" */ = {2569 isa = XCConfigurationList;2570 buildConfigurations = (2571 1AD7453418D0D26C006F3A1E /* Debug */,2572 1AD7453518D0D26C006F3A1E /* Release */,2573 1AD7453618D0D26C006F3A1E /* Production */,2574 );2575 defaultConfigurationIsVisible = 0;2576 defaultConfigurationName = Production;2577 };2578 2455 /* End XCConfigurationList section */ 2579 2456 };
Note: See TracChangeset
for help on using the changeset viewer.