summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav/CachedNode.cpp
Commit message (Collapse)AuthorAgeFilesLines
* don't combine single image bitmapsCary Clark2011-02-141-2/+3
| | | | | | | | | | | | | | | Anchors and other links often contain multiple bitmaps, which must be stitched together when analyzing the picture data to determine if the anchor is fully visible, partially occluded, or fully hidden. For instance, nine-patches in WebKit appear as adjacent bitmaps. If a website design has two or more bitmaps adjacent to each other, these may be mistakenly joined. By tracking whether the original node contained exactly one img element, combining bitmaps based on their location is avoided unncessarily. bug:3373743 Change-Id: I5bcbdaec3097a2b839ee2444e512a0def6a016d0
* compute cursor rings when layers are transparentCary Clark2010-10-181-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Google search suggestions are drawn in a popup menu (a div with a small amount of transparency). This can partially or complete obscure links underneath the popup, and can present touchable targets which may be much larger than the text contained by the link. CachedRoot::checkRings() determines if a larger bounding box can be used for the ring around the link. CachedRoot::maskIfHidden() determines if the ring needs to be cut down in size because it is only partially visible, or fully obscured. Both routines share the implementation that gathers information about the link, which uses RingCanvas to parse the picture, and RingCheck to build layers describing the text and rectangles drawn in the area around the ring. The basic strategy is to find the text contained by the link under consideration, and see if subsequent drawing obscures the text, or if other text would be enclosed by enlarging the ring. Since maskIfHidden() works better now than before, this CL enabled checking for hidden links when recomputing the current selection after the picture updates. It also checks to see if the link can be larger when maskIfHidden() determines that it is unclipped. Also, if a tap is inside the larger ring, but not on the text itself, treat that as a valid hit. (In CachedFrame::findBestHitAt) And, this fixes CacheBuilder debugging code, and the CacheBuilder array crasher described by bug: 3043268 bug: 2661613 Change-Id: I751f6539f6c840889a58de8c4611364442b3e37c
* Add CSS cursor ring definitionsCary Clark2010-08-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows web pages to have fine-grain control over the appearance of the rings drawn around nodes. Generated links (email, addresses, phone numbers) are no longer given unique colors. To preserve this feature, a separate change could add an HTML extension similar to vlink to provide the cursor ring defintions for theses links. The mechanism implemented below isn't appropriate since these links don't necessarily correspond to single DOM nodes or other DOM elements. ------------ CSS examples ------------ The CSS to specify the ring looks like: -webkit-ring-fill-color:rgba(0,0,255,0.4); -webkit-ring-inner-width:2 px; -webkit-ring-outer-width:3.5 px; -webkit-ring-outset: 8 px; -webkit-ring-pressed-inner-color:rgba(0,0,255,0.8); -webkit-ring-pressed-outer-color:rgba(0,0,127,0.3); -webkit-ring-radius: 10 px; -webkit-ring-selected-inner-color:rgba(63,63,255,0.8); -webkit-ring-selected-outer-color:rgba(63,63,127,0.3); and may be alternately defined with a property shortcut: -webkit-ring:rgba(255,0,0,0.4) 5px 7px rgba(255,0,0,0.8) rgba(127,0,0,0.3) 20px rgba(255,63,63,0.8) rgba(127,63,63,0.3); -------------------- Property definitions -------------------- A vertical cross-section of the ring corresponds to these parameters as shown: ______ R / ___O_ R = corner radius / / __I_ o I = inner ring / / / _O_ ^ O = outer ring | | | / F | F = fill |O|I|O| L o = outset | | | \_F_ | L = original link \ \ \__O_ V \ \___I_ o R \____O_ The fill color specifies what to draw inside the ring when the link is followed. The fill area consists of the original link area plus the outset. The inner and outer widths specify the stoke width of the inner and outer rings, respectively. The widths may be specified in fractional pixels. The implementation captures 4 bits of the fraction. The outset specifies the distance from the edge of the original link to the rings' center. Both rings are drawn at the same center location. The radius specifies the curvature of the corners at the center of the rings. ------------- Data lifetime ------------- The selected colors specify the colors of the inner and outer rings when the trackball or D-pad hovers over the link. The pressed colors specify the colors of the rings when the trackball center is pressed or the link is tapped. The CSS data is recorded in the RenderStyle when the DOM is parsed. The widths are scaled up by 16 to preserve the fraction. When the nav cache is built, the CSS style information is recorded in the CachedColor class. Only unique style sets are recorded; many CachedNode instances can share the same CachedColor instance. When the cursor ring is drawn, the CachedColor is retrieved by getting the index from the CachedNode, and looking up the entry in the CachedFrame. The widths are scaled down by 16 since Lengths are stored by the webkit as integers. ---------- File Edits ---------- WebCore/Android.derived.mk - Build the CSS data property tables by concatentating Android specific data and optionally SVG data. WebCore/config.h - Add switch for these rings. This switch is meant as a convenience for finding the code in WebKit that was added to enable this feature. Since the old code in DrawCursor has been removed, it does not revert to the old behavior if the switch is turned off. WebCore/css/AndroidCSSPropertyNames.in - The new ring properties, plus an old one we added before. WebCore/css/CSSComputedStyleDeclaration.cpp WebCore/css/CSSMutableStyleDeclaration.cpp WebCore/css/CSSParser.cpp WebCore/css/CSSStyleSelector.cpp - I can guess what these functions are for as well as anyone, but I really don't know. Do I need all of them? Do I need to modify Mutable at all? WebCore/css/CSSPropertyNames.in - Moved Android addition to AndroidCSSPropertyNames.in WebCore/platform/graphics/Color.h - Added initial color values here. WebCore/platform/graphics/android/android_graphics.* - This draws the cursor ring. The code that draws 'synthetic' links has been discarded. WebCore/rendering/style/RenderStyle.h - Functions to get, set, and initialize the style data. WebCore/rendering/style/StyleRareInheritedData.* - The storage for the style data and an equivalence function. WebKit/Android.mk - Added CachedColor to the build. WebKit/android/nav/CacheBuilder.cpp - Record the color from the DOM into the cache. WebKit/android/nav/CachedColor.* - Store the cached color info. WebKit/android/nav/CachedFrame.* - Where the array of colors is stored. WebKit/android/nav/CachedNode.* - Where the index to the colors is stored. Change-Id: Ia3a931f41d6545e47678e245aafe7c84d4658f94 http://b/2603197
* Merge WebKit at r65072: String class has moved to the WTF namespace.Ben Murdoch2010-08-131-1/+1
| | | | | | See http://trac.webkit.org/changeset/65021 Change-Id: I779a8ec0c3e1e0aed8f8d1894cfc1e5ca33ee549
* Revert "Add CSS cursor ring definitions"Cary Clark2010-07-301-1/+0
| | | | This reverts commit 0ed6485271097ecf1b4cf4e790f9cfdbb57d921c.
* Add CSS cursor ring definitionsCary Clark2010-07-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows web pages to have fine-grain control over the appearance of the rings drawn around nodes. Generated links (email, addresses, phone numbers) are no longer given unique colors. To preserve this feature, a separate change could add an HTML extension similar to vlink to provide the cursor ring defintions for theses links. The mechanism implemented below isn't appropriate since these links don't necessarily correspond to single DOM nodes or other DOM elements. ------------ CSS examples ------------ The CSS to specify the ring looks like: -webkit-ring-fill-color:rgba(0,0,255,0.4); -webkit-ring-inner-width:2 px; -webkit-ring-outer-width:3.5 px; -webkit-ring-outset: 8 px; -webkit-ring-pressed-inner-color:rgba(0,0,255,0.8); -webkit-ring-pressed-outer-color:rgba(0,0,127,0.3); -webkit-ring-radius: 10 px; -webkit-ring-selected-inner-color:rgba(63,63,255,0.8); -webkit-ring-selected-outer-color:rgba(63,63,127,0.3); and may be alternately defined with a property shortcut: -webkit-ring:rgba(255,0,0,0.4) 5px 7px rgba(255,0,0,0.8) rgba(127,0,0,0.3) 20px rgba(255,63,63,0.8) rgba(127,63,63,0.3); -------------------- Property definitions -------------------- A vertical cross-section of the ring corresponds to these parameters as shown: ______ R / ___O_ R = corner radius / / __I_ o I = inner ring / / / _O_ ^ O = outer ring | | | / F | F = fill |O|I|O| L o = outset | | | \_F_ | L = original link \ \ \__O_ V \ \___I_ o R \____O_ The fill color specifies what to draw inside the ring when the link is followed. The fill area consists of the original link area the outset. The inner and outer widths specify the stoke width of the inner and outer rings, respectively. The widths may be specified in fractional pixels. The implementation captures 4 bits of the fraction. The outset specifies the distance from the edge of the original link to the rings' center. Both rings are drawn at the same center location. The radius specifies the curvature of the corners at the center of the rings. ------------- Data lifetime ------------- The selected colors specify the colors of the inner and outer rings when the trackball or D-pad hovers over the link. The pressed colors specify the colors of the rings when the trackball center is pressed or the link is tapped. The CSS data is recorded in the RenderStyle when the DOM is parsed. The widths are scaled up by 16 to preserve the fraction. When the nav cache is built, the CSS style information is recorded in the CachedColor class. Only unique style sets are recorded; many CachedNode instances can share the same CachedColor instance. When the cursor ring is drawn, the CachedColor is retrieved by getting the index from the CachedNode, and looking up the entry in the CachedFrame. The widths are scaled down by 16 since Lengths are stored by the webkit as integers. ---------- File Edits ---------- WebCore/Android.derived.mk - Build the CSS data property tables by concatentating Android specific data and optionally SVG data. WebCore/config.h - Add switch for these rings. This switch is meant as a convenience for finding the code in WebKit that was added to enable this feature. Since the old code in DrawCursor has been removed, it does not revert to the old behavior if the switch is turned off. WebCore/css/AndroidCSSPropertyNames.in - The new ring properties, plus an old one we added before. WebCore/css/CSSComputedStyleDeclaration.cpp WebCore/css/CSSMutableStyleDeclaration.cpp WebCore/css/CSSParser.cpp WebCore/css/CSSStyleSelector.cpp - I can guess what these functions are for as well as anyone, but I really don't know. Do I need all of them? Do I need to modify Mutable at all? WebCore/css/CSSPropertyNames.in - Moved Android addition to AndroidCSSPropertyNames.in WebCore/platform/graphics/Color.h - Added initial color values here. WebCore/platform/graphics/android/android_graphics.* - This draws the cursor ring. The code that draws 'synthetic' links has been discarded. WebCore/rendering/style/RenderStyle.h - Functions to get, set, and initialize the style data. WebCore/rendering/style/StyleRareInheritedData.* - The storage for the style data and an equivalence function. WebKit/Android.mk - Added CachedColor to the build. WebKit/android/nav/CacheBuilder.cpp - Record the color from the DOM into the cache. WebKit/android/nav/CachedColor.* - Store the cached color info. WebKit/android/nav/CachedFrame.* - Where the array of colors is stored. WebKit/android/nav/CachedNode.* - Where the index to the colors is stored. Change-Id: Ia3a931f41d6545e47678e245aafe7c84d4658f94 http://b/2603197
* clean up nav cache debuggingCary Clark2010-05-141-1/+2
| | | | | | | | | This adds additional content to the nav cache dump, and cleans up a few formatting problems. This has no effect on code that does not have nav cache debugging enabled. Change-Id: Ice2c4bb33138a8ddc96739d95ead58fbe328bfa8
* refactor drawing to support layersCary Clark2010-02-241-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Drawing elements that appear atop or below layers need to be drawn both in the proper order and with the correct canvas to respect clipping and the matrix. Drawing the find results, text selection, or the cursor ring, interleaves with any layers that may be drawn. The main picture is treated as owned by a LayerAndroid so each component can decide when to draw. This change leave the main picture in WebViewCore.cpp, and draws everything else in WebView.cpp -- in the future, additional refactoring can put all drawing in one place. The logic of what to draw is still in WebView.java, but the actual drawing calls are now triggered inside the layer code. Android.mk - Add rule to trigger building without layers from buildspec.mk. LayerAndroid.* - Replace FindOnPage reference with abstract DrawExtra class to draw adornments in the layers' canvas context. - Add a LayerAndroid constructor to create a dummy layer with a SkPicture* and a uniqueId==-1 so that extras can detect when they are drawn by the main picture. android_graphics.* - Move cursor ring drawing out of WebView.cpp to here. - Separate cursor ring setup from actual drawing. - Get the cursor ring metrics in local coordinates. ChromeClientAndroid.cpp - Fix compiler warnings. WebViewCore.* - Move updateCursorBounds from WebView.cpp. This permits it to be called from CursorRing::setup. CachedFrame.* CachedNode.* CachedLayer.* - Add local bounds getters. CachedRoot.h - Move class FindCanvas to the android namespace. DrawExtra.h - Add an abstract class called by LayerAndroid to optionally draw extra elements in its canvas context. FindCanvas.* SelectText.* - Refactor drawing to draw in layers context. WebView.cpp - Move drawing from WebView.java. - Remove selection code to SelectText.cpp. - Use inverseScale to simplify viewPort metrics. - Simplify layer root so java doesn't need to know about it. Requires companion change in frameworks/base http://b/2457316 http://b/2454127 http://b/2454149
* minor fixes to layer navCary Clark2010-02-171-1/+1
| | | | | | | | | | | - get rid of the FloatPoint interface in LayerAndroid; use (x, y) instead - make CachedFrame a friend of CachedRoot and CacheBuilder a friend of CachedNode so they alone can access private fields. - assume the LayerAndroid picture can sometimes be null. If it is, use the main page's picture instead. http://b/2369549
* Add UI considerations to layersCary Clark2010-02-171-14/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | companion fix is in framework/base With fixed layers, parts of the web page are now in motion relative to the document when the page scrolls. Many routines that formerly read static coordinates need to compute locations. In some cases, new computations are cached for speed -- for instance, the current cursor position is cached when it is frequently compared. The cursor rings and other drawing elements like finding text on the page now to be drawn in the correct order so that they appear both under and over layers. There's quite a bit more work to be done. Major pieces are drawing the text selection in the correct order, and computing locations based on nest layers. With this checkin, only the position of the child- most layer is considered when computing bounds. http://b/2369549 JavaScriptCore/wtf/Platform.h - Turn compositing on. All routines that reference LayerAndroid are bracketed by this condition. WebCore/platform/graphics/android/LayerAndroid.h WebCore/platform/graphics/android/LayerAndroid.cpp - Add a unique id to each layer. The unique id is used to associate a layer created when the DOM is parsed in the webkit thread with its copy in the UI thread. - Add: draw the text found on the page, as a call out in the primary draw. The call out must follow the drawing the layers' contents to show the found text correctly. Note that this adds a new slot with identical contents in every child LayerAndroid. In a future optimization, a RootLayerAndroid could hold data common for all child layers. - Add: clipArea(), which returns an array of rectangles describing the clip for this LayerAndroid and its children. Generally, this is the part of the webpage which is covered by one or more fixed layers. - Add: find(FloatPoint) that returns the deepest layer that contains this point. This is used to match taps to the layer that is tapped on. - Add: draw all layer pictures and identify which layer is being drawn. This is used to analyze the picture contents for finding and selecting text. - Add: find the layer that matches a given id; this is used to map cached DOM node data back to the layer that contains it. - Fix up includes, delete unused interfaces WebKit/android/jni/WebViewCore.h WebKit/android/jni/WebViewCore.cpp - Remove local mRootLayer; use the one in WebView.cpp instead (which is in sync with WebView.java) WebKit/Android.mk WebKit/android/nav/CachedLayer.h WebKit/android/nav/CachedLayer.cpp - CacheLayer associates the cached node with the LayerAndroid instance. It contains the index to the node in the cached frame, the LayerAndroid's unique id, and the spacial offset of the node within the layer when the DOM information was captured. It also caches a pointer to the LayerAndroid instance. CacheLayer computes the node's location each time it is called, since the fixed layer may be constantly moving relative to the document's coordinates. WebKit/android/nav/CacheBuilder.h WebKit/android/nav/CacheBuilder.cpp - Track the active layer while building the nav cache. The 'Tracker' structs were refactored to share common code, and a new 'LayerTracker' struct identifies when the node walker is inside a layer. - Added code to dump layer information for debugging. - Note that CachedNode::cursorRingsPtr can only be called during nav data construction - The cache builder can limit or exclude nodes that are clipped out -- but until I have more understanding of layer clipping, treat contained nodes as unclipped. WebKit/android/nav/CachedDebug.h - Add a variant that can dump either to a log file or the console including the function it was dumped from. WebKit/android/nav/CachedFrame.h WebKit/android/nav/CachedFrame.cpp - Add an array of CacheLayer instances. - Protect bounds from direct access since they must always be computed. - Remove misnamed focus parameter from many routines since the cursor node can be read from the root frame. - Add: adjustBounds(), which computes the bounds as the layer moves. - Add: checkRings(), which gets the appropriate picture for the node. - Remove disabled code - Find the layer list for the matching node by using a binary search - Add: resetLayers() to reset the LayerAndroid pointer in CachedLayers when the layer world changes. WebKit/android/nav/CachedHistory.h WebKit/android/nav/CachedHistory.cpp - Update history data to have matching frame and node WebKit/android/nav/CachedNode.h WebKit/android/nav/CachedNode.cpp - Refactor functions that directly read coordinates to compute them. In some cases, pass the frame in so that the layer coordinates can be found. - Add a bit to note that the node belongs to a layer. - Remove duplicate bounds interfaces. - Add methods to get cursor ring data at runtime. - Update debugging info. WebKit/android/nav/CachedRoot.h WebKit/android/nav/CachedRoot.cpp - Isolate direct picture access so that the layer picture can be returned. - Add knowledge of how the base is covered by layers. - Add a pointer to the root LayerAndroid. - delete disabled code. - Move the cursor ring into view if it is obscured by a layer (this isn't totally working) - Before finding the next node to move to, set up 'cursor cache' data, including the visible picture. WebKit/android/nav/FindCanvas.h WebKit/android/nav/FindCanvas.cpp - Move find code here so that it can be called from layers. WebKit/android/nav/WebView.cpp - Add java interface to get viewport metrics on demand. - Pass frame with the node. - Remove the find on page code (now in FindCanvas). - Compute focus rings instead of reading them directly. - Transfer layer id when getting new nav cache. - Set up root LayerAndroid. - Add utility to track if cursor is in a layer. - Simplify drawLayers() to use common view metrics.
* move input-related fields out of CachedNode to expandCary Clark2009-12-041-31/+23
| | | | | | | | | | | | | Some of the fields in CachedNode are relevant only to input fields and text areas. Move these into their own vector so that we can add more data without making all CacheNodes bigger. Remove CacheNode entries that are no longer used, or can be consolidated into the node type. Alphabetize some interfaces and implementations. Update the debugging output. part of http://b/2299660
* fix bugs in nav cache dumpCary Clark2009-11-301-4/+10
| | | | | | | Fix errors in empty frames, escape character sequences, and characters outside the ascii range. These fixes are specific to dumping the nav cache and are commented out in all builds.
* Fixes license headers for all files in WebKit/android, other than those in stl/.Steve Block2009-11-131-1/+1
| | | | | | | | | | | | | These files have not yet been upstreamed to webkit.org. WebKit requires either a BSD-style or LGPL 2.1 license for all code. We use a BSD-style 2-clause license for Android-specific files that will be upstreamed to webkit.org. This change adds licenses where absent or simply fixes the names of copyright holders in the license text to 'THE COPYRIGHT OWNER' and cleans up formatting. Files in stl/ currently use licenses other than BSD-style and will require more careful treatment. Change-Id: I67ad4b8932e432d3eaaeecdfeb0d09418496228d
* fix webkit hidden cursor, address crashCary Clark2009-06-161-1/+1
| | | | | | | | http://b/issue?id=1918891 set cursor node hidden to 'true' to hide it also fixing crash if detecting text address runs out of text to look at
* more (browser) trackball-is-a-mouse work in progressCary Clark2009-06-111-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | WebViewCore.cpp: Add parameter to CachedRoot::findAt to suppress check for hidden nodes. This helps find a best match for newly built nav caches. Require that the new cursor node closely match the bounds of the prior cursor node. This may need tuning. CacheBuilder.cpp: Remove isInput flag on cached nodes (no longer used) CachedFrame.cpp: Add hideCursor to complement clearCursor. Hide prevents the cursor from drawing but does not move it. Clear removes it altogether so that the next movement starts from the viewPort edge. CachedHistory.cpp: Don't special case text fields when doing history navigation. This special casing in part allowed setting the focus to the homepage input, but since focus is no longer set by nav, it is not required. CachedNode.cpp: Add hideCursor; clean up debugging CachedRoot.cpp: Use navBounds from history instead of cursor bounds to determine next move. Clean up some obsolete code. WebView.cpp: Add hideCursor; call it when appropriate.
* in the browser, make the trackball more like a mouseCary Clark2009-06-011-40/+39
| | | | | | | | | | | | | | Older code treated the trackball as a four way dpad with equivalents to moving up, down, left and right by generating arrow key events. This change makes the trackball solely generate mousemove events. The old arrow keys in turn were mapped to be as close as possible to tab-key events that moved the focus. The new model leaves focus-changes to the DOM. Clicking the dpad is distinguished from pressing the enter key to be more compatible with desktop-authored web pages.
* use one rectangle for browser focus ringCary Clark2009-05-131-2/+18
| | | | | | | | | | | | Check to see if the potentially larger hit-test bounds can be used in place of the normal bounds, or if the normal bounds can be used in place of the individual text bounds. Construct a region out of the individual focus ring rectangles, then see if any text is drawn inside the bounds but outside of the focus ring. If not, use one rectangle instead of the rings.
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+346
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-346/+0
|
* auto import from //branches/cupcake/...@130745The Android Open Source Project2009-02-101-0/+6
|
* auto import from //branches/cupcake/...@126645The Android Open Source Project2009-01-151-11/+19
|
* Code drop from //branches/cupcake/...@124589The Android Open Source Project2008-12-171-0/+332