|
Lines 32-37
WebCore/editing/ApplyStyleCommand.cpp_sec1
|
| 32 |
#include "CSSPropertyNames.h" |
32 |
#include "CSSPropertyNames.h" |
| 33 |
#include "CSSValueKeywords.h" |
33 |
#include "CSSValueKeywords.h" |
| 34 |
#include "Document.h" |
34 |
#include "Document.h" |
|
|
35 |
#include "Editor.h" |
| 36 |
#include "Frame.h" |
| 35 |
#include "HTMLElement.h" |
37 |
#include "HTMLElement.h" |
| 36 |
#include "HTMLInterchange.h" |
38 |
#include "HTMLInterchange.h" |
| 37 |
#include "HTMLNames.h" |
39 |
#include "HTMLNames.h" |
|
Lines 50-62
WebCore/editing/ApplyStyleCommand.cpp_sec2
|
| 50 |
|
52 |
|
| 51 |
class StyleChange { |
53 |
class StyleChange { |
| 52 |
public: |
54 |
public: |
| 53 |
enum ELegacyHTMLStyles { DoNotUseLegacyHTMLStyles, UseLegacyHTMLStyles }; |
55 |
explicit StyleChange(CSSStyleDeclaration*, const Position&); |
| 54 |
|
56 |
|
| 55 |
explicit StyleChange(CSSStyleDeclaration*, ELegacyHTMLStyles usesLegacyStyles=UseLegacyHTMLStyles); |
|
|
| 56 |
StyleChange(CSSStyleDeclaration*, const Position&, ELegacyHTMLStyles usesLegacyStyles=UseLegacyHTMLStyles); |
| 57 |
|
| 58 |
static ELegacyHTMLStyles styleModeForParseMode(bool); |
| 59 |
|
| 60 |
String cssStyle() const { return m_cssStyle; } |
57 |
String cssStyle() const { return m_cssStyle; } |
| 61 |
bool applyBold() const { return m_applyBold; } |
58 |
bool applyBold() const { return m_applyBold; } |
| 62 |
bool applyItalic() const { return m_applyItalic; } |
59 |
bool applyItalic() const { return m_applyItalic; } |
|
Lines 70-76
WebCore/editing/ApplyStyleCommand.cpp_sec3
|
| 70 |
String fontFace() { return m_applyFontFace; } |
67 |
String fontFace() { return m_applyFontFace; } |
| 71 |
String fontSize() { return m_applyFontSize; } |
68 |
String fontSize() { return m_applyFontSize; } |
| 72 |
|
69 |
|
| 73 |
bool usesLegacyStyles() const { return m_usesLegacyStyles; } |
70 |
bool usesLegacyFormattingTags() const { return m_usesLegacyFormattingTags; } |
| 74 |
|
71 |
|
| 75 |
private: |
72 |
private: |
| 76 |
void init(PassRefPtr<CSSStyleDeclaration>, const Position&); |
73 |
void init(PassRefPtr<CSSStyleDeclaration>, const Position&); |
|
Lines 85-117
WebCore/editing/ApplyStyleCommand.cpp_sec4
|
| 85 |
String m_applyFontColor; |
82 |
String m_applyFontColor; |
| 86 |
String m_applyFontFace; |
83 |
String m_applyFontFace; |
| 87 |
String m_applyFontSize; |
84 |
String m_applyFontSize; |
| 88 |
bool m_usesLegacyStyles; |
85 |
bool m_usesLegacyFormattingTags; |
| 89 |
}; |
86 |
}; |
| 90 |
|
87 |
|
| 91 |
|
88 |
|
| 92 |
|
89 |
StyleChange::StyleChange(CSSStyleDeclaration* style, const Position& position) |
| 93 |
StyleChange::StyleChange(CSSStyleDeclaration* style, ELegacyHTMLStyles usesLegacyStyles) |
|
|
| 94 |
: m_applyBold(false) |
90 |
: m_applyBold(false) |
| 95 |
, m_applyItalic(false) |
91 |
, m_applyItalic(false) |
| 96 |
, m_applySubscript(false) |
92 |
, m_applySubscript(false) |
| 97 |
, m_applySuperscript(false) |
93 |
, m_applySuperscript(false) |
| 98 |
, m_usesLegacyStyles(usesLegacyStyles) |
94 |
, m_usesLegacyFormattingTags(false) |
| 99 |
{ |
95 |
{ |
| 100 |
init(style, Position()); |
|
|
| 101 |
} |
| 102 |
|
| 103 |
StyleChange::StyleChange(CSSStyleDeclaration* style, const Position& position, ELegacyHTMLStyles usesLegacyStyles) |
| 104 |
: m_applyBold(false) |
| 105 |
, m_applyItalic(false) |
| 106 |
, m_applySubscript(false) |
| 107 |
, m_applySuperscript(false) |
| 108 |
, m_usesLegacyStyles(usesLegacyStyles) |
| 109 |
{ |
| 110 |
init(style, position); |
96 |
init(style, position); |
| 111 |
} |
97 |
} |
| 112 |
|
98 |
|
| 113 |
void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position &position) |
99 |
void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position& position) |
| 114 |
{ |
100 |
{ |
|
|
101 |
if (position.node()) |
| 102 |
if (Document* document = position.node()->document()) |
| 103 |
m_usesLegacyFormattingTags = !document->frame()->editor()->styleWithCSS(); |
| 104 |
|
| 115 |
RefPtr<CSSMutableStyleDeclaration> mutableStyle = style->makeMutable(); |
105 |
RefPtr<CSSMutableStyleDeclaration> mutableStyle = style->makeMutable(); |
| 116 |
|
106 |
|
| 117 |
String styleText(""); |
107 |
String styleText(""); |
|
Lines 131-137
WebCore/editing/ApplyStyleCommand.cpp_sec5
|
| 131 |
continue; |
121 |
continue; |
| 132 |
|
122 |
|
| 133 |
// If needed, figure out if this change is a legacy HTML style change. |
123 |
// If needed, figure out if this change is a legacy HTML style change. |
| 134 |
if (m_usesLegacyStyles && checkForLegacyHTMLStyleChange(property)) |
124 |
if (m_usesLegacyFormattingTags && checkForLegacyHTMLStyleChange(property)) |
| 135 |
continue; |
125 |
continue; |
| 136 |
|
126 |
|
| 137 |
if (property->id() == CSSPropertyDirection) { |
127 |
if (property->id() == CSSPropertyDirection) { |
|
Lines 160-170
WebCore/editing/ApplyStyleCommand.cpp_sec6
|
| 160 |
m_cssStyle = styleText.stripWhiteSpace(); |
150 |
m_cssStyle = styleText.stripWhiteSpace(); |
| 161 |
} |
151 |
} |
| 162 |
|
152 |
|
| 163 |
StyleChange::ELegacyHTMLStyles StyleChange::styleModeForParseMode(bool isQuirksMode) |
|
|
| 164 |
{ |
| 165 |
return isQuirksMode ? UseLegacyHTMLStyles : DoNotUseLegacyHTMLStyles; |
| 166 |
} |
| 167 |
|
| 168 |
// This function is the mapping from CSS styles to styling tags (like font-weight: bold to <b>) |
153 |
// This function is the mapping from CSS styles to styling tags (like font-weight: bold to <b>) |
| 169 |
bool StyleChange::checkForLegacyHTMLStyleChange(const CSSProperty* property) |
154 |
bool StyleChange::checkForLegacyHTMLStyleChange(const CSSProperty* property) |
| 170 |
{ |
155 |
{ |
|
Lines 442-448
WebCore/editing/ApplyStyleCommand.cpp_sec7
|
| 442 |
VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); |
427 |
VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); |
| 443 |
VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); |
428 |
VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); |
| 444 |
while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) { |
429 |
while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) { |
| 445 |
StyleChange styleChange(style, paragraphStart.deepEquivalent(), StyleChange::styleModeForParseMode(document()->inCompatMode())); |
430 |
StyleChange styleChange(style, paragraphStart.deepEquivalent()); |
| 446 |
if (styleChange.cssStyle().length() > 0 || m_removeOnly) { |
431 |
if (styleChange.cssStyle().length() > 0 || m_removeOnly) { |
| 447 |
RefPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent().node()); |
432 |
RefPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent().node()); |
| 448 |
RefPtr<Node> newBlock = moveParagraphContentsToNewBlockIfNecessary(paragraphStart.deepEquivalent()); |
433 |
RefPtr<Node> newBlock = moveParagraphContentsToNewBlockIfNecessary(paragraphStart.deepEquivalent()); |
|
Lines 1147-1153
WebCore/editing/ApplyStyleCommand.cpp_sec8
|
| 1147 |
|
1132 |
|
| 1148 |
HTMLElement *element = static_cast<HTMLElement *>(node); |
1133 |
HTMLElement *element = static_cast<HTMLElement *>(node); |
| 1149 |
|
1134 |
|
| 1150 |
StyleChange styleChange(style, Position(element, 0), StyleChange::styleModeForParseMode(document()->inCompatMode())); |
1135 |
StyleChange styleChange(style, Position(element, 0)); |
| 1151 |
if (styleChange.cssStyle().length() > 0) { |
1136 |
if (styleChange.cssStyle().length() > 0) { |
| 1152 |
String cssText = styleChange.cssStyle(); |
1137 |
String cssText = styleChange.cssStyle(); |
| 1153 |
CSSMutableStyleDeclaration *decl = element->inlineStyleDecl(); |
1138 |
CSSMutableStyleDeclaration *decl = element->inlineStyleDecl(); |
|
Lines 1546-1552
WebCore/editing/ApplyStyleCommand.cpp_sec9
|
| 1546 |
if (m_removeOnly) |
1531 |
if (m_removeOnly) |
| 1547 |
return; |
1532 |
return; |
| 1548 |
|
1533 |
|
| 1549 |
StyleChange styleChange(style, Position(startNode, 0), StyleChange::styleModeForParseMode(document()->inCompatMode())); |
1534 |
StyleChange styleChange(style, Position(startNode, 0)); |
| 1550 |
|
1535 |
|
| 1551 |
// |
1536 |
// |
| 1552 |
// Font tags need to go outside of CSS so that CSS font sizes override leagcy font sizes. |
1537 |
// Font tags need to go outside of CSS so that CSS font sizes override leagcy font sizes. |