Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: Source/core/editing/Editor.cpp

Issue 24278008: [oilpan] Handlify Nodes in htmlediting (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 494
495 bool Editor::hasBidiSelection() const 495 bool Editor::hasBidiSelection() const
496 { 496 {
497 if (m_frame->selection()->isNone()) 497 if (m_frame->selection()->isNone())
498 return false; 498 return false;
499 499
500 Handle<Node> startNode; 500 Handle<Node> startNode;
501 if (m_frame->selection()->isRange()) { 501 if (m_frame->selection()->isRange()) {
502 startNode = m_frame->selection()->selection().start().downstream().depre catedNode(); 502 startNode = m_frame->selection()->selection().start().downstream().depre catedNode();
503 Handle<Node> endNode = m_frame->selection()->selection().end().upstream( ).deprecatedNode(); 503 Handle<Node> endNode = m_frame->selection()->selection().end().upstream( ).deprecatedNode();
504 if (enclosingBlock(startNode.raw()) != enclosingBlock(endNode.raw())) 504 if (enclosingBlock(startNode) != enclosingBlock(endNode))
505 return false; 505 return false;
506 } else 506 } else
507 startNode = m_frame->selection()->selection().visibleStart().deepEquival ent().deprecatedNode(); 507 startNode = m_frame->selection()->selection().visibleStart().deepEquival ent().deprecatedNode();
508 508
509 RenderObject* renderer = startNode->renderer(); 509 RenderObject* renderer = startNode->renderer();
510 while (renderer && !renderer->isRenderBlock()) 510 while (renderer && !renderer->isRenderBlock())
511 renderer = renderer->parent(); 511 renderer = renderer->parent();
512 512
513 if (!renderer) 513 if (!renderer)
514 return false; 514 return false;
515 515
516 RenderStyle* style = renderer->style(); 516 RenderStyle* style = renderer->style();
517 if (!style->isLeftToRightDirection()) 517 if (!style->isLeftToRightDirection())
518 return true; 518 return true;
519 519
520 return toRenderBlock(renderer)->containsNonZeroBidiLevel(); 520 return toRenderBlock(renderer)->containsNonZeroBidiLevel();
521 } 521 }
522 522
523 TriState Editor::selectionUnorderedListState() const 523 TriState Editor::selectionUnorderedListState() const
524 { 524 {
525 if (m_frame->selection()->isCaret()) { 525 if (m_frame->selection()->isCaret()) {
526 if (enclosingNodeWithTag(m_frame->selection()->selection().start(), ulTa g)) 526 if (enclosingNodeWithTag(m_frame->selection()->selection().start(), ulTa g))
527 return TrueTriState; 527 return TrueTriState;
528 } else if (m_frame->selection()->isRange()) { 528 } else if (m_frame->selection()->isRange()) {
529 Handle<Node> startNode = adoptRawResult(enclosingNodeWithTag(m_frame->se lection()->selection().start(), ulTag)); 529 Handle<Node> startNode = enclosingNodeWithTag(m_frame->selection()->sele ction().start(), ulTag);
530 Handle<Node> endNode = adoptRawResult(enclosingNodeWithTag(m_frame->sele ction()->selection().end(), ulTag)); 530 Handle<Node> endNode = enclosingNodeWithTag(m_frame->selection()->select ion().end(), ulTag);
531 if (startNode && endNode && startNode == endNode) 531 if (startNode && endNode && startNode == endNode)
532 return TrueTriState; 532 return TrueTriState;
533 } 533 }
534 534
535 return FalseTriState; 535 return FalseTriState;
536 } 536 }
537 537
538 TriState Editor::selectionOrderedListState() const 538 TriState Editor::selectionOrderedListState() const
539 { 539 {
540 if (m_frame->selection()->isCaret()) { 540 if (m_frame->selection()->isCaret()) {
541 if (enclosingNodeWithTag(m_frame->selection()->selection().start(), olTa g)) 541 if (enclosingNodeWithTag(m_frame->selection()->selection().start(), olTa g))
542 return TrueTriState; 542 return TrueTriState;
543 } else if (m_frame->selection()->isRange()) { 543 } else if (m_frame->selection()->isRange()) {
544 Handle<Node> startNode = adoptRawResult(enclosingNodeWithTag(m_frame->se lection()->selection().start(), olTag)); 544 Handle<Node> startNode = enclosingNodeWithTag(m_frame->selection()->sele ction().start(), olTag);
545 Handle<Node> endNode = adoptRawResult(enclosingNodeWithTag(m_frame->sele ction()->selection().end(), olTag)); 545 Handle<Node> endNode = enclosingNodeWithTag(m_frame->selection()->select ion().end(), olTag);
546 if (startNode && endNode && startNode == endNode) 546 if (startNode && endNode && startNode == endNode)
547 return TrueTriState; 547 return TrueTriState;
548 } 548 }
549 549
550 return FalseTriState; 550 return FalseTriState;
551 } 551 }
552 552
553 Result<Node> Editor::insertOrderedList() 553 Result<Node> Editor::insertOrderedList()
554 { 554 {
555 if (!canEditRichly()) 555 if (!canEditRichly())
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 } 1552 }
1553 1553
1554 Position position = spellingSearchRange->startPosition(); 1554 Position position = spellingSearchRange->startPosition();
1555 if (!isEditablePosition(position)) { 1555 if (!isEditablePosition(position)) {
1556 // This shouldn't happen in very often because the Spelling menu items a ren't enabled unless the 1556 // This shouldn't happen in very often because the Spelling menu items a ren't enabled unless the
1557 // selection is editable. 1557 // selection is editable.
1558 // This can happen in Mail for a mix of non-editable and editable conten t (like Stationary), 1558 // This can happen in Mail for a mix of non-editable and editable conten t (like Stationary),
1559 // when spell checking the whole document before sending the message. 1559 // when spell checking the whole document before sending the message.
1560 // In that case the document might not be editable, but there are editab le pockets that need to be spell checked. 1560 // In that case the document might not be editable, but there are editab le pockets that need to be spell checked.
1561 1561
1562 position = firstEditablePositionAfterPositionInRoot(position, frame()->d ocument()->documentElement().handle().raw()).deepEquivalent(); 1562 position = firstEditablePositionAfterPositionInRoot(position, frame()->d ocument()->documentElement()).deepEquivalent();
1563 if (position.isNull()) 1563 if (position.isNull())
1564 return; 1564 return;
1565 1565
1566 Position rangeCompliantPosition = position.parentAnchoredEquivalent(); 1566 Position rangeCompliantPosition = position.parentAnchoredEquivalent();
1567 spellingSearchRange->setStart(rangeCompliantPosition.deprecatedNode(), r angeCompliantPosition.deprecatedEditingOffset(), IGNORE_EXCEPTION); 1567 spellingSearchRange->setStart(rangeCompliantPosition.deprecatedNode(), r angeCompliantPosition.deprecatedEditingOffset(), IGNORE_EXCEPTION);
1568 startedWithSelection = false; // won't need to wrap 1568 startedWithSelection = false; // won't need to wrap
1569 } 1569 }
1570 1570
1571 // topNode defines the whole range we want to operate on 1571 // topNode defines the whole range we want to operate on
1572 Node* topNode = highestEditableRoot(position); 1572 Handle<Node> topNode = highestEditableRoot(position);
1573 // FIXME: lastOffsetForEditing() is wrong here if editingIgnoresContent(high estEditableRoot()) returns true (e.g. a <table>) 1573 // FIXME: lastOffsetForEditing() is wrong here if editingIgnoresContent(high estEditableRoot()) returns true (e.g. a <table>)
1574 spellingSearchRange->setEnd(adoptRawResult(topNode), lastOffsetForEditing(to pNode), IGNORE_EXCEPTION); 1574 spellingSearchRange->setEnd(topNode, lastOffsetForEditing(topNode), IGNORE_E XCEPTION);
1575 1575
1576 // If spellingSearchRange starts in the middle of a word, advance to the nex t word so we start checking 1576 // If spellingSearchRange starts in the middle of a word, advance to the nex t word so we start checking
1577 // at a word boundary. Going back by one char and then forward by a word doe s the trick. 1577 // at a word boundary. Going back by one char and then forward by a word doe s the trick.
1578 if (startedWithSelection) { 1578 if (startedWithSelection) {
1579 VisiblePosition oneBeforeStart = startVisiblePosition(spellingSearchRang e, DOWNSTREAM).previous(); 1579 VisiblePosition oneBeforeStart = startVisiblePosition(spellingSearchRang e, DOWNSTREAM).previous();
1580 if (oneBeforeStart.isNotNull()) 1580 if (oneBeforeStart.isNotNull())
1581 setStart(spellingSearchRange, endOfWord(oneBeforeStart)); 1581 setStart(spellingSearchRange, endOfWord(oneBeforeStart));
1582 // else we were already at the start of the editable node 1582 // else we were already at the start of the editable node
1583 } 1583 }
1584 1584
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 } 1629 }
1630 1630
1631 if (isGrammarCheckingEnabled()) 1631 if (isGrammarCheckingEnabled())
1632 badGrammarPhrase = TextCheckingHelper(client(), grammarSearchRange). findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false); 1632 badGrammarPhrase = TextCheckingHelper(client(), grammarSearchRange). findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false);
1633 #endif 1633 #endif
1634 } 1634 }
1635 1635
1636 // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the 1636 // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the
1637 // block rather than at a selection). 1637 // block rather than at a selection).
1638 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) { 1638 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) {
1639 spellingSearchRange->setStart(adoptRawResult(topNode), 0, IGNORE_EXCEPTI ON); 1639 spellingSearchRange->setStart(topNode, 0, IGNORE_EXCEPTION);
1640 // going until the end of the very first chunk we tested is far enough 1640 // going until the end of the very first chunk we tested is far enough
1641 spellingSearchRange->setEnd(searchEndNodeAfterWrap, searchEndOffsetAfter Wrap, IGNORE_EXCEPTION); 1641 spellingSearchRange->setEnd(searchEndNodeAfterWrap, searchEndOffsetAfter Wrap, IGNORE_EXCEPTION);
1642 1642
1643 if (unifiedTextCheckerEnabled()) { 1643 if (unifiedTextCheckerEnabled()) {
1644 grammarSearchRange = spellingSearchRange->cloneRange(IGNORE_EXCEPTIO N); 1644 grammarSearchRange = spellingSearchRange->cloneRange(IGNORE_EXCEPTIO N);
1645 foundItem = TextCheckingHelper(client(), spellingSearchRange).findFi rstMisspellingOrBadGrammar(isGrammarCheckingEnabled(), isSpelling, foundOffset, grammarDetail); 1645 foundItem = TextCheckingHelper(client(), spellingSearchRange).findFi rstMisspellingOrBadGrammar(isGrammarCheckingEnabled(), isSpelling, foundOffset, grammarDetail);
1646 if (isSpelling) { 1646 if (isSpelling) {
1647 misspelledWord = foundItem; 1647 misspelledWord = foundItem;
1648 misspellingOffset = foundOffset; 1648 misspellingOffset = foundOffset;
1649 } else { 1649 } else {
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 { 2914 {
2915 return m_alternativeTextController->dictationAlternativesForMarker(marker); 2915 return m_alternativeTextController->dictationAlternativesForMarker(marker);
2916 } 2916 }
2917 2917
2918 void Editor::applyDictationAlternativelternative(const String& alternativeString ) 2918 void Editor::applyDictationAlternativelternative(const String& alternativeString )
2919 { 2919 {
2920 m_alternativeTextController->applyDictationAlternative(alternativeString); 2920 m_alternativeTextController->applyDictationAlternative(alternativeString);
2921 } 2921 }
2922 2922
2923 } // namespace WebCore 2923 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698