Home | History | Annotate | Download | only in WebCoreSupport
      1 /*
      2  * Copyright (C) 2005, 2009 Apple Computer, Inc.  All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *
      8  * 1.  Redistributions of source code must retain the above copyright
      9  *     notice, this list of conditions and the following disclaimer.
     10  * 2.  Redistributions in binary form must reproduce the above copyright
     11  *     notice, this list of conditions and the following disclaimer in the
     12  *     documentation and/or other materials provided with the distribution.
     13  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
     14  *     its contributors may be used to endorse or promote products derived
     15  *     from this software without specific prior written permission.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #import <WebKit/WebViewFactory.h>
     30 
     31 #import <WebKit/WebFrameInternal.h>
     32 #import <WebKit/WebViewInternal.h>
     33 #import <WebKit/WebHTMLViewInternal.h>
     34 #import <WebKit/WebLocalizableStrings.h>
     35 #import <WebKit/WebNSUserDefaultsExtras.h>
     36 #import <WebKit/WebNSObjectExtras.h>
     37 #import <WebKit/WebNSViewExtras.h>
     38 #import <WebKit/WebPluginDatabase.h>
     39 #import <WebKitSystemInterface.h>
     40 #import <wtf/Assertions.h>
     41 
     42 @interface NSMenu (WebViewFactoryAdditions)
     43 - (NSMenuItem *)addItemWithTitle:(NSString *)title action:(SEL)action tag:(int)tag;
     44 @end
     45 
     46 @implementation NSMenu (WebViewFactoryAdditions)
     47 
     48 - (NSMenuItem *)addItemWithTitle:(NSString *)title action:(SEL)action tag:(int)tag
     49 {
     50     NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title action:action keyEquivalent:@""] autorelease];
     51     [item setTag:tag];
     52     [self addItem:item];
     53     return item;
     54 }
     55 
     56 @end
     57 
     58 @implementation WebViewFactory
     59 
     60 + (void)createSharedFactory
     61 {
     62     if (![self sharedFactory]) {
     63         [[[self alloc] init] release];
     64     }
     65     ASSERT([[self sharedFactory] isKindOfClass:self]);
     66 }
     67 
     68 - (NSArray *)pluginsInfo
     69 {
     70     return [[WebPluginDatabase sharedDatabase] plugins];
     71 }
     72 
     73 - (void)refreshPlugins
     74 {
     75     [[WebPluginDatabase sharedDatabase] refresh];
     76 }
     77 
     78 - (NSString *)inputElementAltText
     79 {
     80     return UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value");
     81 }
     82 
     83 - (NSString *)resetButtonDefaultLabel
     84 {
     85     return UI_STRING("Reset", "default label for Reset buttons in forms on web pages");
     86 }
     87 
     88 - (NSString *)searchableIndexIntroduction
     89 {
     90     return UI_STRING("This is a searchable index. Enter search keywords: ",
     91         "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'");
     92 }
     93 
     94 - (NSString *)submitButtonDefaultLabel
     95 {
     96     return UI_STRING("Submit", "default label for Submit buttons in forms on web pages");
     97 }
     98 
     99 - (NSString *)fileButtonChooseFileLabel
    100 {
    101     return UI_STRING("Choose File", "title for file button used in HTML forms");
    102 }
    103 
    104 - (NSString *)fileButtonNoFileSelectedLabel
    105 {
    106     return UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected");
    107 }
    108 
    109 - (NSString *)copyImageUnknownFileLabel
    110 {
    111     return UI_STRING("unknown", "Unknown filename");
    112 }
    113 
    114 - (NSString *)searchMenuNoRecentSearchesText
    115 {
    116     return UI_STRING("No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed");
    117 }
    118 
    119 - (NSString *)searchMenuRecentSearchesText
    120 {
    121     return UI_STRING("Recent Searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title");
    122 }
    123 
    124 - (NSString *)searchMenuClearRecentSearchesText
    125 {
    126     return UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents");
    127 }
    128 
    129 - (NSString *)defaultLanguageCode
    130 {
    131     return [NSUserDefaults _webkit_preferredLanguageCode];
    132 }
    133 
    134 - (NSString *)contextMenuItemTagOpenLinkInNewWindow
    135 {
    136     return UI_STRING("Open Link in New Window", "Open in New Window context menu item");
    137 }
    138 
    139 - (NSString *)contextMenuItemTagDownloadLinkToDisk
    140 {
    141     return UI_STRING("Download Linked File", "Download Linked File context menu item");
    142 }
    143 
    144 - (NSString *)contextMenuItemTagCopyLinkToClipboard
    145 {
    146     return UI_STRING("Copy Link", "Copy Link context menu item");
    147 }
    148 
    149 - (NSString *)contextMenuItemTagOpenImageInNewWindow
    150 {
    151     return UI_STRING("Open Image in New Window", "Open Image in New Window context menu item");
    152 }
    153 
    154 - (NSString *)contextMenuItemTagDownloadImageToDisk
    155 {
    156     return UI_STRING("Download Image", "Download Image context menu item");
    157 }
    158 
    159 - (NSString *)contextMenuItemTagCopyImageToClipboard
    160 {
    161     return UI_STRING("Copy Image", "Copy Image context menu item");
    162 }
    163 
    164 - (NSString *)contextMenuItemTagOpenFrameInNewWindow
    165 {
    166     return UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item");
    167 }
    168 
    169 - (NSString *)contextMenuItemTagCopy
    170 {
    171     return UI_STRING("Copy", "Copy context menu item");
    172 }
    173 
    174 - (NSString *)contextMenuItemTagGoBack
    175 {
    176     return UI_STRING("Back", "Back context menu item");
    177 }
    178 
    179 - (NSString *)contextMenuItemTagGoForward
    180 {
    181     return UI_STRING("Forward", "Forward context menu item");
    182 }
    183 
    184 - (NSString *)contextMenuItemTagStop
    185 {
    186     return UI_STRING("Stop", "Stop context menu item");
    187 }
    188 
    189 - (NSString *)contextMenuItemTagReload
    190 {
    191     return UI_STRING("Reload", "Reload context menu item");
    192 }
    193 
    194 - (NSString *)contextMenuItemTagCut
    195 {
    196     return UI_STRING("Cut", "Cut context menu item");
    197 }
    198 
    199 - (NSString *)contextMenuItemTagPaste
    200 {
    201     return UI_STRING("Paste", "Paste context menu item");
    202 }
    203 
    204 - (NSString *)contextMenuItemTagNoGuessesFound
    205 {
    206     return UI_STRING("No Guesses Found", "No Guesses Found context menu item");
    207 }
    208 
    209 - (NSString *)contextMenuItemTagIgnoreSpelling
    210 {
    211     return UI_STRING("Ignore Spelling", "Ignore Spelling context menu item");
    212 }
    213 
    214 - (NSString *)contextMenuItemTagLearnSpelling
    215 {
    216     return UI_STRING("Learn Spelling", "Learn Spelling context menu item");
    217 }
    218 
    219 - (NSString *)contextMenuItemTagSearchInSpotlight
    220 {
    221     return UI_STRING("Search in Spotlight", "Search in Spotlight context menu item");
    222 }
    223 
    224 - (NSString *)contextMenuItemTagSearchWeb
    225 {
    226     return UI_STRING("Search in Google", "Search in Google context menu item");
    227 }
    228 
    229 - (NSString *)contextMenuItemTagLookUpInDictionary
    230 {
    231     return UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item");
    232 }
    233 
    234 - (NSString *)contextMenuItemTagOpenLink
    235 {
    236     return UI_STRING("Open Link", "Open Link context menu item");
    237 }
    238 
    239 - (NSString *)contextMenuItemTagIgnoreGrammar
    240 {
    241     return UI_STRING("Ignore Grammar", "Ignore Grammar context menu item");
    242 }
    243 
    244 - (NSString *)contextMenuItemTagSpellingMenu
    245 {
    246 #ifndef BUILDING_ON_TIGER
    247     return UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item");
    248 #else
    249     return UI_STRING("Spelling", "Spelling context sub-menu item");
    250 #endif
    251 }
    252 
    253 - (NSString *)contextMenuItemTagShowSpellingPanel:(bool)show
    254 {
    255 #ifndef BUILDING_ON_TIGER
    256     if (show)
    257         return UI_STRING("Show Spelling and Grammar", "menu item title");
    258     return UI_STRING("Hide Spelling and Grammar", "menu item title");
    259 #else
    260     return UI_STRING("Spelling...", "menu item title");
    261 #endif
    262 }
    263 
    264 - (NSString *)contextMenuItemTagCheckSpelling
    265 {
    266 #ifndef BUILDING_ON_TIGER
    267     return UI_STRING("Check Document Now", "Check spelling context menu item");
    268 #else
    269     return UI_STRING("Check Spelling", "Check spelling context menu item");
    270 #endif
    271 }
    272 
    273 - (NSString *)contextMenuItemTagCheckSpellingWhileTyping
    274 {
    275 #ifndef BUILDING_ON_TIGER
    276     return UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item");
    277 #else
    278     return UI_STRING("Check Spelling as You Type", "Check spelling while typing context menu item");
    279 #endif
    280 }
    281 
    282 - (NSString *)contextMenuItemTagCheckGrammarWithSpelling
    283 {
    284     return UI_STRING("Check Grammar With Spelling", "Check grammar with spelling context menu item");
    285 }
    286 
    287 - (NSString *)contextMenuItemTagFontMenu
    288 {
    289     return UI_STRING("Font", "Font context sub-menu item");
    290 }
    291 
    292 - (NSString *)contextMenuItemTagShowFonts
    293 {
    294     return UI_STRING("Show Fonts", "Show fonts context menu item");
    295 }
    296 
    297 - (NSString *)contextMenuItemTagBold
    298 {
    299     return UI_STRING("Bold", "Bold context menu item");
    300 }
    301 
    302 - (NSString *)contextMenuItemTagItalic
    303 {
    304     return UI_STRING("Italic", "Italic context menu item");
    305 }
    306 
    307 - (NSString *)contextMenuItemTagUnderline
    308 {
    309     return UI_STRING("Underline", "Underline context menu item");
    310 }
    311 
    312 - (NSString *)contextMenuItemTagOutline
    313 {
    314     return UI_STRING("Outline", "Outline context menu item");
    315 }
    316 
    317 - (NSString *)contextMenuItemTagStyles
    318 {
    319     return UI_STRING("Styles...", "Styles context menu item");
    320 }
    321 
    322 - (NSString *)contextMenuItemTagShowColors
    323 {
    324     return UI_STRING("Show Colors", "Show colors context menu item");
    325 }
    326 
    327 - (NSString *)contextMenuItemTagSpeechMenu
    328 {
    329     return UI_STRING("Speech", "Speech context sub-menu item");
    330 }
    331 
    332 - (NSString *)contextMenuItemTagStartSpeaking
    333 {
    334     return UI_STRING("Start Speaking", "Start speaking context menu item");
    335 }
    336 
    337 - (NSString *)contextMenuItemTagStopSpeaking
    338 {
    339     return UI_STRING("Stop Speaking", "Stop speaking context menu item");
    340 }
    341 
    342 - (NSString *)contextMenuItemTagWritingDirectionMenu
    343 {
    344 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
    345     return UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item");
    346 #else
    347     return UI_STRING("Writing Direction", "Writing direction context sub-menu item");
    348 #endif
    349 }
    350 
    351 - (NSString *)contextMenuItemTagTextDirectionMenu
    352 {
    353     return UI_STRING("Selection Direction", "Selection direction context sub-menu item");
    354 }
    355 
    356 - (NSString *)contextMenuItemTagDefaultDirection
    357 {
    358     return UI_STRING("Default", "Default writing direction context menu item");
    359 }
    360 
    361 - (NSString *)contextMenuItemTagLeftToRight
    362 {
    363     return UI_STRING("Left to Right", "Left to Right context menu item");
    364 }
    365 
    366 - (NSString *)contextMenuItemTagRightToLeft
    367 {
    368     return UI_STRING("Right to Left", "Right to Left context menu item");
    369 }
    370 
    371 - (NSString *)contextMenuItemTagCorrectSpellingAutomatically
    372 {
    373     return UI_STRING("Correct Spelling Automatically", "Correct Spelling Automatically context menu item");
    374 }
    375 
    376 - (NSString *)contextMenuItemTagSubstitutionsMenu
    377 {
    378     return UI_STRING("Substitutions", "Substitutions context sub-menu item");
    379 }
    380 
    381 - (NSString *)contextMenuItemTagShowSubstitutions:(bool)show
    382 {
    383     if (show)
    384         return UI_STRING("Show Substitutions", "menu item title");
    385     return UI_STRING("Hide Substitutions", "menu item title");
    386 }
    387 
    388 - (NSString *)contextMenuItemTagSmartCopyPaste
    389 {
    390     return UI_STRING("Smart Copy/Paste", "Smart Copy/Paste context menu item");
    391 }
    392 
    393 - (NSString *)contextMenuItemTagSmartQuotes
    394 {
    395     return UI_STRING("Smart Quotes", "Smart Quotes context menu item");
    396 }
    397 
    398 - (NSString *)contextMenuItemTagSmartDashes
    399 {
    400     return UI_STRING("Smart Dashes", "Smart Dashes context menu item");
    401 }
    402 
    403 - (NSString *)contextMenuItemTagSmartLinks
    404 {
    405     return UI_STRING("Smart Links", "Smart Links context menu item");
    406 }
    407 
    408 - (NSString *)contextMenuItemTagTextReplacement
    409 {
    410     return UI_STRING("Text Replacement", "Text Replacement context menu item");
    411 }
    412 
    413 - (NSString *)contextMenuItemTagTransformationsMenu
    414 {
    415     return UI_STRING("Transformations", "Transformations context sub-menu item");
    416 }
    417 
    418 - (NSString *)contextMenuItemTagMakeUpperCase
    419 {
    420     return UI_STRING("Make Upper Case", "Make Upper Case context menu item");
    421 }
    422 
    423 - (NSString *)contextMenuItemTagMakeLowerCase
    424 {
    425     return UI_STRING("Make Lower Case", "Make Lower Case context menu item");
    426 }
    427 
    428 - (NSString *)contextMenuItemTagCapitalize
    429 {
    430     return UI_STRING("Capitalize", "Capitalize context menu item");
    431 }
    432 
    433 - (NSString *)contextMenuItemTagChangeBack:(NSString *)replacedString
    434 {
    435     static NSString *formatString = nil;
    436 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
    437     static bool lookedUpString = false;
    438     if (!lookedUpString) {
    439         formatString = [[[NSBundle bundleForClass:[NSSpellChecker class]] localizedStringForKey:@"Change Back to \\U201C%@\\U201D" value:nil table:@"MenuCommands"] retain];
    440         lookedUpString = true;
    441     }
    442 #endif
    443     return formatString ? [NSString stringWithFormat:formatString, replacedString] : replacedString;
    444 }
    445 
    446 - (NSString *)contextMenuItemTagInspectElement
    447 {
    448     return UI_STRING("Inspect Element", "Inspect Element context menu item");
    449 }
    450 
    451 - (BOOL)objectIsTextMarker:(id)object
    452 {
    453     return object != nil && CFGetTypeID(object) == WKGetAXTextMarkerTypeID();
    454 }
    455 
    456 - (BOOL)objectIsTextMarkerRange:(id)object
    457 {
    458     return object != nil && CFGetTypeID(object) == WKGetAXTextMarkerRangeTypeID();
    459 }
    460 
    461 - (WebCoreTextMarker *)textMarkerWithBytes:(const void *)bytes length:(size_t)length
    462 {
    463     return WebCFAutorelease(WKCreateAXTextMarker(bytes, length));
    464 }
    465 
    466 - (BOOL)getBytes:(void *)bytes fromTextMarker:(WebCoreTextMarker *)textMarker length:(size_t)length
    467 {
    468     return WKGetBytesFromAXTextMarker(textMarker, bytes, length);
    469 }
    470 
    471 - (WebCoreTextMarkerRange *)textMarkerRangeWithStart:(WebCoreTextMarker *)start end:(WebCoreTextMarker *)end
    472 {
    473     ASSERT(start != nil);
    474     ASSERT(end != nil);
    475     ASSERT(CFGetTypeID(start) == WKGetAXTextMarkerTypeID());
    476     ASSERT(CFGetTypeID(end) == WKGetAXTextMarkerTypeID());
    477     return WebCFAutorelease(WKCreateAXTextMarkerRange(start, end));
    478 }
    479 
    480 - (WebCoreTextMarker *)startOfTextMarkerRange:(WebCoreTextMarkerRange *)range
    481 {
    482     ASSERT(range != nil);
    483     ASSERT(CFGetTypeID(range) == WKGetAXTextMarkerRangeTypeID());
    484     return WebCFAutorelease(WKCopyAXTextMarkerRangeStart(range));
    485 }
    486 
    487 - (WebCoreTextMarker *)endOfTextMarkerRange:(WebCoreTextMarkerRange *)range
    488 {
    489     ASSERT(range != nil);
    490     ASSERT(CFGetTypeID(range) == WKGetAXTextMarkerRangeTypeID());
    491     return WebCFAutorelease(WKCopyAXTextMarkerRangeEnd(range));
    492 }
    493 
    494 - (void)accessibilityHandleFocusChanged
    495 {
    496     WKAccessibilityHandleFocusChanged();
    497 }
    498 
    499 - (AXUIElementRef)AXUIElementForElement:(id)element
    500 {
    501     return WKCreateAXUIElementRef(element);
    502 }
    503 
    504 - (CGRect)accessibilityConvertScreenRect:(CGRect)bounds
    505 {
    506     NSArray *screens = [NSScreen screens];
    507     if ([screens count]) {
    508         CGFloat screenHeight = NSHeight([[screens objectAtIndex:0] frame]);
    509         bounds.origin.y = (screenHeight - (bounds.origin.y + bounds.size.height));
    510     } else
    511         bounds = CGRectZero;
    512 
    513     return bounds;
    514 }
    515 
    516 - (void)unregisterUniqueIdForUIElement:(id)element
    517 {
    518     WKUnregisterUniqueIdForElement(element);
    519 }
    520 
    521 - (NSString *)AXWebAreaText
    522 {
    523     return UI_STRING("HTML content", "accessibility role description for web area");
    524 }
    525 
    526 - (NSString *)AXLinkText
    527 {
    528     return UI_STRING("link", "accessibility role description for link");
    529 }
    530 
    531 - (NSString *)AXListMarkerText
    532 {
    533     return UI_STRING("list marker", "accessibility role description for list marker");
    534 }
    535 
    536 - (NSString *)AXImageMapText
    537 {
    538     return UI_STRING("image map", "accessibility role description for image map");
    539 }
    540 
    541 - (NSString *)AXHeadingText
    542 {
    543     return UI_STRING("heading", "accessibility role description for headings");
    544 }
    545 
    546 - (NSString *)AXDefinitionListTermText
    547 {
    548     return UI_STRING("term", "term word of a definition");
    549 }
    550 
    551 - (NSString *)AXDefinitionListDefinitionText
    552 {
    553     return UI_STRING("definition", "definition phrase");
    554 }
    555 
    556 - (NSString *)AXARIAContentGroupText:(NSString *)ariaType
    557 {
    558     if ([ariaType isEqualToString:@"ARIAApplicationAlert"])
    559         return UI_STRING("alert", "An ARIA accessibility group that acts as an alert.");
    560     if ([ariaType isEqualToString:@"ARIAApplicationAlertDialog"])
    561         return UI_STRING("alert dialog", "An ARIA accessibility group that acts as an alert dialog.");
    562     if ([ariaType isEqualToString:@"ARIAApplicationDialog"])
    563         return UI_STRING("dialog", "An ARIA accessibility group that acts as an dialog.");
    564     if ([ariaType isEqualToString:@"ARIAApplicationLog"])
    565         return UI_STRING("log", "An ARIA accessibility group that acts as a console log.");
    566     if ([ariaType isEqualToString:@"ARIAApplicationMarquee"])
    567         return UI_STRING("marquee", "An ARIA accessibility group that acts as a marquee.");
    568     if ([ariaType isEqualToString:@"ARIAApplicationStatus"])
    569         return UI_STRING("application status", "An ARIA accessibility group that acts as a status update.");
    570     if ([ariaType isEqualToString:@"ARIAApplicationTimer"])
    571         return UI_STRING("timer", "An ARIA accessibility group that acts as an updating timer.");
    572     if ([ariaType isEqualToString:@"ARIADocument"])
    573         return UI_STRING("document", "An ARIA accessibility group that acts as a document.");
    574     if ([ariaType isEqualToString:@"ARIADocumentArticle"])
    575         return UI_STRING("article", "An ARIA accessibility group that acts as an article.");
    576     if ([ariaType isEqualToString:@"ARIADocumentNote"])
    577         return UI_STRING("note", "An ARIA accessibility group that acts as a note in a document.");
    578     if ([ariaType isEqualToString:@"ARIADocumentRegion"])
    579         return UI_STRING("region", "An ARIA accessibility group that acts as a distinct region in a document.");
    580     if ([ariaType isEqualToString:@"ARIALandmarkApplication"])
    581         return UI_STRING("application", "An ARIA accessibility group that acts as an application.");
    582     if ([ariaType isEqualToString:@"ARIALandmarkBanner"])
    583         return UI_STRING("banner", "An ARIA accessibility group that acts as a banner.");
    584     if ([ariaType isEqualToString:@"ARIALandmarkComplementary"])
    585         return UI_STRING("complementary", "An ARIA accessibility group that acts as a region of complementary information.");
    586     if ([ariaType isEqualToString:@"ARIALandmarkContentInfo"])
    587         return UI_STRING("content", "An ARIA accessibility group that contains content.");
    588     if ([ariaType isEqualToString:@"ARIALandmarkMain"])
    589         return UI_STRING("main", "An ARIA accessibility group that is the main portion of the website.");
    590     if ([ariaType isEqualToString:@"ARIALandmarkNavigation"])
    591         return UI_STRING("navigation", "An ARIA accessibility group that contains the main navigation elements of a website.");
    592     if ([ariaType isEqualToString:@"ARIALandmarkSearch"])
    593         return UI_STRING("search", "An ARIA accessibility group that contains a search feature of a website.");
    594     if ([ariaType isEqualToString:@"ARIAUserInterfaceTooltip"])
    595         return UI_STRING("tooltip", "An ARIA accessibility group that acts as a tooltip.");
    596     if ([ariaType isEqualToString:@"ARIATabPanel"])
    597         return UI_STRING("tab panel", "An ARIA accessibility group that contains the content of a tab.");
    598     if ([ariaType isEqualToString:@"ARIADocumentMath"])
    599         return UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols.");
    600     return nil;
    601 }
    602 
    603 - (NSString *)AXButtonActionVerb
    604 {
    605     return UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility");
    606 }
    607 
    608 - (NSString *)AXRadioButtonActionVerb
    609 {
    610     return UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility");
    611 }
    612 
    613 - (NSString *)AXTextFieldActionVerb
    614 {
    615     return UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility");
    616 }
    617 
    618 - (NSString *)AXCheckedCheckBoxActionVerb
    619 {
    620     return UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility");
    621 }
    622 
    623 - (NSString *)AXUncheckedCheckBoxActionVerb
    624 {
    625     return UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility");
    626 }
    627 
    628 - (NSString *)AXLinkActionVerb
    629 {
    630     return UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility");
    631 }
    632 
    633 - (NSString *)AXMenuListPopupActionVerb
    634 {
    635     return nil;
    636 }
    637 
    638 - (NSString *)AXMenuListActionVerb
    639 {
    640     return nil;
    641 }
    642 
    643 - (NSString *)multipleFileUploadTextForNumberOfFiles:(unsigned)numberOfFiles
    644 {
    645     return [NSString stringWithFormat:UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles];
    646 }
    647 
    648 - (NSString *)unknownFileSizeText
    649 {
    650     return UI_STRING("Unknown", "Unknown filesize FTP directory listing item");
    651 }
    652 
    653 - (NSString*)imageTitleForFilename:(NSString*)filename width:(int)width height:(int)height
    654 {
    655     return [NSString stringWithFormat:UI_STRING("%@ %d%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename, width, height];
    656 }
    657 
    658 - (NSString*)mediaElementLoadingStateText
    659 {
    660     return UI_STRING("Loading...", "Media controller status message when the media is loading");
    661 }
    662 
    663 - (NSString*)mediaElementLiveBroadcastStateText
    664 {
    665     return UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast");
    666 }
    667 
    668 - (NSString*)localizedMediaControlElementString:(NSString*)name
    669 {
    670     if ([name isEqualToString:@"AudioElement"])
    671         return UI_STRING("audio element controller", "accessibility role description for audio element controller");
    672     if ([name isEqualToString:@"VideoElement"])
    673         return UI_STRING("video element controller", "accessibility role description for video element controller");
    674 
    675     // FIXME: the ControlsPanel container should never be visible in the accessibility hierarchy.
    676     if ([name isEqualToString:@"ControlsPanel"])
    677         return @"";
    678 
    679     if ([name isEqualToString:@"MuteButton"])
    680         return UI_STRING("mute", "accessibility role description for mute button");
    681     if ([name isEqualToString:@"UnMuteButton"])
    682         return UI_STRING("unmute", "accessibility role description for turn mute off button");
    683     if ([name isEqualToString:@"PlayButton"])
    684         return UI_STRING("play", "accessibility role description for play button");
    685     if ([name isEqualToString:@"PauseButton"])
    686         return UI_STRING("pause", "accessibility role description for pause button");
    687     if ([name isEqualToString:@"Slider"])
    688         return UI_STRING("movie time", "accessibility role description for timeline slider");
    689     if ([name isEqualToString:@"SliderThumb"])
    690         return UI_STRING("timeline slider thumb", "accessibility role description for timeline thumb");
    691     if ([name isEqualToString:@"RewindButton"])
    692         return UI_STRING("back 30 seconds", "accessibility role description for seek back 30 seconds button");
    693     if ([name isEqualToString:@"ReturnToRealtimeButton"])
    694         return UI_STRING("return to realtime", "accessibility role description for return to real time button");
    695     if ([name isEqualToString:@"CurrentTimeDisplay"])
    696         return UI_STRING("elapsed time", "accessibility role description for elapsed time display");
    697     if ([name isEqualToString:@"TimeRemainingDisplay"])
    698         return UI_STRING("remaining time", "accessibility role description for time remaining display");
    699     if ([name isEqualToString:@"StatusDisplay"])
    700         return UI_STRING("status", "accessibility role description for movie status");
    701     if ([name isEqualToString:@"FullscreenButton"])
    702         return UI_STRING("fullscreen", "accessibility role description for enter fullscreen button");
    703     if ([name isEqualToString:@"SeekForwardButton"])
    704         return UI_STRING("fast forward", "accessibility role description for fast forward button");
    705     if ([name isEqualToString:@"SeekBackButton"])
    706         return UI_STRING("fast reverse", "accessibility role description for fast reverse button");
    707     if ([name isEqualToString:@"ShowClosedCaptionsButton"])
    708         return UI_STRING("show closed captions", "accessibility role description for show closed captions button");
    709     if ([name isEqualToString:@"HideClosedCaptionsButton"])
    710         return UI_STRING("hide closed captions", "accessibility role description for hide closed captions button");
    711 
    712     ASSERT_NOT_REACHED();
    713     return @"";
    714 }
    715 
    716 - (NSString*)localizedMediaControlElementHelpText:(NSString*)name
    717 {
    718     if ([name isEqualToString:@"AudioElement"])
    719         return UI_STRING("audio element playback controls and status display", "accessibility role description for audio element controller");
    720     if ([name isEqualToString:@"VideoElement"])
    721         return UI_STRING("video element playback controls and status display", "accessibility role description for video element controller");
    722 
    723     if ([name isEqualToString:@"MuteButton"])
    724         return UI_STRING("mute audio tracks", "accessibility help text for mute button");
    725     if ([name isEqualToString:@"UnMuteButton"])
    726         return UI_STRING("unmute audio tracks", "accessibility help text for un mute button");
    727     if ([name isEqualToString:@"PlayButton"])
    728         return UI_STRING("begin playback", "accessibility help text for play button");
    729     if ([name isEqualToString:@"PauseButton"])
    730         return UI_STRING("pause playback", "accessibility help text for pause button");
    731     if ([name isEqualToString:@"Slider"])
    732         return UI_STRING("movie time scrubber", "accessibility help text for timeline slider");
    733     if ([name isEqualToString:@"SliderThumb"])
    734         return UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb");
    735     if ([name isEqualToString:@"RewindButton"])
    736         return UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button");
    737     if ([name isEqualToString:@"ReturnToRealtimeButton"])
    738         return UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button");
    739     if ([name isEqualToString:@"CurrentTimeDisplay"])
    740         return UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display");
    741     if ([name isEqualToString:@"TimeRemainingDisplay"])
    742         return UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display");
    743     if ([name isEqualToString:@"StatusDisplay"])
    744         return UI_STRING("current movie status", "accessibility help text for movie status display");
    745     if ([name isEqualToString:@"SeekBackButton"])
    746         return UI_STRING("seek quickly back", "accessibility help text for fast rewind button");
    747     if ([name isEqualToString:@"SeekForwardButton"])
    748         return UI_STRING("seek quickly forward", "accessibility help text for fast forward button");
    749     if ([name isEqualToString:@"FullscreenButton"])
    750         return UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button");
    751     if ([name isEqualToString:@"ShowClosedCaptionsButton"])
    752         return UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button");
    753     if ([name isEqualToString:@"HideClosedCaptionsButton"])
    754         return UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button");
    755     ASSERT_NOT_REACHED();
    756     return @"";
    757 }
    758 
    759 - (NSString*)localizedMediaTimeDescription:(float)time
    760 {
    761     if (!isfinite(time))
    762         return UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value");
    763 
    764     int seconds = (int)fabsf(time);
    765     int days = seconds / (60 * 60 * 24);
    766     int hours = seconds / (60 * 60);
    767     int minutes = (seconds / 60) % 60;
    768     seconds %= 60;
    769 
    770     if (days)
    771         return [NSString stringWithFormat:UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds];
    772     else if (hours)
    773         return [NSString stringWithFormat:UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds];
    774     else if (minutes)
    775         return [NSString stringWithFormat:UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds];
    776 
    777     return [NSString stringWithFormat:UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds];
    778 }
    779 
    780 - (NSString *)validationMessageValueMissingText
    781 {
    782     return UI_STRING("value missing", "Validation message for required form control elements that have no value");
    783 }
    784 
    785 - (NSString *)validationMessageTypeMismatchText
    786 {
    787     return UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type");
    788 }
    789 
    790 - (NSString *)validationMessagePatternMismatchText
    791 {
    792     return UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern");
    793 }
    794 
    795 - (NSString *)validationMessageTooLongText
    796 {
    797     return UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length");
    798 }
    799 
    800 - (NSString *)validationMessageRangeUnderflowText
    801 {
    802     return UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum");
    803 }
    804 
    805 - (NSString *)validationMessageRangeOverflowText
    806 {
    807     return UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum");
    808 }
    809 
    810 - (NSString *)validationMessageStepMismatchText
    811 {
    812     return UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute");
    813 }
    814 
    815 @end
    816