Changeset 20901 in webkit
- Timestamp:
- Apr 16, 2007, 8:41:04 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r20900 r20901 1 2007-04-16 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=13303 6 <rdar://problem/5126341> REGRESSION: controls in a background Safari window 7 maintain active appearance if the address bar has focus (13303) 8 9 - fix a related problem where elements could look focused in non-active windows 10 11 - simplify secure keyboard entry logic in Frame::setIsActive 12 13 * WebCore.exp: Add two new symbols for use by WebKit. 14 15 * html/HTMLInputElement.cpp: 16 (WebCore::HTMLInputElement::dispatchFocusEvent): Call setUseSecureKeyboardEntryWhenActive 17 rather than calling setSecureKeyboardEntry directly -- does nothing if the frame is not active. 18 (WebCore::HTMLInputElement::dispatchBlurEvent): Ditto. 19 20 * page/Frame.cpp: 21 (WebCore::Frame::setUseSecureKeyboardEntryWhenActive): Added. Calls 22 setUseSecureKeyboardEntry only if the frame is active, but also stores away the state, 23 so that the setIsActive function doesn't have to recompute it. 24 (WebCore::Frame::setIsActive): Rewrote all the comments in the function. Removed the code 25 to manage control tints, which are not based on the whether the frame is active but rather 26 on AppKit's concept of whether the window should have "key appearance". Simplified the 27 logic about when to call setUseSecureKeyboardEntry by using the value of 28 m_useSecureKeyboardEntryWhenActive. 29 (WebCore::FramePrivate::FramePrivate): Initialize m_useSecureKeyboardEntryWhenActive. 30 * page/Frame.h: Made setSecureKeyboardEntry private and renamed it to 31 setUseSecureKeyboardEntry, removed isSecureKeyboardEntry, and 32 added a public setUseSecureKeyboardEntryWhenActive. 33 * page/FramePrivate.h: Added m_useSecureKeyboardEntryWhenActive. 34 * page/mac/FrameMac.mm: (WebCore::Frame::setUseSecureKeyboardEntry): Added an assertion, 35 and removed isSecureKeyboardEntry(). 36 37 * page/FrameView.h: Added updateControlTints. 38 * page/FrameView.cpp: (WebCore::FrameView::updateControlTints): Added. Code was moved 39 here from setIsActive for two reasons: (1) it makes more sense in the view class, and 40 (2) it needs to be called at the appropriate time for AppKit, not when active changes. 41 42 * rendering/RenderTheme.cpp: (WebCore::RenderTheme::isFocused): Added an isActive 43 check here to match the logic in the implementation of the CSS pseudo-state. 44 * rendering/RenderThemeMac.mm: 45 (WebCore::RenderThemeMac::updateFocusedState): Use the isFocused function instead of 46 repeating the logic here. Removed the "need to add a key window test here" comment. 47 (WebCore::RenderThemeMac::controlSupportsTints): Added a comment about the NSCell 48 SPI that's related to the _windowChangedKeyState method we now use in WebHTMLView. 49 1 50 2007-04-16 Darin Adler <darin@apple.com> 2 51 -
trunk/WebCore/WebCore.exp
r20837 r20901 441 441 __ZN7WebCore9FrameTree11appendChildEN3WTF10PassRefPtrINS_5FrameEEE 442 442 __ZN7WebCore9FrameTree7setNameERKNS_12AtomicStringE 443 __ZN7WebCore9FrameView18updateControlTintsEv 443 444 __ZN7WebCore9HTMLNames10listingTagE 444 445 __ZN7WebCore9HTMLNames13blockquoteTagE … … 572 573 __ZNK7WebCore5Frame4pageEv 573 574 __ZNK7WebCore5Frame4treeEv 575 __ZNK7WebCore5Frame4viewEv 574 576 __ZNK7WebCore5Frame6bridgeEv 575 577 __ZNK7WebCore5Frame6editorEv -
trunk/WebCore/html/HTMLInputElement.cpp
r20725 r20901 233 233 setAutofilled(false); 234 234 if (inputType() == PASSWORD && document()->frame()) 235 document()->frame()->set SecureKeyboardEntry(true);235 document()->frame()->setUseSecureKeyboardEntryWhenActive(true); 236 236 } 237 237 HTMLGenericFormElement::dispatchFocusEvent(); … … 242 242 if (isTextField() && document()->frame()) { 243 243 if (inputType() == PASSWORD) 244 document()->frame()->set SecureKeyboardEntry(false);244 document()->frame()->setUseSecureKeyboardEntryWhenActive(false); 245 245 document()->frame()->textFieldDidEndEditing(this); 246 246 } -
trunk/WebCore/page/Frame.cpp
r20819 r20901 771 771 772 772 #if !PLATFORM(MAC) 773 void Frame::setSecureKeyboardEntry(bool) 774 { 775 } 776 777 bool Frame::isSecureKeyboardEntry() 778 { 779 return false; 773 774 void Frame::setUseSecureKeyboardEntry(bool) 775 { 780 776 } 781 777 782 778 #endif 779 780 void Frame::setUseSecureKeyboardEntryWhenActive(bool usesSecureKeyboard) 781 { 782 if (d->m_useSecureKeyboardEntryWhenActive == usesSecureKeyboard) 783 return; 784 d->m_useSecureKeyboardEntryWhenActive = usesSecureKeyboard; 785 786 if (d->m_isActive) 787 setUseSecureKeyboardEntry(usesSecureKeyboard); 788 } 783 789 784 790 CSSMutableStyleDeclaration *Frame::typingStyle() const … … 1481 1487 if (d->m_isActive == flag) 1482 1488 return; 1483 1484 1489 d->m_isActive = flag; 1485 1490 1486 // This method does the job of updating the view based on whether the view is "active". 1487 // This involves three kinds of drawing updates: 1488 1489 // 1. The background color used to draw behind selected content (active | inactive color) 1491 // Because RenderObject::selectionBackgroundColor() and 1492 // RenderObject::selectionForegroundColor() check if the frame is active, 1493 // we have to update places those colors were painted. 1490 1494 if (d->m_view) 1491 1495 d->m_view->updateContents(enclosingIntRect(visibleSelectionRect())); 1492 1496 1493 // 2. Caret blinking (blinks | does not blink)1497 // Caret appears in the active frame. 1494 1498 if (flag) 1495 1499 setSelectionFromNone(); 1496 1500 setCaretVisible(flag); 1497 1498 // 3. The drawing of a focus ring around links in web pages.1499 Document *doc = document();1500 if (doc) {1501 Node *node = doc->focusedNode();1502 if ( node) {1501 1502 // Because CSSStyleSelector::checkOneSelector() and 1503 // RenderTheme::isFocused() check if the frame is active, we have to 1504 // update style and theme state that depended on those. 1505 if (d->m_doc) { 1506 if (Node* node = d->m_doc->focusedNode()) { 1503 1507 node->setChanged(); 1504 if (node->renderer() && node->renderer()->style()->hasAppearance()) 1505 theme()->stateChanged(node->renderer(), FocusState); 1508 if (RenderObject* renderer = node->renderer()) 1509 if (renderer && renderer->style()->hasAppearance()) 1510 theme()->stateChanged(renderer, FocusState); 1506 1511 } 1507 1512 } 1508 1509 // 4. Changing the tint of controls from clear to aqua/graphite and vice versa. We 1510 // do a "fake" paint. When the theme gets a paint call, it can then do an invalidate. This is only 1511 // done if the theme supports control tinting. 1512 if (doc && d->m_view && theme()->supportsControlTints() && renderer()) { 1513 doc->updateLayout(); // Ensure layout is up to date. 1514 IntRect visibleRect(enclosingIntRect(d->m_view->visibleContentRect())); 1515 GraphicsContext context((PlatformGraphicsContext*)0); 1516 context.setUpdatingControlTints(true); 1517 paint(&context, visibleRect); 1518 } 1519 1520 // 5. Enable or disable secure keyboard entry 1521 if ((flag && !isSecureKeyboardEntry() && doc && doc->focusedNode() && doc->focusedNode()->hasTagName(inputTag) && 1522 static_cast<HTMLInputElement*>(doc->focusedNode())->inputType() == HTMLInputElement::PASSWORD) || 1523 (!flag && isSecureKeyboardEntry())) 1524 setSecureKeyboardEntry(flag); 1513 1514 // Secure keyboard entry is set by the active frame. 1515 if (d->m_useSecureKeyboardEntryWhenActive) 1516 setUseSecureKeyboardEntry(flag); 1525 1517 } 1526 1518 … … 1871 1863 , m_caretPaint(true) 1872 1864 , m_isActive(false) 1865 , m_useSecureKeyboardEntryWhenActive(false) 1873 1866 , m_lifeSupportTimer(thisFrame, &Frame::lifeSupportTimerFired) 1874 1867 , m_loader(new FrameLoader(thisFrame, frameLoaderClient)) -
trunk/WebCore/page/Frame.h
r20794 r20901 1 1 // -*- c-basic-offset: 4 -*- 2 /* This file is part of the KDE project 3 * 2 /* 4 3 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 5 4 * 1999-2001 Lars Knoll <knoll@kde.org> … … 8 7 * 2000-2001 Dirk Mueller <mueller@kde.org> 9 8 * 2000 Stefan Schimanski <1Stein@gmx.de> 10 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.9 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 11 10 * Copyright (C) 2007 Trolltech ASA 12 11 * … … 43 42 namespace KJS { 44 43 class Interpreter; 45 class JSObject;46 44 47 45 namespace Bindings { … … 53 51 #if PLATFORM(MAC) 54 52 #ifdef __OBJC__ 55 @class WebCoreFrameBridge;56 @class WebScriptObject;57 53 @class NSArray; 58 54 @class NSDictionary; 59 @class NSFont;60 @class NSImage;61 55 @class NSMenu; 62 56 @class NSMutableDictionary; 63 57 @class NSString; 64 58 @class WebCoreFrameBridge; 59 @class WebScriptObject; 65 60 #else 66 class WebCoreFrameBridge;67 class WebScriptObject;68 61 class NSArray; 69 62 class NSDictionary; 70 class NSFont;71 class NSImage;72 63 class NSMenu; 73 64 class NSMutableDictionary; 74 65 class NSString; 75 66 class WebCoreFrameBridge; 76 typedef unsigned int NSDragOperation;67 class WebScriptObject; 77 68 typedef int NSWritingDirection; 78 69 #endif … … 106 97 class Page; 107 98 class Range; 108 class RenderObject;109 99 class RenderPart; 110 class RenderStyle;111 100 class Selection; 112 101 class SelectionController; … … 179 168 // should move to FrameView 180 169 void paint(GraphicsContext*, const IntRect&); 181 void setPaintRestriction(PaintRestriction pr);170 void setPaintRestriction(PaintRestriction); 182 171 183 172 void setUserStyleSheetLocation(const KURL&); … … 326 315 bool isContentEditable() const; // if true, everything in frame is editable 327 316 328 void setSecureKeyboardEntry(bool); 329 bool isSecureKeyboardEntry(); 317 void setUseSecureKeyboardEntryWhenActive(bool); 330 318 331 319 CSSMutableStyleDeclaration* typingStyle() const; … … 344 332 private: 345 333 void caretBlinkTimerFired(Timer<Frame>*); 334 void setUseSecureKeyboardEntry(bool); 346 335 347 336 // === to be moved into the Platform directory … … 360 349 361 350 #if PLATFORM(MAC) 351 362 352 // === undecided, may or may not belong here 363 353 … … 380 370 381 371 public: 382 383 372 FloatRect customHighlightLineRect(const AtomicString& type, const FloatRect& lineRect, Node*); 384 373 void paintCustomHighlight(const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect, bool text, bool line, Node*); … … 387 376 388 377 public: 389 390 378 NSDictionary* fontAttributesForSelectionStart() const; 391 379 NSWritingDirection baseWritingDirectionForSelectionStart() const; 392 380 393 381 void setMarkedTextRange(const Range* , NSArray* attributes, NSArray* ranges); 394 #endif 382 383 #endif 384 395 385 }; 396 386 -
trunk/WebCore/page/FramePrivate.h
r19811 r20901 98 98 bool m_caretPaint : 1; 99 99 bool m_isActive : 1; 100 bool m_useSecureKeyboardEntryWhenActive : 1; 100 101 101 102 RefPtr<CSSMutableStyleDeclaration> m_typingStyle; -
trunk/WebCore/page/FrameView.cpp
r20794 r20901 1 /* This file is part of the KDE project 2 * 1 /* 3 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 4 3 * 1999 Lars Knoll <knoll@kde.org> 5 4 * 1999 Antti Koivisto <koivisto@kde.org> 6 5 * 2000 Dirk Mueller <mueller@kde.org> 7 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.6 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 8 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 9 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) … … 34 33 #include "FrameLoader.h" 35 34 #include "FrameLoaderClient.h" 35 #include "GraphicsContext.h" 36 36 #include "HTMLDocument.h" 37 37 #include "HTMLFrameSetElement.h" … … 39 39 #include "OverflowEvent.h" 40 40 #include "RenderPart.h" 41 #include "RenderTheme.h" 41 42 #include "RenderView.h" 42 43 … … 894 895 } 895 896 896 } 897 void FrameView::updateControlTints() 898 { 899 // This is called when control tints are changed from aqua/graphite to clear and vice versa. 900 // We do a "fake" paint, and when the theme gets a paint call, it can then do an invalidate. 901 // This is only done if the theme supports control tinting. It's up to the theme and platform 902 // to define when controls get the tint and to call this function when that changes. 903 Document* doc = m_frame->document(); 904 if (doc && theme()->supportsControlTints() && m_frame->renderer()) { 905 doc->updateLayout(); // Ensure layout is up to date. 906 PlatformGraphicsContext* const noContext = 0; 907 GraphicsContext context(noContext); 908 context.setUpdatingControlTints(true); 909 m_frame->paint(&context, enclosingIntRect(visibleContentRect())); 910 } 911 } 912 913 } -
trunk/WebCore/page/FrameView.h
r20794 r20901 122 122 123 123 void updateDashboardRegions(); 124 void updateControlTints(); 124 125 125 126 void restoreScrollbar(); -
trunk/WebCore/page/mac/FrameMac.mm
r20404 r20901 507 507 508 508 const short enableRomanKeyboardsOnly = -23; 509 void Frame::setSecureKeyboardEntry(bool enable) 510 { 509 void Frame::setUseSecureKeyboardEntry(bool enable) 510 { 511 // Caller is responsible for only calling when it's an actual change. 512 ASSERT(enable != IsSecureEventInputEnabled()); 511 513 if (enable) { 512 514 EnableSecureEventInput(); 513 // FIXME: KeyScript is deprecated in Leopard, we need a new solution for this<rdar://problem/4727607>515 // FIXME: Since KeyScript is deprecated in Leopard, we need a new solution for this. <rdar://problem/4727607> 514 516 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 515 517 KeyScript(enableRomanKeyboardsOnly); … … 521 523 #endif 522 524 } 523 }524 525 bool Frame::isSecureKeyboardEntry()526 {527 return IsSecureEventInputEnabled();528 525 } 529 526 -
trunk/WebCore/rendering/RenderTheme.cpp
r18263 r20901 24 24 25 25 #include "Document.h" 26 #include "Frame.h" 26 27 #include "GraphicsContext.h" 27 28 #include "HTMLInputElement.h" … … 355 356 bool RenderTheme::isFocused(const RenderObject* o) const 356 357 { 357 if (!o->element()) 358 return false; 359 return o->element() == o->element()->document()->focusedNode(); 358 Node* node = o->element(); 359 if (!node) 360 return false; 361 Document* document = node->document(); 362 Frame* frame = document->frame(); 363 return node == document->focusedNode() && frame && frame->isActive(); 360 364 } 361 365 -
trunk/WebCore/rendering/RenderThemeMac.mm
r20475 r20901 258 258 void RenderThemeMac::updateFocusedState(NSCell* cell, const RenderObject* o) 259 259 { 260 // FIXME: Need to add a key window test here, or the element will look261 // focused even when in the background.262 260 bool oldFocused = [cell showsFirstResponder]; 263 bool focused = (o->element() && o->document()->focusedNode() == o->element()) && (o->style()->outlineStyleIsAuto());261 bool focused = isFocused(o) && o->style()->outlineStyleIsAuto(); 264 262 if (focused != oldFocused) 265 263 [cell setShowsFirstResponder:focused]; … … 283 281 bool RenderThemeMac::controlSupportsTints(const RenderObject* o) const 284 282 { 283 // An alternate way to implement this would be to get the appropriate cell object 284 // and call the private _needRedrawOnWindowChangedKeyState method. An advantage of 285 // that would be that we would match AppKit behavior more closely, but a disadvantage 286 // would be that we would rely on an AppKit SPI method. 287 285 288 if (!isEnabled(o)) 286 289 return false; -
trunk/WebKit/ChangeLog
r20888 r20901 1 2007-04-16 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=13303 6 <rdar://problem/5126341> REGRESSION: controls in a background Safari window 7 maintain active appearance if the address bar has focus (13303) 8 9 * WebView/WebHTMLView.mm: (-[WebHTMLView _windowChangedKeyState]): 10 Added. Calls FrameView::updateControlTints. 11 1 12 2007-04-13 Oliver Hunt <oliver@apple.com> 2 13 -
trunk/WebKit/WebView/WebHTMLView.mm
r20814 r20901 83 83 #import <WebCore/Frame.h> 84 84 #import <WebCore/FrameLoader.h> 85 #import <WebCore/FrameView.h> 85 86 #import <WebCore/HitTestResult.h> 86 87 #import <WebCore/Image.h> … … 129 130 - (void)_setDrawsOwnDescendants:(BOOL)drawsOwnDescendants; 130 131 - (void)_propagateDirtyRectsToOpaqueAncestors; 132 - (void)_windowChangedKeyState; 131 133 @end 132 134 … … 4893 4895 } 4894 4896 4897 // Despite its name, this is called at different times than windowDidBecomeKey is. 4898 // It takes into account all the other factors that determine when NSCell draws 4899 // with different tints, so it's the right call to use for control tints. We'd prefer 4900 // to do this with API. <rdar://problem/5136760> 4901 - (void)_windowChangedKeyState 4902 { 4903 if (Frame* frame = core([self _frame])) 4904 if (FrameView* view = frame->view()) 4905 view->updateControlTints(); 4906 [super _windowChangedKeyState]; 4907 } 4908 4895 4909 @end 4896 4910
Note:
See TracChangeset
for help on using the changeset viewer.