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

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

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-09-20T18:27:32 Created 7 years, 3 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) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. 3 * Portions Copyright (c) 2011 Motorola Mobility, 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 20 matching lines...) Expand all
31 #include "bindings/v8/ExceptionState.h" 31 #include "bindings/v8/ExceptionState.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/dom/Range.h" 33 #include "core/dom/Range.h"
34 #include "core/dom/Text.h" 34 #include "core/dom/Text.h"
35 #include "core/editing/VisibleUnits.h" 35 #include "core/editing/VisibleUnits.h"
36 #include "core/editing/htmlediting.h" 36 #include "core/editing/htmlediting.h"
37 #include "core/html/HTMLElement.h" 37 #include "core/html/HTMLElement.h"
38 #include "core/html/HTMLHtmlElement.h" 38 #include "core/html/HTMLHtmlElement.h"
39 #include "core/platform/graphics/FloatQuad.h" 39 #include "core/platform/graphics/FloatQuad.h"
40 #include "core/rendering/RenderBlock.h" 40 #include "core/rendering/RenderBlock.h"
41 #include "core/rendering/RenderText.h"
41 #include "core/rendering/RootInlineBox.h" 42 #include "core/rendering/RootInlineBox.h"
42 #include "wtf/text/CString.h" 43 #include "wtf/text/CString.h"
43 44
44 #ifndef NDEBUG 45 #ifndef NDEBUG
45 #include <stdio.h> 46 #include <stdio.h>
46 #endif 47 #endif
47 48
48 namespace WebCore { 49 namespace WebCore {
49 50
50 using namespace HTMLNames; 51 using namespace HTMLNames;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (box->bidiLevel() == level) 253 if (box->bidiLevel() == level)
253 break; 254 break;
254 level = box->bidiLevel(); 255 level = box->bidiLevel();
255 } 256 }
256 renderer = box->renderer(); 257 renderer = box->renderer();
257 offset = primaryDirection == LTR ? box->caretMinOffset() : box-> caretMaxOffset(); 258 offset = primaryDirection == LTR ? box->caretMinOffset() : box-> caretMaxOffset();
258 } 259 }
259 break; 260 break;
260 } 261 }
261 262
263 if (renderer->isText())
264 offset += toRenderText(renderer)->textStartOffset();
262 p = createLegacyEditingPosition(renderer->node(), offset); 265 p = createLegacyEditingPosition(renderer->node(), offset);
263 266
264 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree()) 267 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree())
265 return p; 268 return p;
266 269
267 ASSERT(p != m_deepPosition); 270 ASSERT(p != m_deepPosition);
268 } 271 }
269 } 272 }
270 273
271 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const 274 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (box->bidiLevel() == level) 423 if (box->bidiLevel() == level)
421 break; 424 break;
422 level = box->bidiLevel(); 425 level = box->bidiLevel();
423 } 426 }
424 renderer = box->renderer(); 427 renderer = box->renderer();
425 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset(); 428 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset();
426 } 429 }
427 break; 430 break;
428 } 431 }
429 432
433 if (renderer->isText())
434 offset += toRenderText(renderer)->textStartOffset();
430 p = createLegacyEditingPosition(renderer->node(), offset); 435 p = createLegacyEditingPosition(renderer->node(), offset);
431 436
432 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree()) 437 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO fTree() || p.atEndOfTree())
433 return p; 438 return p;
434 439
435 ASSERT(p != m_deepPosition); 440 ASSERT(p != m_deepPosition);
436 } 441 }
437 } 442 }
438 443
439 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const 444 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 652
648 return textNode->data().characterStartingAt(offset); 653 return textNode->data().characterStartingAt(offset);
649 } 654 }
650 655
651 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const 656 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const
652 { 657 {
653 if (m_deepPosition.isNull()) { 658 if (m_deepPosition.isNull()) {
654 renderer = 0; 659 renderer = 0;
655 return IntRect(); 660 return IntRect();
656 } 661 }
657 Node* node = m_deepPosition.anchorNode(); 662 renderer = m_deepPosition.rendererOfAnchorNode();
658
659 renderer = node->renderer();
660 if (!renderer) 663 if (!renderer)
661 return LayoutRect(); 664 return LayoutRect();
662 665
663 InlineBox* inlineBox; 666 InlineBox* inlineBox;
664 int caretOffset; 667 int caretOffset;
665 getInlineBoxAndOffset(inlineBox, caretOffset); 668 getInlineBoxAndOffset(inlineBox, caretOffset);
666 669
667 if (inlineBox) 670 if (inlineBox)
668 renderer = inlineBox->renderer(); 671 renderer = inlineBox->renderer();
669 672
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 if (vpos) 808 if (vpos)
806 vpos->showTreeForThis(); 809 vpos->showTreeForThis();
807 } 810 }
808 811
809 void showTree(const WebCore::VisiblePosition& vpos) 812 void showTree(const WebCore::VisiblePosition& vpos)
810 { 813 {
811 vpos.showTreeForThis(); 814 vpos.showTreeForThis();
812 } 815 }
813 816
814 #endif 817 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698