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

Side by Side Diff: third_party/WebKit/WebCore/page/Frame.cpp

Issue 21184: WebKit merge 40722:40785 (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 10 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 m_script.updateDocument(); 276 m_script.updateDocument();
277 } 277 }
278 278
279 Settings* Frame::settings() const 279 Settings* Frame::settings() const
280 { 280 {
281 return m_page ? m_page->settings() : 0; 281 return m_page ? m_page->settings() : 0;
282 } 282 }
283 283
284 String Frame::selectedText() const 284 String Frame::selectedText() const
285 { 285 {
286 return plainText(selection()->toRange().get()); 286 return plainText(selection()->toNormalizedRange().get());
287 } 287 }
288 288
289 IntRect Frame::firstRectForRange(Range* range) const 289 IntRect Frame::firstRectForRange(Range* range) const
290 { 290 {
291 int extraWidthToEndOfLine = 0; 291 int extraWidthToEndOfLine = 0;
292 ExceptionCode ec = 0; 292 ExceptionCode ec = 0;
293 ASSERT(range->startContainer(ec)); 293 ASSERT(range->startContainer(ec));
294 ASSERT(range->endContainer(ec)); 294 ASSERT(range->endContainer(ec));
295 295
296 InlineBox* startInlineBox; 296 InlineBox* startInlineBox;
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 m_doc->updateStyleSelector(); 835 m_doc->updateStyleSelector();
836 } 836 }
837 837
838 bool Frame::shouldChangeSelection(const Selection& newSelection) const 838 bool Frame::shouldChangeSelection(const Selection& newSelection) const
839 { 839 {
840 return shouldChangeSelection(selection()->selection(), newSelection, newSele ction.affinity(), false); 840 return shouldChangeSelection(selection()->selection(), newSelection, newSele ction.affinity(), false);
841 } 841 }
842 842
843 bool Frame::shouldChangeSelection(const Selection& oldSelection, const Selection & newSelection, EAffinity affinity, bool stillSelecting) const 843 bool Frame::shouldChangeSelection(const Selection& oldSelection, const Selection & newSelection, EAffinity affinity, bool stillSelecting) const
844 { 844 {
845 return editor()->client()->shouldChangeSelectedRange(oldSelection.toRange(). get(), newSelection.toRange().get(), 845 return editor()->client()->shouldChangeSelectedRange(oldSelection.toNormaliz edRange().get(), newSelection.toNormalizedRange().get(),
846 affinity, stillSelectin g); 846 affinity, stillSelectin g);
847 } 847 }
848 848
849 bool Frame::shouldDeleteSelection(const Selection& selection) const 849 bool Frame::shouldDeleteSelection(const Selection& selection) const
850 { 850 {
851 return editor()->client()->shouldDeleteRange(selection.toRange().get()); 851 return editor()->client()->shouldDeleteRange(selection.toNormalizedRange().g et());
852 } 852 }
853 853
854 bool Frame::isContentEditable() const 854 bool Frame::isContentEditable() const
855 { 855 {
856 if (m_editor.clientIsEditable()) 856 if (m_editor.clientIsEditable())
857 return true; 857 return true;
858 if (!m_doc) 858 if (!m_doc)
859 return false; 859 return false;
860 return m_doc->inDesignMode(); 860 return m_doc->inDesignMode();
861 } 861 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 PassRefPtr<CSSComputedStyleDeclaration> Frame::selectionComputedStyle(Node*& nod eToRemove) const 953 PassRefPtr<CSSComputedStyleDeclaration> Frame::selectionComputedStyle(Node*& nod eToRemove) const
954 { 954 {
955 nodeToRemove = 0; 955 nodeToRemove = 0;
956 956
957 if (!document()) 957 if (!document())
958 return 0; 958 return 0;
959 959
960 if (selection()->isNone()) 960 if (selection()->isNone())
961 return 0; 961 return 0;
962 962
963 RefPtr<Range> range(selection()->toRange()); 963 RefPtr<Range> range(selection()->toNormalizedRange());
964 Position pos = range->editingStartPosition(); 964 Position pos = range->editingStartPosition();
965 965
966 Element *elem = pos.element(); 966 Element *elem = pos.element();
967 if (!elem) 967 if (!elem)
968 return 0; 968 return 0;
969 969
970 RefPtr<Element> styleElement = elem; 970 RefPtr<Element> styleElement = elem;
971 ExceptionCode ec = 0; 971 ExceptionCode ec = 0;
972 972
973 if (m_typingStyle) { 973 if (m_typingStyle) {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 IntRect selectionRect = root->selectionBounds(clipToVisibleContent); 1200 IntRect selectionRect = root->selectionBounds(clipToVisibleContent);
1201 return clipToVisibleContent ? intersection(selectionRect, view->visibleConte ntRect()) : selectionRect; 1201 return clipToVisibleContent ? intersection(selectionRect, view->visibleConte ntRect()) : selectionRect;
1202 } 1202 }
1203 1203
1204 void Frame::selectionTextRects(Vector<FloatRect>& rects, bool clipToVisibleConte nt) const 1204 void Frame::selectionTextRects(Vector<FloatRect>& rects, bool clipToVisibleConte nt) const
1205 { 1205 {
1206 RenderView* root = contentRenderer(); 1206 RenderView* root = contentRenderer();
1207 if (!root) 1207 if (!root)
1208 return; 1208 return;
1209 1209
1210 RefPtr<Range> selectedRange = selection()->toRange(); 1210 RefPtr<Range> selectedRange = selection()->toNormalizedRange();
1211 1211
1212 Vector<IntRect> intRects; 1212 Vector<IntRect> intRects;
1213 selectedRange->addLineBoxRects(intRects, true); 1213 selectedRange->addLineBoxRects(intRects, true);
1214 1214
1215 unsigned size = intRects.size(); 1215 unsigned size = intRects.size();
1216 FloatRect visibleContentRect = m_view->visibleContentRect(); 1216 FloatRect visibleContentRect = m_view->visibleContentRect();
1217 for (unsigned i = 0; i < size; ++i) 1217 for (unsigned i = 0; i < size; ++i)
1218 if (clipToVisibleContent) 1218 if (clipToVisibleContent)
1219 rects.append(intersection(intRects[i], visibleContentRect)); 1219 rects.append(intersection(intRects[i], visibleContentRect));
1220 else 1220 else
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 if (n->hasTagName(formTag)) 1254 if (n->hasTagName(formTag))
1255 return static_cast<HTMLFormElement*>(n); 1255 return static_cast<HTMLFormElement*>(n);
1256 else if (n->isHTMLElement() && static_cast<Element*>(n)->isFormControlEl ement()) 1256 else if (n->isHTMLElement() && static_cast<Element*>(n)->isFormControlEl ement())
1257 return static_cast<HTMLFormControlElement*>(n)->form(); 1257 return static_cast<HTMLFormControlElement*>(n)->form();
1258 } 1258 }
1259 1259
1260 // try walking forward in the node tree to find a form element 1260 // try walking forward in the node tree to find a form element
1261 return start ? scanForForm(start) : 0; 1261 return start ? scanForForm(start) : 0;
1262 } 1262 }
1263 1263
1264 // FIXME: should this go in SelectionController?
1265 void Frame::revealSelection(const RenderLayer::ScrollAlignment& alignment) const 1264 void Frame::revealSelection(const RenderLayer::ScrollAlignment& alignment) const
1266 { 1265 {
1267 IntRect rect; 1266 IntRect rect;
1268 1267
1269 switch (selection()->state()) { 1268 switch (selection()->selectionType()) {
1270 case Selection::NONE: 1269 case Selection::NoSelection:
1271 return; 1270 return;
1272 1271 case Selection::CaretSelection:
1273 case Selection::CARET:
1274 rect = selection()->absoluteCaretBounds(); 1272 rect = selection()->absoluteCaretBounds();
1275 break; 1273 break;
1276 1274 case Selection::RangeSelection:
1277 case Selection::RANGE:
1278 rect = enclosingIntRect(selectionBounds(false)); 1275 rect = enclosingIntRect(selectionBounds(false));
1279 break; 1276 break;
1280 } 1277 }
1281 1278
1282 Position start = selection()->start(); 1279 Position start = selection()->start();
1283
1284 ASSERT(start.node()); 1280 ASSERT(start.node());
1285 if (start.node() && start.node()->renderer()) { 1281 if (start.node() && start.node()->renderer()) {
1286 // FIXME: This code only handles scrolling the startContainer's layer, b ut 1282 // FIXME: This code only handles scrolling the startContainer's layer, b ut
1287 // the selection rect could intersect more than just that. 1283 // the selection rect could intersect more than just that.
1288 // See <rdar://problem/4799899>. 1284 // See <rdar://problem/4799899>.
1289 if (RenderLayer *layer = start.node()->renderer()->enclosingLayer()) 1285 if (RenderLayer* layer = start.node()->renderer()->enclosingLayer())
1290 layer->scrollRectToVisible(rect, false, alignment, alignment); 1286 layer->scrollRectToVisible(rect, false, alignment, alignment);
1291 } 1287 }
1292 } 1288 }
1293 1289
1294 void Frame::revealCaret(const RenderLayer::ScrollAlignment& alignment) const 1290 void Frame::revealCaret(const RenderLayer::ScrollAlignment& alignment) const
1295 { 1291 {
1296 if (selection()->isNone()) 1292 if (selection()->isNone())
1297 return; 1293 return;
1298 1294
1299 Position extent = selection()->extent(); 1295 Position extent = selection()->extent();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 if (forward) 1420 if (forward)
1425 searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount() , ec); 1421 searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount() , ec);
1426 else 1422 else
1427 searchRange->setStart(shadowTreeRoot, 0, ec); 1423 searchRange->setStart(shadowTreeRoot, 0, ec);
1428 } 1424 }
1429 1425
1430 RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, forward, caseFlag)); 1426 RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, forward, caseFlag));
1431 // If we started in the selection and the found range exactly matches the ex isting selection, find again. 1427 // If we started in the selection and the found range exactly matches the ex isting selection, find again.
1432 // Build a selection with the found range to remove collapsed whitespace. 1428 // Build a selection with the found range to remove collapsed whitespace.
1433 // Compare ranges instead of selection objects to ignore the way that the cu rrent selection was made. 1429 // Compare ranges instead of selection objects to ignore the way that the cu rrent selection was made.
1434 if (startInSelection && *Selection(resultRange.get()).toRange() == *selectio n.toRange()) { 1430 if (startInSelection && *Selection(resultRange.get()).toNormalizedRange() == *selection.toNormalizedRange()) {
1435 searchRange = rangeOfContents(document()); 1431 searchRange = rangeOfContents(document());
1436 if (forward) 1432 if (forward)
1437 setStart(searchRange.get(), selection.visibleEnd()); 1433 setStart(searchRange.get(), selection.visibleEnd());
1438 else 1434 else
1439 setEnd(searchRange.get(), selection.visibleStart()); 1435 setEnd(searchRange.get(), selection.visibleStart());
1440 1436
1441 if (shadowTreeRoot) { 1437 if (shadowTreeRoot) {
1442 ExceptionCode ec = 0; 1438 ExceptionCode ec = 0;
1443 if (forward) 1439 if (forward)
1444 searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCou nt(), ec); 1440 searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCou nt(), ec);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 if (isContinuousGrammarCheckingEnabled) { 1734 if (isContinuousGrammarCheckingEnabled) {
1739 Selection oldSelectedSentence = Selection(startOfSentenc e(oldStart), endOfSentence(oldStart)); 1735 Selection oldSelectedSentence = Selection(startOfSentenc e(oldStart), endOfSentence(oldStart));
1740 if (oldSelectedSentence != newSelectedSentence) 1736 if (oldSelectedSentence != newSelectedSentence)
1741 editor()->markBadGrammar(oldSelectedSentence); 1737 editor()->markBadGrammar(oldSelectedSentence);
1742 } 1738 }
1743 } 1739 }
1744 } 1740 }
1745 1741
1746 // This only erases markers that are in the first unit (word or sent ence) of the selection. 1742 // This only erases markers that are in the first unit (word or sent ence) of the selection.
1747 // Perhaps peculiar, but it matches AppKit. 1743 // Perhaps peculiar, but it matches AppKit.
1748 if (RefPtr<Range> wordRange = newAdjacentWords.toRange()) 1744 if (RefPtr<Range> wordRange = newAdjacentWords.toNormalizedRange())
1749 document()->removeMarkers(wordRange.get(), DocumentMarker::Spell ing); 1745 document()->removeMarkers(wordRange.get(), DocumentMarker::Spell ing);
1750 if (RefPtr<Range> sentenceRange = newSelectedSentence.toRange()) 1746 if (RefPtr<Range> sentenceRange = newSelectedSentence.toNormalizedRa nge())
1751 document()->removeMarkers(sentenceRange.get(), DocumentMarker::G rammar); 1747 document()->removeMarkers(sentenceRange.get(), DocumentMarker::G rammar);
1752 } 1748 }
1753 1749
1754 // When continuous spell checking is off, existing markers disappear aft er the selection changes. 1750 // When continuous spell checking is off, existing markers disappear aft er the selection changes.
1755 if (!isContinuousSpellCheckingEnabled) 1751 if (!isContinuousSpellCheckingEnabled)
1756 document()->removeMarkers(DocumentMarker::Spelling); 1752 document()->removeMarkers(DocumentMarker::Spelling);
1757 if (!isContinuousGrammarCheckingEnabled) 1753 if (!isContinuousGrammarCheckingEnabled)
1758 document()->removeMarkers(DocumentMarker::Grammar); 1754 document()->removeMarkers(DocumentMarker::Grammar);
1759 } 1755 }
1760 1756
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 frameView->setParentVisible(true); 1822 frameView->setParentVisible(true);
1827 1823
1828 if (ownerRenderer()) 1824 if (ownerRenderer())
1829 ownerRenderer()->setWidget(frameView); 1825 ownerRenderer()->setWidget(frameView);
1830 1826
1831 if (HTMLFrameOwnerElement* owner = ownerElement()) 1827 if (HTMLFrameOwnerElement* owner = ownerElement())
1832 view()->setCanHaveScrollbars(owner->scrollingMode() != ScrollbarAlwaysOf f); 1828 view()->setCanHaveScrollbars(owner->scrollingMode() != ScrollbarAlwaysOf f);
1833 } 1829 }
1834 1830
1835 } // namespace WebCore 1831 } // namespace WebCore
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/page/EventHandler.cpp ('k') | third_party/WebKit/WebCore/platform/ContextMenu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698