Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Enumerations | Functions | Variables
nsChildView.mm File Reference
#include <unistd.h>
#include "nsChildView.h"
#include "nsCOMPtr.h"
#include "nsToolkit.h"
#include "prmem.h"
#include "nsCRT.h"
#include "nsplugindefs.h"
#include "nsIFontMetrics.h"
#include "nsIDeviceContext.h"
#include "nsIEnumerator.h"
#include "nsIRegion.h"
#include "nsIRollupListener.h"
#include "nsIEventSink.h"
#include "nsIScrollableView.h"
#include "nsIInterfaceRequestor.h"
#include "nsIServiceManager.h"
#include "nsCarbonHelpers.h"
#include "nsGfxUtils.h"
#include "nsMacResources.h"
#include "nsIQDFlushManager.h"
#import "nsCursorManager.h"
#import "nsWindowMap.h"

Go to the source code of this file.

Classes

class  NSView(ChildViewExtensions)
class  ChildView(Private)

Defines

#define NSAppKitVersionNumber10_2   663
#define MAX_BUFFER_SIZE   32

Enumerations

enum  {
  kEscapeKeyCode = 0x35, kCommandKeyCode = 0x37, kShiftKeyCode = 0x38, kCapsLockKeyCode = 0x39,
  kControlKeyCode = 0x3B, kOptionkeyCode = 0x3A, kClearKeyCode = 0x47, kF1KeyCode = 0x7A,
  kF2KeyCode = 0x78, kF3KeyCode = 0x63, kF4KeyCode = 0x76, kF5KeyCode = 0x60,
  kF6KeyCode = 0x61, kF7KeyCode = 0x62, kF8KeyCode = 0x64, kF9KeyCode = 0x65,
  kF10KeyCode = 0x6D, kF11KeyCode = 0x67, kF12KeyCode = 0x6F, kF13KeyCode = 0x69,
  kF14KeyCode = 0x6B, kF15KeyCode = 0x71, kPrintScreenKeyCode = kF13KeyCode, kScrollLockKeyCode = kF14KeyCode,
  kPauseKeyCode = kF15KeyCode, kKeypad0KeyCode = 0x52, kKeypad1KeyCode = 0x53, kKeypad2KeyCode = 0x54,
  kKeypad3KeyCode = 0x55, kKeypad4KeyCode = 0x56, kKeypad5KeyCode = 0x57, kKeypad6KeyCode = 0x58,
  kKeypad7KeyCode = 0x59, kKeypad8KeyCode = 0x5B, kKeypad9KeyCode = 0x5C, kKeypadMultiplyKeyCode = 0x43,
  kKeypadAddKeyCode = 0x45, kKeypadSubtractKeyCode = 0x4E, kKeypadDecimalKeyCode = 0x41, kKeypadDivideKeyCode = 0x4B,
  kKeypadEqualsKeyCode = 0x51, kEnterKeyCode = 0x4C, kReturnKeyCode = 0x24, kPowerbookEnterKeyCode = 0x34,
  kInsertKeyCode = 0x72, kDeleteKeyCode = 0x75, kTabKeyCode = 0x30, kBackspaceKeyCode = 0x33,
  kHomeKeyCode = 0x73, kEndKeyCode = 0x77, kPageUpKeyCode = 0x74, kPageDownKeyCode = 0x79,
  kLeftArrowKeyCode = 0x7B, kRightArrowKeyCode = 0x7C, kUpArrowKeyCode = 0x7E, kDownArrowKeyCode = 0x7D
}

Functions

static void ConvertGeckoToCocoaRect (const nsRect &inGeckoRect, NSRect &outCocoaRect)
static void ConvertCocoaToGeckoRect (const NSRect &inCocoaRect, nsRect &outGeckoRect)
static void ConvertGeckoRectToMacRect (const nsRect &aRect, Rect &outMacRect)
static PRUint32 UnderlineAttributeToTextRangeType (PRUint32 aUnderlineStyle, NSRange selRange)
static PRUint32 CountRanges (NSAttributedString *aString)
static void ConvertAttributeToGeckoRange (NSAttributedString *aString, NSRange markRange, NSRange selRange, PRUint32 inCount, nsTextRange *aRanges)
static void FillTextRangeInTextEvent (nsTextEvent *aTextEvent, NSAttributedString *aString, NSRange markRange, NSRange selRange)
PRUint16 COLOR8TOCOLOR16 (PRUint8 color8)

Variables

nsIRollupListenergRollupListener = nsnull
nsIWidgetgRollupWidget = nsnull

Class Documentation

class NSView(ChildViewExtensions)

Definition at line 70 of file nsChildView.mm.


Define Documentation

Definition at line 3090 of file nsChildView.mm.

Definition at line 67 of file nsChildView.mm.


Enumeration Type Documentation

anonymous enum
Enumerator:
kEscapeKeyCode 
kCommandKeyCode 
kShiftKeyCode 
kCapsLockKeyCode 
kControlKeyCode 
kOptionkeyCode 
kClearKeyCode 
kF1KeyCode 
kF2KeyCode 
kF3KeyCode 
kF4KeyCode 
kF5KeyCode 
kF6KeyCode 
kF7KeyCode 
kF8KeyCode 
kF9KeyCode 
kF10KeyCode 
kF11KeyCode 
kF12KeyCode 
kF13KeyCode 
kF14KeyCode 
kF15KeyCode 
kPrintScreenKeyCode 
kScrollLockKeyCode 
kPauseKeyCode 
kKeypad0KeyCode 
kKeypad1KeyCode 
kKeypad2KeyCode 
kKeypad3KeyCode 
kKeypad4KeyCode 
kKeypad5KeyCode 
kKeypad6KeyCode 
kKeypad7KeyCode 
kKeypad8KeyCode 
kKeypad9KeyCode 
kKeypadMultiplyKeyCode 
kKeypadAddKeyCode 
kKeypadSubtractKeyCode 
kKeypadDecimalKeyCode 
kKeypadDivideKeyCode 
kKeypadEqualsKeyCode 
kEnterKeyCode 
kReturnKeyCode 
kPowerbookEnterKeyCode 
kInsertKeyCode 
kDeleteKeyCode 
kTabKeyCode 
kBackspaceKeyCode 
kHomeKeyCode 
kEndKeyCode 
kPageUpKeyCode 
kPageDownKeyCode 
kLeftArrowKeyCode 
kRightArrowKeyCode 
kUpArrowKeyCode 
kDownArrowKeyCode 

Definition at line 3561 of file nsChildView.mm.

{
  kEscapeKeyCode      = 0x35,
  kCommandKeyCode     = 0x37,
  kShiftKeyCode       = 0x38,
  kCapsLockKeyCode    = 0x39,
  kControlKeyCode     = 0x3B,
  kOptionkeyCode      = 0x3A,   // left and right option keys
  kClearKeyCode       = 0x47,
  
  // function keys
  kF1KeyCode          = 0x7A,
  kF2KeyCode          = 0x78,
  kF3KeyCode          = 0x63,
  kF4KeyCode          = 0x76,
  kF5KeyCode          = 0x60,
  kF6KeyCode          = 0x61,
  kF7KeyCode          = 0x62,
  kF8KeyCode          = 0x64,
  kF9KeyCode          = 0x65,
  kF10KeyCode         = 0x6D,
  kF11KeyCode         = 0x67,
  kF12KeyCode         = 0x6F,
  kF13KeyCode         = 0x69,
  kF14KeyCode         = 0x6B,
  kF15KeyCode         = 0x71,
  
  kPrintScreenKeyCode = kF13KeyCode,
  kScrollLockKeyCode  = kF14KeyCode,
  kPauseKeyCode       = kF15KeyCode,
  
  // keypad
  kKeypad0KeyCode     = 0x52,
  kKeypad1KeyCode     = 0x53,
  kKeypad2KeyCode     = 0x54,
  kKeypad3KeyCode     = 0x55,
  kKeypad4KeyCode     = 0x56,
  kKeypad5KeyCode     = 0x57,
  kKeypad6KeyCode     = 0x58,
  kKeypad7KeyCode     = 0x59,
  kKeypad8KeyCode     = 0x5B,
  kKeypad9KeyCode     = 0x5C,
  
  kKeypadMultiplyKeyCode  = 0x43,
  kKeypadAddKeyCode       = 0x45,
  kKeypadSubtractKeyCode  = 0x4E,
  kKeypadDecimalKeyCode   = 0x41,
  kKeypadDivideKeyCode    = 0x4B,
  kKeypadEqualsKeyCode    = 0x51,     // no correpsonding raptor key code
  kEnterKeyCode           = 0x4C,
  kReturnKeyCode          = 0x24,
  kPowerbookEnterKeyCode  = 0x34,     // Enter on Powerbook's keyboard is different
  
  kInsertKeyCode          = 0x72,       // also help key
  kDeleteKeyCode          = 0x75,       // also forward delete key
  kTabKeyCode             = 0x30,
  kBackspaceKeyCode       = 0x33,
  kHomeKeyCode            = 0x73, 
  kEndKeyCode             = 0x77,
  kPageUpKeyCode          = 0x74,
  kPageDownKeyCode        = 0x79,
  kLeftArrowKeyCode       = 0x7B,
  kRightArrowKeyCode      = 0x7C,
  kUpArrowKeyCode         = 0x7E,
  kDownArrowKeyCode       = 0x7D
  
};

Function Documentation

PRUint16 COLOR8TOCOLOR16 ( PRUint8  color8) [inline]

Definition at line 1255 of file nsChildView.mm.

{
  // return (color8 == 0xFF ? 0xFFFF : (color8 << 8));
  return (color8 << 8) | color8;  /* (color8 * 257) == (color8 * 0x0101) */
}
static void ConvertAttributeToGeckoRange ( NSAttributedString *  aString,
NSRange  markRange,
NSRange  selRange,
PRUint32  inCount,
nsTextRange aRanges 
) [static]

Definition at line 248 of file nsChildView.mm.

{
  // Convert the Cocoa range into the nsTextRange Array used in Gecko.
  // Iterate through the attributed string and map the underline attribute to Gecko IME textrange attributes.
  // We may need to change the code here if we change the implementation of validAttributesForMarkedText.
  PRUint32 i = 0;
  NSRange effectiveRange;
  NSRange limitRange = NSMakeRange(0, [aString length]);
  while ((limitRange.length > 0) && (i < inCount)) {
    id attributeValue = [aString attribute:NSUnderlineStyleAttributeName 
                              atIndex:limitRange.location 
                              longestEffectiveRange:&effectiveRange
                              inRange:limitRange];
    aRanges[i].mStartOffset = effectiveRange.location;                         
    aRanges[i].mEndOffset = NSMaxRange(effectiveRange);                         
    aRanges[i].mRangeType = UnderlineAttributeToTextRangeType([attributeValue intValue], selRange); 
    limitRange = NSMakeRange(NSMaxRange(effectiveRange), 
                             NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
    i++;
  }
  // Get current caret position.
  // Caret is indicator of insertion point, so mEndOffset = 0.
  aRanges[i].mStartOffset = selRange.location + selRange.length;                         
  aRanges[i].mEndOffset = 0;                         
  aRanges[i].mRangeType = NS_TEXTRANGE_CARETPOSITION;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ConvertCocoaToGeckoRect ( const NSRect &  inCocoaRect,
nsRect outGeckoRect 
) [inline, static]

Definition at line 167 of file nsChildView.mm.

{
  outGeckoRect.x = NS_STATIC_CAST(nscoord, inCocoaRect.origin.x);
  outGeckoRect.y = NS_STATIC_CAST(nscoord, inCocoaRect.origin.y);
  outGeckoRect.width = NS_STATIC_CAST(nscoord, inCocoaRect.size.width);
  outGeckoRect.height = NS_STATIC_CAST(nscoord, inCocoaRect.size.height);
}

Here is the caller graph for this function:

static void ConvertGeckoRectToMacRect ( const nsRect aRect,
Rect &  outMacRect 
) [inline, static]

Definition at line 177 of file nsChildView.mm.

{
  outMacRect.left = aRect.x;
  outMacRect.top = aRect.y;
  outMacRect.right = aRect.x + aRect.width;
  outMacRect.bottom = aRect.y + aRect.height;
}

Here is the caller graph for this function:

static void ConvertGeckoToCocoaRect ( const nsRect inGeckoRect,
NSRect &  outCocoaRect 
) [inline, static]

Definition at line 158 of file nsChildView.mm.

{
  outCocoaRect.origin.x = inGeckoRect.x;
  outCocoaRect.origin.y = inGeckoRect.y;
  outCocoaRect.size.width = inGeckoRect.width;
  outCocoaRect.size.height = inGeckoRect.height;
}

Here is the caller graph for this function:

static PRUint32 CountRanges ( NSAttributedString *  aString) [static]

Definition at line 228 of file nsChildView.mm.

{
  // Iterate through aString for the NSUnderlineStyleAttributeName and count the 
  // different segments adjusting limitRange as we go.
  PRUint32 count = 0;
  NSRange effectiveRange;
  NSRange limitRange = NSMakeRange(0, [aString length]);
  while (limitRange.length > 0) {
    [aString attribute:NSUnderlineStyleAttributeName 
             atIndex:limitRange.location 
             longestEffectiveRange:&effectiveRange
             inRange:limitRange];
    limitRange = NSMakeRange(NSMaxRange(effectiveRange), 
                             NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
    count++;
  }
  return count;
}

Here is the caller graph for this function:

static void FillTextRangeInTextEvent ( nsTextEvent aTextEvent,
NSAttributedString *  aString,
NSRange  markRange,
NSRange  selRange 
) [static]

Definition at line 276 of file nsChildView.mm.

{ 
  // Count the number of segments in the attributed string and add one more count for sending current caret position to Gecko.
  // Allocate the right size of nsTextRange and draw caret at right position.
  // Convert the attributed string into an array of nsTextRange and get current caret position by calling above functions.
  PRUint32 count = CountRanges(aString) + 1;
  aTextEvent->rangeArray = new nsTextRange[count];
  if (aTextEvent->rangeArray)
  {
    aTextEvent->rangeCount = count;
    ConvertAttributeToGeckoRange(aString, markRange, selRange, aTextEvent->rangeCount,  aTextEvent->rangeArray);
  } 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRUint32 UnderlineAttributeToTextRangeType ( PRUint32  aUnderlineStyle,
NSRange  selRange 
) [static]

Definition at line 186 of file nsChildView.mm.

{
#ifdef DEBUG_IME
  NSLog(@"****in underlineAttributeToTextRangeType = %d", aUnderlineStyle);
#endif

  // For more info on the underline attribute, please see: 
  // http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingTopics/AttributedStrings/Tasks/AccessingAttrs.html
  // We are not clear where the define for value 2 is right now. 
  // To see this value in japanese ime, type 'aaaaaaaaa' and hit space to make the
  // ime send you some part of text in 1 (NSSingleUnderlineStyle) and some part in 2. 
  // ftang will ask apple for more details
  //
  // it probably means show 1-pixel thickness underline vs 2-pixel thickness
  
  PRUint32 attr;
  if (selRange.length == 0) {
    switch (aUnderlineStyle) {
      case 1:
        attr = NS_TEXTRANGE_RAWINPUT;
        break;
      case 2:
      default:
        attr = NS_TEXTRANGE_SELECTEDRAWTEXT;
        break;
    }
  }
  else {
    switch (aUnderlineStyle) {
      case 1:
        attr = NS_TEXTRANGE_CONVERTEDTEXT;
        break;
      case 2:
      default:
        attr = NS_TEXTRANGE_SELECTEDCONVERTEDTEXT;
        break;
    }
  }
  return attr;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 137 of file nsChildView.mm.

Definition at line 138 of file nsChildView.mm.