| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 ApplyStyleCommand::ApplyStyleCommand(Document& document, | 112 ApplyStyleCommand::ApplyStyleCommand(Document& document, |
| 113 const EditingStyle* style, | 113 const EditingStyle* style, |
| 114 InputEvent::InputType input_type, | 114 InputEvent::InputType input_type, |
| 115 EPropertyLevel property_level) | 115 EPropertyLevel property_level) |
| 116 : CompositeEditCommand(document), | 116 : CompositeEditCommand(document), |
| 117 style_(style->Copy()), | 117 style_(style->Copy()), |
| 118 input_type_(input_type), | 118 input_type_(input_type), |
| 119 property_level_(property_level), | 119 property_level_(property_level), |
| 120 start_(MostForwardCaretPosition(EndingSelection().Start())), | 120 start_(MostForwardCaretPosition(EndingSelection().Start())), |
| 121 end_(MostBackwardCaretPosition(EndingSelection().end())), | 121 end_(MostBackwardCaretPosition(EndingSelection().End())), |
| 122 use_ending_selection_(true), | 122 use_ending_selection_(true), |
| 123 styled_inline_element_(nullptr), | 123 styled_inline_element_(nullptr), |
| 124 remove_only_(false), | 124 remove_only_(false), |
| 125 is_inline_element_to_remove_function_(0) {} | 125 is_inline_element_to_remove_function_(0) {} |
| 126 | 126 |
| 127 ApplyStyleCommand::ApplyStyleCommand(Document& document, | 127 ApplyStyleCommand::ApplyStyleCommand(Document& document, |
| 128 const EditingStyle* style, | 128 const EditingStyle* style, |
| 129 const Position& start, | 129 const Position& start, |
| 130 const Position& end) | 130 const Position& end) |
| 131 : CompositeEditCommand(document), | 131 : CompositeEditCommand(document), |
| 132 style_(style->Copy()), | 132 style_(style->Copy()), |
| 133 input_type_(InputEvent::InputType::kNone), | 133 input_type_(InputEvent::InputType::kNone), |
| 134 property_level_(kPropertyDefault), | 134 property_level_(kPropertyDefault), |
| 135 start_(start), | 135 start_(start), |
| 136 end_(end), | 136 end_(end), |
| 137 use_ending_selection_(false), | 137 use_ending_selection_(false), |
| 138 styled_inline_element_(nullptr), | 138 styled_inline_element_(nullptr), |
| 139 remove_only_(false), | 139 remove_only_(false), |
| 140 is_inline_element_to_remove_function_(0) {} | 140 is_inline_element_to_remove_function_(0) {} |
| 141 | 141 |
| 142 ApplyStyleCommand::ApplyStyleCommand(Element* element, bool remove_only) | 142 ApplyStyleCommand::ApplyStyleCommand(Element* element, bool remove_only) |
| 143 : CompositeEditCommand(element->GetDocument()), | 143 : CompositeEditCommand(element->GetDocument()), |
| 144 style_(EditingStyle::Create()), | 144 style_(EditingStyle::Create()), |
| 145 input_type_(InputEvent::InputType::kNone), | 145 input_type_(InputEvent::InputType::kNone), |
| 146 property_level_(kPropertyDefault), | 146 property_level_(kPropertyDefault), |
| 147 start_(MostForwardCaretPosition(EndingSelection().Start())), | 147 start_(MostForwardCaretPosition(EndingSelection().Start())), |
| 148 end_(MostBackwardCaretPosition(EndingSelection().end())), | 148 end_(MostBackwardCaretPosition(EndingSelection().End())), |
| 149 use_ending_selection_(true), | 149 use_ending_selection_(true), |
| 150 styled_inline_element_(element), | 150 styled_inline_element_(element), |
| 151 remove_only_(remove_only), | 151 remove_only_(remove_only), |
| 152 is_inline_element_to_remove_function_(0) {} | 152 is_inline_element_to_remove_function_(0) {} |
| 153 | 153 |
| 154 ApplyStyleCommand::ApplyStyleCommand( | 154 ApplyStyleCommand::ApplyStyleCommand( |
| 155 Document& document, | 155 Document& document, |
| 156 const EditingStyle* style, | 156 const EditingStyle* style, |
| 157 IsInlineElementToRemoveFunction is_inline_element_to_remove_function, | 157 IsInlineElementToRemoveFunction is_inline_element_to_remove_function, |
| 158 InputEvent::InputType input_type) | 158 InputEvent::InputType input_type) |
| 159 : CompositeEditCommand(document), | 159 : CompositeEditCommand(document), |
| 160 style_(style->Copy()), | 160 style_(style->Copy()), |
| 161 input_type_(input_type), | 161 input_type_(input_type), |
| 162 property_level_(kPropertyDefault), | 162 property_level_(kPropertyDefault), |
| 163 start_(MostForwardCaretPosition(EndingSelection().Start())), | 163 start_(MostForwardCaretPosition(EndingSelection().Start())), |
| 164 end_(MostBackwardCaretPosition(EndingSelection().end())), | 164 end_(MostBackwardCaretPosition(EndingSelection().End())), |
| 165 use_ending_selection_(true), | 165 use_ending_selection_(true), |
| 166 styled_inline_element_(nullptr), | 166 styled_inline_element_(nullptr), |
| 167 remove_only_(true), | 167 remove_only_(true), |
| 168 is_inline_element_to_remove_function_( | 168 is_inline_element_to_remove_function_( |
| 169 is_inline_element_to_remove_function) {} | 169 is_inline_element_to_remove_function) {} |
| 170 | 170 |
| 171 void ApplyStyleCommand::UpdateStartEnd(const Position& new_start, | 171 void ApplyStyleCommand::UpdateStartEnd(const Position& new_start, |
| 172 const Position& new_end) { | 172 const Position& new_end) { |
| 173 DCHECK_GE(ComparePositions(new_end, new_start), 0); | 173 DCHECK_GE(ComparePositions(new_end, new_start), 0); |
| 174 | 174 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 186 | 186 |
| 187 Position ApplyStyleCommand::StartPosition() { | 187 Position ApplyStyleCommand::StartPosition() { |
| 188 if (use_ending_selection_) | 188 if (use_ending_selection_) |
| 189 return EndingSelection().Start(); | 189 return EndingSelection().Start(); |
| 190 | 190 |
| 191 return start_; | 191 return start_; |
| 192 } | 192 } |
| 193 | 193 |
| 194 Position ApplyStyleCommand::EndPosition() { | 194 Position ApplyStyleCommand::EndPosition() { |
| 195 if (use_ending_selection_) | 195 if (use_ending_selection_) |
| 196 return EndingSelection().end(); | 196 return EndingSelection().End(); |
| 197 | 197 |
| 198 return end_; | 198 return end_; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void ApplyStyleCommand::DoApply(EditingState* editing_state) { | 201 void ApplyStyleCommand::DoApply(EditingState* editing_state) { |
| 202 DCHECK(StartPosition().IsNotNull()); | 202 DCHECK(StartPosition().IsNotNull()); |
| 203 DCHECK(EndPosition().IsNotNull()); | 203 DCHECK(EndPosition().IsNotNull()); |
| 204 switch (property_level_) { | 204 switch (property_level_) { |
| 205 case kPropertyDefault: { | 205 case kPropertyDefault: { |
| 206 // Apply the block-centric properties of the style. | 206 // Apply the block-centric properties of the style. |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 | 2046 |
| 2047 DEFINE_TRACE(ApplyStyleCommand) { | 2047 DEFINE_TRACE(ApplyStyleCommand) { |
| 2048 visitor->Trace(style_); | 2048 visitor->Trace(style_); |
| 2049 visitor->Trace(start_); | 2049 visitor->Trace(start_); |
| 2050 visitor->Trace(end_); | 2050 visitor->Trace(end_); |
| 2051 visitor->Trace(styled_inline_element_); | 2051 visitor->Trace(styled_inline_element_); |
| 2052 CompositeEditCommand::Trace(visitor); | 2052 CompositeEditCommand::Trace(visitor); |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 } // namespace blink | 2055 } // namespace blink |
| OLD | NEW |