Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1545 if (m_selection.start().isNotNull() && m_selection.end().isNotNull()) { | 1545 if (m_selection.start().isNotNull() && m_selection.end().isNotNull()) { |
| 1546 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) | 1546 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) |
| 1547 cache->selectionChanged(m_selection.start().containerNode()); | 1547 cache->selectionChanged(m_selection.start().containerNode()); |
| 1548 } | 1548 } |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 void FrameSelection::focusedOrActiveStateChanged() | 1551 void FrameSelection::focusedOrActiveStateChanged() |
| 1552 { | 1552 { |
| 1553 bool activeAndFocused = isFocusedAndActive(); | 1553 bool activeAndFocused = isFocusedAndActive(); |
| 1554 | 1554 |
| 1555 RefPtr<Document> document = m_frame->document(); | |
| 1556 document->updateStyleIfNeeded(); | |
| 1557 | |
| 1555 // Because RenderObject::selectionBackgroundColor() and | 1558 // Because RenderObject::selectionBackgroundColor() and |
| 1556 // RenderObject::selectionForegroundColor() check if the frame is active, | 1559 // RenderObject::selectionForegroundColor() check if the frame is active, |
| 1557 // we have to update places those colors were painted. | 1560 // we have to update places those colors were painted. |
| 1558 if (RenderView* view = m_frame->document()->renderView()) | 1561 if (RenderView* view = document->renderView()) |
|
abarth-chromium
2013/09/27 22:55:00
Should we bail out at some point if the document l
| |
| 1559 view->repaintSelection(); | 1562 view->repaintSelection(); |
| 1560 | 1563 |
| 1561 // Caret appears in the active frame. | 1564 // Caret appears in the active frame. |
| 1562 if (activeAndFocused) | 1565 if (activeAndFocused) |
| 1563 setSelectionFromNone(); | 1566 setSelectionFromNone(); |
| 1564 else | 1567 else |
| 1565 m_frame->editor().spellCheckAfterBlur(); | 1568 m_frame->editor().spellCheckAfterBlur(); |
| 1566 setCaretVisibility(activeAndFocused ? Visible : Hidden); | 1569 setCaretVisibility(activeAndFocused ? Visible : Hidden); |
| 1567 | 1570 |
| 1568 // Update for caps lock state | 1571 // Update for caps lock state |
| 1569 m_frame->eventHandler()->capsLockStateMayHaveChanged(); | 1572 m_frame->eventHandler()->capsLockStateMayHaveChanged(); |
| 1570 | 1573 |
| 1571 // Because StyleResolver::checkOneSelector() and | 1574 // Because StyleResolver::checkOneSelector() and |
| 1572 // RenderTheme::isFocused() check if the frame is active, we have to | 1575 // RenderTheme::isFocused() check if the frame is active, we have to |
| 1573 // update style and theme state that depended on those. | 1576 // update style and theme state that depended on those. |
| 1574 if (Element* element = m_frame->document()->focusedElement()) { | 1577 if (Element* element = document->focusedElement()) { |
| 1575 element->setNeedsStyleRecalc(); | 1578 element->setNeedsStyleRecalc(); |
| 1576 if (RenderObject* renderer = element->renderer()) { | 1579 if (RenderObject* renderer = element->renderer()) { |
| 1577 if (renderer && renderer->style()->hasAppearance()) | 1580 if (renderer && renderer->style()->hasAppearance()) |
| 1578 RenderTheme::theme().stateChanged(renderer, FocusState); | 1581 RenderTheme::theme().stateChanged(renderer, FocusState); |
| 1579 } | 1582 } |
| 1580 } | 1583 } |
| 1581 | 1584 |
| 1582 // Secure keyboard entry is set by the active frame. | 1585 // Secure keyboard entry is set by the active frame. |
| 1583 if (m_frame->document()->useSecureKeyboardEntryWhenActive()) | 1586 if (document->useSecureKeyboardEntryWhenActive()) |
| 1584 setUseSecureKeyboardEntry(activeAndFocused); | 1587 setUseSecureKeyboardEntry(activeAndFocused); |
| 1585 } | 1588 } |
| 1586 | 1589 |
| 1587 void FrameSelection::pageActivationChanged() | 1590 void FrameSelection::pageActivationChanged() |
| 1588 { | 1591 { |
| 1589 focusedOrActiveStateChanged(); | 1592 focusedOrActiveStateChanged(); |
| 1590 } | 1593 } |
| 1591 | 1594 |
| 1592 void FrameSelection::updateSecureKeyboardEntryIfActive() | 1595 void FrameSelection::updateSecureKeyboardEntryIfActive() |
| 1593 { | 1596 { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1815 return selectedText(); | 1818 return selectedText(); |
| 1816 } | 1819 } |
| 1817 | 1820 |
| 1818 bool FrameSelection::shouldDeleteSelection(const VisibleSelection& selection) co nst | 1821 bool FrameSelection::shouldDeleteSelection(const VisibleSelection& selection) co nst |
| 1819 { | 1822 { |
| 1820 return m_frame->editor().client().shouldDeleteRange(selection.toNormalizedRa nge().get()); | 1823 return m_frame->editor().client().shouldDeleteRange(selection.toNormalizedRa nge().get()); |
| 1821 } | 1824 } |
| 1822 | 1825 |
| 1823 FloatRect FrameSelection::bounds(bool clipToVisibleContent) const | 1826 FloatRect FrameSelection::bounds(bool clipToVisibleContent) const |
| 1824 { | 1827 { |
| 1825 RenderView* root = m_frame->contentRenderer(); | 1828 m_frame->document()->updateStyleIfNeeded(); |
| 1829 | |
| 1826 FrameView* view = m_frame->view(); | 1830 FrameView* view = m_frame->view(); |
| 1827 if (!root || !view) | 1831 RenderView* renderView = m_frame->contentRenderer(); |
| 1828 return LayoutRect(); | |
| 1829 | 1832 |
| 1830 LayoutRect selectionRect = root->selectionBounds(clipToVisibleContent); | 1833 if (!view || !renderView); |
| 1834 return FloatRect(); | |
| 1835 | |
| 1836 LayoutRect selectionRect = renderView->selectionBounds(clipToVisibleContent) ; | |
| 1831 return clipToVisibleContent ? intersection(selectionRect, view->visibleConte ntRect()) : selectionRect; | 1837 return clipToVisibleContent ? intersection(selectionRect, view->visibleConte ntRect()) : selectionRect; |
| 1832 } | 1838 } |
| 1833 | 1839 |
| 1834 void FrameSelection::getClippedVisibleTextRectangles(Vector<FloatRect>& rectangl es) const | 1840 void FrameSelection::getClippedVisibleTextRectangles(Vector<FloatRect>& rectangl es) const |
| 1835 { | 1841 { |
| 1836 RenderView* root = m_frame->contentRenderer(); | 1842 RenderView* root = m_frame->contentRenderer(); |
| 1837 if (!root) | 1843 if (!root) |
| 1838 return; | 1844 return; |
| 1839 | 1845 |
| 1840 FloatRect visibleContentRect = m_frame->view()->visibleContentRect(); | 1846 FloatRect visibleContentRect = m_frame->view()->visibleContentRect(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1986 sel.showTreeForThis(); | 1992 sel.showTreeForThis(); |
| 1987 } | 1993 } |
| 1988 | 1994 |
| 1989 void showTree(const WebCore::FrameSelection* sel) | 1995 void showTree(const WebCore::FrameSelection* sel) |
| 1990 { | 1996 { |
| 1991 if (sel) | 1997 if (sel) |
| 1992 sel->showTreeForThis(); | 1998 sel->showTreeForThis(); |
| 1993 } | 1999 } |
| 1994 | 2000 |
| 1995 #endif | 2001 #endif |
| OLD | NEW |