changeset 2095:6dc9350d8193

Re-indent selection.cc for clarity
author Jorge Arellano Cid <jcid@dillo.org>
date Wed, 15 Jun 2011 12:51:35 -0400
parents 6cee904c7bb1
children e860e2700446
files dw/selection.cc
diffstat 1 files changed, 45 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/dw/selection.cc	Tue Jun 14 17:53:55 2011 -0400
+++ b/dw/selection.cc	Wed Jun 15 12:51:35 2011 -0400
@@ -103,8 +103,9 @@
    Widget *itWidget = it->getWidget ();
    bool ret = false;
 
-   if (event && event->button == 1 &&
-       !withinContent && event->numPressed == 2) {
+   if (!event) return ret;
+
+   if (event->button == 1 && !withinContent && event->numPressed == 2) {
       // When the user double-clicks on empty parts, emit the double click
       // signal instead of normal processing. Used for full screen
       // mode.
@@ -114,58 +115,51 @@
       highlight (false, 0);
       reset ();
       ret = true;
-   } else {
-      if (linkNo != -1) {
-         // link handling
-         if (event) {
-            (void) layout->emitLinkPress (itWidget, linkNo, -1, -1, -1, event);
-            resetLink ();
-            linkState = LINK_PRESSED;
-            linkButton = event->button;
-            DeepIterator *newLink = new DeepIterator (it);
-            if (newLink->isEmpty ()) {
-               delete newLink;
-               resetLink ();
-            } else {
-               link = newLink;
-               // It may be that the user has pressed on something activatable
-               // (linkNo != -1), but there is no contents, e.g. with images
-               // without ALTernative text.
-               if (link) {
-                  linkChar = correctCharPos (link, charPos);
-                  linkNumber = linkNo;
-               }
-            }
-            // We do not return the value of the signal method,
-            // but we do actually process this event.
-            ret = true;
-         }
+   } else if (linkNo != -1) {
+      // link handling
+      (void) layout->emitLinkPress (itWidget, linkNo, -1, -1, -1, event);
+      resetLink ();
+      linkState = LINK_PRESSED;
+      linkButton = event->button;
+      DeepIterator *newLink = new DeepIterator (it);
+      if (newLink->isEmpty ()) {
+         delete newLink;
+         resetLink ();
       } else {
-         // normal selection handling
-         if (event && event->button == 1) {
-            highlight (false, 0);
-            resetSelection ();
-
-            selectionState = SELECTING;
-            DeepIterator *newFrom = new DeepIterator (it);
-            if (newFrom->isEmpty ()) {
-               delete newFrom;
-               resetSelection ();
-            } else {
-               from = newFrom;
-               fromChar = correctCharPos (from, charPos);
-               to = from->cloneDeepIterator ();
-               toChar = correctCharPos (to, charPos);
-            }
-            ret = true;
-         } else {
-            if (event && event->button == 3) {
-               // menu popup
-               layout->emitLinkPress (itWidget, -1, -1, -1, -1, event);
-               ret = true;
-            }
+         link = newLink;
+         // It may be that the user has pressed on something activatable
+         // (linkNo != -1), but there is no contents, e.g. with images
+         // without ALTernative text.
+         if (link) {
+            linkChar = correctCharPos (link, charPos);
+            linkNumber = linkNo;
          }
       }
+      // We do not return the value of the signal method,
+      // but we do actually process this event.
+      ret = true;
+   } else if (event->button == 1) {
+      // normal selection handling
+      MSG("SelectionState::buttonPress normal selection handling\n");
+      highlight (false, 0);
+      resetSelection ();
+
+      selectionState = SELECTING;
+      DeepIterator *newFrom = new DeepIterator (it);
+      if (newFrom->isEmpty ()) {
+         delete newFrom;
+         resetSelection ();
+      } else {
+         from = newFrom;
+         fromChar = correctCharPos (from, charPos);
+         to = from->cloneDeepIterator ();
+         toChar = correctCharPos (to, charPos);
+      }
+      ret = true;
+   } else if (event->button == 3) {
+      // menu popup
+      layout->emitLinkPress (itWidget, -1, -1, -1, -1, event);
+      ret = true;
    }
 
    return ret;