Permalink
Browse files

Fixed: background-color should only be inherited from inline parent tag.

  • Loading branch information...
1 parent ed31aa0 commit 7769e4ec38539f2b8818fbfd226caa370f2bc920 @odrobnik odrobnik committed Sep 22, 2012
@@ -938,13 +938,20 @@ - (void)parser:(DTHTMLParser *)parser didStartElement:(NSString *)elementName at
{
void (^tmpBlock)(void) = ^
{
+ // this brute-force inherits the nextTags attributes from the previous tag
DTHTMLElement *parent = currentTag;
DTHTMLElement *nextTag = [currentTag copy];
nextTag.tagName = elementName;
nextTag.textScale = textScale;
nextTag.attributes = attributeDict;
[parent addChild:nextTag];
+ // only inherit background-color from inline elements
+ if (parent.displayStyle == DTHTMLElementDisplayStyleInline)
+ {
+ nextTag.backgroundColor = currentTag.backgroundColor;
+ }
+
// apply style from merged style sheet
NSDictionary *mergedStyles = [_globalStyleSheet mergedStyleDictionaryForElement:nextTag];
if (mergedStyles)
@@ -17,7 +17,8 @@ typedef enum
DTHTMLElementDisplayStyleInline = 0, // default
DTHTMLElementDisplayStyleNone,
DTHTMLElementDisplayStyleBlock,
- DTHTMLElementDisplayStyleListItem
+ DTHTMLElementDisplayStyleListItem,
+ DTHTMLElementDisplayStyleTable,
} DTHTMLElementDisplayStyle;
typedef enum
@@ -638,6 +638,10 @@ - (void)applyStyleDictionary:(NSDictionary *)styles
{
_displayStyle = DTHTMLElementDisplayStyleListItem;
}
+ else if ([displayString isEqualToString:@"table"])
+ {
+ _displayStyle = DTHTMLElementDisplayStyleTable;
+ }
else if ([verticalAlignment isEqualToString:@"inherit"])
{
// nothing to do
@@ -916,7 +920,7 @@ - (id)copyWithZone:(NSZone *)zone
newObject.tagContentInvisible = self.tagContentInvisible;
newObject.textColor = self.textColor;
newObject.isColorInherited = YES;
- newObject.backgroundColor = self.backgroundColor;
+
newObject.strikeOut = self.strikeOut;
newObject.superscriptStyle = self.superscriptStyle;
newObject.shadows = self.shadows;
@@ -255,4 +255,11 @@ hr {
-webkit-margin-end: auto;
border-style: inset;
border-width: 1px;
+}
+
+table {
+ display: table;
+ border-collapse: separate;
+ border-spacing: 2px;
+ border-color: gray;
}
@@ -1 +1,3 @@
-This is <sub>subscripted</sub> and <sup>superscripted</sup>
+<table cellpadding="8" class="bodytext" width="100%" style="font-size: 12px; font-family: Geneva, Arial, Helvetica, sans-serif; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.300781); -webkit-composition-fill-color: rgba(175, 192, 227, 0.234375); -webkit-composition-frame-color: rgba(77, 128, 180, 0.234375); -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(102, 102, 102); "><tbody><tr><td width="60" valign="top">Jan. 2000</td><td>The first lines of code for e-Sword are written. e-Sword is birthed with a clear vision of user interface and study approach: keep it simple and do the obvious!</td></tr><tr></tbody></table><br class="Apple-interchange-newline">
+
+<p><span style="background-color:yellow;">Some <b>bold</b> text</span></p>

0 comments on commit 7769e4e

Please sign in to comment.