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

Unified Diff: Source/WebCore/rendering/RenderText.cpp

Issue 9762003: Merge 110323 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/rendering/RenderReplaced.cpp ('k') | Source/WebCore/rendering/RenderView.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/rendering/RenderText.cpp
===================================================================
--- Source/WebCore/rendering/RenderText.cpp (revision 111422)
+++ Source/WebCore/rendering/RenderText.cpp (working copy)
@@ -1131,39 +1131,41 @@
void RenderText::setSelectionState(SelectionState state)
{
- InlineTextBox* box;
-
RenderObject::setSelectionState(state);
- if (state == SelectionStart || state == SelectionEnd || state == SelectionBoth) {
- int startPos, endPos;
- selectionStartEnd(startPos, endPos);
- if (selectionState() == SelectionStart) {
- endPos = textLength();
- // to handle selection from end of text to end of line
- if (startPos != 0 && startPos == endPos)
- startPos = endPos - 1;
- } else if (selectionState() == SelectionEnd)
- startPos = 0;
+ if (canUpdateSelectionOnRootLineBoxes()) {
+ if (state == SelectionStart || state == SelectionEnd || state == SelectionBoth) {
+ int startPos, endPos;
+ selectionStartEnd(startPos, endPos);
+ if (selectionState() == SelectionStart) {
+ endPos = textLength();
- for (box = firstTextBox(); box; box = box->nextTextBox()) {
- if (box->isSelected(startPos, endPos)) {
- RootInlineBox* line = box->root();
- if (line)
- line->setHasSelectedChildren(true);
+ // to handle selection from end of text to end of line
+ if (startPos && startPos == endPos)
+ startPos = endPos - 1;
+ } else if (selectionState() == SelectionEnd)
+ startPos = 0;
+
+ for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
+ if (box->isSelected(startPos, endPos)) {
+ RootInlineBox* root = box->root();
+ if (root)
+ root->setHasSelectedChildren(true);
+ }
}
+ } else {
+ for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
+ RootInlineBox* root = box->root();
+ if (root)
+ root->setHasSelectedChildren(state == SelectionInside);
+ }
}
- } else {
- for (box = firstTextBox(); box; box = box->nextTextBox()) {
- RootInlineBox* line = box->root();
- if (line)
- line->setHasSelectedChildren(state == SelectionInside);
- }
}
- // The returned value can be null in case of an orphaned tree.
- if (RenderBlock* cb = containingBlock())
- cb->setSelectionState(state);
+ // The containing block can be null in case of an orphaned tree.
+ RenderBlock* containingBlock = this->containingBlock();
+ if (containingBlock && !containingBlock->isRenderView())
+ containingBlock->setSelectionState(state);
}
void RenderText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset, unsigned len, bool force)
« no previous file with comments | « Source/WebCore/rendering/RenderReplaced.cpp ('k') | Source/WebCore/rendering/RenderView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698