Substitute the user's preferred standard font for an unknown primary
font before falling back on the platform's last resort font

Cannot be tested in DumpRenderTree because it sets the standard font to
Times, which is also the hard-coded last resort font on Mac.

css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::getFontData): Changed the early bail out
condition to allow getting generic font families from settings even if
there are not @font-face rules. Fixed a typo that mapped fantasy to
cursive. Added a mapping from -webkit-standard to the standard family.

platform/win/Skipped: Removed tests that failed only because they
specified as primary font family a font family that was not available
on Windows and therefore were rendered using the platform last resort
font, Times New Roman. Now they are rendered using the 'standard'
font family, which is set to Times on both Mac and Windows when running
the tests.

Calling Node::willRemove on the focusedNode would immediately tell the document to remove
the focused node, and trigger JS events. This means that the document is mutated while
the engine is trying to tell all child nodes that it's about to removed. To avoid
crashing, we need to hold off on mutating the document until node traversal is finished.

dom/ChildNodeList.cpp: Use the caching NodeList constructor to turn on caching.
(WebCore::ChildNodeList::ChildNodeList):

dom/ClassNodeList.cpp:
(WebCore::ClassNodeList::ClassNodeList):

dom/ClassNodeList.h:

Move getElementsByName and getElementsByClassName to Node so they
can use easily employ the caching already used by ChildNodeLists. In the case of
getElementsByClassName, this reduces code duplication in Element as well

dom/Document.cpp:

dom/Document.h:

Move getElementsByClassName to Node.

dom/Element.cpp:

dom/Element.h:

dom/NameNodeList.cpp: Use the caching NodeList constructor to turn on caching.
(WebCore::NameNodeList::NameNodeList):
(WebCore::NameNodeList::item):

dom/NameNodeList.h:

Add maps of caches for ClassNodeLists and NameNodeList to NodeListsNodeData.

platform/gtk/FontPlatformDataGtk.cpp: added static members for the
FontPlatformData class
(FontPlatformData::FontPlatformData()): implemented the font-matching
with a PangoFontDescription instead of an FcPattern; initialize the
scaled font by using the API for PangoCairoFont
(FontPlatformData::init()): initialize the PangoFontMap and set up a
hash table to translate the font family name into a font family
(FontPlatformData::isFixedPitch()): implemented by querying the
PangoFontFamily
(FontPlatformData::operator==): compare the FontPlatformData by
comparing the font pointers or the described fonts

platform/gtk/GlyphPageTreeNodeGtk.cpp (pango_font_get_glyph()):
added a function to query a glyph from a PangoFont
(GlyphPage::fill()): implemented the fill function with Pango instead
of fontconfig/freetype

This fixes an issue where we were incorrectly setting the lastInPrototypeChain
for the JSDOMWindow (the global object) before a call to setPrototype overwrote
it. This fixes it by passing the prototype up the constructor chain so that it
is set before any calls can be made.

12/18/07:

Fix for <rdar://problem/5616982> SVGs with width and height 100%
fail to render when used as <img> or CSS image (16167)

This final part of the work fixes the <img> tag.

This is the real fix.

rendering/RenderImage.cpp:
(WebCore::RenderImage::calcReplacedWidth): Set the container size
on the image. Setting the container size only actually sticks if
the values are non-zero, so if the container size really was set,
use the imageSize that is calculated using the container size. If
it did not stick but the image does have relative width (meaning
that the container size is 0), set the width to 0 by hand. We want
to avoid setting the width before we have a container size or we
will end up incorrectly using the default size of 300x150.
(WebCore::RenderImage::calcReplacedHeight): Same as above, but for
height.

A few more pieces of information have to be exposed through cached
image to make this happen.

loader/CachedImage.cpp:
(WebCore::CachedImage::usesImageContainerSize): As mentioned above,
when setContainerSize() is called, the container size is only
actually set if the values are non-zero. This call tells you if it
was set.
(WebCore::CachedImage::imageHasRelativeWidth):
(WebCore::CachedImage::imageHasRelativeHeight):

loader/CachedImage.h:

platform/graphics/Image.h:
(WebCore::Image::usesContainerSize):

svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::usesContainerSize):

svg/graphics/SVGImage.h:

LayoutTests:

Reviewed by Oliver.

Test for <rdar://problem/5616982> SVGs with width and height 100%
fail to render when used as <img> or CSS image (16167)

Replace post-parse pass to find declarations with logic in the parser itself

Reviewed by Geoff.

Instead of finding declarations in a pass following the initial parsing of
a program, we incorporate the logic directly into the parser. This lays
the groundwork for further optimisations (such as improving performance in
declaration expressions -- var x = y; -- to match that of standard assignment)
in addition to providing a 0.4% performance improvement in SunSpider.

fast/cookies/local-file-can-set-cookies.html:
cookies are matched by domain and path, and since layout tests are file URLs,
they all match on domain. setting a cookie without specifying the path will
make CFNetwork pick up the path from the URL automatically. Since
fast/cookies/local-file-can-set-cookies.html set a specific path of /, that
cookie will be set for EVERY local file loaded in Safari. removing that
component from the cookie string will fix the problem.

pcre/pcre.h: Changed name of error code to not specifically mention "recursion".

pcre/pcre_exec.cpp:
(match): Replaced the depth limit, MATCH_RECURSION_LIMIT, with a total match looping
limit, matchLimit. Also eliminated the constants for MATCH_MATCH and MATCH_NOMATCH,
since they are just true and false (1 and 0).
(jsRegExpExecute): More of the MATCH_MATCH change.

Some http-auth protected sites have the main resource(s) unprotected, but many subresources are
protected by authentication. Occasionally one can view the main page of a site but the favicon
is behind the iron curtain - in these cases, we should *not* prompt for a username and password
solely for the favicon.

loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didReceiveAuthenticationChallenge): Now that this method
is virtual from ResourceLoader, SubresourceLoader can override. First call to the
SubresourceLoaderClient. If they cancel the resource load, return early. Otherwise, let
ResourceLoader work its magic (resulting in the auth sheet coming down)

WebFrame.cpp:
(WebFrame::forceLayout): Implemented this. Just calling through to
Frame::forceLayout matches the Mac pretty well and should be enough
for now. Without this we won't repaint the new page when we go back
and forward.
(WebFrame::dispatchWillSubmitForm): Use COMPtr's AdoptCOM constructor
instead of the adoptRef function.
(WebFrame::restoreViewState): Removed unneeded notImplemented() call.
This is implemented as much as it needs to be.
(WebFrame::shouldGoToHistoryItem): Ditto.
(WebFrame::saveViewStateToItem): Ditto.
(WebFrame::canCachePage): Ditto, also changed it to return true. This
is what was preventing the back/forward cache from running, and there's
no need for any additional checks in the Windows version.

WebView.cpp:
(PreferencesChangedOrRemovedObserver::onNotify): Fix backwards null check
that was preventing this notification from ever being sent, which in turn
meant that page cache had a capacity of 0.
(WebView::initWithFrame): Removed unneeded setUsesPageCache(false) code.
This actually was ineffective and ended up doing no harm, but we don't
need it.

plugins/win/PluginViewWin.cpp:
(WebCore::PluginViewWin::dispatchNPEvent): Changed to take NPEvent&, not
NPEvent*
(WebCore::PluginViewWin::paint): Pass NPEvent, not NPEvent*
(WebCore::PluginViewWin::handleKeyboardEvent): same
(WebCore::PluginViewWin::handleMouseEvent): same

fix <rdar://problem/5333260> Some Chinese characters in Text Encoding menu are bold, others are not
and <rdar://problem/5280188> Chinese text looks worse on Safari for Windows cf. Safari for Mac

platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::getFontDataForCharacters): To ensure that font
linking gives consistent results for characters that are exclusive to
the simplified Chinese code page and characters that belong to that
code page and other code pages, always ask to map to simplified Chinese
alone first.

improved design of the functions for reading and writing
2-byte values from the opcode stream (in pcre_internal.h)

pcre/dftables.cpp:
(main): Added the kjs prefix a normal way in lieu of using macros.

pcre/pcre_compile.cpp: Moved some definitions here from pcre_internal.h.
(errorText): Name changes, fewer typedefs.
(checkEscape): Ditto. Changed uppercase conversion to use toASCIIUpper.
(isCountedRepeat): Name change.
(readRepeatCounts): Name change.
(firstSignificantOpcode): Got rid of the use of OP_lengths, which is
very lightly used here. Hard-coded the length of OP_BRANUMBER.
(firstSignificantOpcodeSkippingAssertions): Ditto. Also changed to
use the advanceToEndOfBracket function.
(getOthercaseRange): Name changes.
(encodeUTF8): Ditto.
(compileBranch): Name changes. Removed unused after_manual_callout and
the code to handle it. Removed code to handle OP_ONCE since we never
emit this opcode. Changed to use advanceToEndOfBracket in more places.
(compileBracket): Name changes.
(branchIsAnchored): Removed code to handle OP_ONCE since we never emit
this opcode.
(bracketIsAnchored): Name changes.
(branchNeedsLineStart): More fo the same.
(bracketNeedsLineStart): Ditto.
(branchFindFirstAssertedCharacter): Removed OP_ONCE code.
(bracketFindFirstAssertedCharacter): More of the same.
(calculateCompiledPatternLengthAndFlags): Ditto.
(returnError): Name changes.
(jsRegExpCompile): Ditto.

pcre/pcre_exec.cpp: Moved some definitions here from pcre_internal.h.
(matchRef): Updated names.
Improved macros to use the do { } while(0) idiom so they expand to single
statements rather than to blocks or multiple statements. And refeactored
the recursive match macros.
(MatchStack::pushNewFrame): Name changes.
(getUTF8CharAndIncrementLength): Name changes.
(match): Name changes. Removed the ONCE opcode.
(jsRegExpExecute): Name changes.

pcre/pcre_internal.h: Removed quite a few unneeded includes. Rewrote
quite a few comments. Removed the macros that add kjs prefixes to the
functions with external linkage; instead renamed the functions. Removed
the unneeded typedefs pcre_uint16, pcre_uint32, and uschar. Removed the
dead and not-all-working code for LINK_SIZE values other than 2, although
we aim to keep the abstraction working. Removed the OP_LENGTHS macro.
(put2ByteValue): Replaces put2ByteOpcodeValueAtOffset.
(get2ByteValue): Replaces get2ByteOpcodeValueAtOffset.
(put2ByteValueAndAdvance): Replaces put2ByteOpcodeValueAtOffsetAndAdvance.
(putLinkValueAllowZero): Replaces putOpcodeValueAtOffset; doesn't do the
addition, since a comma is really no better than a plus sign. Added an
assertion to catch out of range values and changed the parameter type to
int rather than unsigned.
(getLinkValueAllowZero): Replaces getOpcodeValueAtOffset.
(putLinkValue): New function that most former callers of the
putOpcodeValueAtOffset function can use; asserts the value that is
being stored is non-zero and then calls putLinkValueAllowZero.
(getLinkValue): Ditto.
(putLinkValueAndAdvance): Replaces putOpcodeValueAtOffsetAndAdvance. No
caller was using an offset, which makes sense given the advancing behavior.
(putLinkValueAllowZeroAndAdvance): Ditto.
(isBracketOpcode): Added. For use in an assertion.
(advanceToEndOfBracket): Renamed from moveOpcodePtrPastAnyAlternateBranches,
and removed comments about how it's not well designed. This function takes
a pointer to the beginning of a bracket and advances to the end of the
bracket.

Integrate the GStreamer media backend with the Cairo graphics backend.
There are still some issues: Data is copied more often than necessary,
and repaint() is not called, causing transformed video not to update
sometimes.

WebCore.xcodeproj/project.pbxproj: Remove NetscapePlugInStreamLoader.cpp from the WebCore target.
Mac currently has its own implementation in NetscapePlugInStreamLoaderMac.mm which conflicts with the
new shared implementation.

The problem was that \B was not handled properly in character classes.

Test: fast/js/regexp-overflow.html

pcre/pcre_compile.cpp:
(check_escape): Added handling of ESC_b and ESC_B in character classes here.
Allows us to get rid of the handling of \b in character classes from all the
call sites that handle it separately and to handle \B properly as well.
(compileBranch): Remove the ESC_b handling, since it's not needed any more.
(calculateCompiledPatternLengthAndFlags): Ditto.

(KJS::compareByStringPairForQSort):
(KJS::ArrayInstance::sort): Convert JSValue's to strings once up front and then sort the
results. This avoids calling toString twice per comparison, but requires a temporary buffer
so we only use this approach in cases where the array being sorted is not too large.

Changed SymbolTable to use RefPtr<UString::Rep> as its key instead of
UString::Rep*. With globals, the symbol table can outlast the
declaration node for any given symbol, so the symbol table needs to ref
its symbol names.

System colors are retrieved from NSColor as appropriate. If the color is a pattern color
(and therefore NSColor won't let us retrieve a color from it) we draw a 1x1 image of the
color and sample that to get a solid color.

editing/EditorCommand.cpp: (WebCore::CommandEntry::): Mark InsertText as a text insertion
command, which it is. Previously, we couldn't do it because WebKit didn't really treat insertText:
as a command.

page/EventHandler.cpp: (WebCore::EventHandler::keyEvent): Copy commands saved while interpreting
a keydown event into keypress, to avoid losing state when running interpretKeyEvents: again.

WebKit:

WebView/WebHTMLView.mm:
(-[WebHTMLView _interceptEditingKeyEvent:shouldSaveCommand:]): Made command replaying work
when handling keypress, too.
(-[WebHTMLView doCommandBySelector:]): Adapted for the new way to store commands in events.
(-[WebHTMLView insertText:]): Append a command, not replace the whole existing vector. Also,
restore the state for additional commands to be saved correctly.

platform/graphics/win/FontCacheWin.cpp:
(WebCore::metaFileEnumProc): Added. Called during metafile record
enumeration and extracts the font from the create font record.
(WebCore::FontCache::getFontDataForCharacters): If font linking fails,
let Uniscribe draw the characters and see what font it chooses.

Width of SVG elements not applied to container elements​http://bugs.webkit.org/show_bug.cgi?id=16305
Added calcPrefWidths for RenderSVGRoot (copied from RenderReplaced)
This is caused by poor factoring in the render tree. RenderContainer probably should be a template.

dom/WheelEvent.cpp: (WebCore::WheelEvent::WheelEvent):
Ensure that delta is never rounded down to zero - we are getting values less than 1 from
many mice on OS X, and Google Maps code assumes scrolling down if event.wheelDelta is zero.