OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 .DeepEquivalent(); | 272 .DeepEquivalent(); |
273 | 273 |
274 // If start is in the middle of a text node, split. | 274 // If start is in the middle of a text node, split. |
275 if (!start_style->CollapseWhiteSpace() && | 275 if (!start_style->CollapseWhiteSpace() && |
276 start.OffsetInContainerNode() > 0) { | 276 start.OffsetInContainerNode() > 0) { |
277 int start_offset = start.OffsetInContainerNode(); | 277 int start_offset = start.OffsetInContainerNode(); |
278 Text* start_text = ToText(start.ComputeContainerNode()); | 278 Text* start_text = ToText(start.ComputeContainerNode()); |
279 SplitTextNode(start_text, start_offset); | 279 SplitTextNode(start_text, start_offset); |
280 GetDocument().UpdateStyleAndLayoutTree(); | 280 GetDocument().UpdateStyleAndLayoutTree(); |
281 | 281 |
282 start = Position::FirstPositionInNode(start_text); | 282 start = Position::FirstPositionInNode(*start_text); |
283 if (is_start_and_end_on_same_node) { | 283 if (is_start_and_end_on_same_node) { |
284 DCHECK_GE(end.OffsetInContainerNode(), start_offset); | 284 DCHECK_GE(end.OffsetInContainerNode(), start_offset); |
285 end = Position(start_text, end.OffsetInContainerNode() - start_offset); | 285 end = Position(start_text, end.OffsetInContainerNode() - start_offset); |
286 } | 286 } |
287 if (is_start_and_end_of_last_paragraph_on_same_node) { | 287 if (is_start_and_end_of_last_paragraph_on_same_node) { |
288 DCHECK_GE(end_of_last_paragraph.OffsetInContainerNode(), start_offset); | 288 DCHECK_GE(end_of_last_paragraph.OffsetInContainerNode(), start_offset); |
289 end_of_last_paragraph = | 289 end_of_last_paragraph = |
290 Position(start_text, end_of_last_paragraph.OffsetInContainerNode() - | 290 Position(start_text, end_of_last_paragraph.OffsetInContainerNode() - |
291 start_offset); | 291 start_offset); |
292 } | 292 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 const ComputedStyle* style = | 353 const ComputedStyle* style = |
354 ComputedStyleOfEnclosingTextNode(end_of_next_paragraph_position); | 354 ComputedStyleOfEnclosingTextNode(end_of_next_paragraph_position); |
355 if (!style) | 355 if (!style) |
356 return end_of_next_paragraph; | 356 return end_of_next_paragraph; |
357 | 357 |
358 Text* const end_of_next_paragraph_text = | 358 Text* const end_of_next_paragraph_text = |
359 ToText(end_of_next_paragraph_position.ComputeContainerNode()); | 359 ToText(end_of_next_paragraph_position.ComputeContainerNode()); |
360 if (!style->PreserveNewline() || | 360 if (!style->PreserveNewline() || |
361 !end_of_next_paragraph_position.OffsetInContainerNode() || | 361 !end_of_next_paragraph_position.OffsetInContainerNode() || |
362 !IsNewLineAtPosition( | 362 !IsNewLineAtPosition( |
363 Position::FirstPositionInNode(end_of_next_paragraph_text))) | 363 Position::FirstPositionInNode(*end_of_next_paragraph_text))) |
364 return end_of_next_paragraph; | 364 return end_of_next_paragraph; |
365 | 365 |
366 // \n at the beginning of the text node immediately following the current | 366 // \n at the beginning of the text node immediately following the current |
367 // paragraph is trimmed by moveParagraphWithClones. If endOfNextParagraph was | 367 // paragraph is trimmed by moveParagraphWithClones. If endOfNextParagraph was |
368 // pointing at this same text node, endOfNextParagraph will be shifted by one | 368 // pointing at this same text node, endOfNextParagraph will be shifted by one |
369 // paragraph. Avoid this by splitting "\n" | 369 // paragraph. Avoid this by splitting "\n" |
370 SplitTextNode(end_of_next_paragraph_text, 1); | 370 SplitTextNode(end_of_next_paragraph_text, 1); |
371 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | 371 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); |
372 Text* const previous_text = | 372 Text* const previous_text = |
373 end_of_next_paragraph_text->previousSibling() && | 373 end_of_next_paragraph_text->previousSibling() && |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 } | 411 } |
412 | 412 |
413 HTMLElement* ApplyBlockElementCommand::CreateBlockElement() const { | 413 HTMLElement* ApplyBlockElementCommand::CreateBlockElement() const { |
414 HTMLElement* element = CreateHTMLElement(GetDocument(), tag_name_); | 414 HTMLElement* element = CreateHTMLElement(GetDocument(), tag_name_); |
415 if (inline_style_.length()) | 415 if (inline_style_.length()) |
416 element->setAttribute(styleAttr, inline_style_); | 416 element->setAttribute(styleAttr, inline_style_); |
417 return element; | 417 return element; |
418 } | 418 } |
419 | 419 |
420 } // namespace blink | 420 } // namespace blink |
OLD | NEW |